/* Light is the default. Dark only by system preference or by the bar toggle. */
/* Meldar "Ladder / Gazette" language (D-001): cream, brass, navy, teal. Text tokens meet 4.5:1.
   Type scale: 13 / 16 / 19 / 25 / 34 / 52 — nothing below 13px. Light is the default. */
:root {
  --bg: #F9F6EF; --surface: #ffffff; --surface2: #F1ECE0; --ink: #1d2230; --ink2: #3f4658; --muted: #635C4B;
  --line: #E3DCCB; --accent: #1E4A76; --accent-ink: #ffffff; --accent-soft: #E4ECF4; --brass: #7A5C15;
  --ok: #2F6B54; --ok-soft: #E3F0EA; --warn: #8A6A1F; --warn-soft: #F6EEDB; --bad: #A3423C; --bad-soft: #F6E4E2;
  --listen: #1E4A76; --read: #6B4A8A; --speak: #A3423C; --write: #2C6B62;
  --radius: 14px; --gap: 16px; --maxw: 1080px; --scale: 1;
  --font: "Hanken Grotesk", system-ui, sans-serif; --serif: "EB Garamond", Georgia, serif;
  --lh: 1.6; --ls: 0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15181e; --surface: #1d2129; --surface2: #252a35; --ink: #eceff5; --ink2: #c3c9d6; --muted: #a39d8c;
    --line: #333946; --accent: #8db8e6; --accent-ink: #0d1520; --accent-soft: #1f2d40; --brass: #d7b46a;
    --ok: #7cc9a4; --ok-soft: #1c3226; --warn: #e3b35c; --warn-soft: #362c17; --bad: #ec9a92; --bad-soft: #3a2020;
    --listen: #8db8e6; --read: #c1a6e0; --speak: #ec9a92; --write: #7cc9bb;
  }
}
:root[data-theme="dark"] {
  --bg: #15181e; --surface: #1d2129; --surface2: #252a35; --ink: #eceff5; --ink2: #c3c9d6; --muted: #a39d8c;
  --line: #333946; --accent: #8db8e6; --accent-ink: #0d1520; --accent-soft: #1f2d40; --brass: #d7b46a;
  --ok: #7cc9a4; --ok-soft: #1c3226; --warn: #e3b35c; --warn-soft: #362c17; --bad: #ec9a92; --bad-soft: #3a2020;
  --listen: #8db8e6; --read: #c1a6e0; --speak: #ec9a92; --write: #7cc9bb;
}
:root[data-font="atkinson"] { --font: "Atkinson Hyperlegible", system-ui, sans-serif; }
:root[data-font="lexend"] { --font: "Lexend", system-ui, sans-serif; }
:root[data-font="system"] { --font: system-ui, -apple-system, sans-serif; }
:root[data-line="wide"] { --lh: 1.85; } :root[data-line="widest"] { --lh: 2.1; }
:root[data-letter="wide"] { --ls: 0.04em; }
:root[data-motion="off"] *, :root[data-motion="off"] *::before { animation: none !important; transition: none !important; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: calc(16px * var(--scale)); line-height: var(--lh); letter-spacing: var(--ls); -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
.fr { font-family: var(--serif); font-size: 1.1875em; }
.bigq.fr, .flash .fr { font-size: calc(25px * var(--scale)); }
[hidden] { display: none !important; }

/* Bar */
.bar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); }
.bar-in { max-width: var(--maxw); margin: 0 auto; display: flex; align-items: center; gap: 8px; padding: 8px 16px; }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand b { background: var(--accent); color: var(--accent-ink); border-radius: 8px; padding: 1px 7px; font-size: .85em; }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { text-decoration: none; color: var(--ink2); padding: 6px 10px; border-radius: 10px; white-space: nowrap; font-size: .9em; }
.nav a.on { background: var(--accent-soft); color: var(--ink); font-weight: 700; }
.ico { background: none; border: 1px solid var(--line); border-radius: 10px; padding: 6px 9px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.ico svg { pointer-events: none; display: block; width: 18px; height: 18px; }

main { max-width: var(--maxw); margin: 0 auto; padding: 20px 16px 80px; }
h1 { font-family: var(--serif); font-weight: 600; font-size: calc(34px * var(--scale)); line-height: 1.2; margin: .2em 0 .4em; }
h2 { font-size: calc(25px * var(--scale)); font-family: var(--serif); font-weight: 600; margin: 1.4em 0 .5em; }
h3 { font-size: calc(19px * var(--scale)); margin: 1em 0 .3em; }
p { margin: .4em 0 .8em; }
.lede { color: var(--ink2); max-width: 60ch; }
.muted { color: var(--muted); }
.small { font-size: calc(13px * var(--scale)); }
.small .fr, .fr.small { font-size: calc(16px * var(--scale)); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: var(--gap); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }

.btn { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 12px; padding: 11px 18px; font-weight: 700; cursor: pointer; text-decoration: none; display: inline-block; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 400; }
.btn.sm { padding: 6px 12px; font-size: .88em; }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible, .ico:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: .8em; background: var(--surface2); white-space: nowrap; }
.chip.listen { border-color: var(--listen); color: var(--listen); } .chip.read { border-color: var(--read); color: var(--read); }
.chip.speak { border-color: var(--speak); color: var(--speak); } .chip.write { border-color: var(--write); color: var(--write); }
.lvl { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Skill level picker */
.skillrow { display: grid; grid-template-columns: 150px 1fr; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.skillrow:last-child { border-bottom: 0; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 7px 14px; cursor: pointer; font-weight: 700; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
@media (max-width: 560px) { .skillrow { grid-template-columns: 1fr; } }

/* Session runner */
.steps { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 16px; }
.steps button { font-size: calc(13px * var(--scale)); padding: 5px 12px; border-radius: 99px; background: var(--surface2); color: var(--ink2); border: 1px solid var(--line); cursor: pointer; }
.steps button.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; border-color: var(--accent); }
.steps button.done { background: var(--ok-soft); color: var(--ok); }
.clock, .stat { font-variant-numeric: tabular-nums; font-size: calc(34px * var(--scale)); font-weight: 700; font-family: var(--serif); }
.bigq { line-height: 1.4; }
textarea { width: 100%; min-height: 140px; border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--surface); line-height: 1.5; }
input[type=text], input[type=search], select { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--surface); max-width: 100%; }

