/* Task Labeling UI.
   Tokens: paper #F6F5F1 · panel #FFF · ink #23272E · muted #6C7280 · line #E5E2DA
   accent (teal) #0E6E64 · accent tint #E6F1EF · amber (this-task / flags) #9A6B15 / #F7EDD8
   danger #A63A3A. Transcript body is serif (Charter); UI chrome is system sans. */

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* author display rules must never resurrect hidden elements */

:root {
  --paper: #F6F5F1; --panel: #FFF; --ink: #23272E; --muted: #6C7280; --line: #E5E2DA;
  --teal: #0E6E64; --teal-dark: #0A544C; --teal-tint: #E6F1EF;
  --amber: #9A6B15; --amber-tint: #F7EDD8; --danger: #A63A3A;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --serif: Charter, Georgia, "Times New Roman", serif;
}

body { margin: 0; font: 14px/1.5 var(--sans); color: var(--ink); background: var(--paper); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 4px; }

/* ── top bar ────────────────────────────────────────────────────────────── */
#topbar { display: flex; align-items: center; gap: 18px; padding: 10px 20px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; letter-spacing: -.01em; }
#topbar nav { display: flex; gap: 4px; }
#topbar nav a { padding: 4px 10px; border-radius: 6px; color: var(--teal-dark); text-decoration: none; }
#topbar nav a:hover { background: var(--teal-tint); }
.spacer { flex: 1; }
#whoami { color: var(--muted); }

