:root {
  --bg-1: #0f172a;
  --bg-2: #1e293b;
  --bg-3: #0b1220;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-2: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.10);
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #e6edf6;
  --text-dim: #98a4b6;
  --text-mute: #6b7790;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --radius-sm: 10px;
}

[data-theme="light"] {
  --bg-1: #eef2ff;
  --bg-2: #fdf4ff;
  --bg-3: #f0f9ff;
  --surface: rgba(255, 255, 255, 0.85);
  --surface-2: rgba(255, 255, 255, 0.55);
  --surface-hover: rgba(255, 255, 255, 1);
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.15);
  --text: #0f172a;
  --text-dim: #475569;
  --text-mute: #64748b;
  --shadow: 0 10px 40px rgba(99, 102, 241, 0.15);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14.5px;
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  background:
    radial-gradient(1200px 700px at 10% -10%, rgba(99,102,241,0.35), transparent 50%),
    radial-gradient(900px 600px at 110% 10%, rgba(236,72,153,0.25), transparent 55%),
    radial-gradient(900px 700px at 50% 120%, rgba(34,197,94,0.18), transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-3));
  background-attachment: fixed;
}

[data-theme="light"] body {
  background:
    radial-gradient(1200px 700px at 10% -10%, rgba(99,102,241,0.18), transparent 50%),
    radial-gradient(900px 600px at 110% 10%, rgba(236,72,153,0.12), transparent 55%),
    radial-gradient(900px 700px at 50% 120%, rgba(59,130,246,0.10), transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
}

code, .mono {
  font-family: "JetBrains Mono", "Fira Code", Consolas, "Courier New", monospace;
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12.5px;
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 18px;
}

/* ---------- Header ---------- */
header {
  padding: 36px 0 18px;
  text-align: center;
  position: relative;
}

header h1 {
  margin: 0 0 8px;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 0;
  color: var(--text-dim);
  font-size: 15px;
}

.top-actions {
  position: absolute;
  top: 22px;
  right: 22px;
  display: flex;
  gap: 8px;
}

.pill-btn {
  min-width: 42px;
  height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform 0.15s ease, background 0.15s ease;
}
.pill-btn:hover { transform: translateY(-1px); background: var(--surface-hover); }

main { padding: 14px 0 50px; }

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}

/* ---------- Password display ---------- */
.password-display {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.password-display:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.25);
}

.password-display input {
  flex: 1;
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 19px;
  font-weight: 500;
  padding: 14px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  letter-spacing: 0.5px;
  outline: none;
  min-width: 0;
}

.password-display button {
  padding: 0 16px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}
.password-display button:hover { background: var(--surface); color: var(--text); }
.password-display button.primary-mini {
  background: var(--accent-grad);
  color: #fff;
  padding: 0 20px;
}
.password-display button.primary-mini:hover { filter: brightness(1.1); }

#refresh-btn { font-size: 20px; }

/* ---------- Strength ---------- */
.strength {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  padding: 0 4px;
  font-size: 13px;
  color: var(--text-dim);
  flex-wrap: wrap;
}

.strength-label { min-width: 64px; font-weight: 500; }

.strength-bar {
  flex: 1;
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  min-width: 160px;
  max-width: 360px;
  border: 1px solid var(--border);
}

.strength-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--bad);
  border-radius: 999px;
  transition: width 0.3s ease, background 0.25s ease;
  box-shadow: 0 0 12px currentColor;
}

.strength-text { min-width: 90px; font-weight: 600; }
.entropy {
  color: var(--text-mute);
  font-size: 12px;
  margin-left: auto;
  font-family: "JetBrains Mono", monospace;
}

/* ---------- Sections ---------- */
.section {
  padding: 14px 0;
  border-top: 1px solid var(--border);
}
.section:first-of-type { border-top: none; padding-top: 4px; }

/* ---------- Mode tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  margin-bottom: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease;
  user-select: none;
  position: relative;
}
.tab input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0; height: 0;
}
.tab:hover { color: var(--text); }
.tab:has(input:checked) {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99,102,241,0.35);
}

/* ---------- Length ---------- */
.length-section .row { gap: 12px; }
.length-section input[type="number"] { width: 90px; }
.chips-row { gap: 6px; margin-top: 4px; }

/* ---------- Quick checks (4 main cards) ---------- */
.quick-checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.check-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  font-size: 14px;
}
.check-card:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.check-card:has(input:checked) {
  border-color: var(--accent);
  background: rgba(99,102,241,0.10);
}
.check-text { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.check-text code { font-size: 11.5px; }

/* ---------- Action row ---------- */
.action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 0 4px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.action-row .qty { display: flex; align-items: center; gap: 8px; }
.action-row .qty input { width: 70px; }
.action-row .primary { flex: 1; min-width: 200px; }

/* ---------- Advanced (collapsible) ---------- */
.advanced {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.advanced summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  user-select: none;
  transition: background 0.15s ease;
}
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary:hover { background: var(--surface-hover); }
.advanced summary .adv-icon { font-size: 16px; opacity: 0.8; }
.advanced summary span:not(.adv-icon):not(.chev) { flex: 1; }
.advanced summary .chev {
  font-size: 14px;
  transition: transform 0.2s ease;
  opacity: 0.7;
}
.advanced[open] summary .chev { transform: rotate(180deg); }

.advanced fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 14px 0 0;
  padding: 14px 18px 16px;
  background: var(--surface-2);
}

