/* Etho app. Palette and variable names follow the report (etho/report/report.py); light and dark. */
:root {
  color-scheme: light dark;
  --surface-1: #fcfcfb; --page: #f9f9f7; --text-primary: #0b0b0b; --text-secondary: #52514e; --muted: #898781;
  --grid: #e4e3df; --line: #d8d7d2; --accent: #2a78d6; --on-accent: #ffffff; --danger: #c0392b; --ok: #1b8a5f;
  --warn-bg: #fff4e0; --warn-text: #7a4a00;
  --b0: #2a78d6; --b1: #eb6834; --b2: #1baf7a; --b3: #8e5bd9; --b4: #c9a227; --b5: #d0488f; --b6: #3a9db8; --b7: #7a7a72;
  --shadow: 0 1px 2px rgba(0,0,0,.06);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface-1: #1a1a19; --page: #0d0d0d; --text-primary: #f0efec; --text-secondary: #c3c2b7; --muted: #9a998f;
    --grid: #2e2d2b; --line: #3a3936; --accent: #3987e5; --on-accent: #0b0b0b; --danger: #ef6a5b; --ok: #3ec28f;
    --warn-bg: #3a2c10; --warn-text: #f2c97a;
    --b0: #3987e5; --b1: #d95926; --b2: #199e70; --b3: #a07be8; --b4: #d9b53a; --b5: #e25da4; --b6: #4db3cf; --b7: #9a998f;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { background: var(--page); }
body { margin: 0; background: var(--page); color: var(--text-primary); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); }
header.top { border-bottom: 1px solid var(--line); background: var(--surface-1); }
header.top .in { max-width: 1120px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: baseline; gap: 20px; }
header.top .brand { font-weight: 700; font-size: 20px; letter-spacing: .02em; color: var(--text-primary); text-decoration: none; }
header.top .tag { color: var(--text-secondary); font-size: 13px; flex: 1; }
header.top .spend { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
main { max-width: 1120px; margin: 0 auto; padding: 24px; }
h1 { font-size: 24px; margin: 0 0 4px; line-height: 1.25; }
h2 { font-size: 16px; margin: 0 0 12px; color: var(--text-primary); }
h3 { font-size: 14px; margin: 16px 0 8px; color: var(--text-secondary); }
.sub, .hint { color: var(--text-secondary); font-size: 13px; }
.hint { margin-top: 6px; }
.card { background: var(--surface-1); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin: 0 0 16px;
  box-shadow: var(--shadow); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 > .card { margin: 0; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }
label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin: 0 0 4px; }
input[type=text], input[type=number], textarea, select {
  width: 100%; font: inherit; color: var(--text-primary); background: var(--page); border: 1px solid var(--line);
  border-radius: 6px; padding: 7px 9px; }
textarea { resize: vertical; min-height: 78px; line-height: 1.4; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible,
[tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button, .btn { font: inherit; font-weight: 600; cursor: pointer; border-radius: 7px; border: 1px solid var(--line);
  background: var(--surface-1); color: var(--text-primary); padding: 7px 14px; text-decoration: none; display: inline-block; }
button:hover:not(:disabled), .btn:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button.small { padding: 3px 9px; font-size: 13px; font-weight: 500; }
button.link { border: 0; background: none; color: var(--accent); padding: 0 4px; font-weight: 500; }
button:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
.row > .fit { flex: 0 0 auto; min-width: 0; }
.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 22px; text-align: center; cursor: pointer;
  color: var(--text-secondary); }
.drop.over, .drop:hover { border-color: var(--accent); }
.drop strong { color: var(--text-primary); }
.beh { display: grid; grid-template-columns: 170px 1fr auto; gap: 10px; align-items: start; margin: 0 0 10px; }
@media (max-width: 700px) { .beh { grid-template-columns: 1fr; } }
.err { color: var(--danger); font-size: 14px; margin-top: 10px; min-height: 1.2em; }
.note { background: var(--warn-bg); color: var(--warn-text); border-radius: 8px; padding: 8px 12px; font-size: 13px; margin: 0 0 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 1px 9px; border-radius: 99px;
  border: 1px solid var(--line); color: var(--text-secondary); white-space: nowrap; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex: none; }
.show { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.show .card { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.show h3 { margin: 0; color: var(--text-primary); font-size: 15px; }
.show .btn { align-self: flex-start; margin-top: auto; }
.badge { font-size: 11px; padding: 1px 8px; border-radius: 99px; background: var(--grid); color: var(--text-secondary);
  font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
/* tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 0 0 16px; }
.tile { background: var(--surface-1); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; }
.tile .k { font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .05em; }
.tile .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.25; }
.tile .s { font-size: 12px; color: var(--text-secondary); }
/* tables */
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: right; padding: 5px 8px; border-bottom: 1px solid var(--grid); vertical-align: top; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--text-secondary); font-weight: 600; white-space: nowrap; }
td { font-variant-numeric: tabular-nums; }
td.l, th.l { text-align: left; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--grid); }
.bar { height: 6px; background: var(--grid); border-radius: 3px; overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--accent); }
/* progress */
.stages { list-style: none; padding: 0; margin: 12px 0 0; }
.stages li { display: grid; grid-template-columns: 22px 120px 1fr 70px 64px; gap: 8px; align-items: center; padding: 5px 0;
  border-bottom: 1px solid var(--grid); font-size: 14px; }
.stages .msg { color: var(--text-secondary); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stages .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-secondary); font-size: 13px; }
.dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); margin: auto; }
.dot.running { border-color: var(--accent); border-top-color: transparent; animation: spin .9s linear infinite; }
.dot.done { background: var(--ok); border-color: var(--ok); }
.dot.skipped { background: var(--muted); border-color: var(--muted); }
.dot.failed { background: var(--danger); border-color: var(--danger); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .dot.running { animation: none; border-top-color: var(--accent); } }
.progress-head { display: flex; gap: 20px; flex-wrap: wrap; align-items: baseline; }
.progress-head .big { font-size: 18px; font-weight: 700; }
.progress-head .m { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
@media (max-width: 700px) { .stages li { grid-template-columns: 22px 90px 1fr 54px; } .stages li .cost { display: none; } }
/* player and ethogram */
.player { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 900px) { .player { grid-template-columns: 1fr; } }
video { width: 100%; border-radius: 8px; background: #000; display: block; max-height: 520px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin: 8px 0 0; font-size: 12px; color: var(--text-secondary); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { display: inline-block; width: 14px; height: 0; border-top: 3px solid; }
.etho svg { display: block; width: 100%; height: auto; }
.etho text { fill: var(--text-primary); font-family: inherit; }
.etho .axis text { fill: var(--text-secondary); }
.etho rect.bout { cursor: pointer; }
.etho rect.bout:hover { filter: brightness(1.12); }
.etho rect.sel { stroke: var(--text-primary); stroke-width: 2; }
.etho rect.pend { stroke: var(--danger); stroke-width: 2; stroke-dasharray: 3 2; }
.etho rect.ghost { fill: var(--muted); opacity: .55; }
.vers { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 0 0 10px; }
.vers button[aria-pressed=true] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.sel-panel { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 10px 0 0; font-size: 14px; }
.pending { list-style: none; padding: 0; margin: 8px 0; }
.pending li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--grid); font-size: 14px; }
.delta-up { color: var(--ok); } .delta-down { color: var(--danger); } .delta-0 { color: var(--muted); }
details { margin: 0 0 12px; }
details > summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
pre { background: var(--page); border: 1px solid var(--line); border-radius: 6px; padding: 10px; overflow: auto; font-size: 12px;
  max-height: 340px; white-space: pre-wrap; word-break: break-word; margin: 6px 0; }
