/* Language-laboratory theme.
   Structural rule: target-language text renders in Literata (serif),
   English/UI in system sans, instrumentation (counters, stats, kbd,
   section labels) in IBM Plex Mono. */
:root {
  --bg: #f5f5f1;
  --surface: #fcfcfa;
  --border: #e2e1da;
  --rule: #d3d2c9;
  --fg: #1b1c20;
  --muted: #5d5e64;
  --accent: #1e40a6;
  --accent-soft: #e4eafa;
  --accent-ink: #ffffff;
  --miss-bg: #f6e0dc;
  --miss-fg: #85291e;
  --hard-bg: #f3e9d0;
  --hard-fg: #664a0d;
  --good-bg: #ddeddc;
  --good-fg: #1f5c26;
  --seg-unseen: #a9a99c;
  --seg-learning: #5e8ecf;
  --seg-mature: #1d4785;
  --counter-bg: #14161c;
  --counter-fg: #e9edf6;
  --counter-rule: #2e323c;
  --serif: "Literata", Georgia, "Times New Roman", serif;
  --sans: system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141a;
    --surface: #1b1e26;
    --border: #2c303b;
    --rule: #262a33;
    --fg: #e6e7e3;
    --muted: #9a9ca4;
    --accent: #8aabef;
    --accent-soft: #243049;
    --accent-ink: #0e1118;
    --miss-bg: #3a2523;
    --miss-fg: #f0a396;
    --hard-bg: #37301d;
    --hard-fg: #e0bc6a;
    --good-bg: #22331f;
    --good-fg: #9fd39c;
    --seg-unseen: #555b66;
    --seg-learning: #4f7ec0;
    --seg-mature: #a5c5f7;
    --counter-bg: #0b0d12;
    --counter-fg: #dfe5f0;
    --counter-rule: #262b36;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 1rem/1.6 var(--sans);
}
main {
  max-width: 44rem;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}
h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.7rem;
  letter-spacing: -0.01em;
  margin: 1.5rem 0 .9rem;
}
/* Card section labels: FSI-workbook small caps in mono. */
h2 {
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--muted);
  margin: 0 0 .7rem;
}
a { color: var(--accent); }

/* Target-language text always in the reading serif (interlinear convention).
   |= matches regional variants too (es-419, fr-CA); en is UI language. */
main [lang]:not([lang|="en"]) {
  font-family: var(--serif);
}

