/* ============================================================================
   Bunpou — Japanese grammar practice
   A warm, editorial "textbook meets SRS" design system. Vanilla CSS.
   Tokens → base → components → review shell → motion → responsive.
   ========================================================================== */

/* ---------------------------------------------------------------------------
   1. Design tokens
   ------------------------------------------------------------------------- */
:root {
  /* Paper & ink — warm, bookish neutrals (Sumi + Washi) */
  --bg: #faf7f2;
  --bg-soft: #f3eee6;
  --surface: #fffdf9;
  --surface-2: #f6f1e9;
  --ink: #2b2622;
  --ink-soft: #453d36;
  --ink-mute: #6f655c;
  --ink-sub: #6f655c;
  --ink-faint: #786c62;
  --line: #e7dfd3;
  --line-strong: #d9cebf;
  /* Soft divider for low-emphasis internal rules (never a container edge) */
  --line-soft: #efe8dc;
  /* Interactive control outline. Held apart from --line-strong because that token
     is tuned as a decorative rule and misses the 3:1 WCAG 1.4.11 floor against
     these surfaces; every input, select, chip and outlined button uses this one. */
  --ctrl-border: #948673;
  /* Label colour for text sitting on an --accent fill. */
  --on-accent: #fff8ef;

  /* Aliases used by the V2.4 access-tier surfaces. Kept as real tokens so
     every surface shares one border language instead of falling back to none. */
  --border: #e7dfd3;
  --border-soft: #efe8dc;

  /* Accent — vermilion (shu 朱), a classic Japanese ink color */
  --accent: #c43c2e;
  --accent-ink: #a93024;
  --accent-soft: #f6e3dd;
  --accent-soft-2: #faece8;

  /* Semantic — washi-tinted, desaturated */
  --ok: #4b7a4e;
  --ok-ink: #3c6640;
  --ok-soft: #e3ede2;
  --warn: #a3702c;
  --warn-ink: #8a5c1e;
  --warn-soft: #f3e8d2;
  --bad: #b0483a;
  --bad-ink: #96392d;
  --bad-soft: #f5e0db;

  /* Brand bar mark & inline seal */
  --seal: #c43c2e;
  --seal-paper: #fdf6ee;

  /* Paper-feel surfaces */
  --shadow-paper: 0 1px 2px rgba(68, 55, 40, 0.05), 0 2px 10px rgba(68, 55, 40, 0.05);
  --shadow-lift: 0 2px 4px rgba(68, 55, 40, 0.07), 0 12px 28px -8px rgba(68, 55, 40, 0.18);

  /* Radius — disciplined rectangles. Roundness is reserved for dots,
     numerals and inkan stamps, never for containers. */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-pill: 999px;

  /* Type */
  --font-display: "Bricolage Grotesque", "Zen Kaku Gothic New", "Yu Gothic UI", system-ui, sans-serif;
  --font-heading: var(--font-display);
  --font-body: "Zen Kaku Gothic New", "Yu Gothic UI", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-jp: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;

  --fs-xs: 0.72rem;
  --fs-sm: 0.84rem;
  --fs-md: 0.96rem;
  --fs-base: 1rem;
  --fs-lg: 1.16rem;
  --fs-xl: 1.42rem;
  --fs-2xl: 1.85rem;
  --fs-3xl: 2.4rem;

  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 72px;

  --speed: 160ms;
  --ease: cubic-bezier(0.3, 0.8, 0.3, 1);

  color-scheme: light dark;
}

[data-theme="dark"] {
  --bg: #191512;
  --bg-soft: #211c17;
  --surface: #231e19;
  --surface-2: #2b251f;
  --ink: #eee5d8;
  --ink-soft: #cfc3b4;
  --ink-mute: #a3947f;
  --ink-faint: #9d9080;
  --line: #383027;
  --line-strong: #463c30;
  --line-soft: #322a22;
  --ctrl-border: #877560;
  --on-accent: #191512;

  --ink-sub: #a3947f;
  --border: #463c30;
  --border-soft: #322a22;

  --accent: #e0614f;
  --accent-ink: #ef8373;
  --accent-soft: #452a25;
  --accent-soft-2: #36201d;

  --ok: #8db98f;
  --ok-ink: #a6cba8;
  --ok-soft: #2a3a2a;
  --warn: #cfab6c;
  --warn-ink: #dfc390;
  --warn-soft: #3d3020;
  --bad: #dd6a57;
  --bad-ink: #eb8b79;
  --bad-soft: #452722;

  --seal: #e0614f;
  --seal-paper: #2b211b;

  --shadow-paper: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 10px rgba(0, 0, 0, 0.25);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.35), 0 14px 30px -8px rgba(0, 0, 0, 0.5);
}

/* ---------------------------------------------------------------------------
   2. Base
   ------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Subtle paper grain via layered radial gradients — no image asset needed */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(1200px 500px at 85% -10%, color-mix(in srgb, var(--accent) 5%, transparent), transparent 60%),
    radial-gradient(900px 400px at -10% 20%, color-mix(in srgb, var(--accent) 3%, transparent), transparent 55%);
}

main, .review-shell-inner { position: relative; z-index: 1; }

a { color: var(--accent-ink); }
a:hover { color: var(--accent); }

::selection { background: var(--accent-soft); color: var(--accent-ink); }

/* Accessible focus */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.hidden { display: none !important; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 0 0 10px 0;
  z-index: 100;
}
.skip-link:focus { left: 0; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.25;
  margin: 0;
}

/* ---------------------------------------------------------------------------
   3. Shell — the spine, and the running head beside it
   ---------------------------------------------------------------------------

   The shell is a book, not an app chrome. A permanent left rail (the spine)
   carries the whole syllabus as physical lesson tabs; the running head to its
   right says only where you are and what this page is for. There is no top
   navigation bar and no nav menu — the curriculum itself is the navigation.
   ------------------------------------------------------------------------- */
:root { --spine-w: 76px; --head-h: 54px; }

#app-header {
  position: fixed; top: 0; right: 0; left: 0; width: 100%;
  height: var(--head-h); z-index: 50;
  display: flex; align-items: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex; align-items: center; gap: var(--space-4);
  width: 100%;
  padding: 0 var(--space-3);
  margin: 0;
  justify-content: flex-start;
}
.rh-track {
  display: flex; align-items: center; gap: var(--space-4);
  width: 100%; max-width: 1080px; margin: 0 auto;
  padding: 0 var(--space-5);
}
.header-brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--ink);
  flex-shrink: 0;
  text-align: left;
  margin: 0;
  padding: 0;
}
.header-brand .brand-mark {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--seal); color: var(--on-accent);
  font-size: 1.05rem; font-weight: 700;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.18);
  flex-shrink: 0;
}
.header-brand .brand-titles {
  display: flex; flex-direction: column;
  line-height: 1.25;
  text-align: left;
  align-items: flex-start;
  margin: 0;
  padding: 0;
}
.header-brand .brand-word {
  font-family: var(--font-display); font-weight: 700;
  font-size: 0.98rem; color: var(--ink); letter-spacing: -0.01em;
  text-align: left;
  margin: 0;
}
.header-brand .brand-sub {
  font-family: var(--font-body); font-weight: 500;
  font-size: 0.72rem; letter-spacing: 0.04em; color: var(--ink-mute);
  text-align: left;
  margin: 0;
}
.header-nav {
  display: flex; align-items: center; gap: var(--space-4);
  margin-left: auto;
}
.header-nav a {
  font-size: 0.88rem; font-weight: 600; color: var(--ink-mute);
  text-decoration: none; transition: color var(--speed) var(--ease);
  white-space: nowrap;
}
.header-nav a:hover {
  color: var(--accent-ink);
  text-decoration: underline; text-underline-offset: 3px;
}
.header-nav a.active {
  color: var(--ink);
  font-weight: 700;
}
.rh-where {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 0.88rem; min-width: 0;
}
.rh-here { font-family: var(--font-display); font-weight: 700; font-size: 0.96rem; color: var(--ink); }
.rh-link, .rh-sub { color: var(--ink-mute); }
.rh-link { text-decoration: none; border-bottom: 1px solid transparent; }
.rh-link:hover { color: var(--accent-ink); border-bottom-color: var(--accent); }
.rh-rule { color: var(--line-strong); }
.rh-due { color: var(--accent-ink); font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 6px; margin-left: var(--space-2); }
/* --- The spine ----------------------------------------------------------- */
.spine {
  position: fixed; top: var(--head-h); bottom: 0; left: 0; width: var(--spine-w); z-index: 45;
  background: var(--bg-soft);
  border-right: 1px solid var(--line-strong);
  /* A spine is a physical edge: one inset shadow, no drop shadow. */
  box-shadow: inset -1px 0 0 var(--line);
}
.spine-rail {
  display: flex; flex-direction: column; align-items: center;
  height: 100%; padding: 10px 0 12px; gap: 8px;
}
.spine-home-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 34px;
  border-radius: var(--r-sm);
  color: var(--ink-mute);
  text-decoration: none;
  background: transparent;
  border: 1px solid transparent;
  transition: all var(--speed) var(--ease);
  flex-shrink: 0;
  margin-bottom: 2px;
}
.spine-home-btn:hover {
  color: var(--accent-ink);
  background: var(--bg);
  border-color: var(--line);
}
.spine-home-btn.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}
.spine-brand { display: none; }
.spine-word {
  font-family: var(--font-jp); font-size: 0.56rem; font-weight: 600;
  letter-spacing: 0.04em; color: var(--ink-mute); line-height: 1;
}
.spine-brand .brand-mark {
  width: 34px; height: 34px; border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--seal); color: var(--on-accent);
  font-size: 1.1rem; font-weight: 700;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.18);
}
.spine-book {
  width: 100%; padding: 7px 5px;
  background: transparent; border: none; cursor: pointer;
  color: var(--ink-soft); font-family: var(--font-body);
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.01em;
  line-height: 1.3; text-align: center;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.spine-book .sb-name {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; overflow-wrap: anywhere;
}
.spine-book .sb-caret {
  display: block;
  font-size: 0.88rem;
  font-weight: 900;
  opacity: 1;
  color: var(--accent);
  line-height: 1;
  margin-top: 4px;
  transition: transform var(--speed) var(--ease);
}
.spine-book[aria-expanded="true"] .sb-caret {
  transform: rotate(180deg);
}
.spine-book.is-single { cursor: default; }
.spine-book.is-single .sb-caret { display: none; }
.spine-book:not(.is-single):hover { color: var(--ink); background: var(--bg); }

/* The ladder: one tab per lesson, read top to bottom. The ink bar is real
   progress, filled from the bottom the way a page fills with writing. */
.spine-ladder {
  list-style: none; margin: 0; padding: 0;
  flex: 1; width: 100%;
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 3px;
  /* 50 lessons do not fit a rail. The list scrolls, and a fade at the bottom
     edge is the only honest way to say "there is more below" without a bar.
     Only the bottom edge fades: the first lesson is the start of the book and
     must not look clipped away. */
  mask-image: linear-gradient(to bottom, #000 calc(100% - 18px), transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 18px), transparent 100%);
  scrollbar-width: thin;
  padding-bottom: 12px;
}
.spine-ladder::-webkit-scrollbar { width: 2px; }
.spine-ladder::-webkit-scrollbar-thumb { background: var(--line-strong); }
.spine-cell {
  position: relative; display: block;
  padding: 6px 0 7px; text-decoration: none;
  color: var(--ink-mute); text-align: center;
  border-left: 3px solid transparent;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}
.sc-no {
  position: relative; z-index: 1;
  font-family: var(--font-display); font-weight: 600;
  font-size: 0.86rem; font-variant-numeric: tabular-nums;
}
/* Ink: how much of this lesson has been worked, as a fill, not a number. */
.sc-ink {
  position: absolute; left: 3px; right: 0; bottom: 0;
  height: var(--ink, 0%);
  background: color-mix(in srgb, var(--accent) 26%, transparent);
  transition: height 320ms var(--ease);
}
.spine-cell:hover { background: var(--bg); color: var(--ink); }
.spine-cell.is-part { color: var(--ink); }
.spine-cell.is-solid .sc-ink { background: color-mix(in srgb, var(--accent) 44%, transparent); }
.spine-cell.is-solid { color: var(--accent-ink); font-weight: 700; }
.spine-cell.is-new .sc-ink { display: none; }
.spine-cell.is-locked { color: var(--ink-faint); opacity: 0.62; }
.spine-cell.is-locked .sc-no::after { content: "·"; }
/* You are here: a rule in the gutter the width of the tab. */
.spine-cell.is-here { background: var(--surface); color: var(--ink); border-left-color: var(--accent); }
.spine-cell.is-here .sc-no { color: var(--accent-ink); }

.spine-foot {
  flex-shrink: 0; width: 100%; padding: 8px 4px 10px;
  border-top: 1px solid var(--line);
  text-align: center; font-size: 0.6rem; line-height: 1.3; color: var(--ink-faint);
  letter-spacing: 0;
}
.spine-count b {
  font-family: var(--font-display); font-size: 0.86rem; color: var(--ink);
  font-variant-numeric: tabular-nums; margin-right: 3px;
}
.spine-count span { display: block; }
.spine-auth {
  display: block; margin-top: 6px; color: var(--accent-ink);
  font-weight: 600; text-decoration: none;
}
.spine-auth:hover { text-decoration: underline; }
.spine-books {
  position: absolute; left: calc(100% + 6px); top: 46px;
  min-width: 190px; padding: 5px;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-md); box-shadow: var(--shadow-lift); z-index: 50;
  display: flex; flex-direction: column; gap: 2px;
}
.sb-opt {
  text-align: left; padding: 8px 10px; border: none; background: transparent;
  border-radius: var(--r-xs); cursor: pointer; color: var(--ink-mute);
  font-family: var(--font-body); font-size: 0.86rem;
}
.sb-opt:hover { background: var(--bg-soft); color: var(--ink); }
.sb-opt.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

/* Phones: the rail becomes a drawer, and the toggle stands in for it. */
.spine-toggle {
  display: none; position: fixed; left: 10px; top: calc(var(--head-h) + 8px); z-index: 46;
  align-items: center; gap: 7px; padding: 6px 11px 6px 8px;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); cursor: pointer; color: var(--ink);
}
.st-glyph {
  width: 22px; height: 22px; border-radius: 4px; display: grid; place-items: center;
  background: var(--seal); color: var(--on-accent); font-size: 0.78rem;
}
.st-lesson { font-family: var(--font-display); font-weight: 600; font-size: 0.82rem; }
.spine-scrim { position: fixed; inset: 0; z-index: 44; background: rgba(0,0,0,0.32); }

