[hidden] { display: none !important; }
:root {
  --paper: #EDEFEA;
  --surface: #F8F9F6;
  --ink: #1C2530;
  --muted: #56626C;
  --rule: #C3CBC7;
  --support: #2E6A4E;
  --support-wash: #DCE8E0;
  --contest: #7B2233;
  --contest-wash: #EFDCDF;
  --focus: #2F5D8A;

  --serif: "Source Serif 4", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;

  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.1875rem;
  --step-2: 1.5rem;
  --step-3: 2.125rem;

  color-scheme: light dark;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #161B20;
    --surface: #1E252C;
    --ink: #E3E8E5;
    --muted: #9AA6AE;
    --rule: #34414B;
    --support: #74B896;
    --support-wash: #1F3329;
    --contest: #DB8494;
    --contest-wash: #3A2228;
    --focus: #8DB8E3;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: var(--step-0)/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
a { color: inherit; }
code { font-size: 0.92em; background: var(--surface); padding: 0.05em 0.35em; border-radius: 3px; border: 1px solid var(--rule); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Masthead */
.masthead {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  max-width: 46rem; margin: 0 auto; padding: 1.25rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--rule);
}
.wordmark { font: 600 var(--step-1)/1 var(--serif); text-decoration: none; letter-spacing: -0.01em; }
nav { display: flex; gap: 1.25rem; }
nav a { text-decoration: none; color: var(--muted); padding: 0.25rem 0; border-bottom: 2px solid transparent; }
nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }

.banner { max-width: 46rem; margin: 0.75rem auto 0; padding: 0.6rem 1.25rem; background: var(--surface); border-left: 3px solid var(--muted); font-size: var(--step--1); }

main { max-width: 46rem; margin: 0 auto; padding: 0 1.25rem 4rem; }
.lede { font: 400 var(--step-3)/1.15 var(--serif); letter-spacing: -0.015em; margin: 2.25rem 0 1.5rem; max-width: 22ch; }
.intro { font-family: var(--serif); line-height: 1.65; color: var(--muted); margin-top: -0.5rem; }

/* Composer */
.field-label { display: block; font-weight: 500; margin-bottom: 0.4rem; }
textarea, input, select {
  font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--rule); border-radius: 4px; width: 100%;
}
textarea { font-family: var(--serif); font-size: var(--step-1); line-height: 1.5; padding: 0.85rem 1rem; resize: vertical; min-height: 7rem; border-bottom: none; border-radius: 4px 4px 0 0; }
input, select { padding: 0.55rem 0.7rem; }