/* Flash card */
.flash { min-height: 180px; display: flex; flex-direction: column; justify-content: center; text-align: center; gap: 12px; }
.flash .front { font-size: 1.3em; }
.flash .back { font-size: 1.45em; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grades button { padding: 12px 4px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 700; }

/* Options for MCQ */
.opts { display: grid; gap: 8px; }
.opts button { text-align: left; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; }
.opts button.right { background: var(--ok-soft); border-color: var(--ok); }
.opts button.wrong { background: var(--bad-soft); border-color: var(--bad); }

/* Table */
.tbl { width: 100%; border-collapse: collapse; font-size: .9em; }
.tbl th, .tbl td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 700; font-size: .85em; }
.scrollx { overflow-x: auto; }

/* Toggle switch */
.tog { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.tog:last-child { border-bottom: 0; }
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 99px; cursor: pointer; transition: .15s; }
.switch span::before { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: var(--surface); border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

.note { background: var(--warn-soft); border-left: 4px solid var(--warn); padding: 10px 14px; border-radius: 8px; }
.okbox { background: var(--ok-soft); border-left: 4px solid var(--ok); padding: 10px 14px; border-radius: 8px; }
.res { display: flex; flex-direction: column; gap: 6px; }
.res .t { font-weight: 700; }
.footer { color: var(--muted); font-size: .8em; text-align: center; padding: 24px 16px; }
.focus-mode .bar .nav { display: none; }
.kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 0 6px; font-size: .8em; }
details > summary { cursor: pointer; font-weight: 700; padding: 6px 0; }

.mt0 { margin-top: 0; } .m0 { margin: 0; } .mt { margin-top: 16px; } .mt6 { margin-top: 6px; } .mb { margin-bottom: 12px; }
.wide { width: 100%; } .grow { flex: 1; min-width: 0; } .prewrap { white-space: pre-wrap; } .break { word-break: break-all; }
.seg.wrap { margin-bottom: 4px; }
.skillrow .cando { margin-top: 6px; }
.chip.ok { color: var(--ok); border-color: var(--ok); }
.mine-cell { background: var(--accent-soft); }
.steplist { padding-left: 1.2em; margin: .4em 0 1em; }
.reentry { border-left: 4px solid var(--brass); margin-bottom: 12px; }
.tog.col { flex-direction: column; align-items: stretch; gap: 6px; }
.gaprow { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 8px; }
@media (max-width: 640px) { .gaprow { grid-template-columns: 1fr; } }
.guess { width: 30%; min-width: 120px; margin: 6px 6px 0 0; }
mark { background: var(--warn-soft); color: var(--ink); border-bottom: 2px solid var(--warn); }
.seat { position: fixed; inset: 0; z-index: 50; background: var(--ink); color: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px; text-align: center; }
.seat .muted { color: var(--surface2); }
.seat .broke { font: inherit; font-size: calc(34px * var(--scale)); font-family: var(--serif); padding: 40px 36px; border-radius: 28px; border: 0; background: var(--brass); color: #fff; cursor: pointer; max-width: 90vw; }
.seat .btn.ghost { color: var(--bg); border-color: var(--surface2); }
.sticky-save { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; border-top: 1px solid var(--line); }
audio { max-width: 100%; vertical-align: middle; }
code { font-size: .9em; }

.veiled { color: transparent !important; text-shadow: none; background: repeating-linear-gradient(45deg, var(--surface2), var(--surface2) 6px, var(--line) 6px, var(--line) 12px); }
.cando-q { margin: 8px 0 12px; padding: 8px 14px; border-left: 4px solid var(--brass); background: var(--surface2); border-radius: 8px; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 60; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }
.seat { background: #14171d; color: #f3efe6; }
.seat .muted { color: #c9c2b0; }
.seat .broke { background: #F3D98B; color: #1d2230; }
.seat .btn.ghost { color: #f3efe6; border-color: #6b6557; }
.tog { flex-wrap: wrap; } .tog select, .tog input[type=text] { max-width: 100%; min-width: 0; }
input[type=text], select, textarea { border-color: #8f8672; }
:root[data-theme="dark"] input[type=text], :root[data-theme="dark"] select, :root[data-theme="dark"] textarea { border-color: #6f7789; }
@media (max-width: 640px) {
  .bar-in { flex-wrap: wrap; }
  .nav { order: 3; flex-basis: 100%; flex-wrap: wrap; overflow: visible; }
}