legend {
  padding: 2px 10px;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
  flex-wrap: wrap;
}
.row.inline { gap: 14px; }
.row.small { font-size: 13px; }

label { user-select: none; color: var(--text); }

/* ---------- Inputs ---------- */
input[type="number"], input[type="text"] {
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 14px;
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="number"] { width: 90px; }
input[type="text"] {
  flex: 1;
  min-width: 200px;
  font-family: "JetBrains Mono", monospace;
}

input[type="number"]:focus, input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.25);
}

/* Suppress Firefox's default red :invalid glow — it bleeds into adjacent UI
   (e.g. the red stripe to the left of the Generate button when #quantity is empty). */
input:invalid { box-shadow: none; }
input:-moz-ui-invalid { box-shadow: none; }
input:invalid:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.25);
}

/* ---------- Range slider ---------- */
input[type="range"] {
  flex: 1;
  min-width: 180px;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--surface-2);
  border-radius: 999px;
  outline: none;
  border: 1px solid var(--border);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #6366f1;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(99,102,241,0.45);
  transition: transform 0.15s ease;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #6366f1;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(99,102,241,0.45);
}

/* ---------- Toggle switches (advanced checkboxes) ---------- */
.advanced .checks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 4px 14px;
}
.advanced .checks label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.12s ease;
  font-size: 13.5px;
}
.advanced .checks label:hover { background: var(--surface-2); }

.advanced input[type="checkbox"],
.quick-checks input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 36px;
  height: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.advanced input[type="checkbox"]::after,
.quick-checks input[type="checkbox"]::after {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  top: 50%;
  left: 2px;
  transform: translateY(-50%);
  transition: left 0.18s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.advanced input[type="checkbox"]:checked,
.quick-checks input[type="checkbox"]:checked {
  background: var(--accent-grad);
  border-color: transparent;
}
.advanced input[type="checkbox"]:checked::after,
.quick-checks input[type="checkbox"]:checked::after { left: 18px; }

/* ---------- Buttons ---------- */
button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 16px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}
button:hover { background: var(--surface-hover); }
button:active { transform: translateY(1px); }

button.primary {
  background: var(--accent-grad);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
  padding: 12px 22px;
  box-shadow: 0 4px 16px rgba(99,102,241,0.35);
}
button.primary:hover { filter: brightness(1.1); }

button.link {
  background: transparent;
  border: none;
  color: var(--accent);
  padding: 4px 0;
  text-decoration: underline;
  cursor: pointer;
  font-size: 12.5px;
}

.chip {
  padding: 6px 14px;
  font-size: 12.5px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  cursor: pointer;
  font-family: "JetBrains Mono", monospace;
  font-weight: 500;
  transition: all 0.15s ease;
}
.chip:hover { background: var(--surface-hover); transform: translateY(-1px); }
.chip.active {
  background: var(--accent-grad);
  color: #fff;
  border-color: transparent;
}

.hint {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--text-mute);
  line-height: 1.5;
}

textarea {
  width: 100%;
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  resize: vertical;
  background: var(--surface-2);
  color: var(--text);
}
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.25);
}

.bulk { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.bulk h3 { margin: 0 0 10px; font-size: 15px; }

/* ---------- History ---------- */
.history {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.history h3 {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 600;
}

.history ul {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  max-height: 180px;
  overflow-y: auto;
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
}
.history li {
  padding: 6px 10px;
  display: flex;
  gap: 10px;
  border-radius: 6px;
  align-items: center;
}
.history li:hover { background: var(--surface-2); }

.history .pw {
  flex: 1;
  min-width: 0;
  word-break: break-all;
}
.history .ts {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--text-mute);
  font-family: "JetBrains Mono", monospace;
  letter-spacing: 0.3px;
  white-space: nowrap;
  opacity: 0.75;
}
.history .actions { display: inline-flex; gap: 6px; flex-shrink: 0; }
.history li button {
  font-size: 11px;
  padding: 3px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.history li button:hover { background: var(--surface-hover); }

/* ---------- Info ---------- */
.info h2 {
  font-size: 18px;
  margin: 18px 0 8px;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: inline-block;
}
.info h2:first-child { margin-top: 0; }
.info p { margin: 6px 0; color: var(--text-dim); }
.info ul { margin: 6px 0 12px 22px; padding: 0; color: var(--text-dim); }
.info li { margin: 3px 0; }

/* ---------- Footer ---------- */
footer {
  padding: 18px 0 24px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-mute);
}
footer p { margin: 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--accent-grad);
  color: #fff;
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(99,102,241,0.45);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.masked {
  -webkit-text-security: disc;
  text-security: disc;
}

@keyframes flash {
  0% { box-shadow: 0 0 0 0 rgba(99,102,241,0.45); }
  100% { box-shadow: 0 0 0 12px rgba(99,102,241,0); }
}
.password-display.flash { animation: flash 0.45s ease; }

@media (max-width: 600px) {
  header h1 { font-size: 28px; }
  header { padding-top: 70px; }
  .top-actions { top: 14px; right: 14px; }
  .password-display input { font-size: 16px; padding: 12px 12px; }
  .quick-checks { grid-template-columns: 1fr 1fr; }
  .advanced .checks { grid-template-columns: 1fr; }
  .strength { gap: 8px; }
  .entropy { margin-left: 0; width: 100%; text-align: right; }
  .action-row .primary { width: 100%; flex: 1 0 100%; order: -1; }
  .tab { padding: 8px 12px; font-size: 12.5px; }
}
