:root {
  --bg: #0b0d10; --panel: #151a20; --line: #262e38; --text: #e6e9ee; --muted: #8b95a3;
  --accent: #3fa7ff; --rec: #e0a030; --bad: #d04848; --ok: #3fbf7f;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(12px, env(safe-area-inset-left));
  max-width: 1600px; margin: 0 auto; -webkit-tap-highlight-color: transparent; }

header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 0 8px; flex-wrap: wrap; }
.clock { font-size: 16px; font-variant-numeric: tabular-nums; }
.clock strong { font-size: 20px; }
#rate-badge { color: var(--rec); font-weight: 600; }
.status { color: var(--muted); font-size: 12px; }
.banner { background: #3a1d1d; border: 1px solid var(--bad); color: #ffd6d6; padding: 8px 10px; border-radius: 8px; margin-bottom: 8px; }

.tiles { display: grid; gap: 6px; margin: 0 auto; }
/* keep the timeline and controls on screen: 2 rows of 16:9 = width x 9/16; single = focus + a 1/3-width row = width x 0.75 */
.tiles.mode-grid { grid-template-columns: repeat(2, 1fr); max-width: calc((100dvh - 230px) * 16 / 9); }
.tiles.mode-single { grid-template-columns: repeat(3, 1fr); max-width: calc((100dvh - 230px) / 0.75); }
.tiles.mode-single .tile.focus { grid-column: 1 / -1; order: -1; }
.tile { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 6px; overflow: hidden; cursor: pointer; }
.tile video, .tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.tile .label { position: absolute; left: 6px; top: 6px; background: rgba(0,0,0,.55); padding: 2px 7px; border-radius: 4px; font-size: 12px; pointer-events: none; }
.tile .msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center;
  color: var(--muted); padding: 12px; font-size: 13px; pointer-events: none; }
.mode-single .tile:not(.focus) .label { font-size: 10px; padding: 1px 5px; }
.mode-single .tile:not(.focus) .msg { font-size: 10px; padding: 4px; }
[hidden] { display: none !important; }

.timeline-wrap { margin: 8px 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
#timeline { display: block; width: 100%; height: 84px; touch-action: none; cursor: crosshair; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; padding-bottom: 12px; }
.group { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
button, select, input[type=date] { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  height: 36px; padding: 0 10px; font: inherit; min-width: 40px; }
button:active { background: var(--line); }
button.primary { background: var(--accent); color: #001424; border-color: var(--accent); font-weight: 700; min-width: 56px; }
form.inline { display: inline; margin: 0; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #222a33; border: 1px solid var(--line); padding: 8px 14px; border-radius: 8px; }

@media (max-width: 700px) {
  .clock strong { font-size: 18px; }
  .controls { justify-content: center; }
  button, select, input[type=date] { height: 40px; }
}

/* login */
.login { max-width: 340px; margin: 18vh auto 0; display: grid; gap: 10px; }
.login input { height: 44px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 0 12px; font: inherit; font-size: 16px; }
.login button { height: 44px; }
.login .err { color: #ff9c9c; min-height: 1.4em; }
