:root {
  --bg: #fafaf9; --fg: #1c1917; --muted: #78716c; --line: #e7e5e4; --card: #fff;
  --accent: #2563eb; --warn-bg: #fffbeb; --warn-line: #f59e0b; --err: #b91c1c;
  font: 14px/1.5 system-ui, -apple-system, Segoe UI, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0c0a09; --fg: #e7e5e4; --muted: #a8a29e; --line: #292524; --card: #1c1917;
          --warn-bg: #2a1f05; --err: #f87171; color-scheme: dark; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); padding: 24px 16px 64px; }
main { max-width: 1100px; margin: 0 auto; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 10px; }
h3 { font-size: 13px; margin: 20px 0 8px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.sub, .muted { color: var(--muted); }
.small { font-size: 12px; }
.sub { margin: 4px 0 16px; }
.card, .limits { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.limits { background: var(--warn-bg); border-left: 4px solid var(--warn-line); }
.limits ul { margin: 0 0 10px; padding-left: 18px; }
.limits li { margin-bottom: 4px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.two .card { margin-bottom: 16px; }
@media (max-width: 760px) { .two { grid-template-columns: 1fr; } }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row.center { align-items: center; }
.row.between { justify-content: space-between; align-items: center; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: 6px; margin-top: 8px; color: var(--fg); }
input[type=text], input:not([type]), input[type=number] {
  font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg);
}
input[type=number] { width: 120px; }
input:not([type]) { width: 280px; max-width: 100%; }
button { font: inherit; padding: 6px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); cursor: pointer; }
button:not(:disabled):hover { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
#liveStart:not(:disabled), #upload:not(:disabled) { background: var(--accent); color: #fff; border-color: var(--accent); }
.timer { font: 600 18px ui-monospace, monospace; }
.timer.warn { color: var(--err); }
.meter { height: 6px; background: var(--line); border-radius: 3px; margin-top: 12px; overflow: hidden; }
#level { height: 100%; width: 0; background: #16a34a; transition: width .08s; }
.error { color: var(--err); background: color-mix(in srgb, var(--err) 10%, transparent); padding: 8px 10px; border-radius: 6px; margin-bottom: 12px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
.stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat.big { border-color: var(--accent); }
.stat.big b { font-size: 30px; color: var(--accent); }
.stat span { font-size: 12px; color: var(--muted); }
.good { color: #16a34a; } .bad { color: var(--err); }

.timeline { border: 1px solid var(--line); border-radius: 6px; padding: 8px; overflow-x: auto; }
.lane { display: grid; grid-template-columns: 90px 1fr; align-items: center; gap: 8px; height: 22px; }
.lane .bar { position: relative; height: 14px; background: var(--line); border-radius: 2px; }
.lane .seg { position: absolute; top: 0; bottom: 0; border-radius: 2px; cursor: pointer; min-width: 2px; }
.axis { display: grid; grid-template-columns: 90px 1fr; gap: 8px; font-size: 11px; color: var(--muted); }
.axis div:last-child { display: flex; justify-content: space-between; }
#player { width: 100%; margin-top: 10px; }

.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 500; }
#history tr[data-id] { cursor: pointer; }
#history tr[data-id]:hover td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.chip { display: inline-block; padding: 0 8px; border-radius: 10px; color: #fff; font-size: 12px; font-weight: 600; }

.turn { display: grid; grid-template-columns: 60px 92px 1fr; gap: 8px; padding: 5px 4px; border-radius: 4px; cursor: pointer; }
.turn:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.turn .t { color: var(--muted); font: 12px ui-monospace, monospace; padding-top: 2px; }
.interim { color: var(--muted); font-style: italic; padding: 4px; }
@media (max-width: 560px) { .turn { grid-template-columns: 52px 1fr; } .turn .txt { grid-column: 1 / -1; } }
