:root {
  --accent: #e8663d;
  --thumb: #fff;
}

:root[data-theme="dark"] {
  --bg: oklch(16% 0.01 280);
  --bg-grad-to: oklch(13% 0.012 280);
  --card: oklch(21% 0.014 280);
  --card-border: oklch(30% 0.02 280 / 0.5);
  --controls: oklch(19% 0.013 280);
  --text-primary: oklch(96% 0.005 280);
  --text-muted: oklch(72% 0.01 280);
  --text-faint: oklch(52% 0.012 280);
  --track-off: oklch(32% 0.015 280);
  --seg-off: oklch(28% 0.015 280);
  --password-bg: oklch(13% 0.012 280);
  --header-bg: oklch(16% 0.01 280 / 0.75);
  --toast-bg: oklch(24% 0.02 280);
  --accent-tint: oklch(30% 0.05 280 / 0.4);
  --tab-hover: oklch(32% 0.015 280);
  --history-icon-active: oklch(30% 0.02 280);
  --history-backdrop: rgba(5,5,10,0.6);
  --glow-opacity: 0.16;
  --card-shadow: 0 20px 60px -20px rgba(0,0,0,0.6);
  --modal-shadow: 0 30px 70px -20px rgba(0,0,0,0.7);
}

:root[data-theme="light"] {
  --bg: oklch(97% 0.006 260);
  --bg-grad-to: oklch(94% 0.008 260);
  --card: oklch(100% 0 0);
  --card-border: oklch(88% 0.01 260);
  --controls: oklch(100% 0 0);
  --text-primary: oklch(20% 0.01 260);
  --text-muted: oklch(42% 0.015 260);
  --text-faint: oklch(58% 0.012 260);
  --track-off: oklch(88% 0.012 260);
  --seg-off: oklch(90% 0.01 260);
  --password-bg: oklch(95% 0.01 260);
  --header-bg: oklch(97% 0.006 260 / 0.75);
  --toast-bg: oklch(22% 0.02 280);
  --accent-tint: oklch(94% 0.04 280);
  --tab-hover: oklch(88% 0.012 260);
  --history-icon-active: oklch(93% 0.01 260);
  --history-backdrop: rgba(20,15,35,0.35);
  --glow-opacity: 0.1;
  --card-shadow: 0 20px 60px -30px rgba(30,20,60,0.15);
  --modal-shadow: 0 30px 70px -25px rgba(30,20,60,0.35);
}