button { padding: 6px 14px; border-radius: 7px; border: 1px solid #C9C6BD; background: var(--panel); cursor: pointer; }
button:hover { border-color: #A9A69C; background: #FBFAF7; }
button:disabled { opacity: .45; cursor: default; }
button.ghost { border-color: transparent; background: transparent; }
button.ghost:hover { background: #EFEDE6; }
button.ghost.on { background: var(--amber-tint); border-color: #DCC489; color: var(--amber); }
button.primary { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--teal-dark); }

.pad { padding: 24px 20px 60px; max-width: 980px; margin: 0 auto; }
.err { color: var(--danger); margin-top: 8px; }
.dim { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* ── login ──────────────────────────────────────────────────────────────── */
.login-box { max-width: 360px; margin: 14vh auto; background: var(--panel); padding: 30px;
  border: 1px solid var(--line); border-radius: 12px; }
.login-box h1 { margin: 0 0 4px; font-size: 22px; }
.login-sub { color: var(--muted); margin: 0 0 18px; }
.login-box label { display: block; font-weight: 600; margin: 12px 0 4px; }
.login-box input { display: block; width: 100%; padding: 9px 10px; border: 1px solid #C9C6BD;
  border-radius: 7px; font: inherit; background: #FDFDFB; }
.login-box button { margin-top: 16px; width: 100%; }

/* ── queue ──────────────────────────────────────────────────────────────── */
.progress { position: relative; height: 30px; background: #E9E7E0; border-radius: 8px; overflow: hidden; margin-bottom: 8px; }
.progress-fill { height: 100%; background: var(--teal); transition: width .3s ease; }
@media (prefers-reduced-motion: reduce) { .progress-fill { transition: none; } }
.progress-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-weight: 600; color: var(--ink); mix-blend-mode: multiply; }
.queue-help { color: var(--muted); margin: 0 0 20px; }

.sess-group { margin-bottom: 22px; }
.sess-head { display: flex; align-items: baseline; gap: 10px; padding: 0 4px 6px; min-width: 0; }
.sess-title { font-weight: 700; font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sess-meta { color: var(--muted); white-space: nowrap; }
.sess-tasks { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden; background: var(--panel); }
.qrow { display: flex; align-items: center; gap: 12px; padding: 10px 14px; text-decoration: none;
  color: inherit; border-bottom: 1px solid #EFEDE6; }
.qrow:last-child { border-bottom: none; }
.qrow:hover { background: #F4F8F7; }
.qrow.done { background: #FAFAF8; }
.qrow.done .q-first { color: #9AA0A6; }
.q-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; border: 2px solid #C9C6BD; background: transparent; }
.qrow.started .q-dot { border-color: var(--amber); background: var(--amber-tint); }
.qrow.done .q-dot { border-color: var(--teal); background: var(--teal); }
.q-id { flex: none; width: 118px; }
.q-task { font-weight: 600; }
.q-turns { color: var(--muted); font-size: 12px; }
.q-first { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #4B5058; }
.q-side { flex: none; display: flex; align-items: center; gap: 8px; }
.q-cost { color: var(--muted); width: 62px; text-align: right; }
.q-go { color: var(--teal); font-weight: 600; }
.chip { font-size: 11px; padding: 1px 8px; border-radius: 9px; background: var(--teal-tint); color: var(--teal-dark); white-space: nowrap; }
.chip.flag { background: var(--amber-tint); color: var(--amber); }
.chip.repo { background: #EFEDE6; color: #5A5E52; }
.chip.auto { background: var(--teal-tint); color: var(--teal-dark); border: 1px dashed #9EC4BE; }

.auto-banner { border: 1px dashed #9EC4BE; background: var(--teal-tint); color: #14554E;
  border-radius: 9px; padding: 9px 12px; margin-bottom: 14px; font-size: 12.5px; }
.claim-banner { border: 1px solid #C9DDD9; background: var(--teal-tint); color: #14554E;
  border-radius: 9px; padding: 9px 12px; margin-bottom: 14px; font-size: 12.5px; }
.t-claim { font-size: 11px; padding: 1px 7px; border-radius: 8px; background: var(--teal-tint);
  color: var(--teal-dark); border: 1px dashed #9EC4BE; }
.turn.other-claim { box-shadow: inset -3px 0 0 #9EC4BE; }
.turn.seg-mark.other-claim { box-shadow: inset 3px 0 0 var(--teal), inset -3px 0 0 #9EC4BE; }

/* ── labeling: layout ───────────────────────────────────────────────────── */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 400px; height: calc(100vh - 45px); }
.pane-left { overflow-y: auto; padding: 14px 22px 80px; }
.pane-right { overflow-y: auto; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; }

.task-nav { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--panel); z-index: 2; }
.task-nav .pos { font-weight: 600; }
.task-nav button { padding: 4px 10px; }
.rail { padding: 14px 16px 30px; }

.task-card { border: 1px solid #E4D9BE; background: var(--amber-tint); border-radius: 10px; padding: 10px 12px; margin-bottom: 16px; }
.task-card .tc-title { font-weight: 700; }
.task-card .tc-meta { color: #7A6634; font-size: 12.5px; margin-top: 2px; }

/* ── labeling: transcript ───────────────────────────────────────────────── */
.mtask { border: 1px solid transparent; border-radius: 8px; padding: 2px 12px; margin-bottom: 10px; }
.mtask.other { background: #F1F0EB; border-color: #E9E7E0; }
.mtask.cur { background: #FCF6E8; border: 1px solid #E4D08F; box-shadow: inset 4px 0 0 #D9AE45; }
.mtask-tag { font-size: 12px; color: var(--muted); margin: 8px 0 2px; font-weight: 600; }
.mtask.cur > .mtask-tag { color: var(--amber); }

/* ── inline subagent cards (anchored at their spawn turn) ───────────────── */
.sub-inline { margin: 8px 0 4px 18px; border: 1px dashed #B9C9C5; border-left: 3px solid var(--teal);
  border-radius: 8px; background: #F3F6F5; }
.sub-inline.cur { border-color: var(--amber); background: #FBF6EC; }
.sub-inline > summary { cursor: pointer; padding: 7px 12px; font-size: 12.5px; font-weight: 600;
  color: var(--teal-dark); list-style: none; user-select: none; }
.sub-inline > summary::-webkit-details-marker { display: none; }
.sub-inline > summary::after { content: ' — click to expand'; font-weight: 400; color: var(--muted); }
.sub-inline[open] > summary::after { content: ' — click to collapse'; }
.sub-glyph { margin-right: 4px; }
.sub-target-chip { font-size: 11px; padding: 1px 7px; border-radius: 8px; background: var(--amber);
  color: #fff; font-weight: 600; margin-left: 6px; }
.sub-body { padding: 2px 14px 10px; border-top: 1px dashed #C9D6D3; }
.sub-lbl { font-size: 11px; font-weight: 700; color: var(--teal-dark); text-transform: uppercase;
  letter-spacing: .04em; margin-right: 5px; }
.sub-anchor { font-size: 12.5px; color: var(--muted); margin: 2px 0 6px; }
.sub-anchor a, .turn-jump { color: var(--teal-dark); font-weight: 600; }
.sub-spawn-chip { background: var(--amber); color: #fff; }
.turn.jump-flash { background: var(--teal-tint); transition: background 1.2s ease; }

.turn { padding: 10px 0 12px; border-bottom: 1px solid #E9E7E0; }
.turn:last-child { border-bottom: none; }
.t-head { display: flex; align-items: center; gap: 8px; }
.t-chip { font-size: 11.5px; font-weight: 700; color: var(--muted); background: #ECEAE3; border: 1px solid transparent;
  border-radius: 6px; padding: 1px 7px; font-variant-numeric: tabular-nums; }
.turn.seg-mark .t-chip { background: var(--teal); color: #fff; }
.t-user { font-family: var(--serif); font-size: 15px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: break-word;
  background: #EFF4F3; border-radius: 8px; padding: 8px 12px; margin: 6px 0 4px; }
.t-assist { font-family: var(--serif); font-size: 14px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: break-word;
  color: #43484F; padding: 4px 12px; margin: 4px 0; border-left: 2px solid #D9D6CD; max-height: 240px; overflow-y: auto; }
.t-tools { font-size: 12px; color: var(--amber); margin: 3px 0; }
.turn.seg-mark { box-shadow: inset 3px 0 0 var(--teal); }

/* picking turns for a segment */
body.picking .pane-left { cursor: crosshair; }
body.picking .turn:hover { background: var(--teal-tint); }

/* ── labeling: question rail ────────────────────────────────────────────── */
.step { margin-bottom: 18px; }
.step.disabled { opacity: .4; pointer-events: none; }
.step-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.step-n { flex: none; width: 20px; height: 20px; border-radius: 50%; background: #ECEAE3; color: var(--muted);
  font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.step.answered .step-n { background: var(--teal); color: #fff; }
.step-title { font-weight: 700; }
.step-hint { color: var(--muted); font-size: 12.5px; margin: 0 0 8px 28px; }

.opts { display: flex; flex-wrap: wrap; gap: 6px; margin-left: 28px; }
button.opt { padding: 5px 12px; border-radius: 7px; }
button.opt.on { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 600; }
.opts.stack { flex-direction: column; align-items: stretch; }
.opts.stack button.opt { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; text-align: left; }
.opt-sub { font-size: 12px; color: var(--muted); font-weight: 400; }
button.opt.on .opt-sub { color: #CFE5E1; }

.rail textarea { width: 100%; min-height: 64px; padding: 8px 10px; border: 1px solid #C9C6BD; border-radius: 7px;
  font: inherit; background: #FDFDFB; margin-left: 0; }
.rail-foot { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
#save-state, #seg-state { font-size: 12px; color: var(--muted); }

/* ── segment editor ─────────────────────────────────────────────────────── */
.seg-help { margin: 0 0 10px 28px; padding: 8px 10px; background: var(--teal-tint); border-radius: 8px;
  color: #14554E; font-size: 12.5px; }
.seg-list { margin-left: 28px; }
.seg-row { border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; margin-bottom: 8px; background: #FBFAF7; }
.seg-row.seg-done { border-color: #9EC4BE; background: #F4F9F8; }
.seg-row.armed { border-color: var(--teal); box-shadow: 0 0 0 2px var(--teal-tint); }
.seg-line1 { display: flex; align-items: center; gap: 6px; margin-bottom: 7px; }
.seg-n { font-weight: 700; color: var(--muted); }
.seg-num { width: 60px; padding: 4px 6px; border: 1px solid #C9C6BD; border-radius: 6px; font: inherit;
  font-variant-numeric: tabular-nums; background: #fff; }
.seg-junk { margin-left: auto; font-size: 12px; color: var(--amber); display: flex; align-items: center; gap: 4px; cursor: pointer; }
.seg-del { color: var(--danger); padding: 2px 8px; }
.seg-line2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 6px; }
.seg-line2 select { padding: 6px; border: 1px solid #C9C6BD; border-radius: 6px; font: inherit; font-size: 12.5px;
  width: 100%; background: #fff; }
.seg-notes { width: 100%; padding: 5px 8px; border: 1px solid #DDDACF; border-radius: 6px; font: inherit; font-size: 12.5px; }
.seg-pick { margin-top: 6px; font-size: 12.5px; padding: 3px 10px; color: var(--teal-dark); }
.seg-pick.on { background: var(--teal-tint); border-color: var(--teal); }
#seg-add { margin: 2px 0 8px; color: var(--teal-dark); font-weight: 600; }
.seg-issue { margin: 2px 0 8px; padding: 7px 10px; border-radius: 7px; background: #FBF1EC;
  border: 1px solid #E3C2B2; color: #8C4A2F; font-size: 12.5px; }
#seg-cut { color: var(--teal-dark); font-weight: 600; }
#seg-cut.on { background: var(--teal-tint); border-color: var(--teal); }
.turn.seg-start { border-top: 2px solid var(--teal); }
body.picking .turn:hover { box-shadow: inset 0 3px 0 var(--teal); }

/* ── progress table ─────────────────────────────────────────────────────── */
.ptable { border-collapse: collapse; background: var(--panel); border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line); width: 100%; max-width: 560px; }
.ptable th, .ptable td { border-bottom: 1px solid #EFEDE6; padding: 10px 16px; text-align: left; }
.ptable th { background: #F1F0EB; font-weight: 600; }
.ptable tr:last-child td { border-bottom: none; }

/* ── rubric sheet ───────────────────────────────────────────────────────── */
#rubric-backdrop { position: fixed; inset: 0; background: rgba(30, 32, 30, .32); z-index: 19; }
#rubric-sheet { position: fixed; top: 0; right: 0; width: 640px; max-width: 92vw; height: 100vh; background: var(--panel);
  border-left: 1px solid var(--line); box-shadow: -6px 0 24px rgba(0,0,0,.14); z-index: 20; display: flex; flex-direction: column; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.sheet-head strong { font-size: 16px; }
#rubric-body { flex: 1; overflow-y: auto; padding: 6px 24px 40px; }
#rubric-body h1 { font-size: 20px; }
#rubric-body h2 { font-size: 16px; margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--line); }
#rubric-body h3 { font-size: 14px; }
#rubric-body p, #rubric-body li { font-size: 13.5px; line-height: 1.6; max-width: 72ch; }
#rubric-body code { background: #F1F0EB; border-radius: 4px; padding: 0 4px; font-size: 12.5px; }
#rubric-body table { border-collapse: collapse; margin: 10px 0; font-size: 12.5px; }
#rubric-body th, #rubric-body td { border: 1px solid var(--line); padding: 6px 9px; vertical-align: top; text-align: left; }
#rubric-body th { background: #F1F0EB; }
#rubric-body hr { border: none; border-top: 1px solid var(--line); margin: 20px 0; }
