:root {
  --bg: #f7f7f5; --fg: #1d1d1f; --muted: #6b6b70; --panel: #ffffff; --line: #d9d9de;
  --left: #2f6fde; --right: #e8770e; --centre: #9a9aa2; --away: #8b46d6; --cant_tell: #26262b; --none: #e6e6ea;
  --error: #b42318;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #18181b; --fg: #ececf0; --muted: #a0a0aa; --panel: #232328; --line: #3a3a42; --none: #34343c; --cant_tell: #f0f0f3; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.screen { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }
h1 { margin: 0 0 4px; font-size: 24px; }
.muted { color: var(--muted); }
.error { color: var(--error); }
form { display: grid; gap: 14px; max-width: 560px; margin: 20px 0; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
label { display: grid; gap: 4px; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; }
fieldset label { display: block; }
legend { font-weight: 600; margin-bottom: 4px; }
input, select, button { font: inherit; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--fg); }
button { cursor: pointer; }
button[type=submit] { background: var(--left); color: #fff; border-color: transparent; justify-self: start; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--bg); }
.status-done { color: #1f8a3b; }
.status-partial { color: var(--right); }
.status-blocked { color: var(--muted); font-style: italic; }
tbody tr.blocked { cursor: not-allowed; }
#save-state.error { color: var(--error); font-weight: 600; }
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--none); margin-left: 6px; }
#loading { height: 28px; background: var(--none); border-radius: 6px; position: relative; overflow: hidden; }
#loading-bar { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--left); opacity: .35; }
#loading-text { position: relative; padding: 0 10px; line-height: 28px; font-size: 13px; }
.frame-wrap { position: relative; background: #000; border-radius: 8px; overflow: hidden; }
#frame { display: block; width: 100%; max-height: 66vh; object-fit: contain; image-rendering: auto; }
#current-code { position: absolute; left: 12px; bottom: 12px; padding: 4px 10px; border-radius: 6px; font-weight: 700; color: #fff; background: rgba(0,0,0,.55); }
.readout { display: flex; flex-wrap: wrap; gap: 18px; margin: 10px 0; font-variant-numeric: tabular-nums; }
.timelines { display: grid; grid-template-columns: 90px 1fr; gap: 4px 10px; align-items: center; }
.tl-label { font-size: 12px; color: var(--muted); }
canvas { width: 100%; border-radius: 4px; cursor: pointer; background: var(--none); }
.legend { margin-top: 14px; display: grid; gap: 8px; font-size: 14px; }
.keys { display: flex; flex-wrap: wrap; gap: 6px 18px; }
kbd, button.key { display: inline-block; min-width: 22px; text-align: center; padding: 1px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: var(--panel); font: 12px ui-monospace, monospace; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; }
.sw.left { background: var(--left); } .sw.right { background: var(--right); } .sw.centre { background: var(--centre); }
.sw.away { background: var(--away); } .sw.cant_tell { background: var(--cant_tell); }
button.key { cursor: pointer; color: var(--fg); margin: 0 1px; }
button.key:hover { background: var(--none); }
.hint { margin: 0; font-size: 13px; }
.code-legend, .chart-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; margin: 8px 0 0; color: var(--muted); }
.sw.none { background: var(--none); border: 1px solid var(--line); }
.sw.bg { background: linear-gradient(90deg, color-mix(in srgb, var(--left) 25%, transparent), color-mix(in srgb, var(--right) 25%, transparent)); }
i.marker { display: inline-block; width: 3px; height: 12px; background: #e11d48; vertical-align: -1px; }
#chart-wrap { margin-top: 16px; }
#chart-wrap h3 { margin: 0 0 6px; font-size: 15px; }
#chart { width: 100%; height: 300px; border-radius: 6px; background: var(--panel); border: 1px solid var(--line); }
i.ln { display: inline-block; width: 22px; height: 0; vertical-align: 3px; border-top: 2px solid; }
i.ln.h { border-color: var(--fg); } i.ln.v { border-color: #0f9d8f; } i.ln.c { border-color: #b8860b; }
i.ln.cut { border-top: 2px dashed var(--muted); } i.ln.nf { border-top: 6px solid var(--none); }
.readout-line { font-variant-numeric: tabular-nums; font-size: 14px; margin: 6px 0 0; }

/* hosted site */
#topbar { display: flex; align-items: center; gap: 14px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
#topbar nav { display: flex; gap: 6px; }
#topbar nav button.active { background: var(--none); font-weight: 600; }
#topbar .spacer { flex: 1; }
button.link { border: 0; background: none; color: var(--left); padding: 4px 6px; }
h2 { font-size: 18px; margin: 28px 0 10px; }
.row { display: flex; gap: 8px; }
a.button { display: inline-block; padding: 6px 12px; border-radius: 6px; background: var(--left); color: #fff; text-decoration: none; }
#lead-table tbody tr, #users-table tbody tr, #audit-table tbody tr { cursor: default; }
td.actions { white-space: nowrap; }
td.actions button { font-size: 13px; padding: 3px 8px; }
table.compact td, table.compact th { padding: 4px 8px; font-size: 13px; }
.notice { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
code { font: 13px ui-monospace, monospace; }