/* Header: wordmark + single-line nav; double hairline like a dictionary page rule. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  box-shadow: 0 3px 0 -2px var(--rule);
}
.site-header .inner {
  max-width: 44rem;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.brand {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: .01em;
}
.site-nav {
  display: flex;
  gap: .35rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: .78rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: .95rem .45rem .85rem;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--fg); }
.site-nav a[aria-current="page"] {
  color: var(--accent);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .5rem;
  padding: 1.1rem 1.25rem;
  margin: 1rem 0;
}
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.gap-left { margin-left: 1rem; }

button {
  font: inherit;
  min-height: 2.75rem;
  padding: .5rem 1.1rem;
  border-radius: .45rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
}
button:hover { border-color: var(--muted); }
button:active { transform: translateY(1px); }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
button.big { width: 100%; font-size: 1.05rem; min-height: 3.25rem; }
button[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

label { display: inline-flex; align-items: center; gap: .4rem; }
select, input[type="number"] {
  font: inherit;
  min-height: 2.75rem;
  padding: .3rem .5rem;
  border-radius: .45rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
}

/* Drill */
.progress-track {
  height: .3rem;
  border-radius: .15rem;
  background: var(--border);
  overflow: hidden;
  margin-bottom: .75rem;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: inherit;
  transition: width .2s ease;
}
.drill-prompt {
  font-size: clamp(1.35rem, 5vw, 1.7rem);
  line-height: 1.45;
  margin: .6rem 0;
}
.drill-answer {
  font-size: clamp(1.45rem, 5vw, 1.85rem);
  font-weight: 500;
  line-height: 1.45;
  margin: .6rem 0;
  color: var(--accent);
  animation: reveal .18s ease-out;
}
@keyframes reveal {
  from { opacity: 0; transform: translateY(.3rem); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .drill-answer { animation: none; }
  .progress-fill { transition: none; }
}
.answer-zone { min-height: 5.5rem; }
.grades {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: .5rem;
}
.grades button { min-height: 3.25rem; font-weight: 600; }
.grades kbd {
  font-family: var(--mono);
  font-size: .7rem;
  font-weight: 400;
  opacity: .7;
  display: block;
}
@media (pointer: coarse) { .grades kbd { display: none; } }
button.grade-miss { background: var(--miss-bg); color: var(--miss-fg); border-color: transparent; }
button.grade-hard { background: var(--hard-bg); color: var(--hard-fg); border-color: transparent; }
button.grade-good { background: var(--good-bg); color: var(--good-fg); border-color: transparent; }
.replay-row { margin: .25rem 0 .75rem; }
.replay-row button { min-height: 2.25rem; padding: .25rem .8rem; font-size: .9rem; }
#counter { font-family: var(--mono); font-size: .8rem; }

/* Shadow */
.shadow-target {
  font-size: clamp(1.55rem, 5.5vw, 2.05rem);
  font-weight: 500;
  line-height: 1.45;
  margin: .6rem 0;
}
.transport {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: .5rem;
  margin: .75rem 0 .5rem;
}
.transport button { min-height: 3.25rem; }
.shadow-options { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* Today: due count as a tape-counter readout (Station heritage).
   Digit cells drawn with a 1ch-period gradient; digits are tabular mono. */
.due-count {
  display: inline-block;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 2.4rem;
  line-height: 1;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  color: var(--counter-fg);
  background:
    repeating-linear-gradient(
      to right,
      transparent 0,
      transparent calc(1ch - 1px),
      var(--counter-rule) calc(1ch - 1px),
      var(--counter-rule) 1ch
    ) content-box,
    var(--counter-bg);
  border: 1px solid var(--counter-rule);
  border-radius: .4rem;
  padding: .55rem .5rem .5rem;
  margin: .2rem 0 0;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, .45);
}
.due-count + .muted { margin-top: .5rem; }
.action-row { display: flex; gap: .5rem; margin: .75rem 0 .25rem; }
.action-row a { flex: 1; display: flex; text-decoration: none; }
.action-row button { width: 100%; min-height: 3.25rem; }

/* Progress */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: .5rem;
  margin-bottom: 1rem;
}
.tile {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: .45rem;
  padding: .6rem .8rem;
}
.tile .value {
  font-family: var(--mono);
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}
.tile .label { font-size: .85rem; color: var(--muted); }
.stack-bar {
  display: flex;
  gap: 2px;
  height: 1.4rem;
  border-radius: .3rem;
  overflow: hidden;
  margin: .5rem 0;
}
.seg-unseen { background: var(--seg-unseen); }
.seg-learning { background: var(--seg-learning); }
.seg-mature { background: var(--seg-mature); }
.stack-legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .9rem; color: var(--muted); }
.stack-legend .swatch {
  display: inline-block;
  width: .7rem;
  height: .7rem;
  border-radius: .2rem;
  margin-right: .35rem;
  vertical-align: baseline;
}
input[type="file"] { font: inherit; font-size: .9rem; }

