/* PinSight Admin: dark, phone-first, big tap targets. */
:root {
    --pico-font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    --pico-border-radius: 12px;
    --pico-background-color: #0d0e12;
    --pico-color: #e9ebf1;
    --pico-muted-color: #9aa3b5;
    --pico-primary-background: #ff453a;
    --pico-primary-border: #ff453a;
    --pico-primary-hover-background: #ff6259;
    --pico-primary: #ff7a72;
    --pico-form-element-background-color: #161821;
    --card: #161821;
    --line: rgba(255, 255, 255, 0.08);
    --ok: #32d74b;
    --warn: #ffd60a;
    --fail: #ff453a;
    --guess: #64d2ff;
}
html { -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
body { background: var(--pico-background-color); min-height: 100dvh; }
main.container { padding: 12px 16px calc(32px + env(safe-area-inset-bottom)); max-width: 760px; }
h3 { margin-bottom: 0.25rem; }
h4 { margin: 1.5rem 0 0.6rem; }
.muted { color: var(--pico-muted-color); }
.small { font-size: 0.85rem; }
.bad { color: var(--fail); }
.warn { color: var(--warn); }
.good { color: var(--ok); }

/* --- app bar --- */
.appbar {
    position: sticky; top: 0; z-index: 10; display: flex; align-items: center;
    justify-content: space-between; gap: 12px;
    padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
    background: rgba(13, 14, 18, 0.92); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.appbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: inherit;
    text-decoration: none; }
.appbar .brand img { width: 28px; height: 28px; border-radius: 7px; }
.appbar nav { display: flex; align-items: center; gap: 4px; }
.appbar nav a { padding: 8px 10px; border-radius: 8px; color: var(--pico-muted-color);
    text-decoration: none; }
.appbar nav a[aria-current] { color: var(--pico-color); background: var(--card); }
.appbar form { margin: 0; }
button.avatar { width: 34px; height: 34px; padding: 0; margin: 0 0 0 6px; border-radius: 50%;
    background: #2a2d37; border: 1px solid var(--line); color: var(--pico-color); font-weight: 700;
    font-size: 0.95rem; }
.crumbs { font-size: 0.85rem; color: var(--pico-muted-color); margin-bottom: 0.25rem; }

/* --- cards --- */
ul.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
ul.cards li { list-style: none; margin: 0; padding: 0; }
ul.cards li.card { padding: 12px 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.card-link { display: block; color: inherit; text-decoration: none; }
.card-title { font-weight: 600; word-break: break-word; }
.card progress { margin: 8px 0 4px; }
.big-action { display: block; width: 100%; padding: 16px; font-size: 1.1rem; font-weight: 600;
    text-align: center; margin: 8px 0 16px; }
.small-btn { width: auto; padding: 8px 14px; font-size: 0.9rem; margin-top: 12px; }

.badge { display: inline-block; margin-top: 6px; padding: 2px 10px; border-radius: 999px;
    font-size: 0.8rem; font-weight: 600; }
.badge.v-ok { background: rgba(50, 215, 75, 0.16); color: var(--ok); }
.badge.v-warn { background: rgba(255, 214, 10, 0.16); color: var(--warn); }
.badge.v-fail { background: rgba(255, 69, 58, 0.16); color: var(--fail); }
.badge.v-none { background: rgba(255, 255, 255, 0.08); color: var(--pico-muted-color); }

/* --- clip check --- */
.verdict-box { border-radius: 12px; padding: 14px; margin: 12px 0; border: 1px solid var(--line);
    background: var(--card); }
.verdict-box.v-ok { border-color: rgba(50, 215, 75, 0.5); }
.verdict-box.v-warn { border-color: rgba(255, 214, 10, 0.5); }
.verdict-box.v-fail { border-color: rgba(255, 69, 58, 0.6); }
.verdict-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 4px; }
.verdict-title .badge { font-size: 1rem; margin: 0; }
table.checks { width: 100%; margin: 8px 0; }
table.checks td { padding: 8px 6px; vertical-align: top; border-bottom: 1px solid var(--line);
    background: transparent; }
table.checks td.grade { width: 28px; font-weight: 800; text-align: center; }
tr.g-ok td.grade { color: var(--ok); }
tr.g-warn td.grade { color: var(--warn); }
tr.g-fail td.grade { color: var(--fail); }
table.checks .value { color: var(--pico-muted-color); margin-left: 4px; }
dl.stats { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 0.9rem; }
dl.stats dt { color: var(--pico-muted-color); font-weight: normal; }
dl.stats dd { margin: 0; }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 12px 0; }
.thumbs img { width: 100%; border-radius: 6px; display: block; }
.start-labelling { margin-top: 20px; padding: 14px; background: var(--card); border-radius: 12px;
    border: 1px solid var(--line); }