.icon-btn {
  width: 34px; height: 34px; border-radius: var(--r-sm);
  border: 1px solid transparent; background: transparent;
  color: var(--ink-mute); cursor: pointer;
  display: grid; place-items: center;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease),
              border-color var(--speed) var(--ease);
}
.icon-btn:hover { background: var(--bg-soft); color: var(--ink); border-color: var(--line); }
.icon-btn svg { width: 18px; height: 18px; }
[data-theme="dark"] .ico-sun { display: block; }
[data-theme="dark"] .ico-moon { display: none; }
.ico-sun { display: none; }
.ico-moon { display: block; }

/*
 * The page column sits inboard of the spine and below the running head. Both
 * offsets come from the shell tokens, so hiding the shell (auth and review
 * screens) collapses them to zero in one place rather than per view.
 */
main {
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(18px, 4vw, 40px) var(--space-5) var(--space-8);
  min-height: 70vh;
  margin-left: calc(var(--spine-w) + max(0px, (100% - var(--spine-w) - 1080px) / 2));
  margin-top: var(--head-h);
}
main:focus { outline: none; }
/* Chrome off: the auth screens and the review shell own the whole viewport. */
body.no-chrome main { margin-left: auto; margin-top: 0; }
body.no-chrome .spine,
body.no-chrome #app-header,
body.no-chrome .spine-toggle { display: none !important; }

/* Page hero headers */
.page-head { margin-bottom: var(--space-6); }
.page-head .eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: var(--fs-sm); font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent-ink);
}
.page-head h1 { font-size: clamp(1.7rem, 3.4vw, 2.3rem); margin: 10px 0 6px; }
.page-head .page-sub { color: var(--ink-mute); max-width: 60ch; margin: 0; font-size: 1.02rem; }
.page-head .eyebrow::before { content: ""; width: 22px; height: 1px; background: var(--accent); }

/* ---------------------------------------------------------------------------
   4. Buttons
   ------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-display); font-weight: 600; font-size: 0.98rem;
  border: 1px solid transparent; cursor: pointer;
  background: var(--accent); color: var(--on-accent);
  padding: 10px 18px; border-radius: var(--r-sm);
  text-decoration: none; text-align: center;
  min-height: 42px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.14);
  transition: box-shadow var(--speed) var(--ease), background var(--speed) var(--ease),
              filter var(--speed) var(--ease), border-color var(--speed) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { box-shadow: inset 0 1px 0 rgba(0,0,0,0.14); }
.btn:disabled { opacity: 0.45; cursor: default; filter: none; box-shadow: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn svg { width: 17px; height: 17px; flex-shrink: 0; }

.btn-secondary {
  background: var(--surface); color: var(--ink);
  border-color: var(--ctrl-border);
  box-shadow: none;
}
.btn-secondary:hover { border-color: var(--ink-mute); background: var(--surface); }
.btn-ghost { background: transparent; color: var(--ink-mute); box-shadow: none; border-color: transparent; }
.btn-ghost:hover { background: var(--bg-soft); color: var(--ink); filter: none; border-color: var(--line); }
.btn-small { padding: 6px 12px; font-size: 0.88rem; min-height: 34px; }
.btn-block { width: 100%; }
.btn-lg { padding: 13px 24px; font-size: 1.06rem; border-radius: var(--r-md); min-height: 50px; }
.btn .kbd { font-family: var(--font-body); font-size: 0.78em; opacity: 0.75; }

/* Destructive intent, so callers stop reaching for inline colour overrides. */
.btn-danger { background: transparent; color: var(--bad-ink); border-color: var(--ctrl-border); box-shadow: none; }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad-ink); }

/* ---------------------------------------------------------------------------
   5. Cards & surfaces
   ------------------------------------------------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-paper);
}
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: var(--r-xs);
  background: var(--surface-2); color: var(--ink-mute);
  border: 1px solid var(--line);
  font-size: 0.71rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  white-space: nowrap;
}
.chip-level { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.chip-new { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.chip-line { background: transparent; }
.kbd-hint {
  font-size: 0.68rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-faint); font-family: var(--font-body);
}

/* Text link that goes somewhere else in the book: one weight, one direction. */
.link-more { font-size: 0.9rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.link-more:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Section running head: a title on the left, its escape hatch on the right. */
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--space-3); margin: var(--space-6) 0 var(--space-4);
}
.section-head h2 { font-size: 1.2rem; }
.section-sub { font-size: 0.9rem; color: var(--ink-mute); margin: 4px 0 0; max-width: 68ch; }

/* Reset is destructive intent in a ghost button, so it needs its own colour
   instead of borrowing the neutral ghost language. */
.is-destructive { color: var(--bad-ink); }
.is-destructive:hover { background: var(--bad-soft); color: var(--bad-ink); border-color: var(--bad); }

/* One "selected" language for every control in the app: a vermilion wash with
   vermilion ink. Tabs, filter pills, segmented groups and list rows all use it,
   so the user learns the signal once. */
.is-selected,
.opt-pill.on,
.lesson-tabs .tab.active,
.panel-item.selected {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: color-mix(in srgb, var(--accent) 32%, transparent);
}

/* Sectioned form: a running head plus a rule, so related controls group
   without inventing a new card per group. */
.field-group { margin-bottom: var(--space-6); }
.field-group:last-of-type { margin-bottom: var(--space-4); }
.group-head {
  display: flex; align-items: baseline; gap: 10px;
  font-family: var(--font-display); font-weight: 700;
  font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-mute);
  padding-bottom: 8px; margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--line);
}
.group-head .group-note {
  font-family: var(--font-body); font-weight: 500;
  font-size: 0.82rem; letter-spacing: 0; text-transform: none;
  color: var(--ink-faint); margin-left: auto; text-align: right;
}

/* Segmented control: equal-weight options in one bordered rail. */
.seg {
  display: inline-flex; padding: 3px; gap: 3px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.seg > button {
  all: unset; cursor: pointer;
  font-family: var(--font-display); font-weight: 600; font-size: 0.88rem;
  padding: 7px 14px; border-radius: var(--r-sm);
  color: var(--ink-mute); text-align: center;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}
.seg > button:hover { color: var(--ink); }
.seg > button.on { background: var(--surface); color: var(--accent-ink); box-shadow: var(--shadow-paper); }
.seg > button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Radio group rendered as a segmented rail (keeps native input semantics). */
.seg-radio { display: inline-flex; padding: 3px; gap: 3px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--r-md); }
.seg-radio label {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.9rem; font-weight: 600; color: var(--ink-mute);
  padding: 7px 14px; border-radius: var(--r-sm); cursor: pointer;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}
.seg-radio label:hover { color: var(--ink); }
.seg-radio label:has(input:checked) { background: var(--surface); color: var(--accent-ink); box-shadow: var(--shadow-paper); }
.seg-radio input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }

/* Sticky action bar: the primary action stays reachable however long the form. */
.action-bar {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--space-4);
  padding: 14px 0 16px; margin-top: var(--space-2);
  background: linear-gradient(to top, var(--surface) 72%, color-mix(in srgb, var(--surface) 0%, transparent));
  border-top: 1px solid var(--line);
}
.action-bar .action-summary {
  flex: 1; min-width: 0;
  font-size: 0.86rem; color: var(--ink-mute); line-height: 1.45;
}
.action-bar .action-summary b { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.action-bar .btn { flex-shrink: 0; }

/* Site footer — the page ends deliberately instead of running out of content. */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  margin-top: var(--space-8);
}
.site-footer-inner {
  max-width: 1080px; margin: 0 auto;
  padding: var(--space-6) var(--space-5);
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4) var(--space-6);
}
.site-footer .f-brand { display: flex; align-items: center; gap: 9px; font-family: var(--font-display); font-weight: 700; color: var(--ink); }
.site-footer .f-brand .brand-mark { width: 26px; height: 26px; font-size: 0.9rem; }
.site-footer nav { display: flex; gap: var(--space-4); flex-wrap: wrap; margin-left: auto; }
.site-footer nav a { color: var(--ink-mute); text-decoration: none; font-size: 0.9rem; }
.site-footer nav a:hover { color: var(--accent-ink); }
.site-footer .f-note {
  flex-basis: 100%; padding-top: var(--space-4); border-top: 1px solid var(--line-soft);
  font-size: 0.8rem; color: var(--ink-faint); line-height: 1.6;
}
@media (max-width: 640px) {
  .site-footer-inner { padding: var(--space-5) var(--space-4); }
  .site-footer nav { margin-left: 0; }
}

/* ---------------------------------------------------------------------------
   6. The desk — home
   ---------------------------------------------------------------------------
   Home answers two questions and nothing else: where did I leave off, and what
   is outstanding. The old screen led with a billboard, a progress ring and a
   three-up stat strip that restated the same two numbers; the spine now carries
   progress permanently, so none of that furniture survives.
   ------------------------------------------------------------------------- */
.desk { display: flex; flex-direction: column; gap: var(--space-5); }

/* The debt ribbon states the schedule as a sentence and *is* the review button:
   the count and the action are one object, not a statistic above a button. */
.debt {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-5);
  padding: var(--space-5) var(--space-6);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  border-left: 3px solid var(--line-strong);
}
.debt.is-due { border-left-color: var(--accent); }
.debt-main { flex: 1 1 320px; min-width: 0; }
.debt-eyebrow {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-mute);
}
.debt.is-due .debt-eyebrow { color: var(--accent-ink); }
.debt-line { margin: 6px 0 0; font-size: 1.06rem; color: var(--ink-soft); max-width: 52ch; }
.debt-line b { color: var(--ink); font-weight: 700; }
.debt-figures {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 8px 0 0; font-size: 0.84rem; color: var(--ink-mute);
}
.debt-figures b { color: var(--ink); font-variant-numeric: tabular-nums; }
.debt-action { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; }

/* The bookmark: a ribbon laid across the page where you stopped. */
.bookmark {
  position: relative; display: flex; gap: var(--space-5);
  padding: var(--space-5) var(--space-6) var(--space-5) clamp(44px, 5vw, 56px);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg);
  overflow: hidden;
}
.bm-tab {
  position: absolute;
  top: 0;
  left: 20px;
  width: 20px;
  height: 48px;
  background: var(--accent);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.16);
  z-index: 2;
}
.bm-body { flex: 1; min-width: 0; }
.bm-eyebrow {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-mute);
}
/* The bookmark marks a place, not a state: its eyebrow stays muted like every
   other section label, so vermilion keeps meaning "act on this". */
.bm-lesson {
  font-family: var(--font-jp); font-weight: 700;
  font-size: clamp(1.7rem, 3.6vw, 2.4rem); line-height: 1.1;
  letter-spacing: 0.02em; margin: 4px 0; color: var(--ink);
}
.bm-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 0; font-size: 0.88rem; color: var(--ink-mute);
}
/* The desk keeps its Japanese voice. The phrase sits with the eyebrow it
   translates, above the lesson number — under it, it would read as that
   chapter's furigana, which it is not. */
.bm-kana {
  font-family: var(--font-jp); font-size: 0.9rem; color: var(--ink-faint);
  letter-spacing: 0.06em; margin: 2px 0 2px;
}
.bm-dot { color: var(--line-strong); }
.bm-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-4); }

/* The ledger: recent work as ruled lines, the same texture as the contents. */
.ledger { display: flex; flex-direction: column; }
.ledger-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: var(--space-3); padding-bottom: var(--space-3); border-bottom: 2px solid var(--ink);
}
.ledger-head h2 { font-size: 1.04rem; letter-spacing: 0.02em; }
.ledger-note { margin: 0; font-size: 0.84rem; color: var(--ink-mute); }
.ledger-rows { list-style: none; margin: 0; padding: 0; }
.ledger-row {
  display: flex; align-items: center; gap: var(--space-4);
  padding: 11px var(--space-2); text-decoration: none; color: inherit;
  border-bottom: 1px solid var(--line-soft);
  transition: background var(--speed) var(--ease);
}
.ledger-row:hover { background: var(--bg-soft); }
.lr-no {
  flex-shrink: 0; width: 34px; text-align: right;
  font-family: var(--font-display); font-weight: 700; font-size: 1rem;
  color: var(--ink-faint); font-variant-numeric: tabular-nums;
}
.ledger-row:hover .lr-no { color: var(--accent-ink); }
.lr-main { flex: 1; min-width: 0; }
.lr-title { display: block; font-weight: 600; font-size: 0.96rem; color: var(--ink); }
.lr-title em {
  font-style: normal; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--accent-ink); margin-left: 6px;
}
.lr-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.8rem; color: var(--ink-mute); margin-top: 1px; }
.ledger-row.is-locked .lr-title { color: var(--ink-soft); font-weight: 500; }
/* Ink texture: one fine rule per grammar point, filled as the point is worked. */
.lr-ink { display: inline-flex; gap: 2px; flex-shrink: 0; max-width: 140px; overflow: hidden; }
.lr-ink i { width: 3px; height: 14px; background: color-mix(in srgb, var(--ink) 14%, transparent); border-radius: 1px; }
.lr-ink i.on { background: var(--accent); }
.lr-go { color: var(--ink-faint); flex-shrink: 0; }
.ledger-foot { display: flex; gap: var(--space-5); flex-wrap: wrap; padding-top: var(--space-4); }

