:root {
  --bg: #0e1116; --panel: #171b23; --line: #2a303b; --fg: #e6e9ef; --muted: #8a93a3;
  --accent: #4f8cff; --good: #35c46f; --bad: #ff5c5c; --warn: #ffb547; --fum: #ffb547; --int: #4f8cff;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; }
header { display: flex; align-items: center; gap: 20px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--panel); }
header h1 { font-size: 17px; margin: 0; letter-spacing: .3px; }
nav button { background: transparent; color: var(--muted); border: 1px solid transparent; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 14px; }
nav button.active, nav button:hover { color: var(--fg); border-color: var(--line); background: var(--bg); }
main { padding: 16px; max-width: 1400px; margin: 0 auto; }
h2 { font-size: 15px; margin: 0 0 10px; color: var(--fg); }
.muted { color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.row.spread { justify-content: space-between; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px 14px; margin-bottom: 12px; }
.grid label.wide { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.row label { flex-direction: row; align-items: center; gap: 6px; }
input, select, textarea { background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 14px; }
input[type=checkbox] { width: auto; }
textarea { font: inherit; font-size: 14px; resize: vertical; line-height: 1.35; }
button { background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; cursor: pointer; font-size: 14px; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { border-color: var(--bad); color: var(--bad); }
kbd { background: var(--bg); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 6px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

/* video */
.video-wrap { position: relative; background: #000; border-radius: 10px; overflow: hidden; }
.video-wrap video { display: block; width: 100%; max-height: 82vh; background: #000; }
.video-wrap.small video { max-height: 52vh; }
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; background: rgba(0,0,0,.55); font-size: 22px; }
.overlay:empty { display: none; }
.overlay .big { font-size: 64px; font-weight: 800; letter-spacing: 1px; }
.overlay .resultcard { background: rgba(14,17,22,.92); border: 1px solid var(--line); border-radius: 12px; padding: 20px 28px; min-width: 420px; max-width: 900px; text-align: left; font-size: 16px; }
.overlay .resultcard h3 { margin: 0 0 8px; font-size: 26px; }
.overlay .resultcard .stat { font-size: 40px; font-weight: 800; margin: 4px 0 10px; }
.good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); }
.tag-fumble { color: var(--fum); } .tag-interception { color: var(--int); }
.flash { position: absolute; top: 16px; right: 20px; font-size: 56px; font-weight: 900; color: #fff; text-shadow: 0 0 18px rgba(0,0,0,.9); animation: pop .35s ease-out; }
@keyframes pop { from { transform: scale(1.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.statusbar { padding: 8px 4px; color: var(--muted); font-size: 13px; display: flex; gap: 18px; }

/* annotate */
#view-annotate { display: grid; grid-template-columns: 280px 1fr; gap: 14px; align-items: start; }
#ann-list { max-height: calc(100vh - 110px); overflow-y: auto; padding: 8px; }
#ann-list .item { padding: 8px 10px; border-radius: 6px; cursor: pointer; display: flex; gap: 8px; align-items: center; font-size: 13px; }
#ann-list .item:hover { background: var(--bg); }
#ann-list .item.active { background: var(--bg); border: 1px solid var(--accent); }
#ann-list .item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; }
#ann-list .item .dot.annotated { background: var(--good); }
#ann-list .item .dot.priced { background: var(--accent); }
#ann-list .item .dot.missing { background: var(--bad); }
#ann-list .item .dot.review { background: var(--warn); }
#ann-list .item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.readout { font-family: ui-monospace, Menlo, monospace; font-size: 14px; padding: 8px 2px 2px; display: flex; gap: 22px; flex-wrap: wrap; }
.readout b { color: var(--accent); }
.keys { margin: 4px 0 0; font-size: 12px; }
.list { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; max-height: 320px; overflow-y: auto; }
.list .item { padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; font-size: 13px; display: flex; gap: 10px; }
.list .item:hover { border-color: var(--accent); }
.list .item .mono { font-family: ui-monospace, Menlo, monospace; color: var(--muted); flex: none; }
canvas { width: 100%; display: block; background: var(--bg); border-radius: 8px; }
.pricegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.pricegrid .cell { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.pricegrid .cell .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.pricegrid .cell .v { font-size: 20px; font-weight: 700; font-family: ui-monospace, Menlo, monospace; }
.pricegrid .cell .s { font-size: 12px; color: var(--muted); }

/* results */
.scroll-x { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
td.num, th.num { text-align: right; font-family: ui-monospace, Menlo, monospace; }
@media (max-width: 900px) { #view-annotate { grid-template-columns: 1fr; } }

/* annotate v2: timeline, scrub buttons, mark box */
[hidden] { display: none !important; }
#ann-list-wrap { max-height: calc(100vh - 110px); overflow-y: auto; padding: 8px; }
#ann-list-wrap .listhead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 10px; padding: 2px 6px 8px; font-size: 12px; }
#ann-list-wrap .listhead label { white-space: nowrap; }
label.inline { flex-direction: row; align-items: center; gap: 6px; }
.timeline { position: relative; height: 34px; margin: 10px 0 6px; cursor: pointer; user-select: none; touch-action: none; }
.timeline .tl-track { position: absolute; left: 0; right: 0; top: 12px; height: 10px; background: var(--line); border-radius: 5px; }
.timeline .tl-head { position: absolute; top: 6px; width: 2px; height: 22px; background: var(--fg); transform: translateX(-1px); pointer-events: none; }
.timeline .tl-event { position: absolute; top: 4px; width: 0; height: 26px; border-left: 3px solid var(--fum); transform: translateX(-1.5px); pointer-events: none; }
.timeline .tl-event.confirmed { border-left-color: var(--good); }
.timeline .tl-event.other { border-left-color: var(--muted); }
.timeline .tl-event::after { content: attr(data-label); position: absolute; top: -2px; left: 6px; font: 11px ui-monospace, Menlo, monospace; white-space: nowrap; color: inherit; }
.timeline .tl-t0, .timeline .tl-t1 { position: absolute; top: 24px; font: 10px ui-monospace, Menlo, monospace; }
.timeline .tl-t0 { left: 0; } .timeline .tl-t1 { right: 0; }
.row.scrub { gap: 6px; }
.row.scrub button { padding: 5px 9px; font-size: 13px; font-variant-numeric: tabular-nums; }
.markbox { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
button.big { font-size: 17px; padding: 10px 18px; border-radius: 8px; }
button.big:disabled { opacity: .45; cursor: default; }
#ann-typepick { display: flex; flex-direction: column; gap: 8px; flex: 1 1 420px; }
#ann-typepick .row { gap: 8px; }
button.type { font-weight: 600; padding: 9px 14px; font-size: 15px; }
button.type kbd { margin-left: 6px; }
button.type.fumble { border-color: var(--fum); color: var(--fum); }
button.type.interception { border-color: var(--int); color: var(--int); }
button.type.other { border-color: var(--muted); color: var(--fg); }
button.type.selected, button.type:hover { background: var(--panel); }
button.type.selected { box-shadow: 0 0 0 2px currentColor inset; }
button.ghost { border-color: transparent; color: var(--muted); }
#ann-other-row input { flex: 1 1 280px; }
#ann-mark-status { font-size: 14px; flex: 1 1 100%; min-height: 1.3em; }
#ann-mark-status b { font-family: ui-monospace, Menlo, monospace; }
.tag-other { color: var(--muted); }
#ann-list .item .dot.other { background: var(--muted); }
details.card > summary, form.card > details > summary { cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 12px; }
details summary::-webkit-details-marker { display: none; }
details summary h2 { margin: 0; }
details summary::before { content: "▸"; color: var(--muted); font-size: 12px; }
details[open] summary::before { content: "▾"; }
details[open] > summary { margin-bottom: 10px; }
details .sub { padding-top: 10px; margin-top: 10px; border-top: 1px solid var(--line); }
details .sub h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }

/* play stage + market-review panel */
.mono { font-family: ui-monospace, Menlo, monospace; }
#play-stage { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-items: start; }
#play-stage.reviewing { grid-template-columns: minmax(0, 1fr) 470px; }
#play-main > .overlay { position: static; background: none; padding: 14px 0 0; }
#play-main > .overlay .resultcard { min-width: 0; max-width: none; width: 100%; }
#review-panel { position: sticky; top: 12px; max-height: calc(100vh - 90px); overflow-y: auto; }
#review-panel h2 { margin: 0; }
#review-panel label { flex-direction: row; align-items: center; gap: 5px; font-size: 12px; }
#rev-title { font-size: 12px; margin: 6px 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#rev-chart { cursor: crosshair; touch-action: none; user-select: none; -webkit-user-select: none; }
#rev-readout { font-family: ui-monospace, Menlo, monospace; font-size: 12px; padding: 8px 2px; display: flex; flex-wrap: wrap; gap: 6px 16px; }
#rev-readout b { color: var(--accent); }
#rev-book { font: 12px ui-monospace, Menlo, monospace; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin-bottom: 8px; }
#rev-book .brow { display: flex; justify-content: space-between; }
#rev-book .ask { color: var(--bad); }
#rev-book .bid { color: var(--good); }
.tape { max-height: 170px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; font: 12px ui-monospace, Menlo, monospace; }
.tape .trow { display: grid; grid-template-columns: 62px 52px 62px 1fr; gap: 8px; padding: 2px 10px; }
.tape .trow.cur { background: var(--bg); box-shadow: inset 2px 0 0 var(--accent); }
.tape .buy { color: var(--good); }
.tape .sell { color: var(--bad); }
.revlist { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; max-height: 240px; overflow-y: auto; }
.revlist .mrow { display: grid; grid-template-columns: 30px minmax(0, 1fr) 70px 46px 46px; gap: 8px; align-items: center; padding: 3px 8px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.revlist .mrow:hover { background: var(--bg); }
.revlist .mrow.focus { background: var(--bg); box-shadow: inset 0 0 0 1px var(--accent); }
.revlist .chip { font: 10px ui-monospace, Menlo, monospace; color: var(--muted); }
.revlist .mlabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.revlist .num { text-align: right; font-family: ui-monospace, Menlo, monospace; }
@media (max-width: 1100px) {
  #play-stage.reviewing { grid-template-columns: 1fr; }
  #review-panel { position: static; max-height: none; }
}

/* hosted instance: who is signed in */
#whoami { margin-left: auto; font-size: 12px; }
#whoami a { color: var(--muted); }
#whoami a:hover { color: var(--fg); }