.start-labelling h4 { margin-top: 0; }

/* --- forms --- */
.choice-grid { display: grid; gap: 8px; margin-bottom: 8px; }
.choice-grid.three { grid-template-columns: 1fr; }
label.choice { display: flex; width: 100%; align-items: center; gap: 10px; padding: 14px; margin: 0;
    background: var(--card); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
label.choice:has(input:checked) { border-color: var(--pico-primary-background);
    background: rgba(255, 69, 58, 0.08); }
label.choice input { margin: 0; }
.file-drop { display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 6px; min-height: 140px; margin: 12px 0; padding: 20px; text-align: center;
    border: 2px dashed rgba(255, 255, 255, 0.2); border-radius: 14px; cursor: pointer;
    word-break: break-word; }
.file-drop-icon { font-size: 2.2rem; }
.file-drop input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
details.tip { background: var(--card); border-radius: 12px; padding: 10px 14px; margin-bottom: 16px;
    border: 1px solid var(--line); font-size: 0.9rem; }
details.tip summary { color: var(--guess); }
.up-stats { display: flex; flex-wrap: wrap; gap: 4px 14px; font-variant-numeric: tabular-nums;
    font-size: 0.9rem; }
.row-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.row-buttons button { margin: 0; }
.spinner { display: inline-block; width: 0.9em; height: 0.9em; border: 2px solid currentColor;
    border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite;
    vertical-align: -0.1em; margin-right: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- sign in --- */
body.auth { display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-box { width: 100%; max-width: 340px; text-align: center; }
.login-box label { text-align: left; }
.app-mark { width: 72px; height: 72px; border-radius: 17px; margin-bottom: 0.9rem; }
.login-box .sub { color: var(--pico-muted-color); font-size: 0.9rem; margin-bottom: 1.5rem; }
.error-msg { color: var(--fail); margin-bottom: 1rem; }

/* --- labelling --- */
body.page-label main.container { max-width: none; padding: 0 0 env(safe-area-inset-bottom); }
.label-bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
    padding: calc(6px + env(safe-area-inset-top)) 12px 6px; background: #13151b;
    border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.label-bar .back { font-size: 1.8rem; line-height: 1; padding: 0 8px; color: inherit;
    text-decoration: none; }
.pill { padding: 2px 10px; border-radius: 999px; background: #2a2d37; font-size: 0.85rem; }
.pill.visible { background: var(--ok); color: #000; }
.pill.none { background: #555a66; }
.pill.unsure { background: var(--warn); color: #000; }
#labeller { display: flex; flex-direction: column; }
.viewport { overflow: auto; max-height: 62dvh; background: #000; -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain; }
.wrap { position: relative; margin: 0 auto; touch-action: manipulation; cursor: crosshair; }
.wrap img { display: block; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
    max-width: none; }
.wrap svg { position: absolute; inset: 0; pointer-events: none; }
.hint { font-size: 0.8rem; color: var(--pico-muted-color); padding: 4px 12px; text-align: center; }
.controls { padding: 4px 12px 12px; display: grid; gap: 8px; }
.controls button { margin: 0; padding: 14px 6px; font-size: 1rem; font-weight: 600; min-height: 52px; }
.controls .row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.controls .small-row button { min-height: 44px; padding: 10px 4px; font-size: 0.85rem; font-weight: 500; }
button.act-save { background: var(--ok); border-color: var(--ok); color: #04150a; font-size: 1.15rem;
    min-height: 60px; }
button.act-save:disabled { background: #2a2d37; border-color: #2a2d37; color: var(--pico-muted-color);
    opacity: 1; }
button.act-none { background: #3b3f4b; border-color: #3b3f4b; color: #fff; }
button.act-unsure { background: rgba(255, 214, 10, 0.18); border-color: rgba(255, 214, 10, 0.4);
    color: var(--warn); }
button.act-tool { background: var(--card); border-color: var(--line); color: var(--pico-color); }
.context { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.context figure { margin: 0; cursor: pointer; }
.context figure[hidden] { display: none; }
.context img { width: 100%; display: block; border-radius: 6px; border: 1px solid var(--line); }
.context figcaption { font-size: 0.75rem; color: var(--pico-muted-color); text-align: center; }
.legend { margin: 0; }
.key-red { color: var(--fail); font-weight: 700; }
.key-blue { color: var(--guess); font-weight: 700; }
.key-grey { color: #bbb; font-weight: 700; }
.flash { min-height: 1.4em; text-align: center; font-weight: 600; }
.flash.bad { color: var(--fail); }
.flash.good { color: var(--ok); }

/* Phone on its side, tablets, desktops: frame on the left, controls on the right. */
@media (orientation: landscape) and (min-width: 600px) {
    #labeller { flex-direction: row; align-items: flex-start; }
    .stage-col { flex: 1 1 auto; min-width: 0; }
    .viewport { max-height: calc(100dvh - 52px); }
    .controls { flex: 0 0 300px; max-height: calc(100dvh - 52px); overflow-y: auto; }
    .hint { display: none; }
}
@media (orientation: landscape) and (max-height: 500px) {
    .label-bar { padding-top: 4px; padding-bottom: 4px; }
    .controls { flex-basis: 240px; }
    .controls button { min-height: 44px; padding: 8px 4px; }
    button.act-save { min-height: 50px; }
    .legend { display: none; }
}

/* --- games --- */
a.add-choice { display: block; padding: 14px; border: 1px dashed rgba(100, 210, 255, 0.45);
    border-radius: 12px; color: var(--guess); text-decoration: none; text-align: center; }
@media (max-width: 420px) { .appbar .brand span { display: none; } }
.add-game { margin: 12px 0 20px; }
.add-game h4 { margin-top: 0; }
.add-game details { margin-bottom: 12px; }
.machine-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.machine-row form { margin: 0; flex: none; }
.machine-row .small-btn { margin: 0; }
.machine-row.is-hidden .card-title { color: var(--pico-muted-color); }

/* --- burst playback --- */
.burst { display: grid; grid-template-columns: 5.5rem 1fr 3.5rem; gap: 8px; align-items: center;
    padding: 6px 12px 0; }
.burst button { margin: 0; min-height: 44px; padding: 8px 4px; font-size: 1rem; font-weight: 600; }
.burst input[type=range] { margin: 0; }
button.act-play { background: #3a6ff2; border-color: #3a6ff2; color: #fff; }
.burst-nav { display: grid; grid-template-columns: 5.5rem 1fr 5.5rem; gap: 8px; align-items: center;
    padding: 6px 12px 0; }
.burst-nav button { margin: 0; min-height: 40px; padding: 6px 4px; font-size: 0.9rem; font-weight: 600; }
.burst-where { font-size: 0.8rem; color: var(--pico-muted-color); text-align: center; }
.wrap canvas { position: absolute; inset: 0; pointer-events: none; }

/* --- event review --- */
.events-card { margin-top: 16px; }
.events-card h4 { margin-top: 0; }
.ev-timeline-wrap { margin: 8px 0 12px; }
.ev-timeline { width: 100%; height: 56px; display: block; cursor: pointer; }
.tl-bar { fill: #22252e; }
.tl-unknown { fill: #3a3d48; }
.tl-ev { stroke: #0d0e12; stroke-width: 1.5; }
.tl-ev.drain, .ev-dot.drain, .k.drain { fill: #ff453a; color: #ff453a; background: #ff453a; }
.tl-ev.launch, .ev-dot.launch, .k.launch { fill: #32d74b; color: #32d74b; background: #32d74b; }
.tl-ev.new_ball, .ev-dot.new_ball, .k.new_ball { fill: #64d2ff; color: #64d2ff; background: #64d2ff; }
.tl-ev.hold, .ev-dot.hold, .k.hold { fill: #ffd60a; color: #ffd60a; background: #ffd60a; }
.tl-ev.rejected { opacity: 0.35; }
.tl-ev.confirmed, .tl-ev.fixed { stroke: #fff; stroke-width: 2; }
.tl-now { stroke: #fff; stroke-width: 2; }
.tl-tick { fill: #9aa3b5; font-size: 10px; }
.ev-legend .k { background: none; }
.ev-player { margin-bottom: 12px; }
.ev-stage { display: flex; justify-content: center; background: #000; border-radius: 10px; overflow: hidden; }
.ev-stage canvas { display: block; }
.ev-key { margin: 6px 0; }
.ev-ring { color: #ffd60a; font-weight: 700; }
.ev-actions { display: grid; gap: 8px; margin-top: 8px; }
.ev-actions button, .ev-add { margin: 0; min-height: 50px; font-weight: 600; }
.ev-add { width: 100%; margin-top: 8px; }
.ev-selected { font-size: 0.95rem; }
.ev-editor { margin-top: 10px; display: grid; gap: 10px; }
.ev-editor-title { font-weight: 700; }
.choice-row { display: flex; flex-wrap: wrap; gap: 6px; }
button.chip { width: auto; margin: 0; padding: 8px 12px; font-size: 0.9rem; background: var(--card);
    border: 1px solid var(--line); color: var(--pico-color); border-radius: 999px; }
button.chip.on { background: var(--pico-primary-background); border-color: var(--pico-primary-background); color: #fff; }
.ev-movetime { padding: 10px 12px; }
.ev-list .ev-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; cursor: pointer; }
.ev-row.sel { border-color: var(--pico-primary-background); }
.ev-row.rejected { opacity: 0.55; }
.ev-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.ev-badge { margin-left: auto; font-size: 0.8rem; color: var(--pico-muted-color); }
.ev-row.confirmed .ev-badge, .ev-row.fixed .ev-badge, .ev-row.added .ev-badge { color: var(--ok); }
.ev-done { margin-top: 16px; display: grid; gap: 8px; }
.ev-done button { margin: 0; }

.burst-act { display: flex; gap: 8px; padding: 6px 12px 0; }
.burst-act button { margin: 0; min-height: 48px; }
.burst-act #next-missing { flex: 0 0 7.5rem; padding: 6px 4px; font-size: 0.9rem; font-weight: 600;
    color: var(--warn); border-color: var(--warn); }
button.approve-burst { flex: 1; font-size: 1rem; }
/* frames where the model saw no ball: yellow ticks under the burst slider */
.scrub { position: relative; padding-bottom: 8px; }
.scrub-ticks { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; pointer-events: none; }
.scrub-ticks i { position: absolute; top: 0; width: 3px; height: 6px; margin-left: -1.5px;
    background: var(--warn); border-radius: 1px; }
.scrub-ticks i.weak { background: #ff9f0a; } /* a weaker guess to check (D-084) */
.scrub-ticks i.odd { background: #ff375f; } /* two balls at once, or a jump: usually a lamp */
button.approve-burst.armed { background: var(--warn); border-color: var(--warn); color: #1d1600; }

/* --- Models page (D-109) --- */
table.compare { width: 100%; font-size: 0.9rem; margin: 8px 0; }
table.compare td.better { color: var(--ok); font-weight: 600; }
table.compare td.better::after { content: " ▲"; }
table.compare td.worse { color: var(--bad, #ff453a); font-weight: 600; }
table.compare td.worse::after { content: " ▼"; }
.pin-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.pin-buttons form { flex: 1; margin: 0; }
.pin-buttons button { width: 100%; margin: 0; }