iframe.report { width: 100%; border: 1px solid var(--line); border-radius: 8px; height: 640px; background: #fff; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.sr { position: absolute; left: -9999px; }
.thumb { max-width: 100%; border-radius: 6px; border: 1px solid var(--line); margin-top: 6px; }
footer { max-width: 1120px; margin: 0 auto; padding: 8px 24px 40px; color: var(--muted); font-size: 12px; }

/* ---- progress: phases and the elapsed-time clock */
.clock-row { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; }
.clock-row .grow { flex: 1; min-width: 260px; }
.clock { font-size: 64px; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.clock.live { color: var(--text-primary); }
.clock-cap { font-size: 13px; color: var(--text-secondary); }
.status-big { font-size: 20px; font-weight: 600; line-height: 1.3; }
.progress-meta { color: var(--text-secondary); font-variant-numeric: tabular-nums; margin-top: 4px; }
.stages.phases li { grid-template-columns: 22px 150px 1fr 96px 70px 64px; font-size: 15px; padding: 8px 0; }
.stages.phases .ph { font-weight: 600; }
.stages.phases .state { color: var(--text-secondary); font-size: 13px; text-align: right; }
.stages.phases li.pending .ph, .stages.phases li.pending .msg { color: var(--muted); }
.stages.phases .msg { white-space: normal; overflow: visible; }
.note.fail { font-size: 15px; margin: 12px 0 0; }
@media (max-width: 700px) { .clock { font-size: 44px; } .stages.phases li { grid-template-columns: 22px 110px 1fr 60px; } .stages.phases li .state, .stages.phases li .cost { display: none; } }
/* ---- planner card */
.planner table { font-size: 14px; }
.planner tr.chosen td { background: var(--grid); font-weight: 600; }
.chip.pick { font-weight: 700; color: var(--text-primary); border-color: var(--text-primary); }
.planner .facts { margin: 12px 0 0; display: grid; gap: 4px; font-size: 14px; }
.planner .facts .k { display: inline-block; min-width: 130px; color: var(--text-secondary); }
/* ---- ethogram polish, trace */
.etho rect.static { cursor: default; }
.etho path.mark { fill: var(--warn-text); stroke: var(--surface-1); stroke-width: 1.5; cursor: pointer; }
.etho path.mark:focus-visible { outline: 2px solid var(--accent); }
.trace { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 12px 0 0; font-size: 15px; }
.tstep { display: grid; grid-template-columns: 28px 1fr; gap: 8px; padding: 8px 0; border-top: 1px solid var(--grid); }
.tn { font-weight: 700; color: var(--text-secondary); }
.tt { font-weight: 600; margin: 0 0 4px; }
.verdict { border-left: 4px solid var(--line); padding: 4px 0 4px 10px; margin: 6px 0; }
.verdict.restriction { border-left-color: var(--warn-text); background: var(--warn-bg); }
.verdict.applied { border-left-color: var(--ok); }
.verdict .thumb { max-height: 150px; }
.decided { font-size: 16px; }
/* ---- sample clip */
.sample .attr { font-weight: 600; }
.sample dl { margin: 8px 0 0; }
.sample dt { font-weight: 700; margin-top: 8px; }
.sample dd { margin: 2px 0 0; color: var(--text-secondary); font-size: 14px; }
/* ---- presentation mode (?present=1): everything larger for screen recording */
html.present body { zoom: 1.3; }
html.present .clock { font-size: 96px; }
html.present main { max-width: 1400px; }
a.present-toggle { font-size: 12px; color: var(--muted); }

/* per-stage timing card: fit the card at every width (no horizontal overflow) */
.stagecard { overflow-x: auto; }
table.stagetbl { table-layout: fixed; }
table.stagetbl th:nth-child(1), table.stagetbl td:nth-child(1) { width: 38%; overflow-wrap: anywhere; }
table.stagetbl th:nth-child(3), table.stagetbl td:nth-child(3), table.stagetbl th:nth-child(4), table.stagetbl td:nth-child(4) { width: 72px; }
table.stagetbl td .chip { display: inline-block; max-width: 100%; overflow-wrap: anywhere; white-space: normal; }
@media (max-width: 700px) {
  table.stagetbl th:nth-child(2), table.stagetbl td:nth-child(2) { display: none; }
  table.stagetbl th:nth-child(1), table.stagetbl td:nth-child(1) { width: auto; }
  table.stagetbl th, table.stagetbl td { padding: 5px 4px; }
}
/* a button that is off for a stated reason */
button.primary:disabled { background: var(--grid); color: var(--text-secondary); border-color: var(--line); opacity: .8; }
.why-off { color: var(--text-secondary); font-size: 13px; font-weight: 600; }
/* a wide table in one card must not stretch the page or its neighbours: the card scrolls, the page does not */
.grid2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.grid2 > .card, .planner { min-width: 0; overflow-x: auto; }
@media (max-width: 860px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
