/* pwgen — dark, modern password generator
   Signature: the whole page's accent hue IS the strength reading.
   Palette (graphite + one shifting accent):
   --bg #0B0E14 · --surface #141922 · --line #232B39 · --text #E6EAF2 · --muted #8A94A7 */

@property --accent {
  syntax: '<color>';
  inherits: true;
  initial-value: #4ADE80;
}

:root {
  --bg: #0B0E14;
  --surface: #141922;
  --surface-2: #1B2230;
  --line: #232B39;
  --text: #E6EAF2;
  --muted: #8A94A7;
  --accent: #4ADE80;
  --radius: 14px;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, monospace;
  --sans: 'Space Grotesk', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-x: hidden;
  transition: --accent .5s ease;
  position: relative;
}

body::after {
  content: "";
  position: fixed;
  inset: -20% -20% auto -20%;
  height: 70vh;
  background: radial-gradient(60% 60% at 50% 0%, color-mix(in oklab, var(--accent) 22%, transparent), transparent 70%);
  filter: blur(10px);
  opacity: .5;
  pointer-events: none;
  transition: --accent .5s ease;
  z-index: 0;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: .028;
  mix-blend-mode: screen;
  pointer-events: none;
  z-index: 0;
}


.card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  background: linear-gradient(180deg, var(--surface) 0%, #10151E 100%);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 6px);
  padding: 26px;
  box-shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 40px 80px -30px rgba(0,0,0,.7);
  animation: rise .5s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

.bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 22px;
}
.brand {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .12em;
  text-transform: lowercase;
  color: var(--text);
}
.cursor {
  color: var(--accent);
  animation: blink 1.1s steps(1) infinite;
  transition: --accent .5s ease;
}
@keyframes blink { 50% { opacity: 0; } }
.readout {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .02em;
}
.readout b { color: var(--text); font-weight: 700; }

.stage {
  background: #0C1017;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 20px 16px;
}
.pw {
  font-family: var(--mono);
  font-size: clamp(1.15rem, 6.2vw, 1.9rem);
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: .04em;
  word-break: break-all;
  min-height: 2.1em;
}
.pw.is-phrase {
  word-break: normal;
  overflow-wrap: break-word;
  letter-spacing: .02em;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  outline: none;
  user-select: all;
  -webkit-user-select: all;
}
.pw:focus-visible { box-shadow: 0 0 0 2px color-mix(in oklab, var(--accent) 60%, transparent); border-radius: 6px; }
.pw span { transition: color .18s ease; }
.pw .g-digit { color: var(--accent); transition: color .5s ease; }
.pw .g-sym { color: #9AA6BE; }
.pw .flick { color: var(--muted); opacity: .8; }

.meter {
  margin-top: 14px;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.meter-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--accent);
  transition: width .45s cubic-bezier(.2,.7,.2,1), --accent .5s ease;
}
.meter-row {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-family: var(--mono);
}
.strength { color: var(--accent); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; transition: --accent .5s ease; }
.crack { color: var(--muted); }

/* ---------- actions ---------- */
.actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin: 18px 0 6px;
}
.btn {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .06s ease, color .15s ease;
}
.btn:hover { border-color: color-mix(in oklab, var(--accent) 50%, var(--line)); background: #212a3a; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary {
  color: #0B0E14;
  background: var(--accent);
  border-color: transparent;
  font-weight: 700;
  transition: background .15s ease, transform .06s ease, filter .15s ease, --accent .5s ease;
}
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); border-color: transparent; }
.btn.copied { color: var(--accent); border-color: var(--accent); background: color-mix(in oklab, var(--accent) 12%, var(--surface-2)); }

.controls { margin-top: 18px; display: grid; gap: 16px; }

.seg {
  display: inline-flex;
  padding: 3px;
  background: #0C1017;
  border: 1px solid var(--line);
  border-radius: 10px;
  gap: 3px;
}
.seg-opt {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 7px;
  padding: 7px 16px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.seg-opt.is-active { color: var(--text); background: var(--surface-2); }
.seg-opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.control-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
}
.control-row label {
  font-size: 13px;
  color: var(--muted);
}
#lenOut {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  min-width: 2.5ch;
  text-align: right;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--fill, 30%), var(--surface-2) var(--fill, 30%));
  cursor: pointer;
  transition: --accent .5s ease;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 1px var(--line), 0 2px 6px rgba(0,0,0,.5);
}
input[type="range"]::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--text);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 1px var(--line);
}
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  font-size: 12.5px;
  font-family: var(--mono);
  color: var(--muted);
  background: #0C1017;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  transition: background .14s ease, color .14s ease, border-color .14s ease;
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked) {
  color: var(--text);
  background: var(--surface-2);
  border-color: color-mix(in oklab, var(--accent) 45%, var(--line));
}
.chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.hint {
  margin: 0;
  font-size: 12.5px;
  color: #FF8FA3;
  font-family: var(--mono);
}

.foot {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted);
}
.foot sup { font-size: .75em; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  background: var(--accent);
  color: #0B0E14;
  font-size: 13px;
  font-weight: 700;
  padding: 11px 18px;
  border-radius: 10px;
  box-shadow: 0 16px 40px -12px rgba(0,0,0,.6);
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 420px) {
  .card { padding: 20px; }
  .actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