/* Chart Progress Card in Account Mode */
.chart-progress-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: clamp(20px, 3.5vw, 30px);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-paper);
}
.chart-progress-header {
  margin-bottom: var(--space-4);
}
.chart-progress-header .eyebrow {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent-ink);
  margin-bottom: 4px;
}
.chart-progress-header h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}
.chart-progress-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  flex-wrap: wrap;
}
.chart-ring-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  margin: 0 auto;
}
.ring-wrap {
  position: relative;
  width: 130px;
  height: 130px;
}
.ring-wrap svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.ring-bg {
  fill: none;
  stroke: color-mix(in srgb, var(--ink) 10%, transparent);
  stroke-width: 8;
}
.ring-fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 800ms var(--ease);
}
.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.ring-center .n {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.75rem;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.ring-center .l {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
  font-weight: 700;
  margin-top: 4px;
}
.ring-caption {
  font-size: 0.85rem;
  color: var(--ink-mute);
  margin: 0;
  text-align: center;
}
.ring-caption b {
  color: var(--ink);
}
.chart-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 12px;
  flex: 1 1 280px;
}
.chart-stat-box {
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: border-color var(--speed) var(--ease);
}
.chart-stat-box .cs-num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.45rem;
  line-height: 1.15;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.chart-stat-box .cs-lbl {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
}
.chart-stat-box .cs-desc {
  font-size: 0.75rem;
  color: var(--ink-faint);
  margin-top: 2px;
}
.chart-stat-box.is-due {
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--accent) 6%, var(--bg-soft));
}
.chart-stat-box.is-due .cs-num {
  color: var(--accent);
}

/* Integrated review schedule bar inside chart card (Image 1 combined) */
.chart-progress-card.has-due {
  border-left: 3px solid var(--accent);
}
.chart-progress-due-bar {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}
.chart-progress-due-bar.is-due {
  border-top-color: color-mix(in srgb, var(--accent) 25%, var(--line));
}
.cpd-main {
  flex: 1 1 300px;
  min-width: 0;
}
.cpd-eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  display: block;
}
.chart-progress-due-bar.is-due .cpd-eyebrow {
  color: var(--accent-ink);
}
.cpd-line {
  margin: 4px 0 0;
  font-size: 1.02rem;
  color: var(--ink-soft);
  max-width: 54ch;
  line-height: 1.45;
}
.cpd-line b {
  color: var(--ink);
  font-weight: 700;
}
.cpd-figures {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 6px 0 0;
  font-size: 0.84rem;
  color: var(--ink-mute);
}
.cpd-figures b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.cpd-action {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}
.btn-review-cta {
  background: var(--accent);
  color: var(--on-accent);
  border: 1px solid transparent;
  padding: 10px 20px;
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  box-shadow: 0 2px 6px color-mix(in srgb, var(--accent) 30%, transparent);
  transition: background var(--speed) var(--ease), transform var(--speed) var(--ease);
}
.btn-review-cta:hover {
  background: var(--accent-ink);
  color: var(--on-accent);
  transform: translateY(-1px);
}
.btn-review-cta .kbd {
  background: rgba(255, 255, 255, 0.24);
  color: var(--on-accent);
  font-family: monospace;
  font-size: 0.76rem;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 700;
}

/* Curricula preview cards on Home */
.home-curricula-preview {
  margin-top: var(--space-6);
  margin-bottom: var(--space-6);
}
.home-curricula-preview .section-head {
  margin-bottom: var(--space-5);
}
.home-curricula-preview .section-head h2 {
  font-size: clamp(1.4rem, 2.5vw, 1.85rem);
  margin: 6px 0;
}
.curricula-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-4);
}
.curriculum-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 20px 22px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-paper);
  transition: transform var(--speed) var(--ease), border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}
.curriculum-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-lift);
}
.curriculum-card .cc-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-ink);
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: var(--r-pill);
  margin-bottom: 10px;
}
.curriculum-card .cc-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 6px 0;
  color: var(--ink);
}
.curriculum-card .cc-meta {
  font-size: 0.85rem;
  color: var(--ink-mute);
  line-height: 1.45;
  margin: 0 0 14px 0;
  flex: 1;
}
.curriculum-card .cc-link {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--accent-ink);
}

/* ---------------------------------------------------------------------------
   7. Contents — the syllabus as a ruled table of contents
   ---------------------------------------------------------------------------
   Not a card grid: the spine already carries navigation, so this page's job is
   orientation — where each lesson sits in the book, how big it is, how far it
   has been worked. Read top to bottom, like the front matter it is.
   ------------------------------------------------------------------------- */
.contents { display: flex; flex-direction: column; }
.contents-head { margin-bottom: var(--space-5); }
.contents-head .eyebrow { display: block; margin-bottom: 4px; }
.contents-head h1 { font-size: clamp(1.6rem, 3.2vw, 2.1rem); margin: 8px 0 6px; }
.contents-head h2 { font-size: clamp(1.4rem, 2.8vw, 1.8rem); margin: 6px 0 6px; }
.contents-head .page-sub { color: var(--ink-mute); max-width: 60ch; margin: 0; font-size: 1rem; }

.contents-filters {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}
.filter-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.filter-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  min-width: 65px;
  flex-shrink: 0;
}
.lesson-tabs { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.lesson-tabs .tab {
  padding: 7px 14px; border-radius: var(--r-sm); cursor: pointer;
  font: inherit; font-family: var(--font-display); font-weight: 600; font-size: 0.88rem;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-mute);
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease),
              border-color var(--speed) var(--ease);
}
.lesson-tabs .tab:hover { border-color: var(--line-strong); color: var(--ink); }
.lesson-tabs .tab.active { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.lesson-tabs .tab .cnt {
  font-size: 0.72rem; opacity: 0.75; font-variant-numeric: tabular-nums;
  padding-left: 8px; border-left: 1px solid currentColor;
}
.empty-filter-notice {
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  padding: var(--space-6);
  text-align: center;
  color: var(--ink-mute);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.book-groups { display: flex; flex-direction: column; gap: var(--space-7); }
.book-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4);
  padding-bottom: 8px; border-bottom: 2px solid var(--ink); margin-bottom: 2px;
}
.book-title { font-family: var(--font-display); font-weight: 700; font-size: 1.06rem; letter-spacing: 0.01em; }
.book-count { font-size: 0.82rem; color: var(--ink-mute); font-variant-numeric: tabular-nums; }
.lesson-list { list-style: none; margin: 0; padding: 0; display: block; }

/* One contents line: number in the margin, title, and the ink texture at the
   right edge — the three things a reader scans for. */
.lesson-item {
  display: flex; align-items: center; gap: var(--space-4);
  padding: 11px var(--space-2); text-decoration: none; color: inherit;
  border-bottom: 1px solid var(--line-soft);
  transition: background var(--speed) var(--ease);
}
.lesson-item:hover { background: var(--bg-soft); }
.lesson-no {
  flex-shrink: 0; width: 38px; text-align: right;
  font-family: var(--font-display); font-weight: 700; font-size: 1.02rem;
  color: var(--ink-faint); font-variant-numeric: tabular-nums;
  background: none; border: none; border-radius: 0;
}
.lesson-item:hover .lesson-no { color: var(--accent-ink); }
.lesson-main { flex: 1; min-width: 0; }
.lesson-title { font-weight: 600; font-size: 0.98rem; color: var(--ink); display: block; }
.lesson-desc { font-size: 0.8rem; color: var(--ink-mute); margin-top: 1px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.lesson-counts { flex-shrink: 0; display: flex; align-items: center; gap: 10px; }
.lesson-worked { font-size: 0.78rem; color: var(--ink-mute); font-variant-numeric: tabular-nums; }

/* Locked lesson: readable, not dimmed into illegibility. The lock marker
   carries "not yet available"; the number keeps the 1-50 sequence legible. */
.lesson-item.is-gated .lesson-title { color: var(--ink-soft); font-weight: 500; }
.lesson-item.is-gated .lesson-desc { color: var(--ink-faint); }
.lesson-item.is-gated .chip-full { background: var(--surface); border-color: var(--line-strong); color: var(--ink-mute); }

/* Dots: one per grammar point — sparse = starting out, dense + vermilion = solid */
.dots { display: inline-flex; gap: 3px; max-width: 120px; overflow: hidden; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: color-mix(in srgb, var(--ink) 12%, transparent); flex-shrink: 0; }
.dots i.on { background: var(--accent); }

.progress-line { height: 4px; background: var(--bg-soft); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progress-line > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width 600ms var(--ease); }

/* ---------------------------------------------------------------------------
   8. The lesson page — a numbered contents of grammar notes
   ---------------------------------------------------------------------------
   A lesson opens like a chapter: a folio number set large in the margin, the
   chapter title, one line of context, and a progress meter that is the only
   place on the page that reports a percentage. Under it, the grammar points are
   numbered note lines — the position in the lesson is how the book is cited.
   ------------------------------------------------------------------------- */
.page { display: flex; flex-direction: column; }
.page-opener {
  display: flex; align-items: flex-start; gap: var(--space-5);
  padding-bottom: var(--space-5); margin-bottom: var(--space-5);
  border-bottom: 2px solid var(--ink);
  flex-wrap: wrap;
}
.po-no {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(2.6rem, 7vw, 4rem); line-height: 0.9;
  color: var(--accent-soft);
  /* An outline carries much less weight than the solid title beside it, so the
     stroke is heavy enough to read as a folio rather than as a faint ghost. */
  -webkit-text-stroke: 2px var(--accent);
  font-variant-numeric: tabular-nums; flex-shrink: 0;
  margin-top: -8px;
}
.po-main { flex: 1 1 300px; min-width: 0; }
.po-eyebrow {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-mute);
}
.po-title {
  font-family: var(--font-jp); font-weight: 700;
  font-size: clamp(1.7rem, 4vw, 2.4rem); line-height: 1.2;
  letter-spacing: 0.02em; margin: 6px 0 6px; color: var(--ink);
}
.po-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; font-size: 0.86rem; color: var(--ink-mute); }
/* The metre is a measurement, so the track is drawn even at zero: an empty
   track with a "0%" floating beside it reads as a rendering fault, not a value. */
.po-meter { flex-shrink: 0; display: flex; align-items: center; gap: 10px; min-width: 140px; }
.po-meter .bar {
  flex: 1; min-width: 84px; height: 8px;
  background: var(--bg-soft); border: 1px solid var(--line);
}
.po-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; margin-bottom: var(--space-5); }

/* Adjacent Lesson Step Navigation (Image 2) */
.lesson-step-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: calc(-1 * var(--space-2));
  margin-bottom: var(--space-6);
  padding: 12px 0;
  border-top: 1px dashed var(--line);
  border-bottom: 1px dashed var(--line);
  flex-wrap: wrap;
}
.lesson-step-nav .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  padding: 8px 16px;
  min-height: 38px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--ctrl-border);
  color: var(--ink);
  text-decoration: none;
  transition: all var(--speed) var(--ease);
}
.lesson-step-nav .btn:hover:not(.is-disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.lesson-step-nav .btn.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  background: transparent;
  border-color: var(--line);
  color: var(--ink-faint);
}
.lesson-step-nav .step-arrow {
  font-weight: 800;
  font-size: 1rem;
}
.lesson-step-nav .step-target {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent);
  margin-left: 4px;
}
@media (max-width: 680px) {
  .lesson-step-nav {
    flex-direction: column;
    align-items: stretch;
  }
  .lesson-step-nav .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Lesson Summary 4-Column Stat Card (Image 3) */
.lesson-summary-card {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px clamp(16px, 3vw, 28px);
  margin: var(--space-3) 0 var(--space-5);
  box-shadow: var(--shadow-paper);
}
.ls-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ls-stat .v {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.4rem, 2.5vw, 1.85rem);
  line-height: 1.15;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.ls-stat .k {
  font-family: var(--font-body);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
}
.ls-stat.is-complete .v {
  color: var(--accent);
}
@media (max-width: 600px) {
  .lesson-summary-card {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    padding: 14px 16px;
  }
}

/* Placeholder badges & book headers */
.book-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.chip-placeholder {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent-ink);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
}
.placeholder-notice {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--warn, #cfab6c);
  border-radius: var(--r-md);
  padding: 12px 16px;
  margin-bottom: var(--space-4);
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--ink-soft);
}
.placeholder-notice strong {
  color: var(--ink);
}

.gp-list { display: flex; flex-direction: column; border-top: 1px solid var(--line-soft); }
.gp-row {
  display: flex; align-items: center; gap: var(--space-4);
  padding: 13px var(--space-2);
  text-decoration: none; color: inherit;
  border-bottom: 1px solid var(--line-soft);
  transition: background var(--speed) var(--ease);
}
.gp-row:hover { background: var(--bg-soft); }
.gp-n {
  flex-shrink: 0; width: 30px; text-align: right;
  font-family: var(--font-display); font-weight: 700; font-size: 0.86rem;
  color: var(--ink-faint); font-variant-numeric: tabular-nums;
}
.gp-row:hover .gp-n, .gp-row.is-seen .gp-n { color: var(--accent-ink); }
.gp-main { flex: 1; min-width: 0; }
.gp-grammar { font-family: var(--font-jp); font-size: 1.06rem; font-weight: 600; letter-spacing: 0.01em; display: flex; align-items: center; gap: 8px; color: var(--ink); }
.gp-grammar .pattern-hl { background: var(--accent-soft-2); border-radius: var(--r-xs); padding: 1px 6px; }
.gp-meaning { font-size: 0.86rem; color: var(--ink-mute); margin-top: 1px; }
.gp-side { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.gp-side .progress-line { width: 110px; margin-top: 0; }
.gp-pct { font-size: 0.78rem; color: var(--ink-mute); font-variant-numeric: tabular-nums; }

/* Strength bars */
.bar { height: 5px; background: var(--bg-soft); border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--accent); transition: width 700ms var(--ease); }
.bar.thin { height: 4px; }

