/* Coding portal. One quiet instrument: the document on the left, the decision on the right. */
:root {
  --bg: #eef1f4; --surface: #ffffff; --surface-2: #f6f8fa; --ink: #17202b; --muted: #5e6b7a; --line: #d8dee5;
  --accent: #1f5fa8; --accent-ink: #ffffff; --accent-soft: #e5eef9;
  --target-bg: #fff4d6; --target-line: #c98f1a; --neighbour-bg: #eef4fb; --neighbour-line: #9db8d8;
  --danger: #b3261e; --danger-soft: #fbe9e7; --ok: #1c7c54; --ok-soft: #e6f4ed; --info-soft: #eef2f7;
  --sev-serious: #9b2c2c; --sev-moderate: #8a5a00; --sev-minor: #4a5a6a;
  --radius: 10px; --shadow: 0 1px 2px rgba(20, 32, 45, .06), 0 4px 16px rgba(20, 32, 45, .05);
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Charter, "Bitstream Charter", Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161b; --surface: #1a2027; --surface-2: #151a20; --ink: #e6ebf0; --muted: #9aa7b4; --line: #2c3540;
    --accent: #7fb0ec; --accent-ink: #0d1520; --accent-soft: #1d2a3a;
    --target-bg: #3a2f14; --target-line: #d9a441; --neighbour-bg: #1c2733; --neighbour-line: #4f6c8f;
    --danger: #f2877e; --danger-soft: #3a1d1b; --ok: #6fcf9f; --ok-soft: #173327; --info-soft: #1d2530;
    --sev-serious: #f0a3a3; --sev-moderate: #e7c079; --sev-minor: #a9b6c3;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--ui); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
h1 { font-size: 1.6rem; line-height: 1.2; margin: .2rem 0 .8rem; text-wrap: balance; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; font-weight: 600; color: var(--muted); margin: 0 0 .5rem; }
.lede { color: var(--muted); max-width: 60ch; }
.hint, .qhelp, .muted { color: var(--muted); font-size: .86rem; }
.mono { font-family: var(--mono); font-size: .92em; }
kbd { font: 600 .7rem/1 var(--mono); padding: .2rem .35rem; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; color: var(--muted); background: var(--surface-2); }

.too-narrow { display: none; max-width: 34rem; margin: 18vh auto; padding: 0 1.5rem; }
@media (max-width: 1179px) { .app { display: none; } .too-narrow { display: block; } }

/* bar */
.bar { position: sticky; top: 0; z-index: 5; height: 52px; display: flex; align-items: center; gap: 1rem; padding: 0 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 650; display: flex; align-items: center; gap: .55rem; letter-spacing: -.01em; }
.brand .mark { width: 14px; height: 14px; border-radius: 3px; background: linear-gradient(135deg, var(--accent) 0 50%, var(--target-line) 50% 100%); }
.bar-mid { flex: 1; display: flex; justify-content: center; }
.progress { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.signout { display: flex; align-items: center; gap: .75rem; font-size: .85rem; color: var(--muted); margin: 0; }
main { padding: 1.5rem; }
body.wide main { padding: 0; }

/* buttons and inputs */
button, .button { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: .5rem .9rem; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .5rem; }
button:hover, .button:hover { border-color: var(--muted); }
button.primary, .button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary:hover { filter: brightness(1.06); }
button.big { padding: .75rem 1.4rem; font-size: 1rem; }
button.ghost, .button.ghost { background: transparent; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 500; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem; }
textarea { width: 100%; resize: vertical; }
.stack { display: grid; gap: .45rem; }
.stack button { margin-top: .6rem; justify-self: start; }
.row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; }
.row label { display: grid; gap: .25rem; font-size: .85rem; color: var(--muted); }
form.inline { display: inline; margin: 0; }

.flash { border-radius: 8px; padding: .7rem .9rem; margin: 0 0 1rem; font-size: .92rem; }
.flash.error { background: var(--danger-soft); color: var(--danger); }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.info { background: var(--info-soft); color: var(--ink); }
body.wide main > .flash { margin: .75rem 1.25rem 0; }

/* auth and centred panels */
.auth { max-width: 24rem; margin: 10vh auto; background: var(--surface); padding: 2rem; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem; }
.panel.centre { max-width: 36rem; margin: 8vh auto; }
.facts { display: flex; gap: 2.5rem; margin: 1.25rem 0 1.5rem; }
.facts dt { font-size: .8rem; color: var(--muted); }
.facts dd { margin: .1rem 0 0; font-size: 1.9rem; font-weight: 650; font-variant-numeric: tabular-nums; }
details.clerical { margin-top: 1.75rem; border-top: 1px solid var(--line); padding-top: 1rem; }
details summary { cursor: pointer; font-weight: 600; }

/* workspace */
.workspace { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(470px, .88fr); height: calc(100vh - 52px); }
.doc { overflow-y: auto; border-right: 1px solid var(--line); background: var(--surface); }
.doc-inner { max-width: 74ch; margin: 0 auto; padding: 1.75rem 2rem 40vh; font: 16.5px/1.62 var(--serif); }
.anchor { display: grid; grid-template-columns: 5.2rem minmax(0, 1fr); gap: .9rem; padding: .45rem .6rem; border-left: 3px solid transparent; border-radius: 0 6px 6px 0; }
.anchor + .anchor { margin-top: .1rem; }
.gutter { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; padding-top: .2rem; }
.aid { font: 600 .78rem/1.2 var(--mono); color: var(--muted); }
.anchor.target { background: var(--target-bg); border-left-color: var(--target-line); }
.anchor.target .aid { color: var(--ink); }
.anchor.neighbour { background: var(--neighbour-bg); border-left-color: var(--neighbour-line); }
.tag { font: 600 .62rem/1 var(--ui); text-transform: uppercase; letter-spacing: .07em; padding: .22rem .35rem; border-radius: 4px; background: var(--target-line); color: #fff; white-space: nowrap; }
.tag.soft { background: transparent; color: var(--muted); border: 1px solid var(--neighbour-line); }
.kind { display: block; font: 600 .66rem/1.4 var(--ui); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }

.decide { overflow-y: auto; padding: 1.25rem 1.25rem 30vh; display: grid; gap: 1rem; align-content: start; background: var(--bg); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.spec .frame { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: .45rem 1rem; margin: 0; }
.spec .frame > div { display: contents; }
.spec dt { color: var(--muted); font-size: .85rem; }
.spec dd { margin: 0; font-weight: 550; }

.findings { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .45rem; }
.finding { display: flex; gap: .6rem; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem; background: var(--surface-2); }
.finding:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.finding label { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto auto; gap: .25rem .6rem; align-items: baseline; flex: 1; cursor: pointer; }
.findings.plain .finding label { cursor: default; }
.tick { margin-top: .3rem; width: 1rem; height: 1rem; accent-color: var(--accent); }
.fnum { font-weight: 650; font-variant-numeric: tabular-nums; }
.fanchors { font: .8rem/1.4 var(--mono); color: var(--muted); }
.fstmt { font-family: var(--serif); font-size: 1rem; }
.fsev { font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }
.sev-serious { color: var(--sev-serious); } .sev-moderate { color: var(--sev-moderate); } .sev-minor { color: var(--sev-minor); }
.empty-note { color: var(--muted); font-style: italic; margin: 0 0 1rem; }
blockquote.answer-text { margin: 0 0 1rem; padding: .7rem .9rem; border-left: 3px solid var(--line); background: var(--surface-2); font-family: var(--serif); white-space: pre-wrap; }

.steps { display: grid; gap: .75rem; }
fieldset.q { border: 1px solid var(--line); border-radius: 8px; margin: 0; padding: .75rem .9rem .85rem; }
fieldset.q.sub, fieldset.q.l4 + fieldset.q.l4 { margin-left: 1.1rem; }
fieldset.q legend { float: left; width: 100%; padding: 0; margin: 0 0 .3rem; font-weight: 600; }
fieldset.q legend + * { clear: both; }
fieldset.q.answered { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
fieldset.q.active { box-shadow: 0 0 0 3px var(--accent-soft); }
.yn { display: flex; gap: .5rem; margin-top: .5rem; }
.opt { display: inline-flex; align-items: center; gap: .5rem; border: 1px solid var(--line); border-radius: 999px; padding: .35rem .8rem; cursor: pointer; user-select: none; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt:has(input:checked) { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.opt:has(input:checked) kbd { background: transparent; color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent-ink) 50%, transparent); }
.opt:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.computed { margin: 0; padding: .7rem .9rem; border-radius: 8px; background: var(--info-soft); font-size: .92rem; }
.computed.malformed { background: var(--danger-soft); }
.computed ul { margin: .35rem 0 .35rem 1.1rem; padding: 0; }
details.l5 { border: 1px dashed var(--line); border-radius: 8px; padding: .6rem .9rem; }
details.l5 fieldset { border: 0; padding: .5rem 0 0; margin: 0; display: grid; gap: .35rem; }
.l5check { font-weight: 600; }

details.flags { margin-top: .9rem; border-top: 1px solid var(--line); padding-top: .75rem; }
.flaggrid { display: grid; gap: .45rem; margin-top: .6rem; }
.flaggrid label { display: flex; align-items: center; gap: .45rem; font-family: var(--mono); font-size: .82rem; }
.reveal { display: grid; gap: .4rem; margin-left: 1.5rem; padding: .5rem 0 .25rem; }
.js .reveal { display: none; }
.js .reveal.open { display: grid; }
.quotes { display: grid; gap: .3rem; max-height: 14rem; overflow: auto; }
.qline { display: flex; gap: .5rem; font: .92rem/1.4 var(--serif) !important; }
.submitrow { display: flex; align-items: center; gap: .9rem; margin-top: 1.1rem; }
.tools { display: flex; gap: .5rem; flex-wrap: wrap; }
.fulllist .banner { position: sticky; top: 0; background: var(--danger-soft); color: var(--danger); border-radius: 6px; padding: .55rem .75rem; margin-bottom: .75rem; font-weight: 600; font-size: .88rem; }
.outside-lines { margin: 0; padding-left: 1.1rem; font-family: var(--serif); }
.speclist { list-style: none; margin: .75rem 0 0; padding: 0; display: grid; gap: .35rem; }
.speclist li { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr) auto; gap: .6rem; align-items: baseline; padding: .3rem .4rem; border-radius: 6px; }
.speclist li.current { background: var(--target-bg); }
.js [data-show-if].hidden, .hidden { display: none !important; }

/* guess */
.panel.guess { max-width: 58rem; margin: 2rem auto; }
.choices { display: flex; gap: .75rem; margin-top: 1.25rem; }
.choices button { flex: 1; justify-content: center; padding: .9rem; }

/* admin */
.admin { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 1rem; padding: 1.25rem; }
table.counts { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.counts th, table.counts td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.counts td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.audit td.small { font-size: .78rem; word-break: break-all; }
body.wide main > section.card { margin: 1.25rem; }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
