/* Tonguewright - a linguistics reference on white paper. Hairline tables, one plum accent for selection and the primary
 * action, a soft sage for chosen IPA cells. IPA in a serif with full IPA coverage when installed (Charis SIL, Doulos SIL,
 * Gentium), falling back to Noto Serif, then Times New Roman / DejaVu Serif; spellings in the system monospace. */
:root {
  --paper: #fdfdfb; --paper2: #f6f4f1; --ink: #1d1b1f; --ink2: #4a4450; --muted: #6f6874; --rule: #d9d4dc; --rule2: #ebe7ed;
  --plum: #5b2a5e; --plum2: #7a3d7e; --plum-ink: #ffffff; --plum-wash: #f3eaf3;
  --sage: #dfe9dc; --sage-line: #8fae8a; --sage-ink: #1f3d1c; --imp: #ece8ee; --off: #b3abb8;
  --bad: #a3262a; --bad-wash: #fbecec; --warn: #8a5a00; --warn-wash: #fdf4e3; --ok: #2f6b2a;
  --serif: "Charis SIL", "Doulos SIL", "Gentium Plus", "Gentium Book Plus", "Noto Serif", "Times New Roman", "DejaVu Serif", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #17151a; --paper2: #1f1c23; --ink: #ece8ef; --ink2: #c9c2ce; --muted: #9a92a0; --rule: #3a3540; --rule2: #2a262f;
  --plum: #c792c9; --plum2: #d9aedb; --plum-ink: #1a1020; --plum-wash: #2c2030;
  --sage: #2c4128; --sage-line: #6f9a69; --sage-ink: #d8efd2; --imp: #26222b; --off: #6c6472;
  --bad: #ff8a85; --bad-wash: #3a1d20; --warn: #f0c060; --warn-wash: #33290f; --ok: #9fd895;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 17px/1.55 var(--serif); }
a { color: var(--plum); }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono, .rom { font-family: var(--mono); }
.ipa { font-family: var(--serif); }
.muted { color: var(--muted); } .small { font-size: 0.86rem; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--plum); outline-offset: 2px; }

