  :root {
    --page: #ebe6da; --paper: #f3efe6; --sage: #cdd1b8; --sage-deep: #8f9678;
    --ink: #3f4433; --text: #4d4f44; --dim: #86847a; --field: #f7f4ed;
    --line: #ddd6c8; --line-on: #8f9678; --brown: #7d5d4a; --brown-ink: #fbf7f0;
    --ok: #4f7a4a; --bad: #b0473c; --note: #efe9dc; --warn: #a8742a;
    --shadow: 0 24px 60px rgba(70, 64, 45, .16);
    --serif: 'Lora', Georgia, 'Times New Roman', serif;
    --sans: Vazirmatn, Tahoma, system-ui, sans-serif;
    --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --page: #1b1d16; --paper: #23261d; --sage: #3b4131; --sage-deep: #7d8567;
      --ink: #eeeadd; --text: #dcd8ca; --dim: #9b9887; --field: #1c1e17;
      --line: #3a3e31; --line-on: #9aa37f; --brown: #9b7660; --brown-ink: #fffaf2;
      --ok: #8fbf86; --bad: #e0897d; --note: #2b2f24; --warn: #dcae62; --shadow: 0 24px 60px rgba(0, 0, 0, .45);
    }
  }
  *, *::before, *::after { box-sizing: border-box; }
  html, body { height: 100%; margin: 0; }
  body {
    background: var(--page); color: var(--text); font: 15px/1.75 var(--sans);
    display: flex; align-items: center; justify-content: center; -webkit-font-smoothing: antialiased;
  }
  [hidden] { display: none !important; }
  .card {
    position: relative; overflow: hidden; width: 100%; max-width: 420px;
    min-height: 100vh; min-height: 100dvh; background: var(--paper); display: flex; flex-direction: column;
  }
  @media (min-width: 480px) {
    body { padding: 32px 16px; }
    .card { min-height: 0; border-radius: 34px; box-shadow: var(--shadow); }
  }
  .band { position: relative; background: var(--sage); padding: calc(26px + env(safe-area-inset-top, 0px)) 26px 50px; }
  .band svg.wave { position: absolute; left: 0; right: 0; bottom: -1px; width: 100%; height: 48px; display: block; }
  .brand-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
  .brand h1 { margin: 0; color: var(--ink); font-weight: 800; font-size: 28px; line-height: 1.25; }
  .brand p { margin: 2px 0 0; color: var(--dim); font-size: 14px; font-weight: 500; }
  html[lang="en"] .brand h1 { font-family: var(--serif); font-weight: 500; font-size: 32px; }
  html[lang="en"] .brand p { letter-spacing: .28em; font-size: 12.5px; }
  .tile {
    flex: none; width: 64px; height: 64px; border-radius: 18px; background: var(--sage-deep);
    display: grid; place-items: center; box-shadow: 0 10px 22px rgba(70, 75, 50, .22);
  }
  .tile svg { width: 34px; height: 34px; }
  .lang {
    position: absolute; top: calc(8px + env(safe-area-inset-top, 0px)); inset-inline-start: 18px;
    font: 600 12px var(--sans); color: var(--ink); opacity: .72;
    background: none; border: 0; padding: 6px 8px; cursor: pointer; border-radius: 9px;
  }
  .body { position: relative; z-index: 1; padding: 4px 26px 30px; flex: 1; }
  h2 { margin: 0 0 8px; color: var(--ink); font-size: 24px; font-weight: 800; line-height: 1.5; }
  html[lang="en"] h2 { font-family: var(--serif); font-weight: 500; font-size: 27px; }
  .lead { margin: 0 0 18px; color: var(--dim); font-size: 13.5px; }
  .field {
    display: flex; align-items: center; gap: 10px; background: var(--field);
    border: 1.5px solid var(--line); border-radius: 16px; padding: 7px 14px; margin-bottom: 12px;
    transition: border-color .15s, box-shadow .15s;
  }
  .field:focus-within { border-color: var(--line-on); box-shadow: 0 0 0 3px rgba(143, 150, 120, .16); }
  .field.bad { border-color: var(--bad); }
  .field .in { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .field label { font-size: 11.5px; color: var(--dim); line-height: 1.5; }
  .field input {
    width: 100%; border: 0; outline: 0; background: none; padding: 0;
    font: 500 16px/1.6 var(--sans); color: var(--text);
  }
  .field input.ltr { direction: ltr; text-align: right; }
  html[lang="en"] .field input.ltr { text-align: left; }
  .field input.code { font-family: var(--mono); letter-spacing: 2px; text-transform: uppercase; }
  .eye { flex: none; background: none; border: 0; padding: 4px; cursor: pointer; color: var(--dim); display: grid; }
  .eye svg { width: 20px; height: 20px; }
  .rule { margin: -4px 4px 16px; color: var(--dim); font-size: 12.5px; }
  .btn {
    width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
    padding: 14px 18px; border: 0; border-radius: 999px; cursor: pointer;
    background: var(--brown); color: var(--brown-ink); font: 700 16px var(--sans);
    box-shadow: 0 10px 22px rgba(125, 93, 74, .25);
  }
  html[lang="en"] .btn { font-weight: 600; }
  .btn:disabled { opacity: .55; cursor: default; }
  .ghost {
    width: 100%; margin-top: 10px; padding: 11px; border-radius: 999px; cursor: pointer;
    background: none; border: 1.5px solid var(--line); color: var(--dim); font: 600 14px var(--sans);
  }
  .linkish { display: block; margin: 0 4px 16px; color: var(--dim); font-size: 13px; text-decoration: none; background: none; border: 0; padding: 0; cursor: pointer; font-family: var(--sans); }
  .linkish:hover { color: var(--brown); }
  .msg { font-size: 13.5px; margin-top: 12px; min-height: 22px; text-align: center; }
  .msg:empty { min-height: 0; margin-top: 0; }
  .msg.bad { color: var(--bad); }
  .msg.ok { color: var(--ok); }
  .note { background: var(--note); border-radius: 14px; padding: 12px 14px; font-size: 13px; color: var(--text); margin-top: 18px; }
  .note b { color: var(--ink); }
  .note a { color: var(--brown); font-weight: 700; text-decoration: none; direction: ltr; unicode-bidi: isolate; }
  .codebox {
    margin: 4px 0 12px; padding: 16px 10px; text-align: center; direction: ltr;
    font: 700 23px/1.4 var(--mono); letter-spacing: 1.5px; color: var(--ink);
    background: var(--field); border: 1.5px dashed var(--line-on); border-radius: 16px;
    user-select: all; -webkit-user-select: all; word-break: break-all;
  }
  .row2 { display: flex; gap: 10px; margin-bottom: 14px; }
  .row2 .ghost { margin-top: 0; color: var(--ink); }
  .done-line { color: var(--ok); font-size: 13.5px; margin: 0 0 6px; }
  .foot { position: relative; height: 70px; margin-top: auto; pointer-events: none; }
  .foot svg { position: absolute; bottom: 0; width: 100%; height: 70px; display: block; }

  .pwm { margin: -4px 6px 12px; }
  .pwm-empty { visibility: hidden; }
  .pwm-row { display: flex; align-items: center; gap: 10px; }
  .pwm-bar { flex: 1; display: flex; gap: 4px; }
  .pwm-bar i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
  .pwm-weak .pwm-bar i:first-child { background: var(--bad); }
  .pwm-fair .pwm-bar i:nth-child(-n+2) { background: var(--warn); }
  .pwm-strong .pwm-bar i { background: var(--ok); }
  .pwm-word { min-width: 3.6em; min-height: 1.6em; text-align: end; font-size: 12px; font-weight: 600; line-height: 1.6; }
  .pwm-weak .pwm-word { color: var(--bad); }
  .pwm-fair .pwm-word { color: var(--warn); }
  .pwm-strong .pwm-word { color: var(--ok); }
  .pwm-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .pwm-hint { margin: 2px 0 0; min-height: 1.6em; font-size: 12px; line-height: 1.6; color: var(--dim); }
