@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,400;0,500;0,700;1,400;1,700&display=swap');

[hidden] { display: none !important; }

:root {
  color-scheme: dark;
  --bg: #1d2021;     /* page */
  --bg1: #282828;    /* panels */
  --bg2: #32302f;    /* raised / status bar */
  --line: #3c3836;
  --line2: #504945;
  --fg: #ebdbb2;
  --muted: #a89984;
  --dim: #7c6f64;
  --green: #b8bb26;
  --yellow: #fabd2f;
  --red: #fb4934;
  --aqua: #8ec07c;
  --blue: #83a598;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, 'Courier New', monospace;
}

* { box-sizing: border-box; }
html, body { background: var(--bg); }
body { margin: 0; color: var(--fg); font: 14px/1.5 var(--mono); }
::selection { background: var(--yellow); color: var(--bg); }
button, select, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 1px solid var(--yellow); outline-offset: 2px; }

/* ---------- layout ---------- */
.shell { min-height: 100vh; display: grid; grid-template-columns: 230px 1fr; }
.sidebar { background: var(--bg1); border-right: 1px solid var(--line); padding: 22px 14px; display: flex; flex-direction: column; min-height: 100vh; }
.main { padding: 28px clamp(16px, 4vw, 56px); max-width: 1400px; width: 100%; min-width: 0; margin: 0 auto; }

/* ---------- sidebar ---------- */
.brand { display: flex; align-items: center; gap: 10px; margin: 0 0 36px 4px; }
.brand-mark { background: var(--green); color: var(--bg); font-weight: 700; font-size: 13px; padding: 2px 6px; }
.brand-name { font-weight: 700; font-size: 13px; }
.brand-sub { font-size: 11px; color: var(--muted); }
.nav-item { display: block; width: 100%; border: 0; background: none; text-align: left; padding: 6px 10px; color: var(--muted); cursor: pointer; }
.nav-item:hover { color: var(--fg); }
.nav-item.active { background: var(--bg2); color: var(--yellow); }
.nav-icon { color: var(--dim); margin-right: 8px; }
.nav-item.active .nav-icon { color: var(--yellow); }
.sidebar-bottom { margin-top: auto; }
.local-status { display: flex; gap: 10px; align-items: center; padding: 12px 6px; margin-bottom: 10px; border-top: 1px dashed var(--line); font-size: 11px; }
.local-status b, .local-status small { display: block; }
.local-status small { color: var(--muted); }
.status-dot { width: 8px; height: 8px; background: var(--green); flex: none; }
.sidebar .outline-btn { width: 100%; text-align: left; }

/* comment-style labels */
.side-label, .eyebrow, .prompt-label, .answer-label, .rail-label { font-size: 11px; color: var(--muted); text-transform: lowercase; }
.side-label::before, .eyebrow::before, .prompt-label::before, .answer-label::before, .rail-label::before { content: '# '; color: var(--dim); }
.side-label { padding-left: 10px; margin-bottom: 6px; }

/* ---------- buttons: [ label ] ---------- */
.primary-btn, .outline-btn, .back-btn { background: none; border: 0; padding: 3px 6px; cursor: pointer; font-weight: 700; white-space: nowrap; }
.primary-btn { color: var(--green); }
.outline-btn { color: var(--fg); }
.back-btn { color: var(--muted); font-weight: 500; }
.primary-btn::before, .outline-btn::before { content: '[ '; color: var(--dim); }
.primary-btn::after, .outline-btn::after { content: ' ]'; color: var(--dim); }
.primary-btn:hover { background: var(--green); color: var(--bg); }
.outline-btn:hover { background: var(--fg); color: var(--bg); }
.primary-btn:hover::before, .primary-btn:hover::after, .outline-btn:hover::before, .outline-btn:hover::after { color: inherit; }
.back-btn:hover { color: var(--fg); }
.primary-btn:disabled { opacity: .45; cursor: not-allowed; background: none; color: var(--green); }
.icon-btn { background: none; border: 1px solid var(--line2); color: var(--muted); width: 32px; height: 32px; padding: 0; cursor: pointer; }
.icon-btn:hover { border-color: var(--yellow); color: var(--yellow); }
.full { display: block; width: 100%; margin-top: 22px; border: 1px solid var(--green); padding: 8px; }