@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px) scale(0.96); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@keyframes toastOut { from { opacity: 1; transform: translate(-50%, 0) scale(1); } to { opacity: 0; transform: translate(-50%, 8px) scale(0.96); } }
@keyframes popIn { 0% { transform: scale(0.985); opacity: 0.6; } 100% { transform: scale(1); opacity: 1; } }
@keyframes glowShift { 0%, 100% { transform: translate(-10%, -10%); } 50% { transform: translate(10%, 5%); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

* , *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  -webkit-font-smoothing: antialiased;
  font-family: 'Inter', sans-serif;
}

button { font: inherit; }
input { font: inherit; }

.page {
  position: relative;
  min-height: 100vh;
  width: 100%;
  background: linear-gradient(180deg, var(--bg), var(--bg-grad-to));
  transition: background 0.4s ease;
}

/* Own overflow-clipping wrapper so .page can stay overflow-visible (which
   position: sticky on the header requires). */
.glow-wrap {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 520px;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.glow {
  position: absolute;
  width: 900px;
  height: 900px;
  left: 50%;
  top: -420px;
  margin-left: -450px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  opacity: var(--glow-opacity);
  filter: blur(40px);
  animation: glowShift 14s ease-in-out infinite;
}

.sticky-header {
  position: sticky;
  top: 0;
  z-index: 5;
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 16px 20px;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--card-border);
}

.header-inner {
  width: 100%;
  max-width: 640px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo-mark { display: flex; align-items: center; justify-content: center; color: var(--accent); }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-name { font-size: 16px; font-weight: 800; letter-spacing: -0.015em; color: var(--text-primary); }
.brand-sub { font-size: 11.5px; font-weight: 500; color: var(--text-faint); white-space: nowrap; }

.header-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.privacy-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600;
  color: var(--text-muted);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 6px 11px;
  margin-bottom: 14px;
  white-space: nowrap;
}

.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.icon-btn:hover { color: var(--text-primary); border-color: var(--accent); }

.icon-sun, .icon-moon { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
:root[data-theme="light"] .icon-sun { display: block; }

.content {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 20px 64px;
}

.hero-title {
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 0 0 8px;
  text-align: center;
}
.accent-text { color: var(--accent); }

.hero-sub {
  font-size: 14.5px;
  color: var(--text-muted);
  margin: 0 0 28px;
  text-align: center;
  max-width: 400px;
}

.card {
  width: 100%;
  max-width: 640px;
  border: 1px solid var(--card-border);
  border-radius: 20px;
}

.password-card {
  background: var(--card);
  padding: 32px;
  box-shadow: var(--card-shadow);
  animation: popIn 0.3s ease;
}

/* Mode toggle */
.mode-toggle-outer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.mode-toggle {
  display: flex; align-items: center; gap: 6px;
  height: 40px; box-sizing: border-box;
  padding: 3px;
  border-radius: 12px;
  background: var(--password-bg);
  border: 1px solid var(--card-border);
  width: fit-content;
}
.mode-tab {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 13px; font-weight: 600;
  white-space: nowrap;
  height: 100%; box-sizing: border-box;
  padding: 0 16px; border-radius: 9px; border: none; cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  transition: all 0.15s ease;
}
.history-wrap { position: relative; flex-shrink: 0; }
.mode-tab:hover:not(.active) { color: var(--text-primary); background: var(--tab-hover); }
.mode-tab.active { background: var(--accent); color: #fff; }
.batch-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px;
  font-size: 10px; font-weight: 700;
  background: rgba(255,255,255,0.25); color: #fff;
}

.password-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }

.password-display {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(20px, 4.4vw, 30px);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  background: var(--password-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 22px 20px;
  word-break: break-all;
  line-height: 1.35;
  user-select: all;
}

.action-row { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14.5px; font-weight: 600;
  padding: 13px 18px; border-radius: 12px; border: none; cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease, filter 0.2s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn-primary { flex: 1 1 120px; min-width: 0; box-sizing: border-box; background: var(--accent); color: #fff; }
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn-primary:active { transform: translateY(0) scale(0.98); }
.btn-primary.copied { background: oklch(65% 0.15 160); }

.btn-secondary {
  flex: 1 1 120px; min-width: 0; box-sizing: border-box;
  padding: 13px 20px;
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-primary);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-secondary:active { transform: scale(0.97); }

.history-btn {
  position: relative;
  width: 40px; height: 40px; border-radius: 10px;
  flex-shrink: 0; box-sizing: border-box;
  color: var(--text-primary);
}
.history-btn[aria-expanded="true"] { background: var(--history-icon-active); }
.history-dot {
  position: absolute; top: 8px; right: 8px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  border: 1.5px solid var(--card);
}

.btn-generate {
  padding: 11px 20px; border-radius: 10px;
  font-size: 14px;
  background: var(--accent); color: #fff;
  white-space: nowrap;
}
.btn-generate:hover { filter: brightness(1.08); }
.btn-generate:active { transform: scale(0.97); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-primary);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost.copied { background: oklch(65% 0.15 160); color: #fff; border-color: transparent; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 9px; white-space: nowrap; }

.icon-check, .icon-copy { display: none; }
.btn .icon-copy { display: block; }
.btn.copied .icon-copy { display: none; }
.btn.copied .icon-check { display: block; }

.strength-block { margin-top: 26px; }
.strength-labels { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.label-muted { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.strength-value { font-size: 13px; font-weight: 700; }
.strength-bars { display: flex; gap: 5px; }
.strength-seg { flex: 1; height: 6px; border-radius: 999px; background: var(--seg-off); transition: background 0.3s ease; }

/* Batch mode */
.batch-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 9px;
  border: 1px solid var(--card-border); background: transparent;
  color: var(--text-primary); cursor: pointer; flex-shrink: 0;
  font-size: 17px; font-weight: 600;
  transition: all 0.15s ease;
}
.stepper-btn:hover { border-color: var(--accent); color: var(--accent); }
.stepper-input {
  width: 56px; text-align: center;
  font-family: 'JetBrains Mono', monospace; font-size: 15px; font-weight: 700;
  color: var(--accent);
  background: var(--accent-tint);
  border: none; border-radius: 8px; padding: 7px 4px;
}

.bulk-presets { display: flex; gap: 6px; flex: 1; min-width: 180px; }
.preset-btn {
  flex: 1; text-align: center;
  font-size: 13px; font-weight: 600;
  padding: 8px 0; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--card-border);
  background: transparent;
  color: var(--text-muted);
  transition: all 0.15s ease;
}
.preset-btn:hover:not(.active) { border-color: var(--accent); color: var(--accent); }
.preset-btn.active { border-color: var(--accent); background: var(--accent-tint); color: var(--accent); }

.bulk-copy-all-row { display: flex; justify-content: flex-end; margin-top: 16px; margin-bottom: 8px; }

.bulk-list { display: flex; flex-direction: column; gap: 8px; max-height: 340px; overflow-y: auto; }
.bulk-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; border-radius: 10px;
  background: var(--password-bg);
  border: 1px solid var(--card-border);
}
.bulk-row-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px; color: var(--text-primary);
  word-break: break-all;
}
.row-copy {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px;
  border: none; cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  transition: all 0.15s ease;
}
.row-copy:hover { color: var(--accent); }
.row-copy.copied { background: oklch(65% 0.15 160); color: #fff; }
.row-copy svg { display: none; }
.row-copy .icon-copy { display: block; }
.row-copy.copied .icon-copy { display: none; }
.row-copy.copied .icon-check { display: block; }

.empty-state {
  font-size: 13.5px; line-height: 1.5;
  color: var(--text-faint);
  text-align: center;
  padding: 18px 10px 6px;
}

/* History modal */
.history-backdrop {
  position: fixed; inset: 0;
  background: var(--history-backdrop);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  z-index: 50;
  animation: fadeIn 0.18s ease;
}
.history-modal {
  width: 100%; max-width: 380px;
  max-height: 80vh; overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--modal-shadow);
  animation: popIn 0.22s ease;
}
.history-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
  font-size: 15px; font-weight: 700;
  color: var(--text-primary);
}
.history-close {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 8px;
  border: none; background: transparent; cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s ease;
}
.history-close:hover { color: var(--text-primary); background: var(--track-off); }
.history-rows { display: flex; flex-direction: column; gap: 8px; }
.history-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; border-radius: 10px;
  background: var(--password-bg);
  border: 1px solid var(--card-border);
}
.history-row-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13.5px; color: var(--text-muted);
  word-break: break-all;
}
.history-row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.history-action {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 8px;
  border: none; cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  transition: all 0.15s ease;
}
.history-action:hover { color: var(--accent); background: var(--track-off); }
.history-action.copied { background: oklch(65% 0.15 160); color: #fff; }
.history-action svg { display: none; }
.history-copy .icon-copy { display: block; }
.history-copy.copied .icon-copy { display: none; }
.history-copy.copied .icon-check { display: block; }
.history-restore svg { display: block; }
.clear-history {
  align-self: flex-end;
  font-size: 12px; font-weight: 600;
  color: var(--text-faint);
  background: transparent; border: none; cursor: pointer;
  padding: 2px;
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-top: 4px;
}
.clear-history:hover { color: var(--text-primary); }
.history-empty {
  font-size: 13px; line-height: 1.5;
  color: var(--text-faint);
  padding: 6px 2px 4px;
}

.controls-card {
  background: var(--controls);
  padding: 28px 32px 20px;
  margin-top: 20px;
}

.remember-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  margin-bottom: 22px;
  background: var(--controls);
  border: 1px solid var(--card-border);
  transition: all 0.2s ease;
}
.remember-row.active { border-color: var(--accent); background: var(--accent-tint); }