/* ---------------------------------------------------------------------------
   9. Grammar detail — the spread
   ---------------------------------------------------------------------------
   Two facing pages, not a stack of cards. The left page carries the notes
   (formation, explanation, usage, nuance, mistakes, similar grammar); the right
   page carries the example sentences as ruled practice lines. A ruled gutter
   separates them, and the language switch is ONE control in the running head
   instead of a toggle on every section.
   ------------------------------------------------------------------------- */
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-mute); text-decoration: none; font-size: 0.9rem; font-weight: 500; margin-bottom: var(--space-4); }
.back-link:hover { color: var(--ink); }

.spread { display: flex; flex-direction: column; }
.spread-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--space-5); flex-wrap: wrap;
  padding-bottom: var(--space-4); border-bottom: 2px solid var(--ink);
}
.sp-head-main { flex: 1 1 320px; min-width: 0; }
.sp-eyebrow {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-mute);
}
.gd-pattern {
  font-family: var(--font-jp);
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  font-weight: 700; line-height: 1.25; letter-spacing: 0.02em;
  color: var(--ink); word-break: keep-all; margin: 8px 0 0;
}
.sp-meaning { font-size: 1rem; color: var(--ink-soft); margin: 6px 0 0; max-width: 56ch; }
.gd-meta { display: flex; gap: 8px; margin-top: var(--space-3); flex-wrap: wrap; }
.sp-head-side { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-3); flex-shrink: 0; }
.sp-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; }

/* The two pages. Equal columns with a ruled gutter between them; on one page of
   screen (narrow) the gutter becomes a horizontal rule and they stack. */
.spread-body { display: grid; grid-template-columns: 1fr 1fr; margin-top: var(--space-5); }
.spread-page { padding: 0 var(--space-6) var(--space-4) 0; min-width: 0; }
.page-examples { padding: 0 0 var(--space-4) var(--space-6); border-left: 1px solid var(--line); }
.page-label {
  position: sticky; top: var(--head-h); z-index: 2;
  background: var(--bg); padding: 6px 0 8px;
  font-family: var(--font-display); font-size: 0.78rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--accent-ink);
  display: flex; align-items: center; gap: 10px; margin: 0 0 var(--space-3);
}
.page-label::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.page-label-n {
  font-family: var(--font-body); font-size: 0.72rem; letter-spacing: 0;
  color: var(--ink-mute); font-variant-numeric: tabular-nums;
}
.spread-body .ex-grid { grid-template-columns: 1fr; gap: var(--space-3); }

/* The notes page: each note is a headed block on the ruled page. */
.gd-block { margin-bottom: var(--space-5); }
.note-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  font-family: var(--font-display); font-size: 0.86rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink); margin: 0 0 6px;
  padding-bottom: 5px; border-bottom: 1px solid var(--line);
}
.gd-block .body { color: var(--ink-soft); font-size: 0.97rem; line-height: 1.75; white-space: pre-line; }
.gd-block .body p { margin: 0 0 10px; }

.formation-box {
  background: var(--surface-2); border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  padding: var(--space-4) var(--space-5);
}
.formation-box .f-pattern { font-family: var(--font-jp); font-weight: 700; font-size: 1.2rem; line-height: 1.6; color: var(--ink); }
.formation-box .f-note { color: var(--ink-mute); font-size: 0.9rem; margin-top: 6px; white-space: pre-line; }

.mistake-item, .similar-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 0.96rem; }
.mistake-item:last-child, .similar-item:last-child { border-bottom: none; }
.mistake-item::before { content: "✕"; color: var(--bad); font-weight: 700; flex-shrink: 0; }
.similar-item::before { content: "→"; color: var(--accent); font-weight: 700; flex-shrink: 0; }

/* Master language toolbar and material header */
.gd-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.gd-top-bar .back-link {
  margin-bottom: 0;
}

.gd-material-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-6);
  margin-bottom: var(--space-4);
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-paper);
  flex-wrap: wrap;
}
.gd-material-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
}
.gd-material-sub {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--ink-faint);
}

.lang-toggle-all-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.lang-toggle-all-hint {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}
.lang-toggle-all {
  border: 1px solid var(--ctrl-border);
  background: var(--bg-soft);
  box-shadow: var(--shadow-paper);
}
.lang-toggle-all .lang-toggle-btn {
  font-size: 0.7rem;
  padding: 3px 12px;
  font-weight: 800;
}

/* Bilingual EN ↔ ID toggle — compact pill pair inline with section titles */
.lang-toggle {
  display: inline-flex;
  gap: 2px;
  margin-left: auto;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 2px;
  flex-shrink: 0;
}
.lang-toggle-btn {
  all: unset;
  cursor: pointer;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 2px 10px;
  border-radius: calc(var(--r-sm) - 2px);
  color: var(--ink-faint);
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
  line-height: 1.6;
}
.lang-toggle-btn:hover { color: var(--ink-mute); }
.lang-toggle-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.lang-toggle-btn.active {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.lang-panel.hidden { display: none; }
.lang-empty {
  color: var(--ink-faint);
  font-style: italic;
  font-size: 0.9rem;
}

/* Example sentences — the reading zone */
.examples-section { margin-top: var(--space-7); }
.examples-section > h2 { margin-bottom: var(--space-4); }
.ex-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
.ex-card {
  padding: var(--space-5);
  display: flex; flex-direction: column; gap: 4px;
  transition: box-shadow var(--speed) var(--ease), border-color var(--speed) var(--ease);
}
.ex-card:hover { box-shadow: var(--shadow-lift); border-color: var(--line-strong); }
.ex-top { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); margin-bottom: 8px; flex-wrap: wrap; }
.ex-idx {
  width: 26px; height: 26px; border-radius: var(--r-sm);
  display: grid; place-items: center;
  font-family: var(--font-display); font-size: 0.78rem; font-weight: 700;
  background: var(--bg-soft); color: var(--ink-mute);
}
.ex-card .jp {
  font-family: var(--font-jp); font-size: 1.22rem; font-weight: 500; line-height: 1.7;
  letter-spacing: 0.01em; color: var(--ink);
}
.ex-card .furi { color: var(--ink-faint); font-size: 0.85rem; font-family: var(--font-jp); }
.ex-card .en { color: var(--ink-mute); font-size: 0.94rem; margin-top: 6px; }
.ex-card .id { color: var(--ink-mute); font-size: 0.94rem; margin-top: 6px; }
.ex-context {
  margin-top: 10px; font-size: 0.85rem; color: var(--ink-mute);
  border-top: 1px dashed var(--line); padding-top: 8px;
  display: flex; gap: 6px;
}
.ex-context svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 3px; opacity: 0.7; }
.ex-usage {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--ink-mute);
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.ex-usage-tag {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  /* Annotation, not status: neutral fill, so the vermilion chips keep meaning
     "this is a mastery level". */
  color: var(--ink-mute);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: var(--r-xs);
  flex-shrink: 0;
  line-height: 1.4;
}

/* Similar grammar pointers */
.similar-grammar { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-top: 6px; }
.similar-grammar a { text-decoration: none; font-size: 0.88rem; font-weight: 600; }

/* ---------------------------------------------------------------------------
   10. Forms & practice setup
   ------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-4); }
/* A field's label and its inline hint. Both live in the label row, so they get
   the same weight and colour as any other field label — previously the label row
   was not covered by the `.field > span` rule and fell back to browser default,
   which made JLPT/Category look a weight lighter than Examples/Order. */
.field > span,
.field-label-row > span {
  font-size: 0.86rem; font-weight: 600; color: var(--ink); letter-spacing: 0.01em;
}
.input, select.input, textarea.input {
  font: inherit; font-size: 1rem;
  padding: 10px 13px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--ctrl-border); border-radius: var(--r-sm);
  width: 100%;
  min-height: 42px;
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input:disabled, select.input:disabled { background: var(--bg-soft); color: var(--ink-faint); cursor: default; }
.input[aria-invalid="true"], .input.is-invalid { border-color: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 14%, transparent); }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-faint) 50%), linear-gradient(135deg, var(--ink-faint) 50%, transparent 50%); background-position: calc(100% - 20px) 55%, calc(100% - 15px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.radio-row { display: flex; gap: var(--space-5); min-height: 42px; align-items: center; }
.radio-row label { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 0.95rem; }
.radio-row input { accent-color: var(--accent); width: 16px; height: 16px; flex-shrink: 0; }

/* Drill sheet.
   The old setup screen was a form: four filter groups, each a dropdown or a
   checkbox list, all of it equally loud. Here the sheet asks three questions in
   the order a learner thinks in — scope, what to drill, how many — and puts the
   long lists (lessons, grammar points) inside one collapsed disclosure, since
   almost nobody narrows by both. Tiles, not a multi-select, for the one choice
   that actually changes the exercise. */
.setup-card { padding: clamp(16px, 3vw, 24px) 0; max-width: 780px; }
.sheet-head { margin-bottom: var(--space-6); }
.sheet-head h1 { font-size: clamp(1.5rem, 3vw, 2rem); margin: 8px 0 6px; }
.sheet-head .sub { color: var(--ink-mute); margin: 0; font-size: 0.98rem; max-width: 62ch; }

/* A sheet row: the number and label in the margin, the controls in the body.
   Read down the left edge and you have the whole form. */
.sheet-row {
  display: grid; grid-template-columns: 150px minmax(0, 1fr);
  gap: var(--space-4) var(--space-5);
  padding: var(--space-5) 0;
  border-top: 1px solid var(--line);
}
.sheet-row:last-of-type { border-bottom: 1px solid var(--line); }
.sr-label { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; }
.sr-n {
  font-family: var(--font-display); font-weight: 700; font-size: 0.82rem;
  color: var(--accent-ink); font-variant-numeric: tabular-nums;
}
.sr-label h2 { font-size: 0.86rem; letter-spacing: 0.1em; text-transform: uppercase; margin: 0; }
.sr-label .selection-badge { flex-basis: 100%; }
.sr-body { min-width: 0; display: flex; flex-direction: column; gap: var(--space-4); }
.how-row { display: flex; gap: var(--space-5); flex-wrap: wrap; }

/* The one real choice on the sheet: four ways to meet a grammar point, each
   with its exercise shape spelled out. No version numbers in the label. */
.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.mode-tile {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 12px 14px; cursor: pointer; text-align: left;
  font: inherit; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  transition: border-color var(--speed) var(--ease), background var(--speed) var(--ease);
}
.mode-tile:hover { border-color: var(--ctrl-border); }
.mode-tile.selected { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 32%, transparent); }
.mt-ic { width: 26px; height: 26px; flex-shrink: 0; color: var(--ink-mute); }
.mt-ic svg { width: 100%; height: 100%; }
.mode-tile.selected .mt-ic { color: var(--accent-ink); }
.mode-tile .item-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.mode-tile .item-title { font-weight: 600; font-size: 0.95rem; color: var(--ink); }
.mode-tile .item-sub { font-size: 0.8rem; color: var(--ink-mute); }
.mt-check {
  margin-left: auto; flex-shrink: 0; width: 18px; text-align: center;
  color: var(--accent-ink); font-weight: 800; font-size: 0.9rem;
}

/* Progressive disclosure: the long lists live here, always in the DOM so a
   selection survives collapsing the disclosure. */
.sheet-more { border-top: 1px solid var(--line); padding-top: var(--space-4); }
.sheet-more > summary {
  cursor: pointer; display: flex; align-items: baseline; gap: 10px;
  font-family: var(--font-display); font-weight: 600; font-size: 0.92rem;
  color: var(--ink-mute); list-style: none;
}
.sheet-more > summary::-webkit-details-marker { display: none; }
.sheet-more > summary::before { content: "＋"; color: var(--accent-ink); font-weight: 700; }
.sheet-more[open] > summary::before { content: "−"; }
.sheet-more > summary:hover { color: var(--ink); }
.sm-note { font-family: var(--font-body); font-size: 0.8rem; color: var(--ink-faint); margin-left: auto; }
.sm-body {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-5) var(--space-5); padding-top: var(--space-5);
}
.sm-body .span2 { grid-column: 1 / -1; }
.inline-panel { max-height: 190px; }
.setup-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4); flex-wrap: wrap; padding-top: var(--space-5);
}
/* A control, not a caption: ghost styling on its own read as text. */
.setup-foot #p-reset { border-color: var(--line); }
.setup-cta { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
/* States the consequence of the action, in the action's own eye-line. */
.setup-scope { font-size: 0.86rem; color: var(--ink-mute); font-variant-numeric: tabular-nums; }
.setup-scope.is-empty { color: var(--bad-ink); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--space-4); }
.form-grid .span2 { grid-column: 1 / -1; }

/* Chips used as multi-selects (JLPT, categories) */
.opt-group { display: flex; flex-wrap: wrap; gap: 8px; }
/* Wrapped rows use the same gap as the inline gap, so the group reads as rows
   rather than binding into one block. */
