/* ===========================================================================
   Mr.Wang Chinese — the design language, as tokens.
   ---------------------------------------------------------------------------
   ONE file. Every other stylesheet points at these names instead of carrying
   its own copy of the palette.

   ── Why this file exists ─────────────────────────────────────────────────
   A survey of all 42 pages and 19 stylesheets found the same design language
   copy-pasted under nine different prefixes, and drifting:

     the brand green existed as TEN independent declarations with FOUR
     different values (--mw-green, --sk-green, --ap-green, --md-green,
     --hmp-green, --hz-green, plus raw literals);

     the cool prose/auth palette was copy-pasted into NINE html files and had
     already drifted (--shadow-1 is rgba(15,23,42,.04) in account.html and
     .03 in older page styles; signup.html omits --red entirely while
     forgot-password.js writes color:'var(--red)' at runtime);

     levels.html declared body.levels-page TWICE in one file — the second
     block silently won, so the page rendered Arial where its own source said
     serif, and a flat #f7f9f8 where its own source said a warm gradient;

     token names lie: --gold is blue in nine files, --green is navy #1e3a8a,
     --lp-blue is green in one sheet and blue in another.

   Those prefixes still exist — they are what page CSS references — but they
   are ALIASES declared against the tokens below. Change a value here and the
   site moves together.

   ── Load order ───────────────────────────────────────────────────────────
   FIRST stylesheet on every page, before style.css and before any page CSS.
   It declares custom properties on :root and nothing else, so no rule here
   can outrank a page rule. Custom properties resolve at USE time, so a later
   sheet that re-declares one of these names still wins — which is why the
   rewire edits those blocks rather than relying on load order alone.

   ── How colour is organised ──────────────────────────────────────────────
   Three jobs, three tokens, because one value cannot do all three and stay
   accessible:

     *-mark   vivid. Dots, edges, gradient fills, glows, large marks.
     *-ink    the same hue carried deep enough to be TYPE, and to hold white
              at 4.5:1. Filled buttons and small text take this one. Always.
     *-rgb    bare channels, so a shadow can be tinted with the element's own
              hue: rgba(var(--x-rgb), .5). A neutral black shadow under a
              coloured card looks printed on; one carrying the card's hue
              looks lit.

   Every ratio in the comments was COMPUTED, not estimated. If you move a
   value, recompute — several pairs sit deliberately close to their floor.
   =========================================================================== */