/* Method articles */
article { font-size: .97rem; }
article h1, article h2, article h3 {
  font-family: var(--serif);
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  color: var(--fg);
}
article h2 { font-size: 1.25rem; margin: 1.5rem 0 .5rem; }
article h3 { font-size: 1.05rem; margin: 1.25rem 0 .4rem; }
article img { max-width: 100%; }
article table { display: block; overflow-x: auto; border-collapse: collapse; }
article th, article td { border: 1px solid var(--border); padding: .35rem .6rem; }
article code { font-family: var(--mono); font-size: .88em; background: var(--surface); padding: .1rem .3rem; border-radius: .25rem; }
article pre { background: var(--surface); border: 1px solid var(--border); padding: .75rem; border-radius: .45rem; overflow-x: auto; }
article pre code { background: none; padding: 0; border: 0; }
article blockquote { margin: 1rem 0; padding: .1rem 1rem; border-left: 3px solid var(--accent); color: var(--muted); }
.doc-list { display: flex; flex-direction: column; gap: .4rem; }

/* Guided-path components: daily checklist, band bars, pair choices, tutor quote */
.checklist { list-style: none; padding: 0; margin: 0 0 .75rem; }
.checklist li { display: flex; gap: .55rem; align-items: baseline; margin: .4rem 0; }
.checklist a { color: var(--fg); text-decoration: none; }
.checklist a:hover { color: var(--accent); }
main blockquote { border-left: 3px solid var(--accent); margin: .75rem 0; padding: .25rem .9rem; background: var(--bg); border-radius: 0 .45rem .45rem 0; font-family: var(--serif); }
.bands { display: grid; gap: .4rem; margin: .5rem 0 1rem; }
.band { display: grid; grid-template-columns: 7.5rem 1fr 3.5rem; gap: .6rem; align-items: center; }
.band .track { height: .55rem; background: var(--bg); border: 1px solid var(--border); border-radius: .35rem; overflow: hidden; }
.band .fill { height: 100%; background: var(--accent); width: 0; }
.band .muted { font-family: var(--mono); font-size: .8rem; }
.checkpoint-list { list-style: none; padding: 0; margin: 0 0 .75rem; }
.checkpoint-list li { margin: .65rem 0; }
.checkpoint-list .ratings { display: flex; flex-wrap: wrap; gap: .35rem .9rem; margin-top: .25rem; }
.checkpoint-list .ratings label { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.choice-row { display: flex; gap: .75rem; margin: .75rem 0; }
.choice-row button { font-size: 1.15rem; min-height: 3.25rem; flex: 1; }
.feedback-good { color: var(--good-fg); }
.feedback-bad { color: var(--miss-fg); }
.headword { font-size: 1.8rem; font-weight: 500; margin: .5rem 0; }
.stat-big, .stat-mid {
  font-family: var(--mono);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin: .25rem 0;
  line-height: 1.3;
}
.stat-big { font-size: 1.9rem; }
.stat-mid { font-size: 1.2rem; }

/* Dictation mode */
.mode-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: 0 0 .75rem; }
.mode-row button { min-height: 2.25rem; padding: .25rem .9rem; font-size: .9rem; }
#typeZone { display: grid; gap: .5rem; margin: .5rem 0; }
#typeZone textarea {
  font: inherit;
  font-size: 1.15rem;
  font-family: var(--serif);
  padding: .6rem .75rem;
  border-radius: .45rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  resize: vertical;
}
.diff-out { font-size: clamp(1.2rem, 4vw, 1.45rem); line-height: 1.6; }
.diff-same { color: var(--good-fg); }
.diff-missing { color: var(--miss-fg); text-decoration: underline wavy; }
.diff-extra { color: var(--miss-fg); text-decoration: line-through; }
.diff-note { display: block; font-family: var(--sans); margin-top: .3rem; }

/* Shadow: record-and-compare */
.record-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .75rem 0 .25rem; }
.record-row button { min-height: 2.25rem; padding: .25rem .9rem; font-size: .9rem; }

/* Reader */
.reader-text {
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.9;
}
.rw { cursor: pointer; border-radius: .2rem; padding: 0 .05em; }
.rw:hover, .rw:focus-visible { outline: 1px solid var(--accent); }
.rw-unknown { border-bottom: 1px dotted var(--muted); }
.rw-learning { background: var(--hard-bg); color: var(--hard-fg); }
.rw-known { border-bottom: none; }
#wordCard button[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
