:root {
    --bg: #eef0ea;
    --bg-grid: rgba(26, 30, 24, 0.05);
    --surface: #ffffff;
    --surface-2: #e3e6dd;
    --surface-3: #d7dbcf;
    --ink: #1a1e18;
    --ink-muted: #5b6355;
    --ink-faint: #8b9284;
    --border: #cdd2c3;
    --accent: #3a6ea5;
    --accent-ink: #ffffff;
    --accent-soft: rgba(58, 110, 165, 0.12);
    --good: #3f7d4f;
    --good-soft: rgba(63, 125, 79, 0.14);
    --warn: #b5791f;
    --warn-soft: rgba(181, 121, 31, 0.14);
    --critical: #b3402f;
    --critical-soft: rgba(179, 64, 47, 0.14);
    --shadow: 0 1px 2px rgba(26, 30, 24, 0.06), 0 8px 24px rgba(26, 30, 24, 0.08);
    --font-display: 'IBM Plex Sans', -apple-system, Segoe UI, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  }

  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg: #10131a;
      --bg-grid: rgba(255, 255, 255, 0.045);
      --surface: #191d26;
      --surface-2: #222732;
      --surface-3: #2c323f;
      --ink: #e9ecf1;
      --ink-muted: #9aa3b0;
      --ink-faint: #6b7383;
      --border: #2c323f;
      --accent: #74a3d8;
      --accent-ink: #0e1420;
      --accent-soft: rgba(116, 163, 216, 0.16);
      --good: #6bbf82;
      --good-soft: rgba(107, 191, 130, 0.16);
      --warn: #e0a94b;
      --warn-soft: rgba(224, 169, 75, 0.16);
      --critical: #e07a68;
      --critical-soft: rgba(224, 122, 104, 0.16);
      --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 28px rgba(0, 0, 0, 0.35);
    }
  }

  :root[data-theme="dark"] {
    --bg: #10131a;
    --bg-grid: rgba(255, 255, 255, 0.045);
    --surface: #191d26;
    --surface-2: #222732;
    --surface-3: #2c323f;
    --ink: #e9ecf1;
    --ink-muted: #9aa3b0;
    --ink-faint: #6b7383;
    --border: #2c323f;
    --accent: #74a3d8;
    --accent-ink: #0e1420;
    --accent-soft: rgba(116, 163, 216, 0.16);
    --good: #6bbf82;
    --good-soft: rgba(107, 191, 130, 0.16);
    --warn: #e0a94b;
    --warn-soft: rgba(224, 169, 75, 0.16);
    --critical: #e07a68;
    --critical-soft: rgba(224, 122, 104, 0.16);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 28px rgba(0, 0, 0, 0.35);
  }



  .page {
    width: 100%;  display: flex; flex-direction: column; gap: 22px;
    font-family: var(--font-display); color: var(--ink);
  }

  /* ---------- header ---------- */
  .header { display: flex; align-items: center; gap: 14px; }
  .dial { flex: none; width: 46px; height: 46px; }
  .dial circle.rim { fill: none; stroke: var(--border); stroke-width: 2; }
  .dial circle.face { fill: var(--surface); }
  .dial .tick { stroke: var(--ink-faint); stroke-width: 1.6; stroke-linecap: round; }
  .dial .needle { stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; }
  .dial .hub { fill: var(--accent); }

  h1 { font-size: 1.5rem; font-weight: 700; margin: 0; letter-spacing: -0.01em; text-wrap: balance; }
  .tagline { margin: 2px 0 0; color: var(--ink-muted); font-size: 0.88rem; line-height: 1.4; }

  /* ---------- tabs ---------- */
  .tabs {
    display: grid; grid-template-columns: repeat(3, 1fr);
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 12px; padding: 4px; gap: 4px;
  }
  .tab {
    font-family: inherit; font-size: 0.82rem; font-weight: 600; color: var(--ink-muted);
    background: transparent; border: none; border-radius: 9px; padding: 9px 6px;
    cursor: pointer; transition: background .15s ease, color .15s ease;
  }
  .tab:hover { color: var(--ink); }
  .tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
  .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

  /* ---------- password panel ---------- */
  .panel {
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
    padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px;
  }

  .output-row { display: flex; align-items: stretch; gap: 8px; }
  .output {
    flex: 1; min-width: 0; background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 12px; padding: 14px 16px; font-family: var(--font-mono);
    font-size: 1.28rem; font-variant-numeric: tabular-nums; letter-spacing: 0.02em;
    word-break: break-all; line-height: 1.35; display: flex; align-items: center; min-height: 34px;
  }
  .output.masked { letter-spacing: 0.18em; }

  .icon-btn {
    flex: none; width: 46px; border-radius: 12px; border: 1px solid var(--border);
    background: var(--surface-2); color: var(--ink); cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: background .15s ease, border-color .15s ease, transform .15s ease;
  }
  .icon-btn:hover { background: var(--surface-3); }
  .icon-btn:active { transform: scale(0.94); }
  .icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .icon-btn svg { width: 19px; height: 19px; }

  .primary-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    font-family: inherit; font-weight: 600; font-size: 0.92rem;
    background: var(--accent); color: var(--accent-ink); border: none; border-radius: 12px;
    padding: 12px 16px; cursor: pointer; transition: filter .15s ease, transform .15s ease;
  }
  .primary-btn:hover { filter: brightness(1.06); }
  .primary-btn:active { transform: scale(0.98); }
  .primary-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .primary-btn svg { width: 17px; height: 17px; }

  /* ---------- strength meter ---------- */
  .meter { display: flex; flex-direction: column; gap: 8px; }
  .meter-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 0.82rem; }
  .meter-label { font-weight: 700; }
  .meter-label.good { color: var(--good); }
  .meter-label.warn { color: var(--warn); }
  .meter-label.critical { color: var(--critical); }
  .meter-bits { color: var(--ink-faint); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
  .meter-track { height: 7px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
  .meter-fill { height: 100%; border-radius: 5px; transition: width .25s ease, background-color .25s ease; }
  .meter-fill.good { background: var(--good); }
  .meter-fill.warn { background: var(--warn); }
  .meter-fill.critical { background: var(--critical); }
  .crack-time { font-size: 0.8rem; color: var(--ink-muted); }
  .crack-time b { color: var(--ink); font-weight: 600; }

  /* ---------- controls ---------- */
  .controls { display: flex; flex-direction: column; gap: 16px; }
  .field { display: flex; flex-direction: column; gap: 8px; }
  .field-top { display: flex; justify-content: space-between; align-items: baseline; }
  .field-name { font-size: 0.82rem; font-weight: 600; color: var(--ink-muted); }
  .field-value { font-family: var(--font-mono); font-size: 0.86rem; font-variant-numeric: tabular-nums; }

  input[type="range"] {
    -webkit-appearance: none; appearance: none; width: 100%; height: 6px;
    border-radius: 4px; background: var(--surface-3); outline: none;
  }
  input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
    background: var(--accent); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border);
    cursor: pointer; margin-top: -0.5px;
  }
  input[type="range"]::-moz-range-thumb {
    width: 20px; height: 20px; border-radius: 50%; background: var(--accent);
    border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border); cursor: pointer;
  }
  input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

  .chip-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .chip {
    display: flex; align-items: center; gap: 9px; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
    cursor: pointer; font-size: 0.84rem; user-select: none; transition: border-color .15s ease, background .15s ease;
  }
  .chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
  .chip input { accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
  .chip span.hint { color: var(--ink-faint); font-family: var(--font-mono); font-size: 0.76rem; margin-left: auto; }

  .select-row { display: flex; gap: 8px; }
  select {
    font-family: var(--font-mono); font-size: 0.86rem; background: var(--surface-2);
    color: var(--ink); border: 1px solid var(--border); border-radius: 10px; padding: 9px 10px;
    cursor: pointer;
  }
  select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

  .toast {
    position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 10px);
    background: var(--ink); color: var(--bg); font-size: 0.82rem; font-weight: 600;
    padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none;
    transition: opacity .18s ease, transform .18s ease; box-shadow: var(--shadow);
  }
  .toast.show { opacity: 1; transform: translate(-50%, 0); }

  /* ---------- info panel ---------- */
  .info { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px; box-shadow: var(--shadow); }
  .info h2 { margin: 0 0 4px; font-size: 1rem; font-weight: 700; }
  .info p.lead { margin: 0 0 16px; color: var(--ink-muted); font-size: 0.85rem; line-height: 1.5; }
  .stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat {
    border: 1px solid var(--border); border-radius: 12px; padding: 12px 13px; background: var(--surface-2);
  }
  .stat-label { font-size: 0.72rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
  .stat-value { margin-top: 4px; font-size: 0.88rem; font-weight: 600; line-height: 1.35; }
  .stat-value.mono { font-family: var(--font-mono); }

  footer { text-align: center; color: var(--ink-faint); font-size: 0.76rem; padding-bottom: 4px; }

  @media (prefers-reduced-motion: reduce) {
    .tab, .icon-btn, .primary-btn, .chip, .meter-fill, .toast, select {
      transition: none !important;
    }
  }

  @media (max-width: 420px) {
    .chip-grid { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: 1fr; }
    .output { font-size: 1.05rem; }
  }