/* The ledger: one bar, two directions */
.ledger { display: grid; grid-template-columns: 1fr 1fr; }
.ledger-btn {
  font: 600 var(--step-0)/1 var(--sans); padding: 1rem; border: none; cursor: pointer;
  color: #fff; transition: filter 120ms ease;
}
.ledger-btn.support { background: var(--support); border-radius: 0 0 0 4px; }
.ledger-btn.contest { background: var(--contest); border-radius: 0 0 4px 0; }
@media (prefers-color-scheme: dark) { .ledger-btn { color: #11161A; } }
.ledger-btn:hover { filter: brightness(1.08); }
.ledger-btn:disabled { filter: grayscale(0.6) opacity(0.6); cursor: progress; }
.scope { color: var(--muted); font-size: var(--step--1); margin: 0.6rem 0 0; }
.scope a { color: var(--ink); }

.status { margin: 1.75rem 0 0; font-family: var(--serif); color: var(--muted); }
.status.error { color: var(--contest); }
.status .pulse { display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: currentColor; margin-right: 0.5rem; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

/* Result */
.result { margin-top: 2rem; padding-left: 1.25rem; border-left: 3px solid var(--rule); }
.result.mode-support { border-left-color: var(--support); }
.result.mode-contest { border-left-color: var(--contest); }
.result-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; }
.result-kind { margin: 0; font-weight: 600; }
.result.mode-support .result-kind { color: var(--support); }
.result.mode-contest .result-kind { color: var(--contest); }
.result-statement { font: italic var(--step-1)/1.45 var(--serif); margin: 0.5rem 0 1.25rem; }

.segmented { display: inline-flex; border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; }
.segmented button { font: 500 var(--step--1) var(--sans); background: transparent; color: var(--muted); border: none; padding: 0.4rem 0.8rem; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.verdict { display: inline-block; font-size: var(--step--1); font-weight: 600; padding: 0.2rem 0.6rem; border-radius: 3px; background: var(--surface); border: 1px solid var(--rule); }
.verdict-line { color: var(--muted); font-size: var(--step--1); margin: 0.4rem 0 1rem; }

.prose { font-family: var(--serif); font-size: var(--step-1); line-height: 1.65; }
.prose p { margin: 0 0 1em; }
.result h3 { font: 600 var(--step-0)/1.3 var(--sans); margin: 2rem 0 0.75rem; }

.argument { margin: 0 0 1.75rem; }
.argument-point { font: 600 var(--step-1)/1.4 var(--serif); margin: 0 0 0.4rem; }
.argument-reasoning { font-family: var(--serif); line-height: 1.65; margin: 0 0 0.75rem; }

.evidence { list-style: none; margin: 0; padding: 0; counter-reset: ev; }
.evidence li { position: relative; padding: 0.7rem 0.9rem 0.7rem 2.3rem; background: var(--surface); border: 1px solid var(--rule); border-radius: 4px; margin-bottom: 0.5rem; counter-increment: ev; }
.evidence li::before { content: counter(ev); position: absolute; left: 0.85rem; top: 0.7rem; font: 600 var(--step--1)/1.6 var(--sans); color: var(--muted); }
.evidence a { font-weight: 500; overflow-wrap: anywhere; }
.evidence .excerpt { font-family: var(--serif); margin: 0.3rem 0 0.4rem; }
.meta-row { display: flex; flex-wrap: wrap; gap: 0.4rem; font-size: var(--step--1); color: var(--muted); }
.tag { font-size: 0.78rem; font-weight: 500; padding: 0.1rem 0.5rem; border-radius: 999px; border: 1px solid var(--rule); color: var(--muted); white-space: nowrap; }

.plain-list { padding-left: 1.2rem; font-family: var(--serif); line-height: 1.6; }
.plain-list li { margin-bottom: 0.4rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; padding: 0; }
.footnote { font-size: var(--step--1); color: var(--muted); border-top: 1px solid var(--rule); margin-top: 2rem; padding-top: 0.75rem; }
.result-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }

/* History */
.history { margin-top: 3rem; }
.history h2, .list-head h2, .source-form h2 { font: 600 var(--step-0)/1.3 var(--sans); margin: 0 0 0.75rem; }
.history ul { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--rule); }
.history li button {
  display: grid; grid-template-columns: auto 1fr; gap: 0.75rem; align-items: baseline; width: 100%;
  text-align: left; background: none; border: none; border-bottom: 1px solid var(--rule); padding: 0.7rem 0; color: inherit; font: inherit; cursor: pointer;
}
.history li button:hover .h-text { text-decoration: underline; }
.h-dir { font-size: var(--step--1); font-weight: 600; }
.h-dir.support { color: var(--support); }
.h-dir.contest { color: var(--contest); }
.h-text { font-family: var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Buttons */
.btn { font: 500 var(--step--1) var(--sans); padding: 0.5rem 0.9rem; border-radius: 4px; border: 1px solid var(--rule); background: var(--surface); color: var(--ink); cursor: pointer; }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.quiet { background: transparent; }
.btn.danger { color: var(--contest); }
.btn:hover { border-color: var(--ink); }

/* Sources */
.source-form { background: var(--surface); border: 1px solid var(--rule); border-radius: 4px; padding: 1.1rem; margin: 1.5rem 0 2.5rem; }
.source-form.editing { border-color: var(--ink); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 1rem; }
.grid label { display: flex; flex-direction: column; gap: 0.3rem; font-size: var(--step--1); font-weight: 500; }
.grid .wide { grid-column: 1 / -1; }
.grid input, .grid select { background: var(--paper); font-weight: 400; font-size: var(--step-0); }
.form-error { color: var(--contest); font-size: var(--step--1); min-height: 1.2em; margin: 0.6rem 0; }
.form-actions { display: flex; gap: 0.5rem; }

.list-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.list-head p { margin: 0; color: var(--muted); font-size: var(--step--1); }
.list-head p.over { color: var(--contest); }
.source-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--rule); }
.source-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 0.9rem; align-items: center; padding: 0.9rem 0; border-bottom: 1px solid var(--rule); }
.source-row.off .source-main { opacity: 0.55; }
.source-main p { margin: 0; }
.source-label { font-weight: 600; }
.source-domain { font-size: var(--step--1); color: var(--muted); overflow-wrap: anywhere; }
.source-notes { font: var(--step--1)/1.5 var(--serif); color: var(--muted); margin-top: 0.2rem !important; }
.row-actions { display: flex; gap: 0.25rem; }
.row-actions .btn { padding: 0.35rem 0.6rem; border-color: transparent; }
.row-actions .btn:hover { border-color: var(--rule); }