/* Header and lane strip */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--rule); background: var(--paper); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mark { width: 34px; height: 34px; flex: none; }
.mark .m0 { fill: none; stroke: var(--ink); stroke-width: 1.4; } .mark .m1 { stroke: var(--rule); stroke-width: 1; fill: none; } .mark .m2 { fill: var(--sage); stroke: var(--sage-line); }
.brandtext { display: flex; flex-direction: column; line-height: 1.1; }
.brandtext .name { font-size: 1.35rem; letter-spacing: 0.01em; font-variant: small-caps; font-weight: 600; }
.brandtext .tag { font: 0.78rem var(--sans); color: var(--muted); }
.session { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; font-family: var(--sans); font-size: 0.9rem; }
.back { color: var(--muted); text-decoration: none; }
.credits { font-family: var(--mono); font-size: 0.85rem; color: var(--ink2); }
.btn { font-family: var(--sans); font-size: 0.9rem; border: 1px solid var(--rule); background: var(--paper); color: var(--ink); border-radius: 4px; padding: 7px 13px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover:not(:disabled) { border-color: var(--plum); }
.btn.primary { background: var(--plum); border-color: var(--plum); color: var(--plum-ink); }
.btn.primary:hover:not(:disabled) { background: var(--plum2); border-color: var(--plum2); color: var(--plum-ink); }
.btn.ghost { background: transparent; }
.btn.icon { padding: 6px 10px; font-size: 1rem; }
.btn.big { font-size: 1rem; padding: 11px 20px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.lanebar { display: flex; align-items: center; gap: 14px; padding: 10px 24px; border-bottom: 1px solid var(--rule); background: var(--paper2); flex-wrap: wrap; font-family: var(--sans); }
.lanelabel { font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.lanes { display: flex; gap: 0; flex-wrap: wrap; border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; background: var(--paper); }
.lane { border: 0; border-right: 1px solid var(--rule); background: transparent; padding: 6px 14px; cursor: pointer; text-align: left; display: flex; flex-direction: column; }
.lane:last-child { border-right: 0; }
.lane b { font-size: 0.88rem; font-weight: 600; } .lane small { font-size: 0.72rem; color: var(--muted); }
.lane.on, .lane[aria-selected="true"] { background: var(--plum); color: var(--plum-ink); } .lane.on small { color: var(--plum-ink); opacity: 0.85; }
.tools { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.sel { font-family: var(--sans); font-size: 0.86rem; padding: 6px 8px; border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); }

/* Book layout: a sticky contents column and the sheet */
.layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 0; max-width: 1320px; margin: 0 auto; }
.toc { position: sticky; top: 64px; align-self: start; padding: 28px 12px 28px 24px; font-family: var(--sans); font-size: 0.86rem; max-height: calc(100vh - 64px); overflow: auto; }
.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.toc li { counter-increment: s; margin: 2px 0; }
.toc a { display: block; padding: 4px 8px; color: var(--ink2); text-decoration: none; border-left: 2px solid transparent; }
.toc a::before { content: counter(s) "  "; color: var(--muted); font-family: var(--mono); font-size: 0.78rem; }
.toc a:hover { border-left-color: var(--plum); color: var(--plum); }
.sheet { padding: 8px 32px 64px; min-width: 0; border-left: 1px solid var(--rule2); }
.sec { padding: 26px 0 30px; border-bottom: 1px solid var(--rule2); scroll-margin-top: 70px; }
.sec h2 { font-size: 1.45rem; font-weight: 600; margin: 0 0 10px; font-variant: small-caps; letter-spacing: 0.02em; display: flex; align-items: baseline; gap: 12px; }
.num { font: 600 0.85rem var(--mono); color: var(--plum); border: 1px solid var(--plum); border-radius: 50%; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.sub { font-size: 1rem; font-weight: 600; margin: 18px 0 8px; color: var(--ink2); font-variant: small-caps; letter-spacing: 0.03em; }
.lede { color: var(--ink2); margin: 0 0 12px; max-width: 72ch; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 28px; }
.field { display: flex; flex-direction: column; gap: 4px; font-family: var(--sans); font-size: 0.8rem; color: var(--ink2); }
.field small { color: var(--muted); font-weight: 400; }
.field input, .field select, .field textarea { font-family: var(--serif); font-size: 1rem; padding: 7px 9px; border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); color: var(--ink); width: 100%; }
.field input.mono, .field textarea.mono { font-family: var(--mono); font-size: 0.92rem; }
.field input.big, output.big { font-size: 1.25rem; }
.field.inline { min-width: 120px; } .field.narrow { min-width: 0; width: 92px; flex: none; } .field.grow { flex: 1 1 200px; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin: 10px 0; }
.note { font-family: var(--sans); font-size: 0.86rem; color: var(--ink2); margin: 6px 0; }
.note.bad, p.bad { color: var(--bad); } .note.warn { color: var(--warn); background: var(--warn-wash); padding: 6px 10px; border-radius: 4px; }
.empty { color: var(--muted); font-style: italic; }
.linkish { background: none; border: 0; padding: 0; color: var(--plum); cursor: pointer; text-decoration: underline; font-family: var(--sans); font-size: 0.86rem; }
.mini { font-family: var(--sans); font-size: 0.78rem; border: 1px solid var(--rule); background: var(--paper); color: var(--ink); border-radius: 3px; padding: 3px 8px; cursor: pointer; }
.mini.accent { background: var(--plum); color: var(--plum-ink); border-color: var(--plum); }
.mini:disabled { opacity: 0.45; cursor: not-allowed; }
.mini.del { color: var(--muted); }

/* IPA charts: crisp hairline tables, symbols that fill sage when chosen */
.chartframe { overflow-x: auto; border: 1px solid var(--rule); background: var(--paper); padding: 6px; -webkit-overflow-scrolling: touch; max-width: 100%; }
.chartframe svg { display: block; max-width: none; }
.vowframe svg { width: 540px; height: auto; }
.ipa-chart .hd { font: 600 11px var(--sans); fill: var(--ink2); }
.ipa-chart .ln { stroke: var(--rule); stroke-width: 1; fill: none; shape-rendering: crispEdges; }
.ipa-chart .imp { fill: var(--imp); }
.ipa-chart .vl { stroke: var(--muted); stroke-width: 1.2; fill: none; }
.ipa-chart .dot { fill: var(--ink2); }
.ipa-chart .sym { font-family: var(--serif); font-size: 22px; fill: var(--off); pointer-events: none; }
.ipa-chart .cell { fill: transparent; stroke: transparent; }
.ipa-chart .sy { cursor: pointer; }
.ipa-chart .sy:hover .cell { fill: var(--plum-wash); }
.ipa-chart .sy:focus { outline: none; } .ipa-chart .sy:focus .cell { stroke: var(--plum); stroke-width: 2; }
.ipa-chart .sy.on .cell { fill: var(--sage); stroke: var(--sage-line); }
.ipa-chart .sy.on .sym { fill: var(--sage-ink); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.chip { font-family: var(--serif); font-size: 1.1rem; min-width: 46px; padding: 4px 10px; border: 1px solid var(--rule); background: var(--paper); color: var(--off); border-radius: 3px; cursor: pointer; }
.chip.on { background: var(--sage); border-color: var(--sage-line); color: var(--sage-ink); font-weight: 600; }
.summary { font-size: 1.05rem; color: var(--ink2); word-break: break-word; }

/* Rules */
.classes, .constraints { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule2); }
.classes li, .constraints li { display: flex; gap: 10px; align-items: baseline; padding: 5px 2px; border-bottom: 1px solid var(--rule2); flex-wrap: wrap; }
.cl { font: 600 0.95rem var(--mono); color: var(--plum); width: 1.4em; } .cl-l { font: 0.78rem var(--sans); color: var(--muted); width: 7.5em; } .cl-m { flex: 1; }
.classes li.custom .cl-l { color: var(--plum); }
.constraints .rule { flex: 1; } .constraints li.bad { color: var(--bad); } .constraints .err { font: 0.8rem var(--sans); }
.probe { margin-top: 18px; padding: 14px 16px; border: 1px solid var(--rule); border-left: 3px solid var(--plum); background: var(--paper2); }
.probe-out p { margin: 6px 0; } .probe-out .ok { color: var(--ok); } .probe-out .bad { color: var(--bad); }
.toks { display: flex; gap: 4px; flex-wrap: wrap; }
.tok { border: 1px solid var(--rule); padding: 1px 8px; background: var(--paper); font-size: 1.1rem; } .tok.bad { border-color: var(--bad); background: var(--bad-wash); color: var(--bad); }
.syl { font-family: var(--mono); font-size: 0.86rem; color: var(--muted); }
.flags { margin: 4px 0; padding-left: 18px; color: var(--bad); font: 0.82rem var(--sans); }

/* Spelling */
.roman { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
.rc { display: flex; align-items: center; gap: 6px; border: 1px solid var(--rule2); padding: 4px 6px; background: var(--paper); }
.rc .ipa { width: 3.4em; font-size: 1.05rem; }
.rc input { width: 100%; min-width: 0; font-family: var(--mono); font-size: 0.92rem; border: 0; border-bottom: 1px solid var(--rule); background: transparent; padding: 2px; }

/* Generator */
.gen { list-style: none; padding: 0; margin: 8px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.genw { width: 100%; text-align: left; border: 1px solid var(--rule); background: var(--paper); padding: 6px 9px; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 0 6px; border-radius: 3px; }
.genw:hover { border-color: var(--plum); }
.genw .rom { font-weight: 600; } .genw .ipa { color: var(--ink2); grid-column: 1; } .genw .syl { grid-row: 1 / span 2; grid-column: 2; align-self: center; }
.gen li.have .genw { opacity: 0.5; }

/* Lexicon */
.addword { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; padding: 12px; background: var(--paper2); border: 1px solid var(--rule2); }
.wcheck .ok { color: var(--ok); font: 0.86rem var(--sans); } .wcheck .bad { color: var(--bad); font: 0.86rem var(--sans); }
.ghostbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 12px; border: 1px dashed var(--plum); background: var(--plum-wash); font-family: var(--sans); font-size: 0.88rem; margin: 8px 0; }
.ghostbar span { flex: 1; }
.lexframe { overflow-x: auto; max-height: 640px; overflow-y: auto; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
table { border-collapse: collapse; }
table.lex, table.diff { width: 100%; font-size: 0.96rem; }
table.lex th, table.diff th { font: 600 0.74rem var(--sans); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--rule); background: var(--paper); position: sticky; top: 0; z-index: 1; }
table.lex td, table.diff td { padding: 6px 8px; border-bottom: 1px solid var(--rule2); vertical-align: top; }
.sortbtn { background: none; border: 0; font: inherit; text-transform: inherit; letter-spacing: inherit; color: inherit; cursor: pointer; padding: 0; }
table.lex .c-word .rom { font-weight: 600; } table.lex .c-syl { font-family: var(--mono); font-size: 0.82rem; color: var(--muted); }
table.lex .c-pos { font-style: italic; color: var(--ink2); } table.lex .c-notes { color: var(--ink2); font-size: 0.9rem; max-width: 34ch; }
table.lex .c-act { white-space: nowrap; text-align: right; }
table.lex tr.bad td { background: var(--bad-wash); }
table.lex tr.ghost td { background: repeating-linear-gradient(135deg, var(--plum-wash) 0 8px, transparent 8px 16px); color: var(--ink2); font-style: italic; border-bottom: 1px dashed var(--plum); }
table.lex tr.ghost.bad td { background: repeating-linear-gradient(135deg, var(--bad-wash) 0 8px, transparent 8px 16px); }
table.lex tr.ghost .rom { font-style: normal; }
table.lex .tick { width: 30px; text-align: center; color: var(--plum); }
.who { font: 600 0.72rem var(--sans); text-transform: uppercase; letter-spacing: 0.05em; color: var(--plum); font-style: normal; }
.was { display: block; font-size: 0.82rem; color: var(--muted); text-decoration: line-through; }
.warn { color: var(--warn); font: 0.82rem var(--sans); margin: 2px 0; }
.etym-line { margin: 3px 0 0; font-size: 0.86rem; }

/* Sound changes and frequencies */
.changesum ol.fired { margin: 0; padding-left: 22px; font-size: 0.92rem; } .changesum li.flagged { color: var(--bad); }
.changesum code, .rulenotes code { font-family: var(--serif); background: var(--paper2); padding: 0 4px; border: 1px solid var(--rule2); }
.invdiff { font: 0.86rem var(--sans); color: var(--ink2); }
table.diff tr.changed td { background: var(--paper2); } table.diff .moved { color: var(--plum); font-weight: 600; } table.diff .trace { font: 0.8rem var(--sans); color: var(--muted); }
.stats { display: grid; grid-template-columns: max-content 1fr; gap: 4px 18px; margin: 0 0 14px; font-size: 0.95rem; }
.stats dt { font: 600 0.78rem var(--sans); color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; } .stats dd { margin: 0; }
.bars { display: flex; flex-direction: column; gap: 2px; max-width: 640px; }
.bar { display: grid; grid-template-columns: 3em 1fr 8.5em; align-items: center; gap: 8px; font-size: 0.86rem; }
.bl { font-size: 1.1rem; text-align: center; } .bt { height: 12px; background: var(--rule2); } .bf { display: block; height: 100%; } .bf.c { background: var(--ink2); } .bf.v { background: var(--plum); }
.bn { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
.hist { display: flex; align-items: flex-end; gap: 10px; height: 150px; border-bottom: 1px solid var(--ink); max-width: 480px; padding-top: 18px; }
.hc { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; position: relative; }
.hb { width: 100%; background: var(--sage-line); display: block; } .hn { font: 0.76rem var(--mono); color: var(--muted); } .hl { position: absolute; bottom: -20px; font: 0.74rem var(--sans); color: var(--muted); white-space: nowrap; }
.freq h4 { font: 600 0.8rem var(--sans); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 22px 0 8px; }

/* Ask the model */
.ask { }
.runform { border: 1px solid var(--rule); padding: 16px; background: var(--paper2); }
.pane { margin-bottom: 8px; }
.meter { font: 0.86rem var(--mono); color: var(--ink2); margin: 10px 0 4px; }
.gate { font: 0.88rem var(--sans); color: var(--warn); margin: 6px 0 10px; }
.recoin { list-style: none; padding: 0; margin: 4px 0 10px; font-size: 0.92rem; } .recoin li { padding: 3px 0; border-bottom: 1px solid var(--rule2); }
.progress { margin-top: 14px; padding: 14px 16px; border: 1px solid var(--rule); border-left: 3px solid var(--plum); }
.progress h3 { margin: 0 0 4px; font-size: 1rem; }
.steps { list-style: none; padding: 0; margin: 6px 0 0; font: 0.88rem var(--sans); }
.step { padding: 2px 0; color: var(--muted); } .step.done { color: var(--ok); } .step.active { color: var(--ink); font-weight: 600; }
.step-ic { display: inline-block; width: 1.2em; font-family: var(--mono); }
.result { margin-top: 18px; padding-top: 6px; }
.result h3 { font-size: 1.2rem; margin: 0 0 4px; }
.issues { list-style: none; padding: 0; margin: 8px 0; font: 0.88rem var(--sans); }
.issues li { padding: 5px 10px; border-left: 3px solid var(--rule); margin-bottom: 3px; background: var(--paper2); }
.issues li.ok { border-color: var(--ok); } .issues li.warn { border-color: var(--bad); color: var(--bad); } .issues li.note { border-color: var(--plum); color: var(--ink2); }
.raw { white-space: pre-wrap; word-break: break-word; font: 0.8rem var(--mono); background: var(--paper2); padding: 10px; border: 1px solid var(--rule); max-height: 400px; overflow: auto; }
.recoin-line { margin: 4px 0; } .recoin-line.flagged { color: var(--bad); }
.etyms { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-top: 10px; }
.etym { border: 1px solid var(--rule); padding: 12px 14px; background: var(--paper); }
.etym.flagged { border-color: var(--bad); background: var(--bad-wash); }
.etym-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.kind { font: 600 0.7rem var(--sans); text-transform: uppercase; letter-spacing: 0.08em; color: var(--plum); border: 1px solid var(--plum); padding: 0 6px; border-radius: 2px; }
.gl-word { font-style: italic; color: var(--ink2); }
.parts, .story, .reflex { margin: 6px 0; font-size: 0.94rem; } .pg { font-style: italic; color: var(--ink2); } .trace { font: 0.78rem var(--sans); color: var(--muted); }
.rulenotes { grid-column: 1 / -1; border-top: 1px solid var(--rule); padding-top: 8px; } .rulenotes h4 { margin: 0 0 6px; font-size: 1rem; } .rulenotes ul { margin: 0; padding-left: 18px; } .rulenotes li { margin: 4px 0; } .rulenotes li.flagged { color: var(--bad); }

/* Forms: spelling over IPA, flags attached to the exact form */
.form { display: inline-flex; flex-direction: column; line-height: 1.15; vertical-align: baseline; padding: 0 2px; }
.form.inline { display: inline; }
.form.inline .rom { font-weight: 600; } .form.inline .ipa { color: var(--muted); font-size: 0.86em; margin-left: 3px; }
.form .rom { font-family: var(--mono); font-size: 0.92em; }
.form.flagged { background: var(--bad-wash); border-bottom: 2px wavy var(--bad); text-decoration: none; cursor: help; }
.form.flagged .rom { color: var(--bad); }

/* The reference-grammar page */
.gpage { max-width: 78ch; }
.gsec { margin: 8px 0 30px; }
.gsec h3 { font-size: 1.25rem; font-weight: 600; border-bottom: 1px solid var(--ink); padding-bottom: 4px; margin: 16px 0 8px; font-variant: small-caps; }
.gsum { font-style: italic; color: var(--ink2); }
.gsec p { margin: 8px 0; text-align: justify; hyphens: auto; }
.tablewrap { overflow-x: auto; margin: 12px 0; }
table.paradigm { border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); font-size: 0.96rem; min-width: 60%; }
table.paradigm caption { caption-side: top; text-align: left; font: italic 0.92rem var(--serif); color: var(--ink2); padding: 4px 0; }
table.paradigm th, table.paradigm td { padding: 5px 14px 5px 6px; text-align: left; border-bottom: 1px solid var(--rule2); }
table.paradigm thead th { font-weight: 600; border-bottom: 1px solid var(--ink); font-variant: small-caps; }
table.paradigm tbody th { font-weight: 400; font-style: italic; color: var(--ink2); }
.gflags { margin: 10px 0; padding: 8px 12px; background: var(--bad-wash); border-left: 3px solid var(--bad); font-size: 0.9rem; }
.gtools { display: flex; gap: 8px; margin-top: 8px; }
.igt { margin: 14px 0; padding: 0 0 0 2.6em; position: relative; }
.igt-n { position: absolute; left: 0; top: 0; color: var(--ink2); }
.igt-words { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.igt .w { display: flex; flex-direction: column; line-height: 1.35; }
.igt .surf { font-family: var(--mono); font-weight: 600; } .igt .morph { font-family: var(--serif); } .igt .gl { font-size: 0.94rem; color: var(--ink2); }
.sc { font-variant: small-caps; letter-spacing: 0.04em; text-transform: lowercase; }
.igt .w.flagged .surf, .igt .w.flagged .morph { color: var(--bad); border-bottom: 2px wavy var(--bad); cursor: help; }
.igt .tr { margin-top: 2px; font-style: italic; }
.igt-note { font: 0.84rem var(--sans); color: var(--muted); margin: 2px 0; }
.igt .flags { margin-top: 4px; }
.history { list-style: none; padding: 0; margin: 6px 0; } .history li { padding: 5px 0; border-bottom: 1px solid var(--rule2); display: flex; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.history li.cur .restore { font-weight: 600; } .history .meta { font: 0.78rem var(--sans); color: var(--muted); }
.restore { font-family: var(--serif); font-size: 1rem; }

.foot { border-top: 1px solid var(--rule); padding: 18px 24px 28px; font: 0.82rem var(--sans); color: var(--muted); text-align: center; }
.foot p { margin: 4px 0; }
.toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); }
.toast { font: 0.88rem var(--sans); background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 4px; box-shadow: 0 6px 20px rgba(0,0,0,0.18); transition: opacity 0.5s; }
.toast.err { background: var(--bad); color: #fff; } .toast.gone { opacity: 0; } .toast a { color: inherit; font-weight: 600; }
body.dropping::after { content: "Drop a language JSON or a lexicon CSV"; position: fixed; inset: 12px; border: 3px dashed var(--plum); background: rgba(91, 42, 94, 0.08); display: flex; align-items: center; justify-content: center; font: 600 1.2rem var(--sans); color: var(--plum); z-index: 60; }
.booklet { display: none; }

/* Docs pages (api.html, tokens.html) */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 24px; border-bottom: 1px solid var(--rule); font-family: var(--sans); }
.topbar .brand { gap: 8px; } .backlink, .topup { color: var(--plum); text-decoration: none; } .sep { color: var(--muted); }
.doc { max-width: 860px; margin: 0 auto; padding: 24px 20px 60px; }
.doc h1 { font-size: 1.8rem; font-variant: small-caps; } .doc h2 { margin-top: 34px; border-bottom: 1px solid var(--rule); padding-bottom: 4px; } .doc h3 { margin-top: 24px; }
.doc pre { background: var(--paper2); border: 1px solid var(--rule); padding: 12px; overflow-x: auto; font: 0.82rem/1.45 var(--mono); }
.doc code { font-family: var(--mono); font-size: 0.88em; }
.doc table { width: 100%; font-size: 0.9rem; margin: 10px 0; display: block; overflow-x: auto; }
.doc th, .doc td { border-bottom: 1px solid var(--rule2); padding: 6px 8px; text-align: left; vertical-align: top; }
.codegroup { margin: 10px 0 18px; }
.tabs { display: flex; flex-wrap: wrap; gap: 0; border-bottom: 1px solid var(--rule); }
.tab { font: 0.8rem var(--sans); border: 1px solid transparent; border-bottom: 0; background: none; padding: 6px 10px; cursor: pointer; color: var(--muted); }
.tab.active { border-color: var(--rule); background: var(--paper2); color: var(--plum); font-weight: 600; }
.codegroup pre { margin-top: 0; border-top: 0; }
.statebox { border: 1px solid var(--rule); border-left: 3px solid var(--plum); padding: 10px 14px; background: var(--paper2); }
.tokenrow { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.tokenbox { font: 0.86rem var(--mono); padding: 8px 10px; border: 1px solid var(--rule); background: var(--paper2); word-break: break-all; flex: 1; }
.primary { background: var(--plum); color: var(--plum-ink); border: 1px solid var(--plum); border-radius: 4px; padding: 7px 13px; cursor: pointer; font-family: var(--sans); }

/* Phones: the charts scroll inside their frame, the lexicon becomes cards */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .toc { position: static; max-height: none; padding: 10px 16px; border-bottom: 1px solid var(--rule2); overflow-x: auto; }
  .toc ol { display: flex; gap: 4px; white-space: nowrap; }
  .toc a { border-left: 0; border-bottom: 2px solid transparent; padding: 4px 6px; }
  .sheet { padding: 0 16px 48px; border-left: 0; }
  .top { padding: 10px 16px; } .lanebar { padding: 10px 16px; } .tools { margin-left: 0; }
  .brandtext .tag { display: none; } .back { display: none; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .lanes { width: 100%; } .lane { flex: 1 1 45%; border-bottom: 1px solid var(--rule); }
  .lexframe { max-height: none; border: 0; }
  table.lex, table.lex tbody, table.lex tr, table.lex td { display: block; width: 100%; }
  table.lex thead { display: none; }
  table.lex tr { border: 1px solid var(--rule); margin: 0 0 8px; padding: 6px 10px; position: relative; background: var(--paper); }
  table.lex td { border: 0; padding: 2px 0; }
  table.lex td[data-label]::before { content: attr(data-label); display: inline-block; width: 6.5em; font: 600 0.7rem var(--sans); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
  table.lex .tick { position: absolute; right: 8px; top: 6px; width: auto; }
  table.lex .c-act { text-align: left; padding-top: 6px; }
  table.lex .c-notes { max-width: none; }
  .field.narrow { width: 80px; }
  .igt { padding-left: 2em; }
  .gsec p { text-align: left; }
}
@media (max-width: 520px) { body { font-size: 16px; } .session .btn { padding: 6px 9px; } .lane { flex: 1 1 100%; } .etyms { grid-template-columns: minmax(0, 1fr); } }

/* Print: the booklet only */
@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  body > *:not(.booklet) { display: none !important; }
  .booklet { display: block !important; }
  .booklet h1 { font-size: 30pt; font-variant: small-caps; margin: 30vh 0 4pt; text-align: center; }
  .bk-cover { page-break-after: always; text-align: center; } .bk-sub { font-size: 14pt; font-style: italic; } .bk-brief { color: #444; }
  .booklet section { page-break-before: always; } .booklet section.bk-cover { page-break-before: auto; }
  .booklet h2 { font-variant: small-caps; border-bottom: 1px solid #000; }
  .bk-charts svg { width: 100%; height: auto; margin: 6pt 0; page-break-inside: avoid; }
  .bk-spell td { border: 1px solid #999; padding: 2pt 6pt; text-align: center; }
  .bk-lex { width: 100%; font-size: 10pt; } .bk-lex td { border-bottom: 0.5pt solid #ccc; padding: 2pt 4pt; vertical-align: top; } .bk-lex .pos { font-style: italic; }
  .gsec, .igt, table.paradigm { page-break-inside: avoid; }
  .form.flagged { background: none; border-bottom: 1pt dotted #000; }
  .bk-foot { margin-top: 20pt; font-size: 9pt; color: #555; text-align: center; }
  a { color: #000; }
}
.gen li.empty { grid-column: 1 / -1; }
.hc { max-width: 90px; }
.lede code { font-family: var(--serif); font-size: 1em; background: var(--paper2); padding: 0 4px; border: 1px solid var(--rule2); }
@media (max-width: 900px) { table.lex td:empty { display: none; } }
