:root {
  --bg: #f6f5f2; --panel: #ffffff; --ink: #1d1d1f; --muted: #6b6b70; --line: #e2e0da;
  --accent: #2f5bd3; --accent-ink: #ffffff;
  --actor-bg: #d9e5ff; --actor-line: #2f5bd3;
  --loc-bg: #ffe7ad; --loc-line: #b97800;
  --ok: #1f7a3f; --ok-bg: #e3f3e8; --warn: #8a5a00; --warn-bg: #fff4d6; --bad: #a3221b; --bad-bg: #fde6e4;
  --radius: 8px; --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.35rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); font-size: .85rem; }

nav.top { display: flex; gap: 1rem; align-items: center; padding: .6rem 1.25rem; background: var(--panel);
  border-bottom: 1px solid var(--line); flex-wrap: wrap; }
nav.top .brand { font-weight: 600; margin-right: .5rem; }
nav.top a { text-decoration: none; color: var(--ink); }
nav.top a.active { color: var(--accent); font-weight: 600; }
nav.top .spacer { flex: 1; }
main { padding: 1.25rem; max-width: 1400px; margin: 0 auto; }
main.narrow { max-width: 520px; margin-top: 8vh; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }

table { border-collapse: collapse; width: 100%; background: var(--panel); }
th, td { text-align: left; padding: .4rem .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }

button, .btn { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: .45rem .9rem; border-radius: 6px; cursor: pointer; text-decoration: none; display: inline-block; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.danger { color: var(--bad); border-color: #e9b7b3; }
button:disabled { opacity: .5; cursor: not-allowed; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  font: inherit; padding: .4rem .55rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); }
textarea { width: 100%; min-height: 4.5rem; resize: vertical; }
label { cursor: pointer; }

.banner { padding: .65rem 1rem; border-radius: var(--radius); margin-bottom: .6rem; font-weight: 500; }
.banner.red { background: var(--bad-bg); color: var(--bad); border: 1px solid #f2b9b4; }
.banner.yellow { background: var(--warn-bg); color: var(--warn); border: 1px solid #f0d58f; }
.banner.green { background: var(--ok-bg); color: var(--ok); border: 1px solid #b8dfc4; }
.banner.info { background: #eef2fd; color: #23408f; border: 1px solid #ccd8f7; }
.pill { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .8rem; background: #eeede8; white-space: nowrap; }
.pill.red { background: var(--bad-bg); color: var(--bad); }
.pill.yellow { background: var(--warn-bg); color: var(--warn); }
.pill.ok, .pill.green { background: var(--ok-bg); color: var(--ok); }
.pill.blue { background: #e4ebfd; color: #23408f; }
.stat { font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* highlights */
mark { border-radius: 3px; padding: 0 .1em; color: inherit; }
mark.hl-actor, .chip-actor { background: var(--actor-bg); box-shadow: inset 0 -2px 0 var(--actor-line); }
mark.hl-loc, .chip-loc { background: var(--loc-bg); box-shadow: inset 0 -2px 0 var(--loc-line); }
.chip-actor, .chip-loc { padding: .05rem .4rem; border-radius: 4px; font-weight: 600; }
.article { white-space: pre-wrap; line-height: 1.65; font-size: 1rem; }
.article-scroll { max-height: calc(100vh - 220px); overflow-y: auto; padding-right: .5rem; }
.excerpt { white-space: pre-wrap; max-height: 16rem; overflow-y: auto; font-size: .92rem; line-height: 1.55;
  border-left: 3px solid var(--line); padding-left: .75rem; }

/* annotate layout */
.annotate { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(360px, 1fr); gap: 1.25rem; align-items: start; }
.annotate .side { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; }
@media (max-width: 900px) { .annotate { grid-template-columns: 1fr; } .annotate .side { position: static; max-height: none; } .article-scroll { max-height: none; } }
.instructions { font-size: 1.05rem; margin-bottom: .6rem; }
.llm { background: #f3f1fb; border: 1px solid #ddd7f3; border-radius: var(--radius); padding: .75rem .9rem; margin-bottom: .9rem; }
.llm .lbl { font-weight: 600; }
.llm .expl { margin-top: .4rem; font-style: italic; }
.q { margin: .85rem 0; }
.q > .qtitle { font-weight: 600; margin-bottom: .3rem; }
.yn { display: flex; gap: .5rem; }
.yn label, .opts label { border: 1px solid var(--line); border-radius: 6px; padding: .35rem .7rem; background: #fff; display: flex; gap: .45rem; align-items: flex-start; }
.yn label:has(input:checked), .opts label:has(input:checked) { border-color: var(--accent); background: #eef2fd; }
.opts { display: flex; flex-direction: column; gap: .3rem; }
.opts .key { font-family: var(--mono); font-size: .75rem; color: var(--muted); min-width: 1.2rem; }
.hidden { display: none !important; }
.errors { background: var(--bad-bg); color: var(--bad); border-radius: 6px; padding: .5rem .8rem; margin-bottom: .75rem; }
.errors ul { margin: 0; padding-left: 1.1rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; align-items: center; }
.kbd { font-family: var(--mono); font-size: .75rem; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 .3rem; background: #fff; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); }

.vote-grid td.lbl { white-space: nowrap; }
.split { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, 1fr); gap: 1.25rem; align-items: start; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }
details > summary { cursor: pointer; }
pre.schema { font-size: .75rem; max-height: 24rem; overflow: auto; background: #faf9f6; padding: .75rem; border-radius: 6px; }