.opt-group { row-gap: 8px; column-gap: 8px; }
.opt-pill {
  border: 1px solid var(--ctrl-border); background: var(--surface);
  color: var(--ink-mute); font: inherit; font-size: 0.88rem; font-weight: 600;
  padding: 7px 13px; border-radius: var(--r-sm); cursor: pointer;
  min-height: 36px;
  display: inline-flex; align-items: center; gap: 8px;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease),
              border-color var(--speed) var(--ease);
}
.opt-pill:hover { border-color: var(--accent); color: var(--accent-ink); }
/* The count is separated by weight and size, not by a rule: 14 ruled boxes made
   a grid of small rectangles with ragged right edges that outweighed the CTA. */
.opt-pill .cnt {
  font-size: 0.74rem; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
}
.opt-pill.on .cnt { color: var(--accent-ink); opacity: 0.75; }
.opt-hint { font-size: 0.78rem; color: var(--ink-faint); font-weight: 500; }

/* Multi-select filter component */
.btn-xs { padding: 4px 10px; font-size: 0.76rem; min-height: 28px; }
.field-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-bottom: 3px; }
/* The counter is status, not a control: it says how many values are active and
   never borrows the selected-chip treatment, which used to make a live chip and
   a passive summary look identical. */
.selection-badge {
  font-family: var(--font-display); font-weight: 700;
  font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-faint); font-variant-numeric: tabular-nums;
  white-space: nowrap; flex-shrink: 0;
}
.selection-badge.is-active { color: var(--accent-ink); }
.multi-select-box { position: relative; width: 100%; }
.multi-select-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; font: inherit; font-size: 0.95rem; font-weight: 500;
  padding: 10px 14px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--ctrl-border); border-radius: var(--r-sm);
  cursor: pointer; text-align: left; min-height: 42px;
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}
.multi-select-btn:hover { border-color: var(--accent); }
.multi-select-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.multi-select-btn .btn-text {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.multi-select-arrow {
  width: 14px; height: 14px; color: var(--ink-faint); flex-shrink: 0;
  transition: transform var(--speed) var(--ease);
}
.multi-select-btn.active .multi-select-arrow { transform: rotate(180deg); color: var(--accent-ink); }

/* Selection chip tags below the trigger */
.multi-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; align-items: center; }
.multi-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.76rem; font-weight: 600; padding: 3px 8px;
  background: var(--bg-soft); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-xs);
  transition: border-color var(--speed) var(--ease), background var(--speed) var(--ease);
  max-width: 100%;
}
.multi-chip:hover { border-color: var(--line-strong); background: var(--surface); }
.multi-chip .chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multi-chip .chip-del {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border: none; background: transparent;
  color: var(--ink-faint); font-weight: 700; cursor: pointer;
  font-size: 0.85rem; line-height: 1; padding: 0; margin-left: 2px;
  transition: color var(--speed) var(--ease);
}
.multi-chip .chip-del:hover { color: var(--bad-ink); }
.multi-chip-clear {
  font-size: 0.74rem; font-weight: 600; color: var(--ink-faint);
  background: transparent; border: none; cursor: pointer;
  padding: 2px 6px; text-decoration: underline; text-underline-offset: 2px;
  transition: color var(--speed) var(--ease);
}
.multi-chip-clear:hover { color: var(--bad-ink); }

/* Multi-select dropdown popover */
.multi-panel {
  position: absolute; top: calc(100% + 5px); left: 0; right: 0;
  z-index: 60; background: var(--surface);
  border: 1px solid var(--ctrl-border); border-radius: var(--r-md);
  box-shadow: var(--shadow-lift); padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
  animation: multiPanelIn 140ms var(--ease);
}
@keyframes multiPanelIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
.multi-panel.hidden { display: none; }
.panel-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding-bottom: 7px; border-bottom: 1px solid var(--line);
}
.panel-search { flex: 1; min-width: 0; }
.panel-search input.input {
  padding: 6px 10px; font-size: 0.85rem; height: 32px; min-height: 32px;
}
.panel-btn-group { display: flex; gap: 5px; flex-shrink: 0; }
.panel-items {
  max-height: 240px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
  overscroll-behavior: contain;
}
.panel-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 9px; border-radius: var(--r-sm);
  cursor: pointer; user-select: none;
  transition: background var(--speed) var(--ease);
  font-size: 0.88rem;
  min-height: 36px;
}
.panel-item:hover { background: var(--bg-soft); }
.panel-item .item-main {
  display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 2px;
}
.panel-item .item-title {
  font-weight: 600; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.panel-item .item-sub {
  font-size: 0.76rem; color: var(--ink-mute);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.panel-item .item-book {
  font-size: 0.72rem; color: var(--ink-faint); margin-left: auto;
  padding-left: 6px; flex-shrink: 0; font-variant-numeric: tabular-nums;
}
/* Custom checkbox so the control matches the app's accent and target size
   instead of inheriting the OS widget. */
.panel-item input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 18px; height: 18px; margin: 0; cursor: pointer; flex-shrink: 0;
  border: 1px solid var(--ctrl-border); border-radius: var(--r-xs);
  background: var(--surface);
  display: grid; place-items: center;
  transition: background var(--speed) var(--ease), border-color var(--speed) var(--ease);
}
.panel-item input[type="checkbox"]::after {
  content: ""; width: 9px; height: 5px;
  border-left: 2px solid var(--on-accent); border-bottom: 2px solid var(--on-accent);
  transform: rotate(-45deg) translate(0.5px, -1px) scale(0);
  transition: transform 120ms var(--ease);
}
.panel-item input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
.panel-item input[type="checkbox"]:checked::after { transform: rotate(-45deg) translate(0.5px, -1px) scale(1); }
.panel-item input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.panel-empty {
  padding: 16px; text-align: center; color: var(--ink-mute);
  font-size: 0.85rem; font-style: italic;
}
/* ---------------------------------------------------------------------------
   11. Auth
   ------------------------------------------------------------------------- */
.auth-wrap { max-width: 400px; margin: 6vh auto 0; text-align: center; }
.auth-brand { display: inline-flex; flex-direction: column; align-items: center; gap: 10px; text-decoration: none; margin-bottom: var(--space-6); }
.auth-brand .brand-mark { width: 54px; height: 54px; border-radius: var(--r-lg); font-size: 1.75rem; box-shadow: var(--shadow-lift); }
.auth-brand .name { font-family: var(--font-display); font-weight: 700; font-size: 1.45rem; color: var(--ink); letter-spacing: -0.01em; }
.auth-brand .name small { display: block; color: var(--ink-faint); font-weight: 500; font-size: 0.6em; letter-spacing: 0.12em; text-transform: uppercase; margin-top: 2px; }
.auth-card { padding: var(--space-6); text-align: left; border-radius: var(--r-xl); }
.auth-card h1 { font-size: 1.35rem; margin-bottom: var(--space-4); text-align: center; }
.auth-card .input { margin-bottom: var(--space-4); }
.auth-card .btn { margin-top: var(--space-2); }
.auth-switch { text-align: center; color: var(--ink-mute); font-size: 0.92rem; margin-top: var(--space-4); }
.auth-switch a { font-weight: 600; }
.error-msg {
  background: var(--bad-soft); color: var(--bad-ink);
  border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent);
  border-radius: var(--r-sm); padding: 10px 14px; margin-bottom: var(--space-4);
  font-size: 0.92rem;
}
.auth-note { text-align: center; font-size: 0.8rem; color: var(--ink-faint); margin-top: var(--space-5); line-height: 1.6; }

/* ---------------------------------------------------------------------------
   12. Toast
   ------------------------------------------------------------------------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(8px);
  background: var(--ink); color: var(--bg);
  padding: 11px 18px; border-radius: var(--r-md);
  font-size: 0.9rem; font-weight: 500; z-index: 90;
  max-width: 92vw; box-shadow: var(--shadow-lift);
  border-left: 3px solid var(--accent);
  opacity: 0; transition: opacity var(--speed) var(--ease), transform var(--speed) var(--ease);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.hidden { display: block; visibility: hidden; }
.toast.err { background: var(--bad); color: #fff; border-left-color: var(--bad-ink); }
[data-theme="dark"] .toast { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line-strong); border-left: 3px solid var(--accent); }

/* ---------------------------------------------------------------------------
   13. Empty & loading states
   ------------------------------------------------------------------------- */
.empty { text-align: center; padding: clamp(40px, 8vw, 72px) var(--space-5); }
.empty-glyph {
  width: 64px; height: 64px; margin: 0 auto var(--space-4);
  border-radius: var(--r-lg); display: grid; place-items: center;
  background: var(--surface-2); border: 1px dashed var(--line-strong); color: var(--ink-mute);
}
.empty-glyph svg { width: 28px; height: 28px; }
.empty h2 { font-size: 1.3rem; margin-bottom: 6px; }
.empty p { color: var(--ink-mute); max-width: 44ch; margin: 0 auto var(--space-5); }

.loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-4); padding: var(--space-8) 0; color: var(--ink-mute);
}
.loading-mark { animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }

/* Skeleton shimmer for first paint */
.skel { border-radius: var(--r-md); background: linear-gradient(100deg, var(--bg-soft) 40%, var(--surface-2) 50%, var(--bg-soft) 60%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------------------------------------------------------------------------
   14. Review shell — focused, minimal
   ------------------------------------------------------------------------- */
.review-shell {
  position: fixed; inset: 0; z-index: 60;
  background: var(--bg);
  overflow-y: auto;
  animation: rvFade 240ms var(--ease);
}
@keyframes rvFade { from { opacity: 0; } to { opacity: 1; } }

body.no-scroll { overflow: hidden; }

.review-shell-inner { max-width: 720px; margin: 0 auto; padding: 0 var(--space-5) var(--space-7); display: flex; flex-direction: column; min-height: 100%; }

.review-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: 14px 0 0;
}
.review-topbar .icon-btn { width: 40px; height: 40px; }
.review-toplabel {
  font-family: var(--font-display); font-weight: 600; font-size: 0.78rem;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint);
}
.review-topmeta { display: flex; align-items: center; gap: var(--space-3); }
.review-count { font-size: 0.82rem; color: var(--ink-mute); font-variant-numeric: tabular-nums; font-weight: 600; }
.review-quit { font-size: 0.78rem; color: var(--ink-faint); font-family: ui-monospace, Consolas, monospace; }

.review-stage { flex: 1; display: flex; flex-direction: column; padding-top: var(--space-4); }
.review-stage:focus { outline: none; }

/* Progress dashes along the top of the review area */
.rv-dashes { display: flex; gap: 5px; justify-content: center; margin: 6px 0 4px; }
.rv-dashes i { height: 3px; border-radius: 2px; background: color-mix(in srgb, var(--ink) 14%, transparent); flex: 1; max-width: 46px; transition: background 300ms var(--ease); }
.rv-dashes i.past { background: var(--line-strong); }
.rv-dashes i.cur { background: var(--accent); }

/* Card context line: grammar pattern being practiced */
.rv-context-line { text-align: center; margin: var(--space-4) 0 var(--space-2); }
.rv-pattern {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--font-jp); font-weight: 700; font-size: 1.1rem;
  color: var(--ink-soft); letter-spacing: 0.02em;
  background: var(--surface); border: 1px solid var(--line);
  padding: 6px 14px; border-radius: var(--r-sm);
  box-shadow: var(--shadow-paper);
}
.rv-pattern .cat { font-family: var(--font-body); font-weight: 600; font-size: 0.62rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); border-left: 1px solid var(--line); padding-left: 9px; }

/* The main card */
.rv-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-paper);
  padding: clamp(22px, 5vw, 38px);
  animation: rvCardIn 280ms var(--ease);
  margin-bottom: var(--space-4);
}
@keyframes rvCardIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.rv-card.is-flipping { animation: rvFlip 260ms var(--ease); }
@keyframes rvFlip { 50% { opacity: 0; transform: translateY(-7px) scale(0.995); } }

/* Prompt block — what to recall */
.rv-prompt-label {
  text-align: center;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: 4px;
}
.rv-context { text-align: center; font-size: 0.94rem; color: var(--ink-faint); font-style: italic; max-width: 50ch; margin: 0 auto 2px; }
.rv-english {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  font-weight: 650; line-height: 1.35; letter-spacing: -0.01em;
  text-align: center; color: var(--ink);
  margin: 6px 0 0;
}

/* Answer input zone */
.rv-answer-zone { margin-top: var(--space-6); }
.answer-input {
  font-family: var(--font-jp); font-size: clamp(1.25rem, 4vw, 1.55rem);
  text-align: center; letter-spacing: 0.02em;
  padding: 16px 18px;
  border: 1.5px solid var(--ctrl-border); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink); width: 100%;
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}
.answer-input::placeholder { color: var(--ink-faint); font-size: 0.75em; }
.answer-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.answer-input:disabled { background: var(--surface-2); color: var(--ink-faint); border-color: var(--line); }
.answer-input.ok { border-color: var(--ok); background: var(--ok-soft); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }
.answer-input.no { border-color: var(--bad); background: var(--bad-soft); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 16%, transparent); }

.rv-input-row { display: flex; gap: 10px; align-items: stretch; }
.rv-input-row .answer-input { flex: 1; }
.rv-check-btn { padding: 0 26px; flex-shrink: 0; font-size: 1.02rem; }

