:root {
  --bg: #050810;
  --card-bg: linear-gradient(160deg, rgba(30, 45, 90, 0.55), rgba(10, 15, 30, 0.65));
  --border: rgba(90, 130, 255, 0.22);
  --border-strong: rgba(110, 150, 255, 0.65);
  --text: #eaf0ff;
  --muted: #8a97b8;
  --accent: #4d7bff;
  --accent-2: #1f3fb8;
  --accent-glow: rgba(77, 123, 255, 0.45);
  --danger: #ff4d6a;
  --weak: #ff4d6a;
  --ok: #ffb84d;
  --strong: #3df2a2;
  --very-strong: #4d7bff;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #0a0e18 0%, #0d1220 45%, #0a0d16 100%);
  color: var(--text);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

/* --- Background layers: understated, professional --- */
.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(77, 123, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(77, 123, 255, 0.025) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(circle at 50% 35%, black 5%, transparent 65%);
  z-index: 0;
}

.bg-glow {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(31, 63, 184, 0.16), transparent 55%),
    radial-gradient(ellipse at 85% 100%, rgba(20, 30, 70, 0.22), transparent 55%);
  z-index: 0;
}

/* --- Glassy card --- */
.card {
  position: relative;
  z-index: 1;
  background: var(--card-bg);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 34px;
  width: 100%;
  max-width: 460px;
  transition: box-shadow 0.15s ease-out;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 -1px 0 rgba(0, 0, 0, 0.4) inset,
    0 30px 70px rgba(2, 6, 20, 0.65),
    0 0 60px rgba(77, 123, 255, 0.1);
}

/* Glossy diagonal highlight streak, like light hitting glass */
.card-glare {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  pointer-events: none;
  background: linear-gradient(
    120deg,
    rgba(255, 255, 255, 0.10) 0%,
    rgba(255, 255, 255, 0.02) 22%,
    transparent 40%
  );
  mix-blend-mode: screen;
}

.card-header {
  margin-bottom: 26px;
  transform: translateZ(20px);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  color: var(--accent);
  border: 1px solid var(--border-strong);
  padding: 6px 12px;
  border-radius: 999px;
  margin-bottom: 14px;
  background: rgba(77, 123, 255, 0.08);
  box-shadow: 0 2px 10px rgba(77, 123, 255, 0.15), 0 1px 0 rgba(255, 255, 255, 0.06) inset;
  font-weight: 700;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--strong);
  box-shadow: 0 0 8px var(--strong);
  animation: pulse 1.8s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.75); }
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.subtitle code {
  background: rgba(31, 63, 184, 0.25);
  color: #b9c8ff;
  padding: 1px 6px;
  border-radius: 4px;
}

/* --- Output row --- */
.output-row {
  display: flex;
  gap: 10px;
  margin-bottom: 6px;
  transform: translateZ(24px);
}

.output-field {
  position: relative;
  flex: 1;
  overflow: hidden;
  border-radius: 12px;
}

#passwordOutput {
  width: 100%;
  padding: 15px 16px;
  font-size: 1.05rem;
  letter-spacing: 0.03em;
  font-family: inherit;
  background: rgba(6, 10, 20, 0.75);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--accent);
  min-width: 0;
  text-shadow: 0 0 10px rgba(77, 123, 255, 0.45);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35) inset;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#passwordOutput:focus {
  outline: none;
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(77, 123, 255, 0.18), 0 2px 12px rgba(0, 0, 0, 0.35) inset;
}

#passwordOutput::placeholder {
  color: var(--muted);
  text-shadow: none;
  letter-spacing: 0.08em;
}

.output-scan {
  position: absolute;
  top: 0;
  left: -100%;
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(77, 123, 255, 0.2), transparent);
  pointer-events: none;
}

.output-scan.run {
  animation: scan 0.6s ease;
}

@keyframes scan {
  to { left: 130%; }
}

.icon-btn {
  flex-shrink: 0;
  width: 50px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(160deg, rgba(77, 123, 255, 0.12), rgba(31, 63, 184, 0.08));
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 4px 10px rgba(0, 0, 0, 0.3);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.icon-btn:hover {
  background: linear-gradient(160deg, rgba(77, 123, 255, 0.2), rgba(31, 63, 184, 0.14));
  border-color: var(--border-strong);
}

.icon-btn:active {
  transform: scale(0.94) translateY(1px);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3) inset;
}

.icon-btn.copied {
  color: var(--strong);
  border-color: var(--strong);
  background: rgba(61, 242, 162, 0.1);
}