/* ---------- library ---------- */
.section-head h2 { font-size: 20px; font-weight: 700; margin: 2px 0 4px; color: var(--fg); }
.section-head h2::before { content: '# '; color: var(--yellow); }
.section-head .eyebrow::before { content: none; }
.section-head .eyebrow { letter-spacing: .02em; }
.section-head:not(:first-child) { margin-top: 40px; }
.check-row + .section-head, .stats-langs + .section-head { margin-top: 18px; }
.check-row:empty { display: none; }
.modal p { font-size: 12px; color: var(--muted); margin: 0; }
.sidebar .outline-btn + .outline-btn { margin-top: 4px; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 36px; }
.book-card, .run-card, .stat-card { background: var(--bg1); border: 1px solid var(--line); padding: 14px 16px; }
.book-card, .run-card { cursor: pointer; }
.book-card:hover, .run-card:hover { border-color: var(--yellow); }
.book-card { min-height: 150px; display: flex; flex-direction: column; }
.book-top, .run-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.book-icon { background: var(--aqua); color: var(--bg); font-weight: 700; padding: 0 6px; }
.book-tag { font-size: 11px; color: var(--muted); }
.book-card h3 { font-size: 15px; color: var(--yellow); margin: 12px 0 4px; }
.book-card p { font-size: 12px; color: var(--muted); margin: 0; }
.book-foot { margin-top: auto; padding-top: 14px; display: flex; justify-content: space-between; font-size: 12px; color: var(--green); }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.muted { font-size: 11px; color: var(--muted); }
.run-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.run-card h3 { font-size: 15px; margin: 10px 0 2px; }
.run-sub { font-size: 12px; color: var(--muted); }
.run-card-foot { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.empty { padding: 24px; border: 1px dashed var(--line2); color: var(--muted); font-size: 12px; }
.empty::before { content: '~ '; color: var(--blue); }

/* mode-badge pills */
.pill { font-size: 11px; font-weight: 700; padding: 0 6px; background: var(--bg2); color: var(--muted); white-space: nowrap; }
.pill.blue { background: var(--blue); color: var(--bg); }
.pill.green { background: var(--green); color: var(--bg); }

/* segmented progress bars */
.mini-track, .progress-track { height: 6px; background: var(--bg2); overflow: hidden; }
.mini-track { margin: 12px 0 8px; }
.mini-fill, .progress-fill { height: 100%; background: repeating-linear-gradient(90deg, var(--green) 0 8px, transparent 8px 10px); transition: width .2s; }

/* ---------- stats ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.stat-card .big { font-size: 24px; font-weight: 700; color: var(--yellow); margin: 6px 0; }
.stat-card p { font-size: 11px; color: var(--muted); margin: 0; }
.book-stats-head { margin-top: 36px; }
.breakdown { overflow-x: auto; margin-top: 12px; }
.breakdown table { width: 100%; border-collapse: collapse; background: var(--bg1); border: 1px solid var(--line); font-size: 12px; }
.breakdown th { text-align: left; font-weight: 500; color: var(--muted); text-transform: lowercase; padding: 8px 12px; border-bottom: 1px solid var(--line2); white-space: nowrap; }
.breakdown td { padding: 6px 12px; border-bottom: 1px dashed var(--line); }
.breakdown tr:last-child td { border-bottom: 0; }
.breakdown .num { text-align: right; white-space: nowrap; }
.feedback .breakdown table { background: var(--bg); }

/* ---------- run view: one vim buffer ---------- */
#runView.vim { display: flex; flex-direction: column; min-height: calc(100vh - 56px); font-size: 16px; line-height: 1.6; }
.vim-buf { counter-reset: ln; cursor: text; }
/* every line gets a line number in a gutter; wrapped text keeps the number on its first row, like vim */
.ln { counter-increment: ln; position: relative; padding-left: 6ch; min-height: 1.6em; white-space: pre-wrap; overflow-wrap: anywhere; }
.ln::before { content: counter(ln); position: absolute; left: 0; width: 4ch; text-align: right; color: var(--dim); font-style: normal; user-select: none; }
.cm { color: var(--dim); font-style: italic; }
.dim { color: var(--muted); }
.ok { color: var(--green); }
.partial { color: var(--yellow); }
.err { color: var(--red); }
.gt { color: var(--yellow); }
.prompt { font-weight: 700; }
.pb { color: var(--yellow); font-weight: 700; }
.answer:focus-within { background: var(--bg1); } /* cursorline */
.answer textarea { display: block; width: 100%; min-height: 0; resize: none; overflow: hidden; background: transparent; border: 0; padding: 0; margin: 0; font: inherit; line-height: inherit; color: var(--aqua); caret-color: var(--yellow); outline: none; }
.answer textarea::placeholder { color: var(--dim); }
.answer textarea:disabled { opacity: 1; color: var(--aqua); }
.link { background: none; border: 0; padding: 0; color: var(--green); cursor: pointer; font: inherit; text-align: left; justify-self: start; }
.link:hover, .link:focus-visible { background: var(--green); color: var(--bg); outline: none; }
.link:disabled { color: var(--dim); cursor: default; background: none; }
.vim-tilde { flex: 1; min-height: 3.2em; overflow: hidden; color: var(--blue); white-space: pre; user-select: none; }
.vim-tilde::before { content: '~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A~\A'; }
.vim .breakdown { margin: 4px 0 0; }
.vim .breakdown table { background: none; border: 0; font-size: 14px; }
.vim .breakdown th { padding: 0 2ch 0 0; border-bottom: 1px dashed var(--line2); }
.vim .breakdown td { padding: 0 2ch 0 0; border: 0; }

/* status line + command line */
/* pinned to the bottom of the window, like vim, even when the buffer is long */
.vim-foot { position: sticky; bottom: 0; background: var(--bg); padding-bottom: 6px; }
.statusline { display: flex; font-size: 13px; background: var(--bg2); white-space: nowrap; overflow: hidden; }
.statusline > span { padding: 1px 1.5ch; }
.sl-mode { background: var(--green); color: var(--bg); font-weight: 700; }
.sl-mode.normal { background: var(--blue); }
.sl-mode.grading { background: var(--yellow); }
.sl-mode.err { background: var(--red); }
.sl-mode.done { background: var(--aqua); }
.sl-file { background: var(--line); overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sl-fill { flex: 1; }
.sl-right { background: var(--line); border-left: 1px solid var(--bg2); }
.sl-effort { cursor: pointer; color: var(--aqua); }
.sl-effort:hover { background: var(--line2); }
.sl-time { background: var(--line2); color: var(--yellow); font-weight: 700; }
.sl-time.low { background: var(--red); color: var(--bg); }
.sl-pomo { color: var(--red); }
.vim .breakdown tr.cur-row td { color: var(--yellow); }
.modal .check-row .inline-select { display: inline-block; width: auto; margin: 0; padding: 2px 6px; }
.cmdline { display: flex; justify-content: space-between; align-items: baseline; gap: 2ch; font-size: 14px; min-height: 1.9em; padding-top: 2px; }
#cmdMsg { font-weight: 700; white-space: pre-wrap; }
#cmdMsg.cmd-err { color: var(--red); font-weight: 500; }
#cmdBox { flex: 1; display: flex; }
#cmdInput { flex: 1; background: none; border: 0; outline: none; padding: 0; color: var(--fg); caret-color: var(--yellow); }
.cmd-right { display: flex; gap: 2ch; align-items: baseline; margin-left: auto; text-align: right; }
.cmd-hint { color: var(--dim); font-size: 12px; }

/* ---------- modal & toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .7); display: grid; place-items: center; padding: 16px; z-index: 5; }
.modal { position: relative; width: min(480px, 100%); background: var(--bg1); border: 1px solid var(--yellow); padding: 24px; }
.modal h2 { font-size: 16px; color: var(--yellow); margin: 4px 0 6px; }
.modal-close { position: absolute; right: 12px; top: 6px; background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; }
.modal-close:hover { color: var(--red); }
.modal label { display: block; font-size: 12px; color: var(--muted); margin-top: 16px; }
.modal select { display: block; width: 100%; margin-top: 6px; padding: 8px; background: var(--bg); border: 1px solid var(--line2); border-radius: 0; color: var(--fg); }
.check-row { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 8px; }
.check-row label { margin: 0; color: var(--fg); }
.check-row input { accent-color: var(--green); }
.delete-list { margin-top: 16px; border-top: 1px dashed var(--line2); }
.del-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line2); font-size: 13px; }
.del-row small { display: block; color: var(--muted); font-size: 11px; }
.del-row.confirm b { color: var(--red); }
.del-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.link.danger { color: var(--red); }
.link.danger:hover, .link.danger:focus-visible { background: var(--red); color: var(--bg); }
.toast { position: fixed; bottom: 16px; right: 16px; max-width: calc(100% - 32px); background: var(--bg2); border-left: 3px solid var(--yellow); padding: 8px 12px; font-size: 12px; z-index: 6; }

/* ---------- responsive ---------- */
@media (max-width: 850px) {
  .shell { grid-template-columns: minmax(0, 1fr); align-content: start; }
  .sidebar { min-height: 0; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { margin: 0 auto 0 0; }
  .side-label, .sidebar-bottom { display: none; }
  .nav-item { width: auto; }
  #runView.vim { min-height: 75vh; }
  }
@media (max-width: 520px) {
  #runView.vim { font-size: 15px; }
  .ln { padding-left: 4.5ch; }
  .ln::before { width: 3ch; }
  .sl-file, .sl-opt, .cmd-hint { display: none; }
  .book-grid, .run-list { grid-template-columns: 1fr; }
}

/* the words of a wrong answer the grader called wrong: flash red, then stay red */
.ww { color: var(--red); font-weight: 700; text-decoration: underline wavy var(--red); text-underline-offset: 3px; animation: ww-flash .4s steps(2, jump-none) 6; }
@keyframes ww-flash { 0% { color: var(--red); background: rgba(251, 73, 52, .25); } 100% { color: var(--fg); background: transparent; } }
@media (prefers-reduced-motion: reduce) { .ww { animation: none; } }

/* reading and vocab drill runs: clickable words, and what was looked up */
.lw { cursor: pointer; border-bottom: 1px solid transparent; }
.lw:hover { border-bottom-color: var(--yellow); color: var(--yellow); }
.lw-known { border-bottom: 1px dotted var(--aqua); }
.lw-seen { color: var(--aqua); }
.lk { color: var(--fg); }
.lk-w { color: var(--aqua); }
.err { color: var(--red); }
/* the run dialog: two fields side by side */
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.small { font-size: 12px; }
/* the vocab page */
.vocab-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0 16px; }
.vocab-actions a { text-decoration: none; display: inline-block; }
.vocab-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.vocab-table th { text-align: left; color: var(--muted); font-weight: normal; border-bottom: 1px solid var(--line); padding: 6px 8px; }
.vocab-table td { padding: 6px 8px; vertical-align: top; }
.vocab-table tr:not(.vocab-ex) td { border-top: 1px solid var(--line); }
.vocab-ex td { padding-top: 0; font-size: 12px; }

/* reading runs: the passages around the current one */
.ctx { color: var(--dim); }
#ctxAfter .ctx:first-child { margin-top: 2px; }

/* the vocab page: a heading per language */
.vocab-table tr.vocab-lang td { padding-top: 18px; font-weight: 700; color: var(--yellow); border-top: 0; }

/* study statistics: the language toggles and headings */
.stats-langs { margin: 4px 0 14px; gap: 14px; align-items: center; }
.stats-lang { margin: 36px 0 4px; font-size: 17px; color: var(--fg); }
.stats-lang::before { content: '## '; color: var(--yellow); }
/* the vocab page's pager */
.vocab-pager { margin: 14px 0; display: flex; gap: 12px; align-items: baseline; }
.vocab-pager button[disabled] { opacity: .35; cursor: default; }

#nextRow button[disabled] { opacity: .35; cursor: default; }

/* the character page: talent trees */
.talent-trees { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 10px; }
.tal-tree { border: 1px solid var(--line); padding: 12px; }
.tal-tree.locked { opacity: .45; }
.tal-head h3 { margin: 0 0 2px; }
.tal-tier { margin-top: 12px; }
.tal-tier.shut .tal { opacity: .5; }
.tal-tier-head { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.tal { display: block; width: 100%; text-align: left; background: none; border: 1px solid var(--line); color: var(--fg); font: inherit; font-size: 12px; padding: 7px 8px; margin-bottom: 6px; cursor: pointer; }
.tal:hover:not(.no) { border-color: var(--yellow); }
.tal.no { cursor: default; }
.tal.taken { border-color: var(--aqua); }
.tal-rank { float: right; color: var(--yellow); }
.tal-desc, .tal-next { display: block; color: var(--muted); margin-top: 3px; }
.tal-next { color: var(--dim); font-style: italic; }

/* deleting a run */
.run-card-right { display: flex; align-items: center; gap: 8px; }
.run-del { background: none; border: 0; color: var(--dim); font: inherit; cursor: pointer; padding: 0 4px; }
.run-del:hover, .run-del.armed { color: var(--red); }

/* the credits page */
.credits-page #creditsBody h2 { margin: 36px 0 10px; font-size: 17px; color: var(--fg); }
.credits-page #creditsBody h2::before { content: '## '; color: var(--yellow); }
.credits-page #creditsBody h2:first-child { margin-top: 8px; }
.credits-page h4 { margin: 20px 0 6px; font-size: 14px; }
.credits-page h4::before { content: '### '; color: var(--yellow); }
.credits-page table { border-collapse: collapse; font-size: 12px; margin: 8px 0; }
.credits-page th, .credits-page td { border-bottom: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
.credits-page a { color: var(--blue); }
.credits-page p, .credits-page li { font-size: 13px; line-height: 1.6; }

/* points waiting to be spent */
.nav-badge { background: var(--yellow); color: var(--bg); font-weight: 700; padding: 0 6px; margin-left: 4px; }

/* the character page: the level and its scale */
.char-level { border: 1px solid var(--line); padding: 14px; margin-bottom: 14px; }
.level-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.level-head .big { font-size: 34px; font-weight: 700; color: var(--yellow); }
.level-title { font-size: 16px; color: var(--fg); font-weight: 400; }
.level-rating { text-align: right; font-size: 13px; }
.level-track { height: 6px; background: var(--line); margin: 10px 0 6px; }
.level-fill { height: 100%; background: var(--yellow); }
.level-ladder { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; margin-top: 8px; }
.level-ladder span.here b { color: var(--yellow); }

/* the box explaining a trip to the character page */
.gate-modal p { font-size: 13px; line-height: 1.6; }
.gate-actions { display: flex; gap: 12px; margin-top: 14px; }

/* voice: listen, speak, shadow */
.voice-line { margin-top: 6px; }
.voice-line .ok { color: var(--green, #b8bb26); }
.voice-line .err { color: var(--red, #fb4934); }
.voice-rec { color: var(--red, #fb4934); font-weight: 700; }
.sl-voice { cursor: pointer; }
.sl-voice.on { color: var(--yellow); }
.sl-voice.rec { color: var(--red, #fb4934); }
.book-rec { font-size: 12px; margin: -4px 0 8px; color: var(--yellow); }

/* talent tree art: an emblem per tree, an icon per talent, a meander border, tiers joined by a line */
.tal-tree { --tc: var(--muted); position: relative; padding-top: 18px; background: linear-gradient(180deg, color-mix(in srgb, var(--tc) 7%, transparent), transparent 140px); }
.tal-tree.tree-reading { --tc: var(--blue); }
.tal-tree.tree-writing { --tc: var(--green); }
.tal-tree.tree-speaking { --tc: var(--yellow); }
.tal-tree.tree-listening { --tc: var(--aqua); }
.tal-tree::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 9px; opacity: .8;
  background: var(--tc); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='9'%3E%3Cpath d='M0 8.5h16M0 .5h16M0 6.5h4v-4h8v2h-4' fill='none' stroke='black'/%3E%3C/svg%3E") repeat-x;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='9'%3E%3Cpath d='M0 8.5h16M0 .5h16M0 6.5h4v-4h8v2h-4' fill='none' stroke='black'/%3E%3C/svg%3E") repeat-x; }
.tal-head { display: flex; gap: 10px; align-items: center; }
.tal-emblem { width: 44px; height: 44px; flex: none; color: var(--tc); stroke-width: 1.3; padding: 4px; border: 1px solid color-mix(in srgb, var(--tc) 50%, transparent); border-radius: 50%; }
.tal-tier { position: relative; }
.tal-tier + .tal-tier::before { content: ''; position: absolute; left: 25px; top: -12px; height: 12px; border-left: 1px dashed var(--line2); }
.tal { display: flex; gap: 9px; align-items: flex-start; }
.tal-body { flex: 1; min-width: 0; }
.tal-ico { flex: none; width: 34px; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.tal-icon { width: 34px; height: 34px; padding: 5px; color: var(--muted); border: 1px solid var(--line2); background: var(--bg); }
.tal:hover:not(.no) .tal-icon { color: var(--tc); border-color: var(--tc); }
.tal.taken .tal-icon { color: var(--tc); border-color: var(--tc); box-shadow: 0 0 8px color-mix(in srgb, var(--tc) 35%, transparent); }
.tal.full .tal-icon { background: color-mix(in srgb, var(--tc) 14%, var(--bg)); }
.tal.no:not(.taken) .tal-icon { color: var(--dim); }
.tal-tier.shut .tal-icon { filter: grayscale(1); }
.tal-pips { display: flex; gap: 2px; }
.tal-pips i { width: 5px; height: 5px; border: 1px solid var(--line2); }
.tal-pips i.on { background: var(--tc); border-color: var(--tc); }
.tal.taken { border-color: color-mix(in srgb, var(--tc) 60%, var(--line)); }
.voice-ref { margin-top: 4px; padding-left: 10px; border-left: 2px solid var(--yellow); }
.voice-ref b { color: var(--fg); }

/* ---------- every run: a typeset page (light on dark, a book face, a measure and margins) ---------- */
#runView.page { --page: #e6dcc3; --page-dim: #8c8371; }
#runView.page .vim-buf { font-family: 'EB Garamond', Garamond, 'Adobe Garamond Pro', 'Garamond Premier Pro', Georgia, serif;
  font-size: 22px; line-height: 1.62; color: var(--page); max-width: 34em; margin: 0 auto; padding: 56px 40px 28px;
  font-feature-settings: 'kern', 'liga', 'onum'; hyphens: auto; cursor: auto; }
#runView.page .ln { padding-left: 0; min-height: 0; white-space: normal; }
#runView.page .ln::before { display: none; }
#runView.page .ln:empty { height: .5em; }
#runView.page .vim-tilde { display: none; }
#runView.page .gt { display: none; }
#runView.page #runKicker { font-size: 13px; letter-spacing: .16em; text-transform: uppercase; color: var(--page-dim); text-align: center; font-style: normal; }
#runView.page #runTitle { font-size: 30px; font-style: italic; text-align: center; color: var(--page); margin: 8px 0 4px; line-height: 1.25; }
#runView.page #runMeta { font-size: 14px; text-align: center; color: var(--page-dim); font-style: normal; padding-bottom: 22px; margin-bottom: 26px; border-bottom: 1px solid var(--line); }
#runView.page .ctx { color: var(--page-dim); margin-bottom: .45em; }
#runView.page .ctx-mark { text-align: center; font-variant: small-caps; letter-spacing: .08em; font-size: 17px; font-style: normal; margin: .8em 0; }
#runView.page .prompt { font-weight: 400; color: #f4ead2; margin: .2em 0 .45em; padding-left: .9em; margin-left: -1.05em; border-left: 2px solid color-mix(in srgb, var(--yellow) 65%, transparent); }
#runView.page .lw:hover { color: var(--yellow); }
#runView.page #promptNotes { font-size: 17px; font-style: italic; color: var(--aqua); margin-bottom: .6em; }
#runView.page #promptNotes .ln { margin: .15em 0; }
#runView.page #feedback .dim { font-size: 19px; font-style: italic; color: #b3a88f; border-left: 1px solid var(--line2); padding-left: .9em; }
#runView.page #nextRow .link { color: var(--page-dim); font-style: italic; padding: 0 .2em; }
#runView.page #nextRow .link:hover, #runView.page #nextRow .link:focus-visible { background: none; color: var(--yellow); }
#runView.page #nextRow .link:disabled { color: var(--dim); }
#runView.page #nextRow #nextExercise { color: var(--page); font-style: normal; font-variant: small-caps; letter-spacing: .06em; font-size: 19px; }
#runView.page .rd-sep { color: var(--dim); margin: 0 .5em; }
/* the status line and the command line, set as the page's footer */
#runView.page .vim-foot { font-family: 'EB Garamond', Garamond, 'Adobe Garamond Pro', 'Garamond Premier Pro', Georgia, serif; font-size: 22px; width: 100%; box-sizing: border-box; max-width: 34em; margin: 0 auto; }
#runView.page .statusline { background: none; border-top: 1px solid var(--line); font-size: 15px; padding-top: 6px; justify-content: center; }
#runView.page .statusline > span { background: none; border: 0; color: var(--page-dim); padding: 0 .7em; }
#runView.page .statusline > span:not([hidden]):not(.sl-mode):not(.sl-fill) ~ span:not([hidden]):not(.sl-fill)::before { content: '·'; color: var(--dim); margin-right: 1.1em; margin-left: -.4em; }
#runView.page .statusline > span.sl-voice.on { color: var(--yellow); }
#runView.page .statusline > span.sl-voice.rec { color: var(--red, #fb4934); }
#runView.page .sl-mode, #runView.page .sl-fill { display: none; }
#runView.page .sl-file { font-style: italic; flex: 0 1 auto; }
#runView.page .sl-time { font-feature-settings: 'tnum', 'lnum'; }
#runView.page .cmdline { font-size: 15px; color: var(--page-dim); font-style: italic; justify-content: center; }
#runView.page .cmdline .link { font-style: normal; color: var(--page-dim); }
#runView.page .cmdline .link:hover { background: none; color: var(--yellow); }
#runView.page #cmdInput { font: inherit; font-style: normal; }
#runView.page #nextRow { text-align: center; margin-top: 1.4em; }
#runView.page .voice-line { text-align: center; color: var(--muted); }
@media (max-width: 700px) {
  #runView.page .vim-buf { font-size: 19px; padding: 28px 16px 18px; }
  #runView.page .prompt { margin-left: -.6em; padding-left: .5em; }
}
#runView.page #slAcc, #runView.page #slStreak, #runView.page #slEffort { display: none; } /* nothing graded while reading */

/* ---------- the reading view's sidenotes (Tufte): the text column sits left of centre, the margin holds the notes ---------- */
#runView.reading-mode .vim-foot { max-width: 30em; margin-left: max(0px, calc((100% - 30em - 13.5em) / 2)); margin-right: auto; }
#runView.reading-mode .vim-buf { position: relative; max-width: 30em; margin-left: max(0px, calc((100% - 30em - 13.5em) / 2)); margin-right: auto; }
#runView.reading-mode #promptNotes { position: absolute; left: calc(100% + 1.6em); width: 13.5em; margin: 0; font-style: normal; color: var(--page-dim); }
#runView.reading-mode .sidenote { font-size: 16px; line-height: 1.4; margin: 0 0 .7em; color: #b9ae94; }
#runView.reading-mode .sidenote sup, #runView.reading-mode .sn-ref { font-size: .62em; vertical-align: super; line-height: 0; color: var(--yellow); font-feature-settings: 'lnum'; }
#runView.reading-mode .sn-ref { margin-left: 1px; }
#runView.reading-mode .sidenote b { font-weight: 600; color: var(--page); }
#runView.reading-mode .sidenote.hint { font-style: italic; }
#runView.reading-mode .sn-dim { color: var(--dim); }
#runView.reading-mode .sn-err { color: var(--red); }
/* narrow screens: no margin to spare, so the notes go under the passage */
@media (max-width: 1250px) {
  #runView.reading-mode .vim-buf, #runView.reading-mode .vim-foot { max-width: 34em; margin-left: auto; }
  #runView.reading-mode #promptNotes { position: static; width: auto; padding-left: 1em; border-left: 1px solid var(--line2); margin: .2em 0 .8em; }
}

/* recordings on the stats page */
.rec-stats { margin-top: 28px; }
.rec-filters { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.rec-filters select, .rec-filters input { background: var(--bg1); color: var(--fg); border: 1px solid var(--line2); font: inherit; font-size: 13px; padding: 4px 8px; }
.rec-filters input { min-width: 220px; }
.rec-table .rec-text { line-height: 1.45; }
.rec-table tr.rec-playing td { background: color-mix(in srgb, var(--yellow) 8%, transparent); }
.rec-table tr.rec-playing .rec-play { color: var(--yellow); }
.rec-del.armed { color: var(--red); }

/* ---------- the stats page: language filter, folding books and chapters, scrolling tables, voice controls ---------- */
.stats-filter { margin: 4px 0 14px; position: relative; z-index: 5; }
.lang-filter { display: inline-block; position: relative; }
.lang-filter summary { cursor: pointer; list-style: none; border: 1px solid var(--line2); padding: 5px 10px; font-size: 13px; color: var(--muted); }
.lang-filter summary::-webkit-details-marker { display: none; }
.lang-filter summary b { color: var(--fg); font-weight: 500; }
.lang-filter[open] summary { border-color: var(--yellow); }
.lang-menu { position: absolute; top: calc(100% + 4px); left: 0; min-width: 200px; background: var(--bg1); border: 1px solid var(--line2); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.lang-menu label { font-size: 13px; display: flex; gap: 8px; align-items: center; cursor: pointer; }
.lang-menu-foot { border-top: 1px solid var(--line); padding-top: 6px; }
.book-block { margin-top: 12px; border: 1px solid var(--line); padding: 14px 18px; }
.book-sum { cursor: pointer; font-size: 14px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; line-height: 1.6; }
.book-sum + * { margin-top: 16px; }
.book-block > .breakdown { margin-top: 16px; }
.book-sum b { font-size: 16px; }
.book-sum:hover b { color: var(--yellow); }
.caret { color: var(--yellow); display: inline-block; width: 1em; }
.stats-scroll { max-height: 460px; overflow: auto; }
.stats-scroll thead th { position: sticky; top: 0; background: var(--bg1); z-index: 1; }
.breakdown tr.ch-row { cursor: pointer; }
.breakdown tr.ch-row td { font-weight: 500; padding-top: 9px; padding-bottom: 9px; }
.breakdown tr.ch-row:hover td { color: var(--yellow); }
.breakdown tr.ch-row.idle td { color: var(--dim); font-weight: 400; }
.breakdown tr.ex-row td { padding-left: 12px; }
.breakdown tr.ex-row td.ex-text { padding-left: 34px; }
.breakdown tr.ex-row.idle td { color: var(--muted); }
.breakdown tr.rest-row td { color: var(--dim); cursor: pointer; padding-left: 34px; font-size: 12px; }
.breakdown tr.rest-row:hover td { color: var(--yellow); }
.voice-cell { width: 92px; }
.rec-ctl { display: inline-flex; gap: 3px; }
.ri { background: none; border: 1px solid var(--line2); color: var(--muted); font: inherit; font-size: 12px; line-height: 1; padding: 3px 6px; cursor: pointer; }
.ri:hover { color: var(--yellow); border-color: var(--yellow); }
.ri.playing { color: var(--yellow); border-color: var(--yellow); }
.ri.cert.on, .cert-on { color: var(--green); }
.ri.cert.on { border-color: var(--green); }
.ri.del:hover, .ri.del.armed { color: var(--red); border-color: var(--red); }
.ri-count { color: var(--yellow); font-size: 12px; }

/* ---------- coach marks (tutorials) ---------- */
.coach-shade { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 9000; pointer-events: none; opacity: 0; transition: opacity .2s; }
.coach-shade.on { opacity: 1; }
.coach-ring { position: fixed; z-index: 9001; pointer-events: none; border: 2px solid var(--yellow); border-radius: 4px; box-shadow: 0 0 0 4px color-mix(in srgb, var(--yellow) 25%, transparent), 0 0 24px color-mix(in srgb, var(--yellow) 35%, transparent); transition: all .25s ease; animation: coach-pulse 1.8s ease-in-out infinite; }
@keyframes coach-pulse { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--yellow) 12%, transparent), 0 0 30px color-mix(in srgb, var(--yellow) 25%, transparent); } }
.coach-card { position: fixed; z-index: 9002; background: var(--bg1, #282828); color: var(--fg, #ebdbb2); border: 1px solid var(--yellow); padding: 12px 14px; font-size: 13px; line-height: 1.55; box-shadow: 0 10px 30px rgba(0,0,0,.5); transition: left .25s ease, top .25s ease; font-family: var(--mono, monospace); }
.coach-card h3 { margin: 4px 0 6px; font-size: 15px; color: var(--yellow); }
.coach-card .coach-body b { color: var(--fg, #ebdbb2); }
.coach-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.coach-label { font-size: 11px; color: var(--muted, #a89984); text-transform: lowercase; }
.coach-x { background: none; border: 0; color: var(--muted, #a89984); font: inherit; font-size: 11px; cursor: pointer; padding: 0; }
.coach-x:hover { color: var(--red, #fb4934); }
.coach-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; }
.coach-wait { color: var(--aqua, #8ec07c); font-size: 12px; flex: 1; text-align: right; }
.coach-wait::before { content: '● '; animation: coach-blink 1.2s infinite; }
@keyframes coach-blink { 50% { opacity: .3; } }
.coach-skipstep { font-size: 11px; color: var(--dim, #7c6f64); }
.coach-next { padding: 4px 12px; }
.run-tutorial { display: block; margin: 10px auto 0; font-size: 12px; color: var(--muted); }
.run-tutorial:hover { color: var(--yellow); }

/* ---------- stats: one sentence's attempt history ---------- */
.breakdown tr.ex-row.has-atts { cursor: pointer; }
.breakdown tr.ex-row.has-atts:hover td.ex-text, .breakdown tr.ex-row.att-open td.ex-text { color: var(--yellow); }
.breakdown tr.ex-row .caret { color: var(--dim); margin-left: -14px; display: inline-block; width: 14px; }
.breakdown tr.att-row td { padding: 6px 12px 12px 34px; background: color-mix(in srgb, var(--bg1, #282828) 60%, transparent); white-space: normal; }
.att-key { margin-bottom: 6px; }
.att-mode { margin-top: 8px; }
.att-head { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--aqua, #8ec07c); margin-bottom: 4px; }
.att-head .muted { text-transform: none; letter-spacing: 0; }
.att { border-left: 2px solid var(--dim); padding: 4px 0 4px 10px; margin: 4px 0; }
.att.ok { border-left-color: var(--green, #b8bb26); }
.att.bad { border-left-color: var(--red, #fb4934); }
.att-mark { font-weight: bold; }
.att.ok .att-mark { color: var(--green, #b8bb26); }
.att.bad .att-mark { color: var(--red, #fb4934); }
.att-answer { }
.att-meta { font-size: 11px; color: var(--dim); margin-top: 2px; }
.att-expl { font-size: 12px; color: var(--muted); margin-top: 3px; }
.att-errs { margin: 3px 0 0 18px; padding: 0; font-size: 12px; color: var(--muted); }
.dg-talent-note { color: var(--yellow); font-size: 13px; margin: 8px 0; }
.dg-talent-note .link { color: var(--aqua, #8ec07c); }

/* ---------- the character's profile ---------- */
.char-id { display: flex; align-items: center; gap: 14px; }
.char-avatar { width: 64px; height: 64px; image-rendering: pixelated; background: var(--bg1); border: 1px solid var(--line2); padding: 4px; }
.char-motto { font-size: 12px; color: var(--muted); font-style: italic; }
.char-head-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.char-profile { border: 1px solid var(--line2); background: var(--bg1); padding: 16px 18px; margin-bottom: 18px; }
.cp-fields { display: grid; grid-template-columns: minmax(160px, 260px) 1fr; gap: 14px; margin-bottom: 14px; }
.cp-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); }
.cp-fields input { background: var(--bg); border: 1px solid var(--line2); color: var(--fg); font: inherit; font-size: 13px; padding: 6px 8px; }
.cp-fields input:focus { outline: none; border-color: var(--yellow); }
.cp-group { margin-top: 10px; }
.cp-group-label { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.cp-group-label::before { content: '## '; color: var(--yellow); }
.cp-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.cp-av { background: var(--bg); border: 1px solid var(--line); padding: 3px; cursor: pointer; line-height: 0; }
.cp-av img { width: 40px; height: 40px; image-rendering: pixelated; }
.cp-av:hover { border-color: var(--line2); }
.cp-av.on { border-color: var(--yellow); box-shadow: 0 0 0 1px var(--yellow); }
.cp-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; }
@media (max-width: 700px) { .cp-fields { grid-template-columns: 1fr; } }

/* ---------- the profile menu (sidebar) ---------- */
.profile-nav { margin: -20px 0 18px; }
.profile-btn { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 1px solid var(--line); padding: 6px 10px 6px 6px; color: var(--fg); font: inherit; font-size: 13px; cursor: pointer; text-align: left; }
.profile-btn:hover, .profile-btn.active { border-color: var(--yellow); }
.profile-btn img { width: 32px; height: 32px; image-rendering: pixelated; background: var(--bg); flex: none; }
.profile-btn #profileName { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-btn .caret { width: auto; }
.profile-menu { margin: 4px 0 0; border-left: 1px solid var(--line); margin-left: 21px; }
.nav-item.sub { padding-left: 12px; }
.book-block > .vocab-table { margin-top: 12px; }
.book-block > .vocab-pager { margin-top: 10px; }
@media (max-width: 850px) {
  .profile-nav { margin: 0; position: relative; }
  .profile-btn { width: auto; }
  .profile-menu { position: absolute; top: 100%; left: 0; z-index: 7; background: var(--bg1); border: 1px solid var(--line2); margin: 4px 0 0; min-width: 160px; }
}
.brand-mark.book { background: none; padding: 0; width: 32px; height: 32px; image-rendering: pixelated; flex: none; }
#runView.reading-mode .lw-known { border-bottom: 0; text-decoration: underline solid #f4ead2; text-decoration-thickness: 1px; text-underline-offset: 4px; text-decoration-skip-ink: auto; }

/* ---------- my data ---------- */
.md-h2 { font-size: 17px; margin: 36px 0 8px; color: var(--fg); }
.md-h2::before { content: '## '; color: var(--yellow); }
.mydata-page .vocab-actions { align-items: center; }
.mydata-page .delete-list { margin-top: 12px; max-width: 760px; }
.book-format { max-width: 860px; }
.book-format h4 { margin: 18px 0 4px; font-size: 14px; }
.book-format h4::before { content: '### '; color: var(--yellow); }
.book-format ul { margin: 4px 0; padding-left: 20px; line-height: 1.65; }
.book-format code { color: var(--aqua); }
.format-example { background: var(--bg1); border: 1px solid var(--line); padding: 12px 14px; font-size: 12px; line-height: 1.5; overflow-x: auto; color: var(--fg); }
.yours-tag { color: var(--yellow); }

/* the sidebar stays in view on a long page */
@media (min-width: 851px) {
  .sidebar { position: sticky; top: 0; height: 100vh; min-height: 0; overflow-y: auto; }
}

/* ---------- signing in ---------- */
.auth-back { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.auth-box { width: 100%; max-width: 380px; background: var(--bg1); border: 1px solid var(--line2); padding: 22px 24px; }
.auth-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
.auth-brand img { width: 40px; height: 40px; image-rendering: pixelated; }
.auth-brand b { display: block; color: var(--fg); }
.auth-brand small { color: var(--muted); font-size: 11px; }
.auth-tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.auth-tabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font: inherit; font-size: 13px; padding: 6px 10px; cursor: pointer; margin-bottom: -1px; }
.auth-tabs button.on { color: var(--yellow); border-bottom-color: var(--yellow); }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); }
.auth-form input:not([type=checkbox]) { background: var(--bg); border: 1px solid var(--line2); color: var(--fg); font: inherit; font-size: 14px; padding: 7px 9px; }
.auth-form input:focus { outline: none; border-color: var(--yellow); }
.auth-error { color: var(--red); font-size: 12px; }
.auth-go { margin-top: 4px; padding: 8px; }
.auth-note { font-size: 11px; color: var(--dim); line-height: 1.5; margin: 6px 0 0; }
.auth-sso { display: block; text-align: center; margin: 4px 0 2px; padding: 8px; text-decoration: none; }
.auth-alt { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.auth-alt summary { cursor: pointer; color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.acct-pw { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin: 6px 0 4px; }
.acct-pw label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); }
.acct-pw input { background: var(--bg); border: 1px solid var(--line2); color: var(--fg); font: inherit; font-size: 13px; padding: 6px 8px; }

/* ---------- my data: invites and limits (the admin) ---------- */
.admin-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin: 10px 0; }
.admin-row label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); }
.admin-row input, .admin-row select { background: var(--bg); border: 1px solid var(--line2); color: var(--fg); font: inherit; font-size: 13px; padding: 6px 8px; }
.admin-row input[type=number] { width: 110px; }
.del-row.spent { opacity: .55; }
.invite-link { color: var(--dim); word-break: break-all; }
.admin-h { margin: 18px 0 6px; font-size: 14px; }
.admin-h::before { content: '### '; color: var(--yellow); }
.admin-users { font-size: 13px; line-height: 1.8; }

.usage { font-size: 13px; display: grid; gap: 6px; margin: 8px 0 4px; max-width: 760px; }
.usage > div { display: grid; grid-template-columns: 140px 160px 1fr; gap: 12px; align-items: center; }
.usage-k { color: var(--muted); font-size: 12px; }
.usage-bar { height: 6px; background: var(--bg2); border: 1px solid var(--line); display: block; }
.usage-bar.blank { background: none; border: 0; }
.usage-bar i { display: block; height: 100%; background: var(--green); }
.usage-bar i.full { background: var(--red); }
.usage p { grid-column: 1 / -1; margin: 4px 0 0; }
@media (max-width: 700px) { .usage > div { grid-template-columns: 1fr; gap: 3px; } }

/* word lookups in reading: the sense here, and the full dictionary entry */
.sidenote .sn-here { margin-top: 2px; font-size: .92em; }
.sidenote .sn-label { color: var(--yellow); font-size: .85em; margin-right: 2px; }
button.link.sn-entry { font-size: .85em; padding: 0 2px; }
.dict-modal { width: min(820px, 100%); max-height: 86vh; display: flex; flex-direction: column; }
.dict-modal h2 { font-family: 'EB Garamond', Garamond, Georgia, serif; font-size: 22px; }
.dict-body { overflow-y: auto; font-size: 13px; line-height: 1.55; padding-right: 6px; }
.dict-body .ls-hd { margin-bottom: 8px; }
.dict-body .ls-s { margin: 4px 0; padding: 2px 6px; border-left: 2px solid transparent; }
.dict-body .ls-l2 { margin-left: 16px; } .dict-body .ls-l3 { margin-left: 32px; } .dict-body .ls-l4 { margin-left: 48px; }
.dict-body .ls-l5 { margin-left: 64px; } .dict-body .ls-l6 { margin-left: 80px; }
.dict-body .ls-n { color: var(--yellow); margin-right: 4px; }
.dict-body .ls-h { color: var(--yellow); }
.dict-body i { color: var(--fg); }
.dict-body q { font-family: 'EB Garamond', Garamond, Georgia, serif; font-style: italic; color: var(--muted); quotes: none; }
.dict-body .ls-b, .dict-body .ls-e { color: var(--muted); font-size: .9em; }
.dict-body .ls-here { border-left-color: var(--green); background: var(--bg2); }
@media (max-width: 700px) { .dict-body .ls-l3, .dict-body .ls-l4, .dict-body .ls-l5, .dict-body .ls-l6 { margin-left: 24px; } }
/* the dictionary entry's find box */
.dict-find { display: flex; gap: 10px; align-items: center; margin: 2px 0 10px; }
.dict-find input { flex: 1; font: inherit; font-size: 13px; background: var(--bg2); color: var(--fg); border: 1px solid var(--line); padding: 4px 8px; }
.dict-find input:focus { border-color: var(--yellow); outline: none; }
.dict-body mark.dict-hit { background: rgba(250, 189, 47, .28); color: inherit; padding: 0 1px; }
.dict-body mark.dict-hit.now { background: var(--yellow); color: var(--bg); }
.dict-body .ls-x { margin: 2px 0 0 18px; color: var(--muted); font-size: .92em; }