.answer-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 0.8rem; color: var(--ink-faint); }
.kbd { font-family: var(--font-body); background: var(--surface-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 6px; font-size: 0.74rem; color: var(--ink-mute); }

/* Verdict */
.rv-verdict {
  margin-top: var(--space-5); border-radius: var(--r-md);
  padding: var(--space-4) var(--space-5);
  display: flex; align-items: flex-start; gap: 12px;
  animation: verdictIn 300ms var(--ease);
}
@keyframes verdictIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.answer-input.warn { border-color: var(--warn); background: var(--warn-soft); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 18%, transparent); }
.rv-verdict .v-ic { flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 0.9rem; margin-top: 1px; }
.rv-verdict.correct { background: var(--ok-soft); }
.rv-verdict.correct .v-ic { background: var(--ok); color: #fff; }
.rv-verdict.correct .v-title { color: var(--ok-ink); }
.rv-verdict.partial { background: var(--warn-soft); }
.rv-verdict.partial .v-ic { background: var(--warn); color: #fff; }
.rv-verdict.partial .v-title { color: var(--warn-ink); }
.rv-verdict.incorrect { background: var(--bad-soft); }
.rv-verdict.incorrect .v-ic { background: var(--bad); color: #fff; }
.rv-verdict.incorrect .v-title { color: var(--bad-ink); }
.rate-btn.highlight-rating { border-color: var(--accent); background: var(--accent-soft-2); box-shadow: 0 0 0 2px var(--accent-soft); }
.rv-verdict .v-body { flex: 1; min-width: 0; }
.rv-verdict .v-title { font-family: var(--font-display); font-weight: 700; font-size: 1.02rem; }
.rv-verdict .v-note { font-size: 0.82rem; opacity: 0.8; margin-top: 1px; }

/* Answer comparison */
.rv-compare { margin-top: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.rv-compare-row { display: grid; grid-template-columns: 96px 1fr; gap: var(--space-3); align-items: baseline; }
.rv-compare-row .k { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-faint); }
.rv-compare-row .jp-ans { font-family: var(--font-jp); font-size: 1.3rem; font-weight: 600; color: var(--ink); line-height: 1.6; }
.rv-compare-row .furi { color: var(--ink-faint); font-size: 0.85rem; }
.rv-compare-row .jp-ans.mine { color: var(--ink-mute); }
.rv-compare-row .jp-ans.mine.mismatch { color: var(--bad-ink); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--bad) 60%, transparent); text-decoration-thickness: 2px; }

/* Rating controls */
.rv-ratings { margin-top: var(--space-5); animation: verdictIn 300ms var(--ease); }
.rv-ratings .rate-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rate-btn {
  border: 1px solid var(--ctrl-border); background: var(--surface);
  color: var(--ink); font: inherit; font-family: var(--font-display); font-weight: 600;
  padding: 12px 8px 10px; border-radius: var(--r-sm); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-height: 56px;
  transition: border-color var(--speed) var(--ease), background var(--speed) var(--ease),
              box-shadow var(--speed) var(--ease);
}
.rate-btn:disabled { opacity: 0.4; cursor: default; }
.rate-btn .rt { font-size: 1rem; }
.rate-btn .ks { font-size: 0.66rem; color: var(--ink-faint); font-weight: 500; letter-spacing: 0.04em; }
.rate-btn[data-r="1"]:hover { border-color: var(--bad); background: var(--bad-soft); color: var(--bad-ink); }
.rate-btn[data-r="2"]:hover { border-color: var(--warn); background: var(--warn-soft); color: var(--warn-ink); }
.rate-btn[data-r="3"]:hover { border-color: var(--ok); background: var(--ok-soft); color: var(--ok-ink); }
.rate-btn[data-r="4"]:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.rate-tip { text-align: center; margin-top: 12px; font-size: 0.78rem; color: var(--ink-faint); }

/* Session finish */
.finish-wrap { text-align: center; padding: clamp(30px, 8vh, 70px) 0; }
.finish-stamp { margin: 0 auto var(--space-5); }
.finish-wrap h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); margin-bottom: 8px; }
.finish-wrap .finish-sub { color: var(--ink-mute); max-width: 44ch; margin: 0 auto; }
.finish-stats { display: flex; justify-content: center; gap: clamp(20px, 6vw, 56px); margin: var(--space-6) 0 var(--space-6); }
.finish-stat { display: flex; flex-direction: column; }
.finish-stat .n { font-family: var(--font-display); font-weight: 700; font-size: clamp(2rem, 5vw, 2.7rem); line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.finish-stat .n.ok { color: var(--ok-ink); }
.finish-stat .k { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-mute); font-weight: 600; margin-top: 6px; }
.finish-actions { display: flex; justify-content: center; gap: var(--space-3); flex-wrap: wrap; }

/* Review loading */
.rv-loading { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); padding: var(--space-8) 0; color: var(--ink-faint); font-size: 0.92rem; }

/* Stamp seal for the finish screen */
.stamp {
  width: 108px; height: 108px;
  border: 4px solid var(--accent); border-radius: 50%;
  display: grid; place-items: center;
  color: var(--accent); font-family: var(--font-display); font-weight: 700;
  transform: rotate(-9deg);
  opacity: 0.9;
  box-shadow: inset 0 0 0 3px var(--bg);
  animation: stampIn 500ms var(--ease) both;
}
@keyframes stampIn { from { transform: rotate(-9deg) scale(1.7); opacity: 0; } to { transform: rotate(-9deg) scale(1); opacity: 0.9; } }
.stamp .s-kanji { font-size: 2.3rem; line-height: 1; }
.stamp .s-sub { font-size: 0.58rem; letter-spacing: 0.18em; margin-top: 2px; font-weight: 600; }

/* ---------------------------------------------------------------------------
   14b. Book groups (lessons page)
   ------------------------------------------------------------------------- */
.book-groups { display: flex; flex-direction: column; gap: var(--space-6); }
.book-group { display: flex; flex-direction: column; gap: var(--space-3); }
.book-head {
  display: flex; align-items: baseline; gap: var(--space-3);
  padding-bottom: 8px; border-bottom: 2px solid var(--accent);
}
.book-title {
  font-family: var(--font-display); font-weight: 700; font-size: 1.12rem;
  letter-spacing: -0.01em; color: var(--ink);
  min-width: 0; overflow-wrap: anywhere;
}
.book-count {
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-faint); white-space: nowrap;
}
.book-group .lesson-list { margin-top: 2px; }

/* ---------------------------------------------------------------------------
   14c. Two-level curriculum navigation (grammar page)
   ------------------------------------------------------------------------- */
.gd-nav-wrap { display: flex; flex-direction: column; gap: var(--space-4); margin: var(--space-5) 0 var(--space-3); }
.gd-nav-wrap:empty { display: none; margin: 0; }
.nav-group { display: flex; flex-direction: column; gap: 7px; }
.nav-group-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-faint);
}
.nav-group-label::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.nav-pos { color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.nav-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.nav-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line);
  text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow-paper);
  min-width: 0;
  transition: box-shadow var(--speed) var(--ease), border-color var(--speed) var(--ease);
}
.nav-btn:hover { box-shadow: var(--shadow-lift); border-color: var(--line-strong); }
.nav-btn.is-disabled { opacity: 0.55; cursor: default; box-shadow: none; }
.nav-btn.is-disabled:hover { box-shadow: none; border-color: var(--line); }
.nav-arrow {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: var(--r-xs);
  display: grid; place-items: center;
  font-size: 1.15rem; line-height: 1;
  background: var(--bg-soft); color: var(--ink-soft);
}
.nav-btn.nav-gp .nav-arrow { background: var(--accent-soft); color: var(--accent-ink); }
.nav-btn.nav-gp .nav-label { color: var(--accent-ink); }
.nav-btn.is-disabled .nav-arrow { background: var(--bg-soft); color: var(--ink-faint); }
.nav-body { display: flex; flex-direction: column; gap: 0; min-width: 0; flex: 1; }
.nav-label { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); }
.nav-text {
  font-family: var(--font-display); font-weight: 600; font-size: 0.96rem;
  color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-btn.is-disabled .nav-text { color: var(--ink-faint); }

/* ---------------------------------------------------------------------------
   14d. Developer Mode drawer (technical, contained — never affects normal users)
   ------------------------------------------------------------------------- */
.dev-shell { position: fixed; inset: 0; z-index: 80; }
.dev-backdrop { position: absolute; inset: 0; background: rgba(20, 14, 8, 0.45); backdrop-filter: blur(2px); }
.dev-drawer {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(440px, 92vw);
  background: var(--surface); border-left: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lift);
  display: flex; flex-direction: column;
  animation: devSlideIn 220ms var(--ease);
}
@keyframes devSlideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.dev-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.dev-title { display: flex; align-items: center; gap: 9px; font-family: var(--font-display); font-weight: 700; font-size: 1rem; }
.dev-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dev-body { flex: 1; overflow-y: auto; padding: 6px 0 var(--space-6); }
.dev-section { padding: var(--space-3) 18px 0; }
.dev-subhead {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent-ink); margin-bottom: 6px;
}
.dev-line { display: flex; gap: 12px; align-items: baseline; padding: 3px 0; font-size: 0.84rem; min-width: 0; }
.dev-line .dev-k { flex-shrink: 0; width: 74px; color: var(--ink-faint); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.dev-line .dev-v { color: var(--ink-soft); min-width: 0; overflow-wrap: anywhere; }
.dev-mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 0.76rem; }
.dev-n { color: var(--ink-faint); font-weight: 600; }
.dev-scroll { max-height: 46vh; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-sm); }
.dev-book {
  padding: 7px 12px; font-size: 0.78rem; font-weight: 700;
  color: var(--accent-ink); background: var(--accent-soft-2);
  border-bottom: 1px solid var(--line); position: sticky; top: 0;
}
.dev-row {
  display: flex; gap: 10px; align-items: baseline; width: 100%;
  padding: 8px 12px; border: none; border-bottom: 1px dashed var(--line);
  background: transparent; color: var(--ink-soft);
  font: inherit; font-size: 0.8rem; text-align: left; cursor: pointer;
  min-width: 0;
}
.dev-row:hover { background: var(--bg-soft); color: var(--ink); }
.dev-row .dev-k { flex-shrink: 0; font-family: ui-monospace, Consolas, monospace; font-size: 0.74rem; color: var(--ink-mute); }
.dev-gp-row { padding-left: 26px; }
.dev-gp-row .dev-k { color: var(--accent-ink); }
.dev-lesson-row .dev-k { color: var(--ink-soft); }
.dev-lesson-row .dev-v { color: var(--ink-faint); }
.dev-row .dev-v { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.dev-loading, .dev-error { padding: var(--space-5) 18px; color: var(--ink-faint); font-size: 0.88rem; }
.dev-error { color: var(--bad-ink); }

/* ---------------------------------------------------------------------------
   14e. Developer chip (review card + grammar example cards)
   ------------------------------------------------------------------------- */
.dev-chip-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 0.8rem; font-weight: 600;
  color: var(--ink-faint); background: transparent;
  border: 1px dashed var(--line-strong); border-radius: var(--r-xs);
  padding: 4px 12px; cursor: pointer;
  transition: color var(--speed) var(--ease), border-color var(--speed) var(--ease), background var(--speed) var(--ease);
}
.dev-chip-btn svg { width: 13px; height: 13px; }
.dev-chip-btn:hover { color: var(--accent-ink); border-color: var(--accent); background: var(--accent-soft-2); }
.ex-dev-edit {
  font: inherit; font-size: 0.72rem; font-weight: 600;
  color: var(--ink-faint); background: var(--bg-soft);
  border: 1px solid transparent; border-radius: var(--r-xs);
  padding: 2px 10px; cursor: pointer; margin-left: auto;
  transition: color var(--speed) var(--ease), background var(--speed) var(--ease);
}
.ex-dev-edit:hover { color: var(--accent-ink); background: var(--accent-soft-2); }
/* Dev row inside the review card: hint + edit, kept out of the learner flow */
.rv-dev-actions {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; margin-top: 14px; min-height: 0;
}
.rv-dev-hint {
  font-size: 0.74rem; font-weight: 600; letter-spacing: 0.02em;
  color: var(--warn-ink); background: var(--warn-soft);
  border-radius: var(--r-xs); padding: 3px 12px;
}
.rv-english + .rv-dev-actions { margin-top: 4px; }

/* ---------------------------------------------------------------------------
   14f. Example editor modal (Developer Mode content QA)
   ------------------------------------------------------------------------- */
