:root {
  --bg: #0E1011;
  --panel: #15181A;
  --section: #1B1F22;
  --rule: #2A2F33;
  --rule-strong: #3A4046;
  --text: #D8D6CF;
  --bright: #F2F0E8;
  --dim: #8B9096;
  --amber: #FFB454;
  --amber-wash: rgba(255, 180, 84, 0.10);
  --link: #7CB7FF;
  --link-hover: #B5D6FF;
  --red: #FF7A6B;
  --green: #9BD770;
  --g1: #7CB7FF;
  --g2: #6FD6B5;
  --g3: #C9A3FF;
  --g4: #FF9EC4;
  --g5: #E6D06A;
  --g6: #8FD3FF;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}
a { color: var(--link); }
a:hover { color: var(--link-hover); }
code, kbd, var, input, select, button, textarea { font-family: inherit; }
var { font-style: italic; color: var(--dim); }
kbd { border: 1px solid var(--rule-strong); padding: 0 5px; color: var(--text); font-size: 11px; }
h1, h2 { margin: 0; font-size: 13px; font-weight: 700; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
[hidden] { display: none !important; }
.hide { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.dim { color: var(--dim); }
.grow { flex: 1 1 auto; }
.bad, .lost { color: var(--red); font-weight: 700; }
.hit, .changed { color: var(--amber); font-weight: 700; }
.same { color: var(--text); font-weight: 700; }

/*************************
 ** Header, status line **
 *************************/

.top { display: flex; flex-wrap: wrap; align-items: center; gap: 0 28px; padding: 0 24px; border-bottom: 1px solid var(--rule); }
.wordmark { display: inline-flex; align-items: center; min-height: 52px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 14px; white-space: nowrap; }
.wordmark b { color: var(--amber); }
.top nav { display: flex; flex-wrap: wrap; flex: 1 1 auto; }
.top nav a { display: inline-flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 16px; color: var(--text); text-decoration: none; }
.top nav a span { color: var(--dim); }
.top nav a[aria-current] { background: var(--amber); color: var(--bg); font-weight: 700; }
.top nav a[aria-current] span { color: inherit; }

.status { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; margin-top: auto; padding: 0 24px 0 0; border-top: 1px solid var(--rule); background: var(--panel); font-size: 12px; color: var(--dim); }
.status .mode { background: var(--link); color: var(--bg); font-weight: 700; padding: 8px 14px; }
.status .route { color: var(--text); overflow-wrap: anywhere; }
.status a { color: var(--dim); }

/*****************
 ** Page layout **
 *****************/

main { display: flex; flex-direction: column; gap: 24px; width: 100%; max-width: 1440px; margin: 0 auto; padding: 24px; }
main.wide { max-width: none; }
.split { display: flex; flex-wrap: wrap; gap: 24px 32px; width: 100%; max-width: 1440px; margin: 0 auto; }
body > .split { padding: 24px; }
.split > main { flex: 999 1 560px; min-width: 0; padding: 0; }
.split > aside { flex: 1 1 200px; max-width: 240px; }
.split > .main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.split > .side { flex: 1 1 380px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
@media (max-width: 760px) { .split > aside { display: none; } }

.frame { border: 1px solid var(--rule); }
.frame.strong { border-color: var(--rule-strong); }
.frame.amber { border-color: var(--amber); }
.frame.red { border-color: var(--red); }
.frame > h2, .frame > summary { padding: 12px; background: var(--panel); font-weight: 700; }
.frame > summary { cursor: pointer; }
.scroll { overflow-x: auto; }
.pad { padding: 11px 12px; }
.fine { color: var(--dim); font-size: 12px; max-width: 100ch; }
.count { color: var(--dim); font-weight: 400; margin-left: 12px; }

.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; padding: 0 0 0 12px; min-height: 44px; background: var(--panel); border-bottom: 1px solid var(--rule); }
.bar.foot { border-bottom: 0; border-top: 1px solid var(--rule); background: none; font-size: 12px; }
.bar > button, .bar > a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border: 0; border-left: 1px solid var(--rule); white-space: nowrap; }
.frame.amber h1 { color: var(--amber); }
.frame.red h1 { color: var(--red); }

/**************
 ** Controls **
 **************/

.controls { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 16px 24px; border-bottom: 1px solid var(--rule); }
.stack, #tester { display: flex; flex-direction: column; gap: 16px; margin: 0; }
form { margin: 0; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.field { display: flex; flex-direction: column; gap: 8px; }
label, legend, .label { color: var(--dim); }
legend, .label, dt { padding: 0 0 8px 0; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
fieldset:disabled { display: none; }

input[type=text], input[type=search], select, textarea {
  min-height: 44px; padding: 0 12px; background: var(--panel); border: 1px solid var(--rule-strong); color: var(--text); font-size: 14px;
}
input[type=search] { flex: 1 1 240px; min-width: 0; }
input.big { min-height: 48px; min-width: 0; color: var(--bright); font-size: 15px; }
input.grow { flex: 999 1 420px; }
select { font-size: 13px; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; margin: 0; accent-color: var(--amber); }
button { min-height: 44px; padding: 0 14px; background: transparent; border: 1px solid var(--rule-strong); color: var(--link); font-size: 13px; cursor: pointer; }
button:hover { color: var(--link-hover); }
button.primary { border-color: var(--amber); color: var(--amber); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.dialects { padding: 16px 24px; border-bottom: 1px solid var(--rule); }
main .chips.dialects { padding: 0; border: 0; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border: 1px solid var(--rule); color: var(--text); text-decoration: none; white-space: nowrap; cursor: pointer; }
.chip b { color: var(--bright); }
.chip:has(input:checked), .chip[aria-current] { border-color: var(--amber); background: var(--amber-wash); color: var(--amber); }
.chip[aria-current] { font-weight: 700; }
.chip:has(input[type=radio]) input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:focus-visible) { outline: 2px solid var(--amber); outline-offset: 2px; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; color: var(--text); }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 28px; color: var(--dim); font-size: 12px; }
.legend code.diff { color: var(--amber); font-size: 13px; }

/************
 ** Tables **
 ************/

table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; font-weight: 400; }
thead th { color: var(--dim); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; background: var(--panel); }
tbody th { color: var(--text); }
tbody tr:last-child > * { border-bottom: 0; }
tr.self, tr.match { background: rgba(255, 180, 84, 0.08); }
tr.self th, tr.match th { color: var(--amber); font-weight: 700; }
tr.dim td { color: var(--dim); }
td p { margin: 4px 0 0 0; }
td p:first-child { margin-top: 0; }

.sp { display: inline-flex; align-items: baseline; gap: 6px; margin: 0 14px 2px 0; white-space: nowrap; }
.sp code { color: var(--bright); font-size: 14px; }
.sp.neg code { color: var(--text); }
.not { color: var(--dim); font-size: 11px; }
.tag { display: inline-block; border: 1px solid var(--rule-strong); padding: 0 5px; font-size: 11px; color: var(--dim); white-space: nowrap; }
.tag.strong { color: var(--text); margin-right: 8px; }
/* One colour per kind of label. */
.tag.impl { border-color: var(--g2); color: var(--g2); }
.tag.mode { border-color: var(--green); color: var(--green); }
.tag.absent { border-color: var(--red); color: var(--red); }
.tag.partial { border-color: var(--amber); color: var(--amber); }
.na { color: var(--dim); font-size: 12px; }
.flag { margin-right: 14px; color: var(--dim); white-space: nowrap; }
.flag code { color: var(--bright); font-size: 14px; }
.variant { margin-top: 4px; }
.variant .tag { margin-right: 8px; }

/* The matrix: constructs as rows, dialects as columns. No box around it
   scrolls, so the page does in both directions and the sticky dialect
   headings and construct names hold to the window's edges; an overflow box
   would capture them. Borders are per cell (separate model) so they move
   with the sticky cells. Dialect columns share one width and wrap. */
.matrix { border: 1px solid var(--rule-strong); border-right: 0; border-collapse: separate; border-spacing: 0; }
.matrix th, .matrix td { width: 160px; min-width: 160px; border-right: 1px solid var(--rule-strong); }
.matrix code { white-space: normal; overflow-wrap: anywhere; }
/* top: -1px, as the table can sit on a half pixel and Chrome then shows a
   pixel of the rows above a heading stuck at 0. */
.matrix thead th { position: sticky; top: -1px; z-index: 1; text-transform: none; letter-spacing: 0; }
.matrix thead th:first-child { left: 0; z-index: 2; }
.matrix thead th a { display: block; font-size: 13px; font-weight: 700; }
.matrix thead th span { display: block; overflow-wrap: anywhere; }
.matrix th:first-child { width: 240px; min-width: 200px; }
.matrix tbody th { background: var(--bg); position: sticky; left: 0; }
.matrix tr.v th { padding-left: 28px; color: var(--dim); }
.matrix tr.sec th { position: static; background: var(--section); font-weight: 700; }
.matrix tr.sec label { position: sticky; left: 12px; display: inline-flex; align-items: center; gap: 10px; color: var(--text); cursor: pointer; }
.matrix tr.sec .hiddennote { margin-left: 12px; color: var(--dim); font-weight: 400; font-size: 12px; }
.matrix tbody:has(.fold:not(:checked)) tr.r { display: none; }
.matrix td.diff .sp:not(.neg) code, .matrix td.diff .flag code { color: var(--amber); }
.matrix td.base, .matrix th.base { background: var(--panel); }

/* One dialect's reference. */
.title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; }
.title h1 { font-size: 28px; line-height: 1.2; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); gap: 16px 32px; margin: 0; padding: 16px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.facts div { display: flex; flex-direction: column; }
.facts dd { margin: 0; }
.toc { display: flex; flex-direction: column; position: sticky; top: 16px; }
.toc a { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; border-bottom: 1px solid var(--rule); color: var(--text); text-decoration: none; }
.ref { min-width: 680px; }
.ref .w-syntax { width: 26%; }
.ref .w-what { width: 30%; }
.ref .w-try { width: 96px; }
.ref .name { display: block; color: var(--text); }
.ref .summary { display: block; color: var(--dim); font-size: 12px; }
.ref .notes { color: var(--dim); }
.ref .notes code { color: var(--text); }
.ref td.try { padding: 0; }
.ref td.try a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; white-space: nowrap; }
.ref tr.lacks td { color: var(--dim); }
:root:has(#lacks:not(:checked)) .ref tr.lacks { display: none; }

/************
 ** Tester **
 ************/

/* The text area sits on top of a layer that shows the same text with the
   matches marked. Both layers use the same font metrics and neither wraps,
   so a character is at the same place in both. */
.editor { position: relative; height: 22em; resize: vertical; overflow: hidden; min-height: 8em; }
.editor .layer {
  position: absolute; inset: 0; margin: 0; padding: 10px 12px; border: 0;
  font: 13px/1.9 "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  white-space: pre; overflow: auto; tab-size: 8;
}
.editor #backdrop { color: transparent; overflow: hidden; }
.editor textarea { background: transparent; color: var(--text); resize: none; min-height: 0; }
.editor textarea:focus-visible { outline-offset: -2px; }
mark { color: inherit; background: none; }
mark.m { background: rgba(255, 180, 84, 0.16); box-shadow: 0 2px 0 var(--amber); }
mark.empty { box-shadow: 0 0 0 1px var(--amber); }
mark.g1 { background: color-mix(in srgb, var(--g1) 30%, transparent); }
mark.g2 { background: color-mix(in srgb, var(--g2) 30%, transparent); }
mark.g3 { background: color-mix(in srgb, var(--g3) 30%, transparent); }
mark.g4 { background: color-mix(in srgb, var(--g4) 30%, transparent); }
mark.g5 { background: color-mix(in srgb, var(--g5) 30%, transparent); }
mark.g6 { background: color-mix(in srgb, var(--g6) 30%, transparent); }
.swatch { display: inline-block; width: 10px; height: 10px; margin: 0 8px 0 0; }
.swatch.g1 { background: var(--g1); }
.swatch.g2 { background: var(--g2); }
.swatch.g3 { background: var(--g3); }
.swatch.g4 { background: var(--g4); }
.swatch.g5 { background: var(--g5); }
.swatch.g6 { background: var(--g6); }
.matches th { white-space: nowrap; }
code.value { color: var(--bright); white-space: pre-wrap; overflow-wrap: anywhere; }
pre.error { margin: 0; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; border-top: 1px solid var(--rule); }
ul.parts { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
ul.parts li { display: flex; flex-direction: column; gap: 4px; padding: 11px 12px; border-bottom: 1px solid var(--rule); }
ul.parts li:last-child { border-bottom: 0; }
ul.parts code { color: var(--bright); overflow-wrap: anywhere; }
.htmx-request #result, .htmx-request#all-run { opacity: 0.6; }

/***************
 ** Translate **
 ***************/

.out { padding: 16px 12px; font-size: 16px; color: var(--bright); overflow-wrap: anywhere; }
table.parts { min-width: 860px; }
code.chunk { background: var(--panel); padding: 2px 4px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--bright); }
code.chunk.changed { color: var(--amber); font-weight: 400; }
tr.dim code.chunk { color: var(--dim); }
code.wrap { color: var(--bright); overflow-wrap: anywhere; }
td .tag { margin-left: 6px; }
.out .with { margin-left: 16px; color: var(--dim); font-size: 13px; }
.out .with code { color: var(--bright); }
textarea.try { display: block; width: 100%; padding: 10px 12px; border: 0; background: none; font-size: 13px; line-height: 1.9; white-space: pre; resize: vertical; }
.bar.foot > span { padding: 8px 12px 8px 0; }
.htmx-request#check + #every { opacity: 0.6; }