.icon {
  width: 20px;
  height: 20px;
  position: absolute;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.icon-hidden {
  opacity: 0;
  transform: scale(0.6);
  pointer-events: none;
}

.copied-msg {
  min-height: 18px;
  font-size: 0.75rem;
  color: var(--strong);
  margin-bottom: 10px;
  letter-spacing: 0.04em;
}

/* --- Mode toggle (Random / Passphrase) --- */
.mode-toggle {
  display: flex;
  gap: 6px;
  padding: 4px;
  margin-bottom: 20px;
  border-radius: 10px;
  background: rgba(6, 10, 20, 0.5);
  border: 1px solid var(--border);
  transform: translateZ(20px);
}

.mode-btn {
  flex: 1;
  padding: 9px 10px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.mode-btn:hover {
  color: var(--text);
}

.mode-btn.active {
  background: linear-gradient(160deg, rgba(77, 123, 255, 0.35), rgba(31, 63, 184, 0.35));
  color: var(--text);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1) inset, 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* --- Mode-specific parameter groups --- */
.mode-params.hidden {
  display: none;
}

.passphrase-row {
  margin-bottom: 16px;
}

.select-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.select-field select {
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--text);
  background: rgba(6, 10, 20, 0.8);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s ease;
}

.select-field select:hover,
.select-field select:focus {
  border-color: var(--border-strong);
}

/* --- Strength meter --- */
.strength-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  transform: translateZ(18px);
}

.strength-bar {
  flex: 1;
  height: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4) inset;
}

.strength-fill {
  height: 100%;
  width: 0%;
  background: var(--weak);
  box-shadow: 0 0 10px currentColor;
  transition: width 0.3s ease, background 0.3s ease;
}

.strength-label {
  font-size: 0.72rem;
  color: var(--muted);
  width: 140px;
  text-align: right;
  letter-spacing: 0.03em;
}

/* --- Compact auto-clear clock row --- */
.clock-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
  transform: translateZ(16px);
}

.clock-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--muted);
  transition: color 0.3s ease;
}

.clock-icon.urgent {
  color: var(--danger);
}

.timer-label {
  flex: 1;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
}

.timer-label.urgent {
  color: var(--danger);
}

.timer-select-inline {
  font-family: inherit;
  font-size: 0.7rem;
  color: var(--text);
  background: rgba(6, 10, 20, 0.7);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s ease;
}

.timer-select-inline:hover,
.timer-select-inline:focus {
  border-color: var(--border-strong);
}

/* --- Collapsible parameters --- */
.parameters-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(160deg, rgba(77, 123, 255, 0.08), rgba(10, 15, 30, 0.3));
  color: var(--text);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  cursor: pointer;
  margin-bottom: 0;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 4px 10px rgba(0, 0, 0, 0.25);
  transition: background 0.15s ease, border-color 0.15s ease;
  transform: translateZ(14px);
}

.parameters-toggle:hover {
  border-color: var(--border-strong);
  background: linear-gradient(160deg, rgba(77, 123, 255, 0.14), rgba(10, 15, 30, 0.35));
}

.parameters-toggle .chevron {
  width: 16px;
  height: 16px;
  transition: transform 0.3s ease;
}

.parameters-toggle.open .chevron {
  transform: rotate(180deg);
}

.parameters-panel {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.45s ease, opacity 0.35s ease;
}

.parameters-panel.open {
  max-height: 600px;
  opacity: 1;
}

.parameters-inner {
  padding-top: 20px;
}

/* --- Length slider --- */
.option-row {
  margin-bottom: 20px;
}

.option-row label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
  color: var(--muted);
}

.length-value {
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: normal;
  text-shadow: 0 0 8px rgba(77, 123, 255, 0.5);
}

.option-row input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  outline: none;
  cursor: pointer;
}

.option-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--accent);
  box-shadow: 0 0 10px rgba(77, 123, 255, 0.8), 0 2px 4px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.option-row input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--accent);
  box-shadow: 0 0 10px rgba(77, 123, 255, 0.8), 0 2px 4px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

/* --- Checkbox / toggle grid --- */
.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  margin-bottom: 8px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.78rem;
  color: var(--text);
  cursor: pointer;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  transition: border-color 0.15s ease, background 0.15s ease;
  user-select: none;
}

.toggle:hover {
  border-color: var(--border-strong);
}

.toggle-wide {
  grid-column: span 2;
}

.toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-box {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--muted);
  position: relative;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.toggle-box::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 2px;
  background: var(--accent);
  transform: scale(0);
  transition: transform 0.12s ease;
  box-shadow: 0 0 8px rgba(77, 123, 255, 0.8);
}

.toggle input[type="checkbox"]:checked + .toggle-box {
  border-color: var(--accent);
}

.toggle input[type="checkbox"]:checked + .toggle-box::after {
  transform: scale(0.55);
}

.toggle input[type="checkbox"]:focus-visible + .toggle-box {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Error / button --- */
.error-msg {
  min-height: 18px;
  color: var(--danger);
  font-size: 0.75rem;
  margin: 8px 0;
}

.generate-btn {
  width: 100%;
  padding: 15px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: linear-gradient(160deg, rgba(77, 123, 255, 0.28), rgba(31, 63, 184, 0.28));
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
  margin-top: 6px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 6px 16px rgba(31, 63, 184, 0.3);
  transform: translateZ(20px);
}

.generate-btn:hover {
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 0 28px rgba(77, 123, 255, 0.35);
}

.generate-btn:active {
  transform: translateZ(20px) scale(0.98);
}

.generate-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.security-note {
  margin: 20px 0 0;
  font-size: 0.68rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
  letter-spacing: 0.01em;
}

@media (max-width: 480px) {
  .card {
    padding: 24px 20px;
  }
}