.edit-shell { position: fixed; inset: 0; z-index: 85; display: flex; align-items: center; justify-content: center; }
.edit-backdrop { position: absolute; inset: 0; background: rgba(20, 14, 8, 0.5); backdrop-filter: blur(2px); }
.edit-dialog {
  position: relative; width: min(620px, 94vw); max-height: 88vh;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lift);
  animation: editIn 200ms var(--ease);
}
@keyframes editIn { from { opacity: 0; transform: translateY(10px) scale(0.99); } to { opacity: 1; transform: none; } }
.edit-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 18px; border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.edit-title { display: flex; align-items: center; gap: 9px; font-family: var(--font-display); font-weight: 700; font-size: 1.02rem; }
.edit-pen { color: var(--accent-ink); }
.edit-body { flex: 1; overflow-y: auto; padding: var(--space-4) 18px var(--space-5); }
.edit-loading, .edit-error { padding: var(--space-6) 0; text-align: center; color: var(--ink-faint); }
.edit-error { color: var(--bad-ink); }
.edit-meta {
  display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center;
  font-family: ui-monospace, Consolas, monospace; font-size: 0.74rem;
  color: var(--ink-mute); background: var(--bg-soft);
  border-radius: var(--r-sm); padding: 6px 12px; margin-bottom: var(--space-3);
  min-width: 0;
}
.edit-details { margin-bottom: var(--space-3); }
.edit-details summary {
  cursor: pointer; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-faint);
}
.edit-detail-grid {
  display: grid; grid-template-columns: auto 1fr; gap: 3px 16px;
  margin-top: 8px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: var(--r-sm); font-size: 0.8rem; min-width: 0;
}
.edit-detail-grid .k { color: var(--ink-faint); font-size: 0.7rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; padding-top: 2px; }
.edit-detail-grid .v { color: var(--ink-soft); min-width: 0; overflow-wrap: anywhere; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace !important; font-size: 0.86rem !important; }
.edit-warnings { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-3); }
.edit-warn {
  font-size: 0.82rem; color: var(--warn-ink); background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  border-radius: var(--r-sm); padding: 7px 12px;
}
.edit-fields { display: flex; flex-direction: column; gap: var(--space-3); }
.edit-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.edit-label { font-size: 0.78rem; font-weight: 700; color: var(--ink-soft); display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.edit-label .req { color: var(--bad-ink); font-style: normal; }
.edit-hint { font-weight: 500; font-size: 0.72rem; color: var(--ink-faint); }
.edit-input {
  font: inherit; font-size: 0.96rem; line-height: 1.6;
  padding: 9px 12px; width: 100%; resize: vertical;
  background: var(--surface); color: var(--ink);
  border: 1.5px solid var(--ctrl-border); border-radius: var(--r-sm);
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
  min-width: 0;
}
.edit-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.edit-input.mono { font-family: var(--font-jp); font-size: 1.05rem !important; }
.edit-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: var(--space-4); }
.edit-actions .btn { min-width: 96px; }
.edit-foot { font-size: 0.72rem; color: var(--ink-faint); margin: var(--space-3) 0 0; }
.edit-ordering-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 600px) { .edit-ordering-grid { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------------------
   15. Motion
   ------------------------------------------------------------------------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fade-up { animation: fadeUp 340ms var(--ease) both; }
.fade-up-1 { animation: fadeUp 340ms var(--ease) 60ms both; }
.fade-up-2 { animation: fadeUp 340ms var(--ease) 120ms both; }
@keyframes popIn { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }
.pop-in { animation: popIn 240ms var(--ease) both; }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}

/* ---------------------------------------------------------------------------
   16. Responsive
   ------------------------------------------------------------------------- */

/* Global overflow guards — the underlying cause of mobile horizontal
   scrolling is unbreakable content: long words, nowrap text and fixed-size
   rows escaping flexible containers. These let text wrap everywhere while
   keeping layout sane. */
main { min-width: 0; }
img, svg, canvas { max-width: 100%; }
.gd-pattern, .sp-meaning, .gd-block .body,
.lesson-title, .lesson-desc, .gp-meaning, .gp-grammar,
.rv-english, .rv-context, .rv-pattern, .ex-card .jp,
.page-sub, .auth-note, .bm-lesson, .po-title, .lr-title,
.formation-box, .f-pattern, .f-note, .book-title, .landing-title,
.nav-btn, .dev-v, .edit-input { overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .ex-grid { grid-template-columns: 1fr; }
  /* Nav strips must never force a wide row on tablets */
  .gd-nav-wrap { margin-top: var(--space-4); }
  /* The spread folds: notes over examples, with the gutter becoming a rule. */
  .spread-body { grid-template-columns: 1fr; }
  .spread-page { padding-right: 0; }
  .page-examples { padding-left: 0; border-left: none; border-top: 1px solid var(--line); padding-top: var(--space-5); }
  .sm-body { grid-template-columns: 1fr; }
  .loop-steps { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  /* The spine becomes a drawer, and the toggle stands in for it. */
  .spine {
    transform: translateX(-100%); z-index: 48;
    transition: transform 220ms var(--ease);
    box-shadow: 4px 0 20px -6px rgba(0,0,0,0.3);
  }
  body.spine-open .spine { transform: none; }
  .spine-toggle { display: inline-flex; }
  main { margin-left: auto; padding-top: calc(var(--head-h) + var(--space-4)); }
  .rh-due, .rh-sub, .rh-where { display: none; }
  .header-nav { gap: var(--space-3); }
}

@media (max-width: 680px) {
  .header-brand .brand-sub { display: none; }
}

@media (max-width: 640px) {
  :root { --space-6: 26px; }
  .header-nav {
    gap: var(--space-2);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    max-width: 58vw;
  }
  .header-nav::-webkit-scrollbar { display: none; }
  .header-nav a { font-size: 0.8rem; }
  main { padding: var(--space-4) var(--space-4) var(--space-7); padding-top: calc(var(--head-h) + var(--space-4)); }
  .sheet-row { grid-template-columns: 1fr; gap: var(--space-3); padding: var(--space-4) 0; }
  .sr-label .selection-badge { flex-basis: auto; margin-left: auto; }
  .mode-grid { grid-template-columns: 1fr; }
  .how-row { gap: var(--space-4); }
  .setup-foot { flex-direction: column-reverse; align-items: stretch; }
  .setup-cta { flex-direction: column; align-items: stretch; }
  .setup-cta .btn { width: 100%; }
  .setup-scope { text-align: center; }
  .debt { padding: var(--space-4) var(--space-5); }
  .debt-action .btn { width: 100%; }
  .bookmark { padding: var(--space-4) var(--space-4) var(--space-4) 42px; gap: var(--space-4); }
  .bm-tab { left: 14px; width: 18px; height: 42px; }
  .bm-actions .btn { width: 100%; }
  .ledger-foot { gap: var(--space-4); }
  .lesson-item, .gp-row, .ledger-row { gap: var(--space-3); padding-left: 0; padding-right: 0; }
  .lr-ink, .dots { display: none; }
  .po-actions { flex-direction: column; align-items: stretch; }
  .po-actions .btn { width: 100%; }
  .sp-head-side { align-items: flex-start; width: 100%; }
  .spread-page { padding-right: 0; }
  .landing-hero { gap: var(--space-4); }
  .cover { width: 56px; }
  .landing-actions { flex-direction: column; align-items: stretch; }
  .landing-actions .btn { width: 100%; }
  .landing-foot { flex-direction: column; align-items: flex-start; }
  .lp-foot .lf-nav, .lf-nav { margin-left: 0; }
  .gp-side .progress-line { width: 76px; }
  .form-grid { grid-template-columns: 1fr; }
  .rv-input-row { flex-direction: column; }
  .rv-check-btn { width: 100%; padding: 14px; }
  .rate-btn .ks { display: none; }
  .rv-ratings .rate-row { gap: 8px; }
  .review-shell-inner { padding: 0 var(--space-4) var(--space-6); }
  .rv-compare-row { grid-template-columns: 1fr; gap: 2px; }
  .finish-stats { gap: 26px; }

  /* Review shell: give the input + ratings full comfort width */
  .review-shell-inner { max-width: 100%; }
  .rv-card { padding: var(--space-5) var(--space-4); }

  /* Dev drawer: near-full width */
  .dev-drawer { width: 100vw; }

  /* Editor modal: full-bleed on phones — no horizontal overflow possible */
  .edit-shell { align-items: stretch; }
  .edit-dialog {
    width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh;
    border-radius: 0; border: none;
  }
  .edit-body { padding: var(--space-3) 14px var(--space-5); }
  .edit-actions { position: sticky; bottom: 0; background: var(--surface); padding-top: 10px; }
}

/* Extra-tiny phones (<= 380px): two lesson-navigation buttons still fit a row */
@media (max-width: 380px) {
  .nav-row { gap: 8px; }
  .nav-btn { padding: 10px 10px; gap: 7px; }
  .nav-arrow { width: 22px; height: 22px; font-size: 1.05rem; }
  .nav-label { font-size: 0.6rem; }
  .nav-text { font-size: 0.88rem; }
  .header-actions { gap: 2px; }
}

/* Keep the review pattern pill from overflowing its row on small screens */
.rv-context-line { overflow: hidden; }
.rv-pattern { max-width: 100%; flex-wrap: wrap; justify-content: center; text-align: center; }

/* ---------------------------------------------------------------------------
   17. V2.1 Grammar Cloze Practice Styles
   ------------------------------------------------------------------------- */
.rv-mode-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--r-xs);
  background: var(--accent-soft);
  color: var(--accent-ink);
  margin-left: 8px;
  vertical-align: middle;
}

.rv-cloze-prompt {
  text-align: center;
  margin: var(--space-4) 0 var(--space-2);
}

.rv-cloze-sentence {
  font-family: var(--font-jp);
  font-size: clamp(1.4rem, 4.5vw, 2.1rem);
  font-weight: 700;
  line-height: 1.5;
  color: var(--ink);
  letter-spacing: 0.02em;
  margin-bottom: 10px;
}

.cloze-blank {
  display: inline-block;
  min-width: 60px;
  padding: 0 10px;
  margin: 0 4px;
  border-bottom: 3px solid var(--accent);
  color: var(--accent);
  background: var(--accent-soft-2);
  border-radius: var(--r-xs);
  font-weight: 800;
  text-align: center;
  letter-spacing: 2px;
}

.cloze-target-filled {
  color: var(--ok-ink);
  font-weight: 800;
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 4px;
  background: var(--ok-soft);
  padding: 2px 6px;
  border-radius: var(--r-xs);
}

.rv-cloze-full-sentence {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: var(--space-3);
  align-items: baseline;
}

.rv-cloze-full-sentence .jp-sentence {
  font-family: var(--font-jp);
  font-size: 1.2rem;
  line-height: 1.6;
  color: var(--ink-soft);
}

.cloze-explanations {
  margin-top: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cloze-exp-block {
  border-radius: var(--r-md);
  padding: 12px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.cloze-exp-block.en {
  border-left: 4px solid var(--accent);
}

.cloze-exp-block.id {
  border-left: 4px solid var(--ok);
}

.cloze-exp-block .exp-header {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  gap: 6px;
}

.cloze-exp-block .exp-tag {
  display: inline-block;
  font-size: 0.62rem;
  padding: 1px 6px;
  border-radius: var(--r-xs);
  font-weight: 800;
}

.cloze-exp-block.en .exp-tag {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.cloze-exp-block.id .exp-tag {
  background: var(--ok-soft);
  color: var(--ok-ink);
}

.cloze-exp-block .exp-text {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0;
}

.edit-fields-section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-ink);
  padding-bottom: 6px;
  border-bottom: 1.5px solid var(--accent);
  margin-bottom: var(--space-3);
}

.edit-cloze-toggle-wrap {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  margin-bottom: var(--space-3);
}

.edit-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--ink);
}

.edit-checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ============================================================================
   V2.2 Particle & Function Retrieval Practice
   ========================================================================== */
.particle-gap {
  display: inline-block;
  min-width: 68px;
  padding: 0 12px;
  margin: 0 4px;
  border-bottom: 3px solid var(--accent);
  color: var(--accent);
  background: var(--accent-soft-2);
  border-radius: var(--r-xs);
  font-weight: 800;
  text-align: center;
  letter-spacing: 2px;
  animation: pulse-subtle 2s infinite ease-in-out;
}

@keyframes pulse-subtle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}

.function-highlight {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 800;
  padding: 2px 8px;
  border-radius: var(--r-xs);
  border-bottom: 2.5px solid var(--accent);
}

.particle-filled {
  color: var(--ok-ink);
  font-weight: 800;
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 4px;
  background: var(--ok-soft);
  padding: 2px 8px;
  border-radius: var(--r-xs);
}

/* Choice Grid (Multiple Choice) */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: var(--space-4);
  margin-bottom: var(--space-3);
  width: 100%;
}

@media (max-width: 600px) {
  .choice-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

.choice-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--speed) var(--ease);
  box-shadow: var(--shadow-paper);
  text-align: left;
  user-select: none;
  position: relative;
}

.choice-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--surface-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lift);
}

.choice-btn:active:not(:disabled) {
  transform: translateY(0);
}

.choice-btn.selected {
  border-color: var(--accent);
  background: var(--accent-soft-2);
  color: var(--accent-ink);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.choice-btn .choice-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-xs);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--ink-mute);
  font-size: 0.78rem;
  font-weight: 700;
  font-family: var(--font-display);
  flex-shrink: 0;
  transition: all var(--speed) var(--ease);
}

.choice-btn.selected .choice-key {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.choice-btn .choice-text {
  flex: 1;
  font-family: var(--font-jp);
}

.choice-btn.choice-function .choice-text {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
}

/* Verdict highlights on choices */
.choice-btn.is-correct {
  border-color: var(--ok);
  background: var(--ok-soft) !important;
  color: var(--ok-ink) !important;
  font-weight: 700;
}

.choice-btn.is-correct .choice-key {
  background: var(--ok);
  color: #fff;
  border-color: var(--ok);
}

.choice-btn.is-wrong {
  border-color: var(--bad);
  background: var(--bad-soft) !important;
  color: var(--bad-ink) !important;
  text-decoration: line-through;
}

.choice-btn.is-wrong .choice-key {
  background: var(--bad);
  color: #fff;
  border-color: var(--bad);
}

.choice-btn:disabled {
  cursor: default;
  opacity: 0.75;
}

.choice-btn.is-correct:disabled,
.choice-btn.is-wrong:disabled {
  opacity: 1;
}

.choice-btn .choice-status-icon {
  margin-left: auto;
  font-weight: 800;
  font-size: 1.1rem;
}

/* ---------------------------------------------------------------------------
 * Sentence Ordering (V2.3)
 * ------------------------------------------------------------------------- */
.ordering-wrap {
  width: 100%;
  margin-top: var(--space-3);
  margin-bottom: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ordering-tray-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-mute);
  padding: 0 4px;
}

.ordering-tray {
  background: var(--surface-2);
  border: 2px dashed var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px;
  min-height: 64px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  transition: all var(--speed) var(--ease);
}

.ordering-tray.has-items {
  border-style: solid;
  border-color: var(--line-strong, var(--line));
  background: var(--surface);
}