.remember-info { display: flex; align-items: center; gap: 12px; }
.remember-icon {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: var(--track-off);
  color: var(--text-faint);
  transition: all 0.2s ease;
}
.remember-row.active .remember-icon { background: var(--accent); color: #fff; }
.remember-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.remember-sub { font-size: 12px; color: var(--text-faint); margin-top: 1px; }

.switch {
  width: 44px; height: 26px; border-radius: 999px;
  background: var(--track-off);
  border: none; cursor: pointer; position: relative; padding: 0;
  transition: background 0.2s ease; flex-shrink: 0;
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch-knob {
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: left 0.2s cubic-bezier(0.34,1.56,0.64,1);
}
.switch[aria-checked="true"] .switch-knob { left: 21px; }

.length-block { margin-bottom: 22px; }
.length-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.length-label { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.length-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px; font-weight: 700;
  color: var(--accent);
  background: var(--accent-tint);
  border-radius: 8px; padding: 3px 10px;
  min-width: 38px; text-align: center;
}

.pg-range { -webkit-appearance: none; appearance: none; background: transparent; width: 100%; height: 22px; border-radius: 999px; }
.pg-range::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; }
.pg-range::-moz-range-track { height: 6px; border-radius: 999px; }
.pg-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--thumb); border: 3px solid var(--accent);
  margin-top: -8px; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  transition: transform 0.12s ease;
}
.pg-range::-webkit-slider-thumb:active { transform: scale(1.12); }
.pg-range::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--thumb); border: 3px solid var(--accent);
  cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}
