:root {
  --page: #f7f7f8;
  --card: #ffffff;
  --surface: #f7f7f8;
  --border: #e4e4e7;
  --border-strong: #d1d1d6;
  --text: #18181b;
  --muted: #71717a;
  --accent: #5e6ad2;
  --accent-hover: #4f5bbd;
  --accent-subtle: #eef0fb;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  padding: clamp(8px, 2.5vw, 18px);
}

.generator {
  width: min(100%, 480px);
  max-height: 100%;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 0 1px rgba(0, 0, 0, 0.04);
  padding: clamp(13px, 2.5vw, 18px);
}

.heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.shield {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border-radius: 12px;
  background: var(--accent-subtle);
  color: var(--accent);
  font-size: 22px;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: clamp(18px, 5vw, 23px);
  line-height: 1.15;
}

.heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.result-box {
  display: flex;
  min-height: 54px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 8px 8px 8px 13px;
}

#result {
  min-width: 0;
  flex: 1;
  overflow-x: auto;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: clamp(13px, 3.8vw, 17px);
  line-height: 1.4;
  scrollbar-width: thin;
  white-space: nowrap;
}

button,
input {
  font: inherit;
}

button,
label {
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.copy-button {
  min-height: 40px;
  flex: 0 0 auto;
  border: 1px solid #c9cff0;
  border-radius: 9px;
  background: var(--accent-subtle);
  color: var(--accent);
  cursor: pointer;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
}

.strength {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  margin: 8px 2px 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

#strength-label {
  color: var(--success);
}

.strength-track {
  height: 5px;
  grid-column: 1 / -1;
  overflow: hidden;
  border-radius: 99px;
  background: #e4e4e7;
}

#strength-bar {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--success);
  transition: width 160ms ease, background 160ms ease;
}

.settings {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}

.length-setting,
.setting {
  display: flex;
  min-height: 35px;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  padding: 7px 12px;
  font-size: 13px;
}

.setting:last-child {
  border-bottom: 0;
}

.length-setting label,
.setting span {
  flex: 1;
}

#length {
  width: min(42%, 170px);
  accent-color: var(--accent);
}

#length-value {
  width: 28px;
  color: var(--accent);
  font-weight: 800;
  text-align: right;
}

.setting input {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  accent-color: var(--accent);
  cursor: pointer;
}

.error {
  min-height: 14px;
  margin: 4px 2px 2px;
  color: var(--danger);
  font-size: 11px;
}

.generate-button {
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 11px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
}

.generate-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(24, 24, 27, 0.48);
  padding: 14px;
}

.modal-card {
  width: min(100%, 430px);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.22);
  padding: 20px;
  text-align: center;
}

.modal-icon {
  display: grid;
  width: 40px;
  height: 40px;
  margin: 0 auto 10px;
  place-items: center;
  border-radius: 50%;
  background: #fef6e7;
  color: var(--warning);
  font-size: 22px;
  font-weight: 850;
}

.modal-card h2 {
  margin: 0;
  color: var(--text);
  font-size: 19px;
}

.modal-card > p {
  margin: 8px auto 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

#modal-password {
  display: block;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  padding: 11px;
  font-size: 14px;
  white-space: nowrap;
}

.acknowledgement {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 14px 0;
  color: var(--text2, #52525b);
  font-size: 12px;
  line-height: 1.4;
  text-align: left;
}

.acknowledgement input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--accent);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-actions .generate-button {
  width: auto;
  padding-inline: 14px;
}

.secondary-button {
  min-height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 700;
}

.copy-button:hover,
.generate-button:hover {
  filter: brightness(1.12);
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 5;
  border-radius: 999px;
  background: var(--text);
  color: #fff;
  opacity: 0;
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 750;
  pointer-events: none;
  transform: translate(-50%, 18px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-height: 540px) {
  body {
    padding: 5px;
  }

  .generator {
    padding: 10px 14px;
  }

  .heading {
    margin-bottom: 8px;
  }

  .heading p {
    display: none;
  }

  .shield {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .result-box {
    min-height: 49px;
  }

  .strength {
    margin: 6px 2px 8px;
  }

  .length-setting,
  .setting {
    min-height: 34px;
    padding-block: 4px;
  }

  .error {
    margin-top: 3px;
  }

  .generate-button {
    min-height: 38px;
  }

  .modal-card {
    padding: 14px;
  }

  .modal-card > p {
    margin-block: 6px 9px;
  }

  .acknowledgement {
    margin: 10px 0;
  }
}