.ordering-tray.is-complete {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.ordering-tray-placeholder {
  color: var(--ink-subtle, var(--ink-mute));
  font-size: 0.95rem;
  font-style: italic;
  width: 100%;
  text-align: center;
  padding: 8px 0;
  user-select: none;
}

.ordering-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1.5px solid var(--line);
  color: var(--ink);
  font-family: var(--font-jp);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: all var(--speed) var(--ease);
  box-shadow: var(--shadow-paper);
}

.ordering-chip:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--surface-2);
  transform: translateY(-1px);
}

.ordering-chip.placed {
  background: var(--accent-soft-2);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.ordering-chip.placed:hover {
  border-color: var(--bad);
  background: var(--bad-soft);
  color: var(--bad-ink);
}

.ordering-chip.placed .ordering-remove-icon {
  font-size: 0.8rem;
  opacity: 0.6;
  margin-left: 2px;
}

.ordering-chip.placed:hover .ordering-remove-icon {
  opacity: 1;
}

.ordering-pos {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  font-family: var(--font-display);
  flex-shrink: 0;
}

.ordering-chip.placed:hover .ordering-pos {
  background: var(--bad);
}

.ordering-bank-header {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-mute);
  padding: 0 4px;
  margin-top: 4px;
}

.ordering-bank {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
}

@media (max-width: 600px) {
  .ordering-bank {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

.ordering-bank-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  color: var(--ink);
  font-family: var(--font-jp);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--speed) var(--ease);
  box-shadow: var(--shadow-paper);
  text-align: left;
  user-select: none;
}

.ordering-bank-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--surface-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lift);
}

.ordering-bank-btn .choice-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-xs);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--ink-mute);
  font-size: 0.78rem;
  font-weight: 700;
  font-family: var(--font-display);
  flex-shrink: 0;
}

.ordering-bank-btn .choice-text {
  flex: 1;
}

.ordering-bank-btn .choice-slot-hint {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink-faint);
  margin-left: auto;
}

.ordering-bank-btn.is-used {
  opacity: 0.35;
  pointer-events: none;
  border-style: dashed;
  box-shadow: none;
  background: var(--bg-soft);
}

.ordering-reset-btn {
  background: none;
  border: none;
  color: var(--ink-mute);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--r-xs);
  transition: all var(--speed) var(--ease);
}

.ordering-reset-btn:hover {
  color: var(--ink);
  background: var(--bg-soft);
}

.ordering-canonical {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  margin-top: 6px;
  font-family: var(--font-jp);
}

.ordering-part-pill {
  display: inline-block;
  padding: 2px 6px;
  margin: 0 2px;
  border-radius: var(--r-xs);
  background: var(--accent-soft-2);
  color: var(--accent-ink);
  font-weight: 700;
}

/* Collapse bank when card is answered to keep ratings visible */
.rv-card.is-answered .ordering-bank,
.rv-card.is-answered .ordering-bank-header,
.rv-card.is-answered .ordering-tray-header .ordering-reset-btn {
  display: none;
}

/* ---------------------------------------------------------------------------
   V2.4: Access Tiers, Soft-Gate Hero & Anonymous Landing Styles
   ------------------------------------------------------------------------- */
.tier-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-sub);
  border: 1px solid var(--border-soft);
  line-height: 1;
}

.tier-badge.tier-full {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent-ink);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}

.tier-badge.tier-dev {
  background: color-mix(in srgb, var(--warn) 15%, transparent);
  color: var(--warn-ink);
  border-color: color-mix(in srgb, var(--warn) 30%, transparent);
}

.chip-full {
  background: var(--bg-soft);
  color: var(--ink-sub);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: var(--r-xs);
  font-weight: 600;
}

.chip-full svg {
  width: 11px;
  height: 11px;
  stroke: currentColor;
  stroke-width: 2;
  opacity: 0.75;
}

/* Soft-gated access hero (calm editorial messaging) */
.soft-gate-wrap {
  max-width: 720px;
  margin: 24px auto 48px auto;
}

.soft-gate-hero {
  padding: 36px 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-paper);
}

.soft-gate-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.soft-gate-title {
  font-family: var(--font-heading);
  font-size: clamp(1.4rem, 3vw, 1.85rem);
  font-weight: 800;
  margin: 0 0 12px 0;
  color: var(--ink);
  line-height: 1.25;
}

.soft-gate-lead {
  font-size: 1rem;
  color: var(--ink-sub);
  margin-bottom: 24px;
  line-height: 1.6;
}

.soft-gate-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 24px 0 28px 0;
}

@media (max-width: 640px) {
  .soft-gate-options {
    grid-template-columns: 1fr;
  }
}

.soft-gate-option {
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color var(--speed) var(--ease);
}

.soft-gate-option:hover {
  border-color: var(--border);
}

.soft-gate-option h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 6px 0;
  color: var(--ink);
}

.soft-gate-option p {
  font-size: 0.88rem;
  color: var(--ink-sub);
  margin: 0 0 16px 0;
  line-height: 1.5;
  flex-grow: 1;
}

.contact-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.btn-contact {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--r-md);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform var(--speed) var(--ease), box-shadow var(--speed) var(--ease), filter var(--speed) var(--ease);
}

.btn-contact:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.btn-telegram {
  background: #229ED9;
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(34, 158, 217, 0.25);
}

.btn-discord {
  background: #5865F2;
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(88, 101, 242, 0.25);
}

.btn-contact svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.soft-gate-footer {
  border-top: 1px solid var(--border-soft);
  padding-top: 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.88rem;
  color: var(--ink-sub);
}

/* The guest reading room.
   Nobody is signed in, so there is no progress to report. The page's job is to
   show a real textbook that can be read right now and to make starting the
   obvious move: a cover plate, the session loop as three numbered steps, then
   the open lessons as the same ruled contents the signed-in app uses.
   The old landing ran a hero card, three pillar cards and an eight-card grid —
   three ways of saying the same "here is what this is". */
.reading-room { max-width: 960px; margin: 0 auto; }
.reading-room .desk-progress { margin-bottom: var(--space-7); }

.landing-hero {
  display: flex; align-items: flex-start; gap: clamp(18px, 4vw, 36px);
  padding-bottom: var(--space-6); margin-bottom: var(--space-6);
  border-bottom: 2px solid var(--ink);
  flex-wrap: wrap;
}
/* The cover plate: the app's seal, set as a book's front board. */
.cover {
  flex-shrink: 0; width: clamp(64px, 11vw, 88px); aspect-ratio: 3 / 4;
  display: grid; place-items: center;
  background: var(--seal); color: var(--on-accent);
  font-family: var(--font-jp); font-size: clamp(1.6rem, 4vw, 2.3rem); font-weight: 700;
  border-radius: 2px 6px 6px 2px;
  box-shadow: inset 3px 0 0 rgba(0,0,0,0.22), var(--shadow-paper);
}
.landing-hero-copy { flex: 1 1 300px; min-width: 0; }
.landing-eyebrow {
  display: block; font-family: var(--font-jp);
  font-size: 0.95rem; font-weight: 600; color: var(--accent); margin-bottom: 10px;
}
.landing-title {
  font-family: var(--font-heading);
  font-size: clamp(1.7rem, 3.6vw, 2.5rem); font-weight: 800;
  letter-spacing: -0.02em; line-height: 1.12; margin: 0 0 14px 0;
  color: var(--ink); text-wrap: balance;
}
.landing-subtitle { font-size: 1.02rem; color: var(--ink-sub); max-width: 54ch; line-height: 1.6; margin: 0 0 var(--space-5) 0; }
/* A landing page has one primary action. */
.landing-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: var(--space-4); }
.landing-actions .btn-secondary { border-color: color-mix(in srgb, var(--ink) 24%, transparent); }
.landing-note { font-size: 0.88rem; color: var(--ink-mute); margin: 0; max-width: 70ch; }

/* The session loop: three steps down a rule, numbered like a set of notes. */
.loop { margin-bottom: var(--space-7); }
.loop-head {
  font-family: var(--font-display); font-weight: 700;
  font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-mute); margin: 0 0 var(--space-4);
}
.loop-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-5); }
.loop-steps li { display: flex; gap: 11px; align-items: flex-start; padding-top: var(--space-3); border-top: 2px solid var(--ink); }
.loop-n {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: var(--r-xs);
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink);
  font-family: var(--font-display); font-weight: 700; font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
}
.loop-t { font-size: 0.9rem; font-weight: 600; color: var(--ink); line-height: 1.35; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.loop-t small { font-weight: 500; font-size: 0.8rem; color: var(--ink-mute); line-height: 1.45; }

/* The page previously stopped after the last card. A one-line footer gives it an
   end without pretending there is a marketing site behind it. */
.landing-foot {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: var(--space-4);
  margin-top: var(--space-7); padding-top: var(--space-5);
  border-top: 1px solid var(--line);
}
.landing-foot .lf-brand { display: flex; align-items: center; gap: 10px; }
.landing-foot .lf-nav { align-self: center; display: flex; gap: var(--space-4); flex-wrap: wrap; }
.landing-foot .lf-nav a { color: var(--ink-mute); text-decoration: none; font-size: 0.9rem; }
.landing-foot .lf-nav a:hover { color: var(--accent-ink); }
.landing-foot .lf-name { display: flex; flex-direction: column; font-family: var(--font-display); font-weight: 700; font-size: 0.98rem; }
.landing-foot .lf-name small { font-family: var(--font-body); font-weight: 500; font-size: 0.76rem; color: var(--ink-mute); }

.lf-brand .brand-mark { width: 34px; height: 34px; border-radius: var(--r-sm); font-size: 1.05rem; display: grid; place-items: center; background: var(--seal); color: var(--on-accent); font-weight: 700; }
.lf-name {
  display: flex; flex-direction: column;
  font-family: var(--font-display); font-weight: 700; font-size: 0.98rem;
  color: var(--ink); letter-spacing: -0.01em; line-height: 1.25;
}
.lf-name small {
  font-family: var(--font-body); font-weight: 500;
  font-size: 0.72rem; letter-spacing: 0.04em; color: var(--ink-faint);
}
.lf-nav { display: flex; flex-wrap: wrap; gap: var(--space-4); }
.lf-nav a { font-size: 0.88rem; font-weight: 600; color: var(--ink-mute); text-decoration: none; }
.lf-nav a:hover { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }

/* Muted tier: the lesson subtitles, hero fine print and footer line all sat at one
   flat, too-light value. They are lifted to --ink-mute, which is the token that
   actually meets 4.5:1 on these surfaces. */
.landing-note { color: var(--ink-mute); }
.quick-body .qd { color: var(--ink-mute); }
.lf-name small { color: var(--ink-mute); }
.section-sub { color: var(--ink-mute); }

/* The lesson grid ended in the footer with only a small text link above it, so
   the 17 unseen lessons had no way out of the preview. */
.section-foot { display: flex; justify-content: center; margin-top: var(--space-6); }

@media (max-width: 640px) {
  .landing-foot { flex-direction: column; align-items: flex-start; }
}

/* Notice panel: icon + bold state + explanation, so it reads as a status line
   rather than a wall of grey. Left rule marks it as informational at a glance. */
.guest-notice-banner {
  display: flex; align-items: flex-start; gap: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  padding: 13px 16px;
  margin-bottom: var(--space-5);
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink-soft);
}
.guest-notice-banner .gnb-icon {
  flex-shrink: 0; width: 17px; height: 17px; margin-top: 2px;
  color: var(--accent-ink);
}
.guest-notice-banner .gnb-icon svg { width: 100%; height: 100%; display: block; }
.guest-notice-banner .gnb-body { min-width: 0; max-width: 74ch; }
.guest-notice-banner strong { color: var(--ink); font-weight: 700; }
.guest-notice-banner a { font-weight: 600; white-space: nowrap; }

/* Setup footer: reset on the left, scope + primary action on the right. */
.setup-foot {
  display: flex; align-items: flex-end; justify-content: space-between;
  flex-wrap: wrap; gap: var(--space-4);
  margin-top: var(--space-4); padding-top: var(--space-5);
  border-top: 1px solid var(--line);
}
/* A control, not a caption: ghost styling on its own read as text. */
.setup-foot .btn-ghost { border-color: var(--ctrl-border); color: var(--ink-mute); background: var(--surface); }
.setup-foot .btn-ghost:hover { border-color: var(--ink-mute); background: var(--bg-soft); color: var(--ink); }
.setup-cta { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-3); min-width: 0; }
.setup-cta .btn-lg { min-width: 220px; }
/* States the consequence of the action, in the action's own eye-line. */
.setup-scope {
  font-size: 0.82rem; font-weight: 600; color: var(--ink-mute);
  font-variant-numeric: tabular-nums; text-align: right;
}
.setup-scope.is-empty { color: var(--warn-ink); }
@media (max-width: 520px) {
  /* Reset sits above the primary, not below it: the destructive-ish control
     should not be the last thing under the thumb. */
  .setup-foot { flex-direction: column; align-items: stretch; }
  .setup-cta { align-items: stretch; }
  .setup-cta .btn-lg { min-width: 0; }
  .setup-scope { text-align: center; order: -1; }
  /* Chip rows wrap ragged at phone width; a two-up grid reads as deliberate. */
  .opt-group { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .opt-pill { justify-content: space-between; min-height: 44px; }
  .opt-pill .cnt { margin-left: auto; }
}

.guest-complete-banner {
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: var(--r-md);
  padding: 16px 20px;
  margin-top: 24px;
  text-align: left;
}

.guest-complete-banner h4 {
  margin: 0 0 4px 0;
  color: var(--ink);
  font-size: 0.95rem;
}

.guest-complete-banner p {
  margin: 0 0 12px 0;
  font-size: 0.88rem;
  color: var(--ink-sub);
  line-height: 1.5;
}