.switch { position: relative; display: inline-block; width: 2.4rem; height: 1.4rem; cursor: pointer; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.track { position: absolute; inset: 0; border-radius: 999px; background: var(--rule); transition: background 150ms ease; }
.track::after { content: ""; position: absolute; top: 0.2rem; left: 0.2rem; width: 1rem; height: 1rem; border-radius: 50%; background: var(--paper); transition: transform 150ms ease; }
.switch input:checked + .track { background: var(--support); }
.switch input:checked + .track::after { transform: translateX(1rem); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }

.io { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 1.5rem; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.hint { margin: 0; font-size: var(--step--1); color: var(--muted); }

.empty { font-family: var(--serif); color: var(--muted); padding: 1rem 0; }

@media (max-width: 34rem) {
  .lede { font-size: 1.75rem; }
  .grid { grid-template-columns: 1fr; }
  .source-row { grid-template-columns: auto 1fr; }
  .source-row .tag { grid-column: 2; justify-self: start; }
  .row-actions { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Static PWA additions */
.intro.small { font-size: var(--step--1); margin: 0 0 0.9rem; }
.intro a { color: var(--ink); }
.section-title { font: 400 var(--step-2)/1.2 var(--serif); margin: 3rem 0 0.75rem; }
#stop-btn { margin-top: 0.75rem; }
#key-form { margin-top: 0; }
.form-error.ok { color: var(--support); }
.source-form h2.sub { margin-top: 1.75rem; }
.inline-field { display: flex; gap: 0.5rem; }
.inline-field input { flex: 1; min-width: 0; }
.grid .hint { margin: -0.3rem 0 0; }
.grid .hint a, .choice a { color: var(--ink); }
.choices { display: grid; gap: 0.5rem; margin-bottom: 0.9rem; }
.choice { display: flex; gap: 0.65rem; align-items: flex-start; padding: 0.7rem 0.8rem; border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); cursor: pointer; font-size: var(--step--1); line-height: 1.45; }
.choice input { width: auto; margin-top: 0.2rem; accent-color: var(--ink); }
.choice.disabled { opacity: 0.55; cursor: not-allowed; }
.choice strong { font-size: var(--step-0); font-weight: 600; }
#model-picker { margin-top: 0.4rem; background: var(--paper); font-weight: 400; }
.field { display: flex; flex-direction: column; gap: 0.3rem; font-size: var(--step--1); font-weight: 500; }
.field select, .field input { background: var(--paper); font-weight: 400; font-size: var(--step-0); }
#model-custom { margin-top: 0.4rem; }
#load-models { white-space: nowrap; }

/* ---------- Topics ---------- */
.topic-row { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 0.75rem; align-items: center; margin-bottom: 0.9rem; }
.topic-row .field-label { margin: 0; }
.topic-row select { max-width: 26rem; }
.topic-row .hint { grid-column: 2; margin: 0; }
.topic-row .hint:empty { display: none; }
.topic-list .topic-row { display: grid; grid-template-columns: 1fr auto; gap: 0.9rem; align-items: center; padding: 0.9rem 0; border-bottom: 1px solid var(--rule); margin: 0; }
.source-topics { font-size: var(--step--1); color: var(--muted); margin-top: 0.2rem !important; }
fieldset.checks { border: 1px solid var(--rule); border-radius: 4px; margin: 0.9rem 0 0; padding: 0.6rem 0.8rem 0.8rem; background: var(--paper); }
fieldset.checks legend { font-size: var(--step--1); font-weight: 500; padding: 0 0.3rem; }
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.35rem 1rem; max-height: 16rem; overflow-y: auto; }
.check { display: flex; gap: 0.5rem; align-items: flex-start; font-size: var(--step--1); cursor: pointer; }
.check input { width: auto; margin-top: 0.2rem; accent-color: var(--ink); }
.muted { color: var(--muted); font-weight: 400; }
.filter-row { display: flex; align-items: center; gap: 0.6rem; margin: 0 0 0.6rem; font-size: var(--step--1); }
.filter-row select { width: auto; min-width: 12rem; }

/* ---------- History ---------- */
.history li { display: grid; grid-template-columns: 1fr auto; align-items: center; border-bottom: 1px solid var(--rule); }
.history li button.h-open { border-bottom: none; }
.h-remove { background: none; border: none; color: var(--muted); font: 500 var(--step--1) var(--sans); cursor: pointer; padding: 0.4rem 0.2rem 0.4rem 0.8rem; }
.h-remove:hover { color: var(--contest); }

/* ---------- Source colours (Okabe–Ito based, distinguishable with most colour-vision types) ---------- */
:root { --c0: #D55E00; --c1: #0072B2; --c2: #009E73; --c3: #CC79A7; --c4: #E69F00; --c5: #56B4E9; --c6: #8C6D31; --c7: #7A7A7A; }
@media (prefers-color-scheme: dark) {
  :root { --c0: #FF8F52; --c1: #5AAEF0; --c2: #3FD2A2; --c3: #E8A6CE; --c4: #F5BD4F; --c5: #92D6FF; --c6: #D1AE6E; --c7: #B3B3B3; }
}
.c0 { --c: var(--c0); } .c1 { --c: var(--c1); } .c2 { --c: var(--c2); } .c3 { --c: var(--c3); }
.c4 { --c: var(--c4); } .c5 { --c: var(--c5); } .c6 { --c: var(--c6); } .c7 { --c: var(--c7); }

mark.hl { color: inherit; background: color-mix(in srgb, var(--c) 20%, transparent); box-shadow: inset 0 -2px 0 var(--c); padding: 0 0.1em; border-radius: 2px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.ref {
  display: inline-flex; align-items: center; justify-content: center; min-width: 1.35em; height: 1.35em; padding: 0 0.3em; margin: 0 0.1em;
  border-radius: 999px; border: none; background: var(--c); color: #fff; font: 600 0.72rem/1 var(--sans); vertical-align: 0.35em; cursor: pointer;
}
@media (prefers-color-scheme: dark) { .ref { color: #10151A; } }
button.ref:hover { filter: brightness(1.1); }

.legend { margin: 0.25rem 0 1.25rem; padding: 0.7rem 0.9rem; border: 1px solid var(--rule); border-radius: 4px; background: var(--surface); }
.legend-title { margin: 0 0 0.4rem; font-weight: 600; font-size: var(--step--1); }
.legend ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.35rem 1.1rem; font-size: var(--step--1); }
.legend li { display: flex; align-items: center; gap: 0.4rem; }
.swatch { width: 0.95rem; height: 0.95rem; border-radius: 3px; background: color-mix(in srgb, var(--c) 30%, transparent); box-shadow: inset 0 -3px 0 var(--c); flex: none; }
.swatch.plain { background: transparent; box-shadow: inset 0 0 0 1px var(--rule); }

ul.evidence { list-style: none; margin: 0; padding: 0; }
ul.evidence li { display: grid; grid-template-columns: auto 1fr; gap: 0.6rem; padding: 0.7rem 0.9rem; background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--c); border-radius: 4px; margin-bottom: 0.5rem; }
ul.evidence li::before { content: none; }
ul.evidence .ref { vertical-align: 0; margin-top: 0.15rem; }

.source-refs { list-style: none; padding: 0; margin: 0; }
.source-refs li { display: grid; grid-template-columns: auto 1fr; gap: 0.6rem; padding: 0.55rem 0.6rem; border-left: 4px solid var(--c); margin-bottom: 0.35rem; background: var(--surface); border-radius: 0 4px 4px 0; }
.source-refs .ref { vertical-align: 0; cursor: default; margin-top: 0.15rem; }
.source-refs a { font-weight: 500; overflow-wrap: anywhere; }
.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { background: color-mix(in srgb, var(--c) 35%, var(--surface)); } 100% { background: var(--surface); } }
.history li button.h-remove { display: inline; width: auto; border-bottom: none; padding: 0.4rem 0.2rem 0.4rem 0.8rem; }

/* ---------- Accordions (settings) ---------- */
.acc { border: 1px solid var(--rule); border-radius: 6px; background: var(--surface); margin-bottom: 0.9rem; }
.acc[open] { border-color: color-mix(in srgb, var(--ink) 30%, var(--rule)); }
.acc > summary, .sub-acc > summary, .topic-item > summary { list-style: none; cursor: pointer; }
.acc > summary::-webkit-details-marker, .sub-acc > summary::-webkit-details-marker, .topic-item > summary::-webkit-details-marker { display: none; }
.acc-head { display: flex; align-items: baseline; gap: 0.75rem; padding: 1rem 1.1rem; }
.acc-head::before, .sub-acc > summary::before, .topic-item > summary::before {
  content: ""; flex: none; width: 0.5rem; height: 0.5rem; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform 150ms ease; align-self: center;
}
details[open] > .acc-head::before, .sub-acc[open] > summary::before, .topic-item[open] > summary::before { transform: rotate(45deg); }
.acc-title { font: 400 var(--step-2)/1.2 var(--serif); margin: 0; }
.acc-meta { margin-left: auto; font-size: var(--step--1); color: var(--muted); text-align: right; }
.acc-meta.warn { color: var(--contest); }
.acc-body { padding: 0 1.1rem 1.1rem; }
.acc-body > .intro.small:first-child { margin-top: 0; }
.acc-sub { font: 600 var(--step-0)/1.3 var(--sans); margin: 0.5rem 0 0.4rem; }
.acc-sub:not(:first-child) { margin-top: 1.6rem; }
#key-form.source-form { border: none; background: none; padding: 0; margin: 0; }

.sub-acc { border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); margin: 0 0 1.1rem; }
.sub-acc > summary { display: flex; align-items: center; gap: 0.65rem; padding: 0.7rem 0.9rem; font-weight: 600; }
.sub-acc .source-form { border: none; background: none; margin: 0; padding: 0 0.9rem 0.9rem; }
.sub-acc .source-form.editing { border: none; }
.sub-acc:has(.editing) { border-color: var(--ink); }
.sub-acc .grid input, .sub-acc .grid select, .sub-acc fieldset.checks { background: var(--surface); }

.topic-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.topic-list > li { border-bottom: 1px solid var(--rule); }
.topic-item > summary { display: flex; align-items: center; gap: 0.65rem; padding: 0.8rem 0.1rem; }
.topic-name { font-weight: 600; }
.topic-body { padding: 0 0.1rem 0.9rem 1.15rem; }
.topic-body .source-notes { margin: 0 0 0.5rem; }
.member-list { margin: 0 0 0.6rem; padding-left: 1.1rem; font-size: var(--step--1); line-height: 1.6; }
.member-list li.off { opacity: 0.6; }
.topic-body .row-actions { margin-left: -0.6rem; }
.acc-body .list-head { margin-top: 0.3rem; }
.acc-body .io { margin-top: 1.2rem; }
@media (max-width: 34rem) {
  .acc-head { flex-wrap: wrap; }
  .acc-meta { flex-basis: 100%; margin-left: 1.25rem; text-align: left; }
}
.grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.grid > * { min-width: 0; }
.acc-body form, .acc-body .grid { max-width: 100%; }
@media (max-width: 34rem) { .grid { grid-template-columns: minmax(0, 1fr); } }
/* Trace heading stays on one line and scales down on narrow screens */
#trace-heading { max-width: none; white-space: nowrap; font-size: clamp(1rem, 5.4vw, 2.125rem); }

/* ---------- Four actions ---------- */
.ledger:not(.second) .ledger-btn.support { border-radius: 0; }
.ledger:not(.second) .ledger-btn.contest { border-radius: 0; }
.ledger.second .ledger-btn.neutral {
  background: var(--surface); color: var(--ink); border: 1px solid var(--rule); border-top: none;
  font-weight: 600; padding: 0.85rem 1rem;
}
.ledger.second .ledger-btn.neutral:first-child { border-radius: 0 0 0 4px; border-right: none; }
.ledger.second .ledger-btn.neutral:last-child { border-radius: 0 0 4px 0; }
.ledger.second .ledger-btn.neutral:hover { background: var(--paper); filter: none; }
.mode-hint { margin: 0.5rem 0 0; }
.hint { font-size: var(--step--1); color: var(--muted); }

.result.mode-balanced { border-left-color: var(--ink); }
.result.mode-check { border-left-color: var(--focus); }
.result.mode-balanced .result-kind, .result.mode-check .result-kind { color: var(--ink); }
.h-dir.balanced, .h-dir.check { color: var(--ink); }

/* ---------- Balanced report ---------- */
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; margin-top: 0.5rem; }
.col { border-top: 3px solid var(--rule); padding-top: 0.2rem; }
.col.for { border-top-color: var(--support); }
.col.against { border-top-color: var(--contest); }
.col h3 { margin-top: 0.6rem; }
.col.for h3 { color: var(--support); }
.col.against h3 { color: var(--contest); }
.conflict { border: 1px solid var(--rule); border-radius: 4px; padding: 0.6rem 0.8rem; margin-bottom: 0.5rem; background: var(--surface); font-family: var(--serif); line-height: 1.6; }
.conflict p { margin: 0.2rem 0; }
.conflict-issue { font-weight: 600; }
.tag.favours-for { color: var(--support); border-color: var(--support); }
.tag.favours-against { color: var(--contest); border-color: var(--contest); }
details.case { border: 1px solid var(--rule); border-radius: 4px; margin: 1rem 0 0; background: var(--surface); }
details.case > summary { cursor: pointer; padding: 0.7rem 0.9rem; font-weight: 600; display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.case-body { padding: 0 0.9rem 0.9rem; font-family: var(--serif); line-height: 1.6; }
.case-body h4 { font: 600 var(--step-0)/1.3 var(--sans); margin: 1.2rem 0 0.5rem; }
.verdict.small { font-size: 0.75rem; padding: 0.1rem 0.45rem; }
.prose-small { font-family: var(--serif); line-height: 1.6; }

/* ---------- Correctness check ---------- */
.tone { display: inline-block; font: 600 0.78rem/1.3 var(--sans); padding: 0.12rem 0.5rem; border-radius: 3px; border: 1px solid var(--rule); white-space: nowrap; }
.tone.good { background: var(--support-wash); color: var(--support); border-color: var(--support); }
.tone.bad { background: var(--contest-wash); color: var(--contest); border-color: var(--contest); }
.tone.mid { background: color-mix(in srgb, var(--c4) 18%, transparent); color: var(--ink); border-color: var(--c4); }
.tone.none { color: var(--muted); }
.verdict.tone { font-size: var(--step--1); padding: 0.2rem 0.6rem; }
.notice { border-left: 3px solid var(--c4); background: var(--surface); padding: 0.6rem 0.8rem; font-size: var(--step--1); }
.app-check { border: 1px solid var(--rule); border-left: 4px solid var(--rule); border-radius: 4px; padding: 0.7rem 0.9rem; margin-bottom: 0.7rem; background: var(--surface); }
.app-check.good { border-left-color: var(--support); }
.app-check.bad { border-left-color: var(--contest); }
.app-check p { margin: 0.35rem 0; }
.app-check-title { font-weight: 500; }
.logic-table, .calc-table { border-collapse: collapse; width: 100%; font-size: var(--step--1); margin: 0.4rem 0; }
.logic-table th, .logic-table td, .calc-table th, .calc-table td { text-align: left; padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
.logic-table th { white-space: nowrap; font-weight: 600; }
.calc-table th { font-weight: 600; }
.table-wrap { overflow-x: auto; }
.small { font-size: var(--step--1); }
.claim-list { list-style: none; padding: 0; margin: 0; }
.claim-list li { padding: 0.45rem 0; border-bottom: 1px solid var(--rule); font-family: var(--serif); line-height: 1.55; }
.claim { border-bottom: 1px solid var(--rule); padding: 0.4rem 0 1rem; margin-bottom: 0.6rem; }
.claim-head { margin: 0.3rem 0; font-family: var(--serif); font-size: var(--step-1); line-height: 1.45; }
.claim-head .claim-text { font-weight: 600; }
.claim > .muted.small { margin: 0 0 0.5rem; }
.scope-note { font-size: var(--step--1); background: var(--surface); border-left: 3px solid var(--rule); padding: 0.4rem 0.7rem; }
.tag.stance-supports { color: var(--support); border-color: var(--support); }
.tag.stance-contradicts { color: var(--contest); border-color: var(--contest); }

/* ---------- Local files ---------- */
.local-actions { margin-top: 0; }
.check-group { grid-column: 1 / -1; margin: 0.6rem 0 0.1rem; font-size: var(--step--1); font-weight: 600; color: var(--muted); }
.lib-item.off .topic-name { opacity: 0.6; }
.lib-item .topic-body > .check { margin-bottom: 0.4rem; }
.lib-problems-title { font-size: var(--step--1); font-weight: 600; color: var(--contest); margin: 0.6rem 0 0.2rem; }
.member-list.problems li { color: var(--ink); }
details.file-list { margin: 0.5rem 0; font-size: var(--step--1); }
details.file-list > summary { cursor: pointer; color: var(--muted); }
details.file-list .member-list { max-height: 14rem; overflow-y: auto; margin-top: 0.4rem; }
.local-title { font-weight: 500; }
details.passage { margin-top: 0.35rem; font-size: var(--step--1); }
details.passage > summary { cursor: pointer; color: var(--muted); }
details.passage p { font-family: var(--serif); line-height: 1.55; white-space: pre-wrap; margin: 0.4rem 0 0; }
#local-progress { margin: 0.4rem 0 0.8rem; font-size: var(--step--1); }

@media (max-width: 34rem) {
  .two-col { grid-template-columns: minmax(0, 1fr); }
  .ledger.second .ledger-btn.neutral { font-size: var(--step--1); padding: 0.8rem 0.5rem; }
}

/* ---------- Print / save as PDF ---------- */
@media print {
  :root { --paper: #fff; --surface: #fff; --ink: #111; --muted: #444; --rule: #bbb; }
  body { background: #fff; }
  .masthead, #trace-form, #status, #stop-btn, #history, .no-print, .banner, h1.lede { display: none !important; }
  main { max-width: none; padding: 0; }
  .result { border-left: none; padding-left: 0; margin: 0; }
  mark.hl, .ref, .swatch { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .argument, .claim, .conflict, .source-refs li, ul.evidence li { break-inside: avoid; }
  a { color: inherit; }
}
.topic-item > summary { flex-wrap: wrap; }
.topic-item > summary .topic-name { flex: 1 1 10rem; }
.topic-item > summary .acc-meta { margin-left: auto; }

/* ---------- Four inline actions ---------- */
.actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.act {
  position: relative; font: 600 var(--step-0)/1.1 var(--sans); padding: 0.95rem 0.4rem; border: none; cursor: pointer;
  color: #fff; transition: filter 120ms ease; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.act + .act { box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.35); }
.act-support { background: var(--support); border-radius: 0 0 0 4px; }
.act-contest { background: var(--contest); }
.act-both { background: var(--ink); color: var(--paper); }
.act-verify { background: var(--focus); border-radius: 0 0 4px 0; }
@media (prefers-color-scheme: dark) { .act { color: #11161A; } .act-both { color: var(--paper); } }
.act:hover:not(:disabled) { filter: brightness(1.1); }
.act:disabled { cursor: progress; filter: grayscale(0.7) opacity(0.45); }
.act.running { filter: none; opacity: 1; }
.act.running::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.95), transparent); background-size: 50% 100%; background-repeat: no-repeat;
  animation: sweep 1.1s linear infinite;
}
@media (max-width: 22rem) {
  .actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .act-support { border-radius: 0; } .act-verify { border-radius: 0 0 4px 0; } .act-both { border-radius: 0 0 0 4px; }
}
@media (max-width: 30rem) { .act { font-size: var(--step--1); padding: 0.9rem 0.25rem; } }
.mode-hint strong { color: var(--ink); font-weight: 600; }

/* ---------- Busy indicator ---------- */
.busy-bar { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 50; overflow: hidden; background: color-mix(in srgb, var(--focus) 20%, transparent); padding-top: env(safe-area-inset-top, 0px); }
.busy-bar span { position: absolute; top: 0; bottom: 0; width: 35%; background: var(--focus); animation: slide 1.3s ease-in-out infinite; }
@keyframes slide { 0% { left: -35%; } 100% { left: 100%; } }
@keyframes sweep { 0% { background-position: -100% 0; } 100% { background-position: 200% 0; } }

.busy-panel {
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 0.8rem;
  margin-top: 1.4rem; padding: 0.85rem 1rem; border: 1px solid var(--rule); border-left: 4px solid var(--focus);
  border-radius: 4px; background: var(--surface);
}
.busy-title { margin: 0; font-weight: 600; }
.busy-msg { margin: 0.15rem 0 0; font-family: var(--serif); color: var(--muted); font-size: var(--step--1); }
.busy-time { font: 600 var(--step--1) var(--sans); font-variant-numeric: tabular-nums; color: var(--muted); }
.spinner { width: 1.5rem; height: 1.5rem; border-radius: 50%; border: 3px solid color-mix(in srgb, var(--focus) 25%, transparent); border-top-color: var(--focus); animation: spin 0.8s linear infinite; display: inline-block; vertical-align: middle; }
.spinner.small { width: 0.95rem; height: 0.95rem; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 30rem) {
  .busy-panel { grid-template-columns: auto 1fr auto; }
  .busy-panel #stop-btn { grid-column: 1 / -1; justify-self: start; }
}
body.is-busy #statement { opacity: 0.75; }
#local-progress progress { display: block; width: 100%; height: 0.5rem; margin-top: 0.4rem; accent-color: var(--focus); }
@media (prefers-reduced-motion: reduce) {
  .busy-bar span { animation: none; left: 0; width: 100%; opacity: 0.6; }
  .spinner { animation: none; border-top-color: var(--focus); border-right-color: var(--focus); }
}

/* ---------- Balances ---------- */
.balance-line { margin: 0.35rem 0 0; display: flex; flex-direction: column; gap: 0.2rem; font-size: var(--step--1); color: var(--muted); }
.balance-line:empty { display: none; }
.bal-bar { display: inline-block; width: 3rem; height: 0.4rem; border-radius: 999px; background: var(--rule); overflow: hidden; margin-right: 0.45rem; vertical-align: middle; }
.bal-bar > span { display: block; height: 100%; background: var(--support); }
.bal.mid .bal-bar > span { background: var(--c4); }
.bal.bad .bal-bar > span { background: var(--contest); }
.bal.bad { color: var(--contest); }
.bal-bar.wide { display: block; width: 100%; max-width: 22rem; margin: 0.35rem 0 0; }
.balance-list { list-style: none; margin: 0 0 0.6rem; padding: 0; font-size: var(--step--1); }
.balance-list li { padding: 0.5rem 0; border-bottom: 1px solid var(--rule); line-height: 1.5; }
.balance-list li:first-child { border-top: 1px solid var(--rule); }
.balance-list a { color: var(--ink); margin-left: 0.3rem; }
#balance-refresh { margin-bottom: 0.4rem; }
@media (max-width: 30rem) {
  .act { white-space: normal; overflow: visible; text-overflow: clip; font-size: 0.82rem; line-height: 1.15; padding: 0.7rem 0.2rem; min-height: 3.2rem; hyphens: none; }
}
fieldset.focus-choices { border: none; padding: 0; margin: 1rem 0 0.4rem; }
fieldset.focus-choices legend { font-size: var(--step--1); font-weight: 500; margin-bottom: 0.4rem; padding: 0; }

/* No long-press callout menu on iPhone/iPad, except in text boxes */
body { -webkit-touch-callout: none; }
input, textarea, select { -webkit-touch-callout: default; }

/* ---------- Help ---------- */
.help-body { font-family: var(--serif); line-height: 1.65; }
.help-body h3 { font: 600 var(--step-0)/1.3 var(--sans); margin: 1.4rem 0 0.5rem; }
.help-body h3:first-child { margin-top: 0.2rem; }
.help-body p { margin: 0 0 0.8rem; }
.help-body ul, .help-body ol { margin: 0 0 0.9rem; padding-left: 1.3rem; }
.help-body li { margin-bottom: 0.4rem; }
.help-body a { color: var(--ink); }
.help-body code { font-size: 0.85em; }
.help-body .muted { font-size: var(--step--1); }
ol.steps { counter-reset: step; list-style: none; padding-left: 0; }
ol.steps > li { counter-increment: step; position: relative; padding-left: 2.1rem; }
ol.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0.1rem; width: 1.45rem; height: 1.45rem; border-radius: 50%;
  background: var(--ink); color: var(--paper); font: 600 0.78rem/1.45rem var(--sans); text-align: center;
}
.help-table { border-collapse: collapse; width: 100%; font: var(--step--1)/1.5 var(--sans); margin: 0.4rem 0 0.9rem; }
.help-table th, .help-table td { text-align: left; vertical-align: top; padding: 0.5rem 0.55rem; border-bottom: 1px solid var(--rule); }
.help-table th { font-weight: 600; background: var(--paper); }
.help-table td:first-child { white-space: nowrap; }
.help-table a { overflow-wrap: anywhere; }
dl.faq { margin: 0; }
dl.faq dt { font: 600 var(--step-0)/1.35 var(--sans); margin-top: 0.9rem; }
dl.faq dt:first-child { margin-top: 0; }
dl.faq dd { margin: 0.25rem 0 0; }
.help .notice { font-family: var(--sans); }
@media (max-width: 34rem) {
  .help-table td:first-child { white-space: normal; }
  nav { gap: 0.9rem; }
}
@media (max-width: 34rem) {
  .help-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .help-table, .help-table tbody, .help-table tr, .help-table td { display: block; width: 100%; }
  .help-table tr { border: 1px solid var(--rule); border-radius: 4px; margin-bottom: 0.6rem; padding: 0.5rem 0.7rem; background: var(--paper); }
  .help-table td { border: none; padding: 0.15rem 0; }
  .help-table td:first-child { font-weight: 600; font-size: var(--step-0); padding-bottom: 0.3rem; }
  .help-table td:not(:first-child)::before { content: attr(data-label) ": "; font-weight: 600; color: var(--muted); }
  .table-wrap { overflow: visible; }
}