.pg-range:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--accent); outline-offset: 2px; }

.length-scale { display: flex; justify-content: space-between; margin-top: 6px; }
.length-scale span { font-size: 11px; color: var(--text-faint); }

.option-rows { display: flex; flex-direction: column; gap: 2px; }
.option-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 0;
  border-bottom: 1px solid var(--card-border);
}
.option-row:last-child { border-bottom: none; }
.option-label { font-size: 14.5px; font-weight: 600; color: var(--text-primary); }
.option-sub { font-size: 12.5px; color: var(--text-faint); margin-top: 2px; }

.exclude-chars-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 0 6px; flex-wrap: wrap;
}
.exclude-chars-label { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.exclude-chars-input {
  width: 160px;
  font-family: 'JetBrains Mono', monospace; font-size: 13.5px;
  color: var(--text-primary);
  background: var(--password-bg);
  border: 1px solid var(--card-border);
  border-radius: 9px; padding: 8px 12px;
}
.exclude-chars-input:focus { outline: none; border-color: var(--accent); }

.footnote {
  font-size: 12.5px;
  color: var(--text-faint);
  margin-top: 28px;
  text-align: center;
  max-width: 420px;
}

.consent-banner {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 40;
  width: calc(100% - 40px);
  max-width: 560px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  box-shadow: var(--modal-shadow);
  animation: popIn 0.25s ease;
}
.consent-text {
  flex: 1;
  min-width: 220px;
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-muted);
}
.consent-text a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.consent-actions { display: flex; gap: 8px; flex-shrink: 0; }
.consent-btn {
  font-size: 13px; font-weight: 600;
  padding: 8px 16px; border-radius: 9px; cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}
.consent-accept { background: var(--accent); color: #fff; }
.consent-accept:hover { filter: brightness(1.08); }
.consent-decline { background: transparent; border-color: var(--card-border); color: var(--text-primary); }
.consent-decline:hover { border-color: var(--accent); color: var(--accent); }

.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600;
  color: #fff;
  background: var(--toast-bg);
  border: 1px solid var(--accent);
  padding: 12px 20px; border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  z-index: 60;
  pointer-events: none;
  opacity: 0;
}
.toast.show { animation: toastIn 0.25s ease forwards; }
.toast.hide { animation: toastOut 0.2s ease forwards; }

/* Mobile */
@media (max-width: 560px) {
  .sticky-header { padding: 12px 14px; }

  .password-card { padding: 22px 18px; border-radius: 16px; }
  .controls-card { padding: 18px 16px 12px; border-radius: 16px; }

  .action-row { gap: 8px; margin-top: 18px; }
  .btn-primary, .btn-secondary {
    height: 40px; padding: 0 10px;
    font-size: 13.5px; border-radius: 10px;
  }

  .stepper { flex: 1 1 100%; }
  .bulk-presets { min-width: 100%; }

  /* History modal becomes a bottom sheet */
  .history-backdrop { align-items: flex-end; padding: 0; }
  .history-modal { max-width: 100%; border-radius: 18px 18px 0 0; padding: 18px 16px; }

  .exclude-chars-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .exclude-chars-input { width: 100%; }
}
