/* Lexicommons design system: tokens and built-in themes.
 *
 * Built on NeedWright's design system (app/ds/tokens.css, design-system branch): monochrome, white ink is the only
 * emphasis, Graphite neutrals on black, Instrument Sans UI, Onest headings, Geist Mono for numbers.
 * Lexicommons adds meaning colors, so every way of studying shows the same signals: right, wrong, slipping, new,
 * hint and moved words. Meaning never travels by color alone (always an icon, a word or a shape too), and the
 * palette passes scripts/check-palette.py under protanopia, deuteranopia and tritanopia.
 *
 * Every value here is a theme token: built-in themes override them below, and a user's theme or custom CSS can
 * override any of them. The token names are part of the theming surface (docs/design-system.md). */

/* The app's CSS sits in cascade layers, in this order, so a person's own CSS (unlayered, from the theme engine)
 * always wins over it, whatever its selectors. Load tokens.css first: this line fixes the order. */
@layer lx.tokens, lx.base, lx.components, lx.presets, lx.page;


@font-face { font-family: "Instrument Sans"; src: url("/fonts/instrument-sans-var.woff2") format("woff2-variations"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Onest"; src: url("/fonts/onest-var-latin.woff2") format("woff2-variations"); font-weight: 100 900; font-display: swap; unicode-range: U+0000-00FF, U+0100-017F, U+018F, U+01A0-01A1, U+01AF-01B0, U+0218-021B, U+0259, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0300-0304, U+0306-0309, U+030B-030C, U+0323, U+0326-0328, U+1E00-1EFF, U+2000-206F, U+20AC, U+20B4, U+20BA, U+20BD, U+2122, U+2190-2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Onest"; src: url("/fonts/onest-var-cyrillic.woff2") format("woff2-variations"); font-weight: 100 900; font-display: swap; unicode-range: U+0400-052F, U+1C80-1C88, U+2116; }
/* Letters beyond the shell's files (scripts/fonts/subset-fonts.py, each family's own, from its source at a pinned google/fonts commit): a page
   downloads one only when it shows its letters, so a learner of English or Dutch fetches nothing more. Each comes after the face it extends, so
   it's tried first for its own range.
   - Instrument Sans's Latin Extended (č ł ő ș ğ ā ǎ ...), with the letters the family has no glyph for built from its own (ǐ ǒ ǔ ǖ ǘ ǚ ǜ,
     ĉ ĝ ŝ: its base letter and combining mark, which its ccmp swaps in and its mark positioning places); its symbols (← → ↔ ..., ‰) in a
     file of their own, so a page showing an arrow fetches 2 KB and never the letters.
   - Onest's (its carons for a pinyin title, IPA ...) with its combining marks, so ɔ̀ is one face's.
   - Onest Cyrillic: Onest's Cyrillic with the stress mark Russian's readings put on a vowel (молоко́), placed over а о у ы А О too: the
     reading face of a language written in Cyrillic (below).
   - Onest Fill: Onest's own files again, each limited to exactly what Instrument Sans can't draw (Cyrillic, Vietnamese's horned and dotted
     letters, Ə, ʻ, IPA, ḍ ṇ ṛ, ¹), second in --type-ui: a letter the app's face lacks is Onest's, never a system font's.
   - Greek: Noto Sans (OFL: /fonts/noto-OFL.txt); neither Instrument Sans nor Onest has it. */
@font-face { font-family: "Instrument Sans"; src: url("/fonts/instrument-sans-var-latin-ext.woff2") format("woff2-variations"); font-weight: 400 700; font-display: swap; unicode-range: U+0100-0101, U+0103-0130, U+0132-0137, U+0139-013E, U+0141-0148, U+014A-0151, U+0154-0165, U+0168-017E, U+01CD-01DC, U+01DE-01E3, U+01E6-01ED, U+01F0, U+01F4-01F5, U+01F8-01FF, U+0218-021B, U+021E-021F, U+0226-0233, U+0237, U+02C7, U+1E02-1E03, U+1E08-1E0B, U+1E10-1E11, U+1E14-1E17, U+1E1C-1E23, U+1E26-1E29, U+1E2E-1E31, U+1E3E-1E41, U+1E44-1E45, U+1E4C-1E59, U+1E60-1E61, U+1E64-1E67, U+1E6A-1E6B, U+1E78-1E7D, U+1E80-1E87, U+1E8A-1E91, U+1E97-1E99, U+1E9E, U+1EA4-1EA7, U+1EAA-1EAB, U+1EAE-1EB1, U+1EB4-1EB5, U+1EBC-1EC1, U+1EC4-1EC5, U+1ED0-1ED3, U+1ED6-1ED7, U+1EF2-1EF3, U+1EF8-1EF9; }
@font-face { font-family: "Instrument Sans"; src: url("/fonts/instrument-sans-var-symbols.woff2") format("woff2-variations"); font-weight: 400 700; font-display: swap; unicode-range: U+02D8-02D9, U+02DB, U+02DD, U+2030, U+2190, U+2192, U+2194-2199; }
@font-face { font-family: "Onest"; src: url("/fonts/onest-var-latin-ext.woff2") format("woff2-variations"); font-weight: 100 900; font-display: swap; unicode-range: U+0181, U+0186-018A, U+018E, U+0190-0194, U+0196-0199, U+019D, U+01A4-01A5, U+01AC-01AD, U+01B2-01B4, U+01B7, U+01CD-01DD, U+01E6-01E7, U+01F0, U+01F8-01F9, U+0237, U+0244-0245, U+024C-024D, U+0253-0254, U+0256-0257, U+025B, U+0260, U+0263, U+0268-0269, U+0272, U+0289, U+028B-028C, U+0292, U+0294, U+02B7, U+02C7, U+02D8-02D9, U+02DB, U+02DD, U+0300-0304, U+0306-030C, U+0312, U+031B, U+0323, U+0326-0329, U+0331, U+20B8, U+20BC, U+2117, U+2153-215E, U+2196-2199, U+21A9, U+21B6-21B7, U+21BA-21BB, U+2248, U+2260, U+2264-2265, U+2713, U+27F5-27F6, U+A78B-A78C; }
@font-face { font-family: "Onest Cyrillic"; src: url("/fonts/onest-var-cyrillic-marks.woff2") format("woff2-variations"); font-weight: 100 900; font-display: swap; unicode-range: U+0300-0301, U+0306, U+0308, U+0401-040C, U+040E-044F, U+0451-045C, U+045E-045F, U+0490-049D, U+04A0-04A5, U+04AA-04AB, U+04AE-04B3, U+04B6-04BB, U+04C0-04C2, U+04CF-04D9, U+04DC-04DF, U+04E2-04EB, U+04EE-04F5, U+2116; }
@font-face { font-family: "Onest Fill"; src: url("/fonts/onest-var-latin.woff2") format("woff2-variations"); font-weight: 100 900; font-display: swap; unicode-range: U+00B1-00B3, U+00B9, U+00BC-00BE, U+0138, U+013F-0140, U+0149, U+0166-0167, U+017F, U+018F, U+01A0-01A1, U+01AF-01B0, U+0259, U+02BB-02BC, U+1E04-1E05, U+1E0C-1E0D, U+1E24-1E25, U+1E32-1E3B, U+1E42-1E43, U+1E46-1E47, U+1E5A-1E5D, U+1E62-1E63, U+1E6C-1E6D, U+1E92-1E93, U+1EA0-1EA3, U+1EA8-1EA9, U+1EAC-1EAD, U+1EB2-1EB3, U+1EB6-1EBB, U+1EC2-1EC3, U+1EC6-1ECF, U+1ED4-1ED5, U+1ED8-1EF1, U+1EF4-1EF7, U+2044, U+20B4, U+20BA, U+20BD; }
@font-face { font-family: "Onest Fill"; src: url("/fonts/onest-var-cyrillic.woff2") format("woff2-variations"); font-weight: 100 900; font-display: swap; unicode-range: U+0401-040C, U+040E-044F, U+0451-045C, U+045E-045F, U+0490-049D, U+04A0-04A5, U+04AA-04AB, U+04AE-04B3, U+04B6-04BB, U+04C0-04C2, U+04CF-04D9, U+04DC-04DF, U+04E2-04EB, U+04EE-04F5, U+2116; }
@font-face { font-family: "Onest Fill"; src: url("/fonts/onest-var-latin-ext.woff2") format("woff2-variations"); font-weight: 100 900; font-display: swap; unicode-range: U+0181, U+0186-018A, U+018E, U+0190-0194, U+0196-0199, U+019D, U+01A4-01A5, U+01AC-01AD, U+01B2-01B4, U+01B7, U+01DD, U+0244-0245, U+024C-024D, U+0253-0254, U+0256-0257, U+025B, U+0260, U+0263, U+0268-0269, U+0272, U+0289, U+028B-028C, U+0292, U+0294, U+02B7, U+0300-0304, U+0306-030C, U+0312, U+031B, U+0323, U+0326-0329, U+0331, U+20B8, U+20BC, U+2117, U+2153-215E, U+21A9, U+21B6-21B7, U+21BA-21BB, U+2248, U+2260, U+2264-2265, U+2713, U+27F5-27F6, U+A78B-A78C; }
@font-face { font-family: "Noto Sans Greek"; src: url("/fonts/noto-sans-greek-var.woff2") format("woff2-variations"); font-weight: 400 700; font-display: swap; unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03E1, U+03F0-03FF, U+1F00-1F15, U+1F18-1F1D, U+1F20-1F45, U+1F48-1F4D, U+1F50-1F57, U+1F59, U+1F5B, U+1F5D, U+1F5F-1F7D, U+1F80-1FB4, U+1FB6-1FC4, U+1FC6-1FD3, U+1FD6-1FDB, U+1FDD-1FEF, U+1FF2-1FF4, U+1FF6-1FFE; }
@font-face { font-family: "Geist Mono"; src: url("/fonts/geist-mono-var-latin.woff2") format("woff2-variations"); font-weight: 100 900; font-display: swap; }
/* Google Sans Medium (OFL, Google Fonts' latin subset): only the "Continue with Google" button uses it, as Google's
   sign-in branding asks. */
@font-face { font-family: "Google Sans"; src: url("/fonts/google-sans-500-latin.woff2") format("woff2"); font-weight: 500; font-display: swap; }
/* Hebrew, Arabic, Armenian, Georgian, Thai, Devanagari, Gurmukhi and Gujarati script (Noto, OFL: /fonts/noto-OFL.txt):
   Instrument Sans has none of them, so they come next in the stacks, and a page downloads one only when it shows its
   letters (unicode-range, each script's own blocks: never a character English text may hold, such as U+25CC or a
   joiner). Urdu is written in Nastaliq; Thai in Noto's looped face, the letters a learner's textbook uses. Gurmukhi and
   Gujarati take the danda from their own face. */
@font-face { font-family: "Noto Sans Arabic"; src: url("/fonts/noto-sans-arabic-var.woff2") format("woff2-variations"); font-weight: 400 700; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Noto Sans Hebrew"; src: url("/fonts/noto-sans-hebrew-var.woff2") format("woff2-variations"); font-weight: 400 700; font-display: swap; unicode-range: U+0590-05FF, U+FB1D-FB4F; }
@font-face { font-family: "Noto Sans Thai Looped"; src: url("/fonts/noto-sans-thai-looped-var.woff2") format("woff2-variations"); font-weight: 100 900; font-display: swap; unicode-range: U+0E01-0E5B; }
@font-face { font-family: "Noto Nastaliq Urdu"; src: url("/fonts/noto-nastaliq-urdu-var.woff2") format("woff2-variations"); font-weight: 400 700; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Noto Sans Armenian"; src: url("/fonts/noto-sans-armenian-var.woff2") format("woff2-variations"); font-weight: 400 700; font-display: swap; unicode-range: U+0530-058F, U+FB13-FB17; }
@font-face { font-family: "Noto Sans Georgian"; src: url("/fonts/noto-sans-georgian-var.woff2") format("woff2-variations"); font-weight: 400 700; font-display: swap; unicode-range: U+10A0-10FF, U+1C90-1CBF, U+2D00-2D2F; }
@font-face { font-family: "Noto Sans Devanagari"; src: url("/fonts/noto-sans-devanagari-var.woff2") format("woff2-variations"); font-weight: 100 900; font-display: swap; unicode-range: U+0900-097F, U+A8E0-A8FF; }
@font-face { font-family: "Noto Sans Gurmukhi"; src: url("/fonts/noto-sans-gurmukhi-var.woff2") format("woff2-variations"); font-weight: 100 900; font-display: swap; unicode-range: U+0964-0965, U+0A01-0A76; }
@font-face { font-family: "Noto Sans Gujarati"; src: url("/fonts/noto-sans-gujarati-var.woff2") format("woff2-variations"); font-weight: 100 900; font-display: swap; unicode-range: U+0964-0965, U+0A80-0AFF; }

@layer lx.tokens {
  :root {
    /* The way forward (Start, Continue): Tinta's ink, its deep shade the hard edge. */
    --go: var(--art-violet);
    --go-deep: var(--art-violet-deep);
    --on-go: #ffffff;
    /* Solid line colors, so lines that meet or cross never double up (docs/design-bible.md). */
    --line-strong: color-mix(in srgb, var(--ink-1) 26%, var(--canvas));
    --line: color-mix(in srgb, var(--ink-1) 14%, var(--canvas));
    --size-stat: 40px;
    --bar-height: 64px;
    --bar-gap: max(12px, calc(env(safe-area-inset-bottom) - 12px));
    --bar-room: calc(var(--bar-height) + var(--bar-gap) + 24px);
    /* Type. --type-read is for long reading and the sentence you're studying; themes often change only this. */
    --type-ui: "Instrument Sans", "Onest Fill", "Noto Sans Greek", "Noto Sans Armenian", "Noto Sans Georgian", "Noto Sans Arabic", "Noto Sans Hebrew", "Noto Sans Thai Looped", "Noto Sans Devanagari", "Noto Sans Gurmukhi", "Noto Sans Gujarati", ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
    --type-head: "Onest", "Instrument Sans", "Noto Sans Greek", "Noto Sans Armenian", "Noto Sans Georgian", "Noto Sans Arabic", "Noto Sans Hebrew", "Noto Sans Thai Looped", "Noto Sans Devanagari", "Noto Sans Gurmukhi", "Noto Sans Gujarati", ui-sans-serif, sans-serif;
    --type-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
    --type-read: var(--type-ui);

    /* One scale. Product text uses 12/14/16/20/28; reading and the studied sentence have their own sizes, which the
     * text-size preset scales. */
    --size-12: 12px;
    --size-14: 14px;
    --size-16: 16px;
    --size-20: 20px;
    --size-28: 28px;
    --size-read: 19px;
    --size-target: 26px;
    --track-head: -0.02em;

    /* Five radii, each tied to a size of thing. */
    --radius-8: 8px;
    --radius-12: 12px;
    --radius-16: 16px;
    --radius-24: 24px;
    --radius-full: 999px;

    /* Controls: 32px like NeedWright on a desk, 44px for touch. The density preset picks one. */
    --control-32: 32px;
    --control-44: 44px;
    --control: var(--control-44);

    /* Space: one scale, multiplied by the density preset. */
    --density: 1;
    --space-1: calc(4px * var(--density));
    --space-2: calc(8px * var(--density));
    --space-3: calc(12px * var(--density));
    --space-4: calc(16px * var(--density));
    --space-5: calc(24px * var(--density));
    --space-6: calc(32px * var(--density));
    --space-7: calc(48px * var(--density));
    --page-width: 720px;
    /* The grid pages of Study, Explore and Knowledge on a wide screen (1280 and up: shell.css), so their grids use the room. */
    --page-width-wide: 960px;
    /* Settings on a wide screen (1280 and up: shell.css): its menu's pane, then the page it opened at the column's own width. */
    --settings-pane: 320px;
    /* A line of reading text at most ~68 characters: Instrument Sans averages ~0.46em a character (measured 8 Nov 2026: 68 of them 29.5–32.2em;
       "ch" is its 0, 0.67em, so 68ch would be ~100), and never wider than 640 px (the reader's larger type: ~60 characters at 22.8 px). Set on
       the text itself, where em is its own size; left where its column starts (only the reader centers). site.css mirrors it for the public
       pages. */
    --measure: min(31em, 640px);

    --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-spring: cubic-bezier(0.3, 1.4, 0.5, 1);
    --dur-150: 150ms;
    --dur-200: 200ms;
    --dur-320: 320ms;
    --dur-640: 640ms; /* signature moments: the Dutch-order morph, a session's summary */
    --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
    /* A sheet's slide in, out and back: quick off the mark, long and soft at the end, like iOS's own sheets. */
    --dur-sheet: 500ms;
    --dur-page: 350ms; /* a move between a tab's pages, iPhone-style (shell/page-slide.js; on --ease-sheet) */
    --ease-sheet: cubic-bezier(0.32, 0.72, 0, 1);
    /* A cover leaving from rest (a session's Done): the same long, soft end, but starting from standing still. --ease-sheet
     * starts at 2.25× its average speed: a whole screen's cover went 98 px in its first frame. */
    --ease-sheet-away: cubic-bezier(0.36, 0, 0.1, 1);

    /* The shapes that go with right and wrong wherever a part has no icon of its own (tiles, matches, words), so
     * meaning never rests on color. Masks, drawn in the part's current color; a theme can redraw them. */
    --mark-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 12.5l5 5L19.5 7'/%3E%3C/svg%3E");
    --mark-wrong: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.2' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E");

    /* Image slots a theme can fill (custom images are stored on the device and set here as blob: URLs). */
    --image-background: none;
    --image-mark: none;
    /* How the background image sits: its size (cover, contain, or auto for tiles), repeat, position, how much of the
     * page color lies over it so text stays readable (0% to 90%), and blur. */
    --image-background-size: cover;
    --image-background-repeat: no-repeat;
    --image-background-position: center;
    --image-background-dim: 0%;
    --image-background-blur: 0px;
  }

  /* The language you're learning reads in its own script's font under any theme: a theme's reading font has no Hebrew,
     Arabic, Armenian or Georgian letters (and a device may have no font of its own for them), and Urdu wants Nastaliq
     where Arabic and Persian use naskh. */
  :lang(ar), :lang(fa), :lang(ps), :lang(ckb) { --type-read: "Noto Sans Arabic", var(--type-ui); }
  :lang(ur) { --type-read: "Noto Nastaliq Urdu", var(--type-ui); }
  :lang(he), :lang(yi) { --type-read: "Noto Sans Hebrew", var(--type-ui); }
  :lang(hy) { --type-read: "Noto Sans Armenian", var(--type-ui); }
  :lang(ka) { --type-read: "Noto Sans Georgian", var(--type-ui); }
  :lang(th) { --type-read: "Noto Sans Thai Looped", var(--type-ui); }
  :lang(hi), :lang(mr), :lang(ne) { --type-read: "Noto Sans Devanagari", var(--type-ui); }
  :lang(pa) { --type-read: "Noto Sans Gurmukhi", var(--type-ui); }
  :lang(gu) { --type-read: "Noto Sans Gujarati", var(--type-ui); }
  :lang(el) { --type-read: "Noto Sans Greek", var(--type-ui); }
  /* Instrument Sans has no Cyrillic, nor Vietnamese's horned and dotted letters or Azerbaijani's Ə: a language written with them is in Onest
     throughout (its reading, its words in the app's own type and in headings), so no word mixes two faces. Cyrillic's comes with its stress
     marks (Onest Cyrillic); its Latin, digits and marks between words stay Instrument Sans's, as Arabic's do. */
  :lang(be), :lang(bg), :lang(kk), :lang(mk), :lang(ru), :lang(sr), :lang(uk) {
    --type-ui: "Onest Cyrillic", "Instrument Sans", "Onest Fill", "Noto Sans Greek", "Noto Sans Armenian", "Noto Sans Georgian", "Noto Sans Arabic", "Noto Sans Hebrew", "Noto Sans Thai Looped", "Noto Sans Devanagari", "Noto Sans Gurmukhi", "Noto Sans Gujarati", ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
    --type-head: "Onest Cyrillic", "Onest", "Instrument Sans", "Noto Sans Greek", "Noto Sans Armenian", "Noto Sans Georgian", "Noto Sans Arabic", "Noto Sans Hebrew", "Noto Sans Thai Looped", "Noto Sans Devanagari", "Noto Sans Gurmukhi", "Noto Sans Gujarati", ui-sans-serif, sans-serif;
    --type-read: var(--type-ui);
  }
  :lang(vi), :lang(az) {
    --type-ui: "Onest", "Instrument Sans", "Onest Fill", "Noto Sans Greek", "Noto Sans Armenian", "Noto Sans Georgian", "Noto Sans Arabic", "Noto Sans Hebrew", "Noto Sans Thai Looped", "Noto Sans Devanagari", "Noto Sans Gurmukhi", "Noto Sans Gujarati", ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
    --type-read: var(--type-ui);
  }
  /* These faces reach every element of their language, whether it names a family or not. A family is inherited as the list its ancestor
     resolved, in the language before: an element of the language naming none (a stress reading's span, font: inherit, in a word whose lang
     element names none) kept the English list, which has no face with both a Cyrillic vowel and its stress mark (14 Nov 2026: ко́фе's о́ drew
     in Helvetica). Where the language begins (an element with lang), its reading type, at no specificity, so a rule of the element's own wins.
     An element of the language holds only the language (its lang on its own words, never around English: a screen reader reads by it). */
  :where([lang]:is(:lang(be), :lang(bg), :lang(kk), :lang(mk), :lang(ru), :lang(sr), :lang(uk), :lang(vi), :lang(az), :lang(el))) { font-family: var(--type-read); }

  /* ---------- Graphite: NeedWright's dark register (the default) ---------- */
  :root,
  :root[data-theme="graphite"],
  [data-theme-preview="graphite"],
  [data-theme-preview="auto"] {
    color-scheme: dark;
    --canvas: #000000;
    /* The floating tab bar, and the tab you're on, seen through its lens. The glass (the bar, the header's buttons): the theme's own
     * chrome, thin, over what's behind it blurred and dimmed (--bar-filter), with its words in the theme's strongest ink (--bar-ink)
     * so they keep 4.5:1 over anything, even white; the tab you're on is on a lens with body (--tab-bubble) for the same reason.
     * A light edge, and a highlight along its top (--bar-rim). Solid with reduced transparency (redesign.css). */
    --bar-glass: color-mix(in srgb, var(--chrome) 30%, transparent);
    --bar-filter: blur(16px) saturate(1.8) brightness(0.55);
    --bar-ink: var(--ink-1);
    --bar-edge: rgba(255, 255, 255, 0.13);
    --bar-rim: inset 0 1px 0 rgba(255, 255, 255, 0.09);
    --bar-shadow: 0 10px 28px -6px rgba(0, 0, 0, 0.7);
    --tab-on: #a68cff;
    --tab-bubble: color-mix(in srgb, var(--tab-on) 18%, color-mix(in srgb, var(--chrome) 82%, transparent));
    --tab-bubble-edge: rgba(166, 140, 255, 0.28);
    --chrome: #0b0b0a;
    --well: #151513;
    --fill: rgba(30, 29, 26, 0.88);
    --fill-hover: rgba(46, 44, 40, 0.92);
    --fill-active: rgba(60, 58, 53, 0.92);
    --hair: rgba(234, 228, 214, 0.09);
    --edge: rgba(234, 228, 214, 0.14);
    --edge-strong: rgba(234, 228, 214, 0.26);
    --ink-1: #f1efea;
    --ink-2: #a7a49c;
    --ink-3: #78756d;
    --ink-4: #56544d;
    --solid: #f7f6f2;
    --solid-hover: #dedcd6;
    --on-solid: #0b0b0a;
    --ring: rgba(247, 246, 242, 0.6);
    --selection: rgba(247, 246, 242, 0.18);
    /* Your highlights in the reader: the wash, its line, and the ✦ by it. */
    --highlight: rgba(226, 166, 79, 0.18);
    --highlight-edge: rgba(226, 166, 79, 0.5);
    --highlight-mark: #e2a64f;
    --backdrop: rgba(0, 0, 0, 0.62);
    --shadow-pop: 0 16px 40px -12px rgba(0, 0, 0, 0.72), 0 2px 8px rgba(0, 0, 0, 0.4);

    /* Meaning. Text-strength color, a tint behind it, and an edge. */
    --m-right: #5ab0f0;
    --m-right-bg: rgba(90, 176, 240, 0.14);
    --m-right-edge: rgba(90, 176, 240, 0.42);
    --m-wrong: #ff6e40;
    --m-wrong-bg: rgba(255, 110, 64, 0.14);
    --m-wrong-edge: rgba(255, 110, 64, 0.45);
    --m-slipping: #f2d25c;
    --m-slipping-bg: rgba(242, 210, 92, 0.13);
    --m-slipping-edge: rgba(242, 210, 92, 0.4);
    /* "New" and "hint" carry no hue: bright ink plus a sparkle, dim ink plus a dashed outline and a bulb. */
    --m-new: var(--ink-1);
    --m-new-bg: rgba(241, 239, 234, 0.08);
    --m-new-edge: rgba(241, 239, 234, 0.34);
    --m-hint: var(--ink-2);
    --m-hint-bg: transparent;
    --m-hint-edge: rgba(234, 228, 214, 0.34);
    /* Moved words: a highlighter mark behind ink, plus a dotted underline so it isn't color alone. */
    --m-moved-mark: rgba(122, 62, 110, 0.85);
    --m-moved-ink: var(--ink-1);
    --m-moved-line: #d98cc0;

    /* How well you know something, 0 (unseen) to 4 (solid): one ink, five steps. */
    --strength-0: rgba(234, 228, 214, 0.08);
    --strength-1: rgba(234, 228, 214, 0.22);
    --strength-2: rgba(234, 228, 214, 0.42);
    --strength-3: rgba(234, 228, 214, 0.66);
    --strength-4: #f1efea;
  }

  /* ---------- Paper: NeedWright's light register ---------- */
  :root[data-theme="paper"],
  [data-theme-preview="paper"] {
    color-scheme: light;
    --canvas: #fdfdfc;
    --bar-glass: color-mix(in srgb, var(--chrome) 35%, transparent);
    --bar-filter: blur(16px) saturate(1.6) contrast(0.6) brightness(1.35);
    --bar-edge: rgba(255, 255, 255, 0.7);
    --bar-rim: inset 0 1px 0 rgba(255, 255, 255, 0.9);
    --bar-shadow: 0 0 0 0.5px rgba(40, 34, 20, 0.12), 0 10px 28px -8px rgba(40, 30, 10, 0.28);
    --tab-on: #5e40c4;
    --tab-bubble: color-mix(in srgb, var(--tab-on) 10%, rgba(255, 255, 255, 0.88));
    --tab-bubble-edge: rgba(94, 64, 196, 0.2);
    --chrome: #f6f5f2;
    --well: #f3f2ee;
    --fill: rgba(250, 249, 246, 0.94);
    --fill-hover: rgba(236, 234, 229, 0.96);
    --fill-active: rgba(226, 224, 218, 0.96);
    --hair: rgba(38, 33, 20, 0.08);
    --edge: rgba(38, 33, 20, 0.14);
    --edge-strong: rgba(38, 33, 20, 0.26);
    --ink-1: #1b1a17;
    --ink-2: #57544d;
    --ink-3: #77746c;
    --ink-4: #99968d;
    --solid: #1b1a17;
    --solid-hover: #35342f;
    --on-solid: #fdfdfc;
    --ring: rgba(27, 26, 23, 0.5);
    --selection: rgba(27, 26, 23, 0.12);
    --highlight: rgba(196, 128, 20, 0.16);
    --highlight-edge: rgba(156, 103, 8, 0.45);
    --highlight-mark: #9c6708;
    --backdrop: rgba(20, 19, 17, 0.32);
    --shadow-pop: 0 16px 40px -12px rgba(30, 27, 20, 0.28), 0 2px 8px rgba(30, 27, 20, 0.12);

    --m-right: #0b6fb3;
    --m-right-bg: rgba(11, 111, 179, 0.09);
    --m-right-edge: rgba(11, 111, 179, 0.36);
    --m-wrong: #c2410c;
    --m-wrong-bg: rgba(194, 65, 12, 0.08);
    --m-wrong-edge: rgba(194, 65, 12, 0.36);
    --m-slipping: #3d3200;
    --m-slipping-bg: rgba(233, 190, 40, 0.24);
    --m-slipping-edge: rgba(160, 125, 0, 0.45);
    --m-new: var(--ink-1);
    --m-new-bg: rgba(27, 26, 23, 0.05);
    --m-new-edge: rgba(27, 26, 23, 0.36);
    --m-hint: var(--ink-2);
    --m-hint-bg: transparent;
    --m-hint-edge: rgba(38, 33, 20, 0.34);
    --m-moved-mark: #f5c6e4;
    --m-moved-ink: var(--ink-1);
    --m-moved-line: #9c3d76;

    --strength-0: rgba(38, 33, 20, 0.07);
    --strength-1: rgba(38, 33, 20, 0.2);
    --strength-2: rgba(38, 33, 20, 0.4);
    --strength-3: rgba(38, 33, 20, 0.64);
    --strength-4: #1b1a17;
  }

  /* ---------- Match device: Graphite or Paper, following the system setting ---------- */
  @media (prefers-color-scheme: light) {
    :root[data-theme="auto"],
    [data-theme-preview="auto"] {
      color-scheme: light;
      --canvas: #fdfdfc;
      --bar-glass: color-mix(in srgb, var(--chrome) 35%, transparent);
      --bar-filter: blur(16px) saturate(1.6) contrast(0.6) brightness(1.35);
      --bar-edge: rgba(255, 255, 255, 0.7);
      --bar-rim: inset 0 1px 0 rgba(255, 255, 255, 0.9);
      --bar-shadow: 0 0 0 0.5px rgba(40, 34, 20, 0.12), 0 10px 28px -8px rgba(40, 30, 10, 0.28);
      --tab-on: #5e40c4;
      --tab-bubble: color-mix(in srgb, var(--tab-on) 10%, rgba(255, 255, 255, 0.88));
      --tab-bubble-edge: rgba(94, 64, 196, 0.2);
      --chrome: #f6f5f2;
      --well: #f3f2ee;
      --fill: rgba(250, 249, 246, 0.94);
      --fill-hover: rgba(236, 234, 229, 0.96);
      --fill-active: rgba(226, 224, 218, 0.96);
      --hair: rgba(38, 33, 20, 0.08);
      --edge: rgba(38, 33, 20, 0.14);
      --edge-strong: rgba(38, 33, 20, 0.26);
      --ink-1: #1b1a17;
      --ink-2: #57544d;
      --ink-3: #77746c;
      --ink-4: #99968d;
      --solid: #1b1a17;
      --solid-hover: #35342f;
      --on-solid: #fdfdfc;
      --ring: rgba(27, 26, 23, 0.5);
      --selection: rgba(27, 26, 23, 0.12);
    --highlight: rgba(196, 128, 20, 0.16);
    --highlight-edge: rgba(156, 103, 8, 0.45);
    --highlight-mark: #9c6708;
      --backdrop: rgba(20, 19, 17, 0.32);
      --shadow-pop: 0 16px 40px -12px rgba(30, 27, 20, 0.28), 0 2px 8px rgba(30, 27, 20, 0.12);
      --m-right: #0b6fb3;
      --m-right-bg: rgba(11, 111, 179, 0.09);
      --m-right-edge: rgba(11, 111, 179, 0.36);
      --m-wrong: #c2410c;
      --m-wrong-bg: rgba(194, 65, 12, 0.08);
      --m-wrong-edge: rgba(194, 65, 12, 0.36);
      --m-slipping: #3d3200;
      --m-slipping-bg: rgba(233, 190, 40, 0.24);
      --m-slipping-edge: rgba(160, 125, 0, 0.45);
      --m-new: var(--ink-1);
      --m-new-bg: rgba(27, 26, 23, 0.05);
      --m-new-edge: rgba(27, 26, 23, 0.36);
      --m-hint: var(--ink-2);
      --m-hint-edge: rgba(38, 33, 20, 0.34);
      --m-moved-mark: #f5c6e4;
      --m-moved-line: #9c3d76;
      --strength-0: rgba(38, 33, 20, 0.07);
      --strength-1: rgba(38, 33, 20, 0.2);
      --strength-2: rgba(38, 33, 20, 0.4);
      --strength-3: rgba(38, 33, 20, 0.64);
      --strength-4: #1b1a17;
    }
  }

  /* ---------- High contrast: pure black and white, full-strength edges ---------- */
  :root[data-theme="contrast"],
  [data-theme-preview="contrast"] {
    --canvas: #000000;
    --chrome: #000000;
    /* No glass: solid black, a full-strength edge. */
    --bar-glass: #000000;
    --bar-filter: none;
    --bar-edge: #ffffff;
    --bar-rim: none;
    --well: #0d0d0d;
    --fill: #141414;
    --fill-hover: #262626;
    --fill-active: #333333;
    --hair: rgba(255, 255, 255, 0.28);
    --edge: rgba(255, 255, 255, 0.55);
    --edge-strong: #ffffff;
    --ink-1: #ffffff;
    --ink-2: #e6e6e6;
    --ink-3: #c2c2c2;
    --ink-4: #9e9e9e;
    --solid: #ffffff;
    --solid-hover: #e6e6e6;
    --ring: #ffffff;
    --m-right-bg: rgba(90, 176, 240, 0.24);
    --m-wrong-bg: rgba(255, 110, 64, 0.24);
    --m-slipping-bg: rgba(242, 210, 92, 0.22);
    --m-moved-mark: #8f4a82;
    --highlight: rgba(226, 166, 79, 0.3);
    --highlight-edge: #e2a64f;
  }

  /* ---------- Sepia: warm paper for long reading sessions ---------- */
  :root[data-theme="sepia"],
  [data-theme-preview="sepia"] {
    color-scheme: light;
    --canvas: #f4ecd8;
    --bar-glass: color-mix(in srgb, var(--chrome) 45%, transparent);
    --bar-filter: blur(16px) saturate(1.6) contrast(0.6) brightness(1.4);
    --bar-edge: rgba(255, 255, 255, 0.7);
    --bar-rim: inset 0 1px 0 rgba(255, 255, 255, 0.9);
    --bar-shadow: 0 0 0 0.5px rgba(40, 34, 20, 0.12), 0 10px 28px -8px rgba(40, 30, 10, 0.28);
    --tab-on: #5e40c4;
    --tab-bubble: color-mix(in srgb, var(--tab-on) 10%, rgba(255, 255, 255, 0.88));
    --tab-bubble-edge: rgba(94, 64, 196, 0.2);
    --chrome: #efe5cc;
    --well: #ebe0c4;
    --fill: rgba(239, 229, 204, 0.94);
    --fill-hover: rgba(228, 216, 186, 0.96);
    --fill-active: rgba(218, 205, 172, 0.96);
    --hair: rgba(70, 52, 20, 0.1);
    --edge: rgba(70, 52, 20, 0.18);
    --edge-strong: rgba(70, 52, 20, 0.32);
    --ink-1: #2b2214;
    --ink-2: #5b4b31;
    --ink-3: #7a684a;
    --ink-4: #9c8a68;
    --solid: #2b2214;
    --solid-hover: #463924;
    --on-solid: #f4ecd8;
    --ring: rgba(43, 34, 20, 0.5);
    --selection: rgba(43, 34, 20, 0.14);
    --highlight: rgba(176, 112, 10, 0.18);
    --highlight-edge: rgba(140, 90, 6, 0.5);
    --highlight-mark: #8a5a06;
    --backdrop: rgba(43, 34, 20, 0.3);
    --shadow-pop: 0 16px 40px -12px rgba(60, 44, 16, 0.3), 0 2px 8px rgba(60, 44, 16, 0.14);
    --m-right: #0b6fb3;
    --m-right-bg: rgba(11, 111, 179, 0.1);
    --m-right-edge: rgba(11, 111, 179, 0.38);
    --m-wrong: #b23c0a;
    --m-wrong-bg: rgba(178, 60, 10, 0.1);
    --m-wrong-edge: rgba(178, 60, 10, 0.38);
    --m-slipping: #3d3200;
    --m-slipping-bg: rgba(215, 165, 20, 0.26);
    --m-slipping-edge: rgba(150, 110, 0, 0.45);
    --m-new: var(--ink-1);
    --m-new-bg: rgba(43, 34, 20, 0.06);
    --m-new-edge: rgba(43, 34, 20, 0.38);
    --m-hint: var(--ink-2);
    --m-hint-edge: rgba(70, 52, 20, 0.36);
    --m-moved-mark: #ecc0d9;
    --m-moved-line: #8f3a6c;
    --strength-0: rgba(70, 52, 20, 0.08);
    --strength-1: rgba(70, 52, 20, 0.22);
    --strength-2: rgba(70, 52, 20, 0.42);
    --strength-3: rgba(70, 52, 20, 0.66);
    --strength-4: #2b2214;
    --type-read: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  }

  /* Everything in the theme's own ink (Settings → Appearance → Drawings). After the themes, so it wins over each. */
  :root[data-art="theme"] {
    --go: var(--solid);
    --go-deep: color-mix(in oklab, var(--solid) 62%, var(--canvas));
    --on-go: var(--on-solid);
    --tab-on: var(--ink-1);
    --tab-bubble: color-mix(in srgb, var(--ink-1) 12%, color-mix(in srgb, var(--chrome) 82%, transparent));
    --tab-bubble-edge: color-mix(in srgb, var(--ink-1) 22%, transparent);
  }
}