:root {
  /* Account surfaces use the same palette on every learning-area theme. */
  --auth-accent: #C23F46;
  --auth-hover: #A9323A;
  --auth-rgb: 194, 63, 70;
  --auth-ink: #1F1A1A;
  --auth-body: #4A4040;
  --auth-muted: #7A6B6B;
  --auth-tint: #FFF1F0;
  --auth-tint-2: #FFE3E1;
  --auth-wash: #FFFCFB;
  --auth-line: #E8DAD8;


  /* ═══ 1. Neutrals ════════════════════════════════════════════════════
     Warm and faintly green, not neutral grey. Against a green brand a true
     grey reads as dirty. Ratios are against --white. */
  --t-ink:       #16211c;   /* headings, primary text            16.6:1 */
  --t-ink-2:     #33443c;   /* body copy                         10.3:1 */
  --t-muted:     #5c6e65;   /* secondary text. Clears 4.5:1 on EVERY surface
                              in this file, which is why it is this dark:
                              5.4 white, 5.2 cream, 4.9 sand, 4.7 sunk,
                              4.9 green-tint, 4.7 grammar-tint. It was
                              #5f7168 and missed on --t-sunk at 4.47. */
  --t-faint:     #93a49b;   /* DECORATION ONLY — 2.6:1. Never text.
                               Eyebrows and labels take --t-muted. */
  --t-line:      #e7e4da;   /* hairlines with a job to do */
  --t-line-soft: #f0ede4;   /* hairlines that only separate */

  --t-white:     #ffffff;
  --t-cream:     #fbfaf5;   /* the warm page base */
  --t-sand:      #f6f3ea;   /* the alternate band */
  --t-sunk:      #f1eee4;   /* inset wells, code blocks */
  --t-scrim:     rgba(18, 26, 22, .46);

  --t-inverted:     #1b2b23;   /* dark panels */
  --t-on-inverted:  #eef3ef;

  /* ═══ 2. Brand ═══════════════════════════════════════════════════════
     White on --t-green-deep is 7.9:1; on --t-green-bright only 3.9:1, so
     --t-green-bright NEVER carries small white text. */
  --t-green-bright: #3d9163;
  --t-green:        #2f7d52;
  --t-green-deep:   #215c3b;
  --t-green-tint:   #e9f6ee;
  --t-green-tint-2: #d4eddd;
  --t-green-rgb:      61, 145, 99;    /* --t-green-bright, for glows and fills */
  /* A shadow must be DARKER than the thing casting it. Tinting one with
     --t-green-rgb lightens it instead, which is how a shadow stops reading
     as depth. Shadows take these channels. */
  --t-green-deep-rgb: 33, 92, 59;

  /* The site's gold. Brand accent and the "missed" teaching colour share it
     deliberately — see §5. --t-gold is decoration; --t-gold-ink is type. */
  --t-gold:      #c9922f;
  --t-gold-ink:  #8a5f16;   /* 5.0:1 on --t-gold-tint, 5.6:1 white-on.
                              Was #95681a, which measured 4.38:1 on its own
                              tint — this file documented that as "4.4:1"
                              and shipped it anyway. */
  --t-gold-tint: #fbf1dc;

  --t-vermilion: #a52a2a;   /* the seal red from the logo. Brand only. */

  /* ═══ 3. The four learning areas ═════════════════════════════════════
     RESERVED. The survey found FIVE independent four-way colour systems on
     this site competing for four hues. These four hues belong to the four
     learning AREAS — the site's primary taxonomy — and to nothing else. The
     other four-way systems are re-encoded in §7 on a lightness axis instead,
     because they are ordinal anyway and were never categorical. */
  --t-area-pron-mark:  #3a72c4;
  --t-area-pron-ink:   #23508f;   /* 7.1:1 on tint, 8.0:1 white-on */
  --t-area-pron-tint:  #eaf2fe;
  --t-area-pron-tint2: #d9e8fc;
  --t-area-pron-rgb:   58, 114, 196;

  --t-area-char-mark:  #3d9163;
  --t-area-char-ink:   #256b43;   /* 5.8:1 on tint, 6.4:1 white-on */
  --t-area-char-tint:  #e9f6ee;
  --t-area-char-tint2: #d4eddd;
  --t-area-char-rgb:   61, 145, 99;

  --t-area-vocab-mark: #d66f2f;   /* 3.1:1 on its tint — the floor for a mark */
  --t-area-vocab-ink:  #a84d16;   /* 5.1:1 on tint, 5.6:1 white-on */
  --t-area-vocab-tint: #fef1e7;
  --t-area-vocab-tint2:#fbe1cf;
  --t-area-vocab-rgb:  214, 111, 47;

  --t-area-gram-mark:  #8663d6;
  --t-area-gram-ink:   #5b38ab;   /* 7.0:1 on tint, 8.1:1 white-on */
  --t-area-gram-tint:  #f2ecfd;
  --t-area-gram-tint2: #e5dafb;
  --t-area-gram-rgb:   134, 99, 214;

  /* The HSK Test (2026-10-31) is the exam hub, not a fifth learning area, so it does not take a fifth subject hue:
     it wears the coral of the header (Sign Up, the current-page mark). */
  /* HSK is blue (2026-11-03, Yi: "颜色要和主页区分"): the home page's own cue for it (the book's right page),
     and the blue of Reading, which sits under HSK. The same five values as the read tokens below. */
  --t-area-hsk-mark:   #3f7fd8;   /* 3.6:1 on its tint — the floor for a mark */
  --t-area-hsk-ink:    #2b62b3;   /* 5.4:1 on tint, 6.0:1 white-on */
  --t-area-hsk-tint:   #ecf3fe;
  --t-area-hsk-tint2:  #d8e7fc;
  --t-area-hsk-rgb:    63, 127, 216;

  /* Reading (2026-11-01) sits under Practice, not a fifth learning area: it wears the blue of the Practice page
     in the home page's book (--hc-blue-deep), carried deeper for type. */
  --t-area-read-mark:  #3f7fd8;   /* 3.6:1 on its tint — the floor for a mark */
  --t-area-read-ink:   #2b62b3;   /* 5.4:1 on tint, 6.0:1 white-on */
  --t-area-read-tint:  #ecf3fe;
  --t-area-read-tint2: #d8e7fc;
  --t-area-read-rgb:   63, 127, 216;

  /* ═══ 4. Actions ═════════════════════════════════════════════════════ */
  --t-action-fill:  var(--t-green-deep);   /* white on it: 7.9:1 */
  --t-action-hover: #1a4a30;
  --t-action-edge:  rgba(47, 125, 82, .38);
  --t-action-ink:   var(--t-green-deep);

  /* Deliberately the same family as --t-wrong but deeper. Destructive
     actions and wrong answers never share a view; red is the convention for
     both and inventing a second red would be worse than sharing one. */
  --t-destructive:      #93231b;   /* 8.4:1 white-on */
  --t-destructive-tint: #fdeceb;

  /* The one focus token. The survey found NO :focus-visible at all in
     style.css, level-page.css, skill-page.css, area-page.css, all twelve
     lesson pages and all four prose pages — keyboard users get the UA ring
     against whatever the theme puts behind it. It must never equal
     --t-current or --t-selected, or "focused" and "chosen" merge. */
  --t-focus:        #1d6fd6;
  --t-focus-halo:   rgba(29, 111, 214, .28);

  /* ═══ 5. Answer states ═══════════════════════════════════════════════
     Three verdicts, three unmistakable hues, each as a trio so a component
     can tint a surface, draw an edge and set type without inventing values.

     THE GOLD/AMBER COLLISION, RESOLVED. "Missed" (this was right and you
     did not pick it) has been gold since the lessons were written, and the
     lesson copy says so out loud — starter-lesson-5 "gold = missed",
     starter-lesson-12 "marked gold". So gold stays with MISSED, and the
     advisory "warning" role — quota notices, retest banners — takes the
     vocabulary orange instead. Warning and missed never appear in one view;
     warning and wrong do, and orange vs red is a clear pair. */
  --t-correct-mark: #2f9e5c;
  --t-correct-ink:  #177d43;   /* 4.6:1 on tint, 5.2:1 white-on.
                                  Replaces #16a34a, whose white tick was
                                  3.3:1 and failed. */
  --t-correct-tint: #e6f6ec;
  --t-correct-edge: #bfe6cd;

  --t-wrong-mark:   #d64a3f;
  --t-wrong-ink:    #b3261e;   /* 5.7:1 on tint, 6.5:1 white-on */
  --t-wrong-tint:   #fdeceb;
  --t-wrong-edge:   #f6cdc9;

  --t-missed-mark:  #a87a24;   /* 3.4:1 on tint — deepened from #c9922f,
                                  which was 2.5:1 and failed as a mark */
  --t-missed-ink:   var(--t-gold-ink);   /* 5.0:1 on tint, 5.6:1 white-on */
  --t-missed-tint:  #fbf1dc;
  --t-missed-edge:  #ecd6a4;

  --t-warning-mark: var(--t-area-vocab-mark);
  --t-warning-ink:  var(--t-area-vocab-ink);
  --t-warning-tint: var(--t-area-vocab-tint);

  --t-info-mark:    var(--t-area-pron-mark);
  --t-info-ink:     var(--t-area-pron-ink);
  --t-info-tint:    var(--t-area-pron-tint);

  /* Progress-through-the-course states, as distinct from answer verdicts.
     --t-current is "you are here", --t-done is "finished". They must not
     equal each other, --t-focus, or --t-correct. */
  --t-current:      var(--t-green-deep);
  --t-current-tint: var(--t-green-tint);
  --t-done:         var(--t-green-bright);
  --t-done-tint:    var(--t-green-tint-2);
  --t-selected:     var(--t-area-pron-ink);
  --t-selected-tint:var(--t-area-pron-tint);

  /* Locked / disabled. Today this is opacity ALONE at ~20 sites, which
     survives a retheme untouched and then multiplies against whatever new
     fill arrives. A real pair means a locked control can be recognised
     without comparing it to an unlocked one. */
  --t-locked-ink:  #7d8b83;
  --t-locked-tint: #f2f1ec;
  --t-locked-edge: #ddd9cd;

  /* Paid tier. Was #f59e0b with white at 2.15:1 — the worst pair on the
     site, and it labelled the paid plan. Now the brand green, which reads
     as premium and clears 7.9:1. */
  --t-premium-fill: var(--t-green-deep);
  --t-premium-ink:  var(--t-gold-ink);
  --t-premium-tint: var(--t-gold-tint);

  /* ═══ 6. Quantity ════════════════════════════════════════════════════ */
  --t-track:     #e5e2d8;
  --t-fill:      var(--t-green);   /* 3.9:1 on the track. --t-green-bright was
                                      2.98:1 — below the 3:1 floor for a graphic
                                      that carries a quantity, and the comment
                                      here claimed 3.1:1. It was measured wrong. */
  --t-exhausted: var(--t-wrong-mark);

  /* ═══ 7. Ordinal ramps ═══════════════════════════════════════════════
     The four-way systems that are NOT the learning areas. Each is ordinal —
     "how far through", "how complex", "how overdue" — so each is one hue at
     four lightnesses. Sequential data wants a sequential ramp; giving it
     four categorical hues was the original mistake and is what created five
     systems competing for four colours. */
  --t-step-1: #dcece2;
  --t-step-2: #a9d3bd;
  --t-step-3: #5da37c;
  --t-step-4: var(--t-green-deep);

  /* The on-colour flips to white at the DARKEST step only. Step 3 took white
     at exactly 3.00:1 — fine for a large mark, a failure for the 11-13px badge
     type that actually sits on it, and it made steps 3 and 4 share one ink.
     Dark ink on step 3 is 5.51:1 and leaves the ramp's lightness spacing
     untouched (1.35 / 1.82 / 2.63 between steps). */
  --t-step-1-ink: #2c4738;   /* 8.3:1 on step 1 */
  --t-step-2-ink: #24503a;   /* 5.6:1 on step 2 */
  --t-step-3-ink: var(--t-ink);   /* 5.5:1 on step 3 */
  --t-step-4-ink: #ffffff;   /* 7.9:1 on step 4 */

  /* ═══ 8. The teaching signal ═════════════════════════════════════════
     THE MOST IMPORTANT COLOURS ON THE SITE, and until now none of them was
     in a stylesheet — they are literals inside script.js, level-view.js,
     demo.js, decompose.js, place-strokes.js and five lesson pages. They are
     declared here so there is one place to read them from, and so the
     numbers below are written down somewhere.

     The hard constraint: the stroke BEING TAUGHT, the strokes ALREADY
     WRITTEN, and the ghost NOT YET WRITTEN must all separate from each
     other and from the paper. No single highlight cleared 3:1 against both
     the ink and the ghost; this pair does, at 3.03 and 3.23. It is the
     floor, so do not nudge either value without recomputing both. */
  --t-stroke-ink:     #2d2823;   /* the character itself. 14.6:1 on paper  */
  --t-stroke-ghost:   #d8d3c8;   /* not yet written                        */
  --t-stroke-current: #b85520;   /* 3.03:1 vs ink, 3.23:1 vs ghost         */
  --t-stroke-trace:   #3a72c4;   /* the learner's own in-progress trace    */
  --t-radical:        #c05621;   /* 3.2:1 vs ink, 4.6:1 vs paper           */

  /* The two halves of a decomposed character. */
  --t-part-a: #2d6a4f;
  --t-part-b: #b8862c;

  /* 形 (meaning) vs 声 (sound). These were #95681a and #177d43 — 1.05:1
     apart, i.e. the SAME lightness: indistinguishable in greyscale and to a
     red-green colour deficiency, on a lesson whose entire point is telling
     them apart. Separated on lightness to 2.8:1, and the lesson labels them
     in words as well — hue alone should never have been the whole signal. */
  --t-part-meaning: #b8862c;   /* 3.2:1 on paper */
  --t-part-sound:   #14532d;   /* 9.1:1 on paper */

  /* Stroke identity series: hue = which stroke, in order. Six, because the
     learner counts them; ordered light-to-dark so the sequence survives
     greyscale and print. */
  --t-series-1: #2f6fd0;
  --t-series-2: #2f9e5c;
  --t-series-3: #b8862c;
  --t-series-4: #c05621;
  --t-series-5: #8663d6;
  --t-series-6: #4b5b54;

  /* ═══ 9. Paper ═══════════════════════════════════════════════════════
     The 田字格 / 米字格 sheet. style.css forces print-color-adjust: exact
     site-wide, so every value here actually inks — these are print colours
     first and screen colours second. The ORDERING is the real promise: the
     cell frame must read stronger than the inner guide, or the guide starts
     reading as the box. */
  --t-paper:          #ffffff;
  --t-grid-border:    #bfb49c;   /* 2.05:1 on paper */
  --t-grid-guide:     #ded6c4;   /* 1.45:1 on paper — deliberately weaker */
  --t-pinyin-stave:   #d5cdb9;
  --t-watermark:      #9a9184;

  /* ═══ 10. Type ═══════════════════════════════════════════════════════ */
  --t-display: 'Lora', Georgia, 'Times New Roman', serif;
  --t-ui:      'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --t-sans:    -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --t-chinese: 'LXGW WenKai Screen', 'Kaiti SC', 'STKaiti', 'KaiTi', 'Kaiti',
               'AR PL UKai CN', 'STSong', 'SimSun', 'Noto Serif CJK SC', serif;

  /* ═══ 11. Shape ══════════════════════════════════════════════════════ */
  --t-r-sm:   .625rem;
  --t-r-md:   1.25rem;
  --t-r-lg:   1.75rem;
  --t-r-xl:   2.25rem;
  --t-r-pill: 999px;

  /* ═══ 12. Depth ══════════════════════════════════════════════════════
     Two parts every time: a 1px contact shadow that keeps the edge crisp,
     and a wide soft one that does the lifting. One blurry shadow doing both
     is what reads as a cheap drop-shadow. */
  --t-sh-1: 0 1px 2px rgba(22, 33, 28, .05);
  --t-sh-2: 0 1px 2px rgba(22, 33, 28, .05), 0 16px 32px -22px rgba(22, 33, 28, .35);
  --t-sh-3: 0 1px 2px rgba(22, 33, 28, .06), 0 28px 50px -28px rgba(22, 33, 28, .42);
  --t-sh-4: 0 1px 2px rgba(22, 33, 28, .07), 0 40px 70px -34px rgba(22, 33, 28, .48);

  /* ═══ 13. Motion ═════════════════════════════════════════════════════ */
  --t-ease:     cubic-bezier(.4, 0, .2, 1);
  --t-ease-out: cubic-bezier(.16, 1, .3, 1);
  --t-fast:     .15s;
  --t-base:     .22s;
}

/* ───────────────────────────────────────────────────────────────────────
   Focus, once, for the whole site.

   Low specificity on purpose (0,1,0 via :where) so any component that wants
   its own ring still wins. What this guarantees is that nothing is left with
   NO ring — which is the state most of the site was in.
   ─────────────────────────────────────────────────────────────────────── */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--t-focus);
  outline-offset: 2px;
  border-radius: 3px;
}

@media (prefers-reduced-motion: reduce) {
  :root { --t-fast: .01ms; --t-base: .01ms; }
}
