:root {
  --bg: #05080b;
  --panel: #0a0f14;
  --panel-2: #0e151c;
  --line: #1d2933;
  --line-soft: #14202a;
  --text: #f4f7f9;
  --muted: #82909c;
  --green: #22d65f;
  --green-dark: #0e7c36;
  --blue: #1688ff;
  --red: #ef3447;
  --amber: #ffad16;
  --purple: #9b55ff;
  --cyan: #21c6e6;
  --radius: 10px;
  --shadow: 0 16px 45px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
body {
  color: var(--text);
  background: radial-gradient(circle at 50% -20%, #12202a 0, #070b0f 32%, #030506 72%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
[hidden] { display: none !important; }

.var-body { overflow: hidden; overscroll-behavior: none; }
.var-app {
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr) 34px;
}

.topbar {
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 7px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(4, 8, 11, .96);
  backdrop-filter: blur(12px);
  z-index: 20;
}
.brand-lockup, .topbar-actions, .review-status { display: flex; align-items: center; }
.brand-lockup { gap: 10px; }
.brand-logo { width: 96px; height: 42px; object-fit: contain; object-position: left center; }
.version-pill, .fps-label {
  border: 1px solid #2a3640;
  color: #c5ced4;
  background: #0c1217;
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
}
.review-status {
  min-width: 250px;
  justify-content: center;
  gap: 9px;
  padding: 6px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #10171d, #0b1116);
}
.review-status > div { display: flex; gap: 12px; align-items: baseline; }
.review-status strong { font-size: 14px; letter-spacing: .04em; }
.review-status span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.status-dot, .camera-live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px rgba(34,214,95,.8);
}
.topbar-actions { justify-content: flex-end; gap: 8px; }
.top-action, .icon-action {
  height: 36px;
  border: 1px solid #26323c;
  background: #0a1015;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.top-action { padding: 0 14px; display: inline-flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 800; letter-spacing: .04em; }
.icon-action { width: 38px; }
.top-action:hover, .icon-action:hover { border-color: #435361; background: #111920; transform: translateY(-1px); }
.live-indicator { color: var(--green); border-color: rgba(34,214,95,.35); }

.workspace {
  min-height: 0;
  min-width: 0;
  padding: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 306px;
  gap: 8px;
}
.review-stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 28px 98px;
  gap: 7px;
}
.video-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #000;
  box-shadow: var(--shadow);
}
.view-container, .video-viewport, .media-surface { width: 100%; height: 100%; }
.video-viewport { overflow: hidden; position: relative; background: #000; }
.media-surface {
  position: relative;
  transform-origin: center center;
  transition: transform .15s ease-out;
  will-change: transform;
}
.video-js {
  width: 100% !important;
  height: 100% !important;
  background: #000;
}
.video-js .vjs-tech { object-fit: contain; }
.video-js .vjs-control-bar, .video-js .vjs-big-play-button, .video-js .vjs-error-display { display: none !important; }
#drawCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  touch-action: none;
  z-index: 5;
}
#drawCanvas.drawing { pointer-events: auto; cursor: crosshair; }
.video-overlay {
  position: absolute;
  z-index: 8;
  top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(5, 9, 12, .78);
  backdrop-filter: blur(8px);
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 11px;
}
.video-overlay strong { color: var(--green); }
.video-overlay span:last-child { color: #c6cdd3; }
.top-left { left: 12px; }
.top-right { right: 12px; }
.compact-overlay-actions { padding: 3px; gap: 3px; }
.compact-overlay-actions button {
  height: 28px;
  min-width: 30px;
  border: 0;
  border-radius: 4px;
  color: #e6ecef;
  background: rgba(255,255,255,.05);
  cursor: pointer;
  font-size: 10px;
}
.compact-overlay-actions button:hover { background: rgba(255,255,255,.14); }
.draw-palette {
  position: absolute;
  z-index: 11;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  background: rgba(7, 12, 16, .93);
  border: 1px solid #2c3a44;
  border-radius: 7px;
  box-shadow: 0 10px 25px rgba(0,0,0,.45);
}
.draw-palette input[type="color"] { width: 28px; height: 28px; padding: 0; border: 0; background: transparent; }
.draw-palette button { height: 28px; border: 1px solid #2c3943; border-radius: 4px; background: #111820; cursor: pointer; }
.thickness-control { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 11px; }
.thickness-control input { width: 86px; }

.media-error {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  color: #d8e0e5;
  background: radial-gradient(circle, rgba(17,24,31,.8), rgba(0,0,0,.94));
}
.media-error > i { font-size: 30px; color: var(--amber); }
.media-error span { max-width: 480px; color: var(--muted); font-size: 12px; }
.media-error button { margin-top: 5px; border: 1px solid #34444f; border-radius: 5px; background: #111a21; padding: 7px 13px; cursor: pointer; }

.quad-view { position: relative; padding: 43px 5px 5px; background: #030608; }
.quad-toolbar {
  position: absolute;
  z-index: 12;
  left: 5px;
  right: 5px;
  top: 5px;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 9px;
  border: 1px solid #1e2b35;
  border-radius: 6px;
  background: rgba(8,14,18,.96);
  color: #82909b;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .04em;
}
.quad-toolbar strong { color: #f4f7f9; }
.quad-toolbar button {
  margin-left: auto;
  height: 24px;
  border: 1px solid #2c3b46;
  border-radius: 4px;
  padding: 0 9px;
  background: #101820;
  color: #eef3f5;
  cursor: pointer;
  font-size: 9px;
  font-weight: 800;
}
.quad-toolbar button:hover { border-color: var(--blue); color: #8bc8ff; }
.quad-sync-lock { color: var(--green); }
.quad-grid { width: 100%; height: 100%; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 5px; }
.quad-cell {
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
  border: 1px solid #21303a;
  border-radius: 7px;
  background: #000;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
  touch-action: manipulation;
}
.quad-cell:hover { border-color: #425866; }
.quad-cell:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.quad-cell.selected { border-color: var(--blue); box-shadow: inset 0 0 0 2px rgba(22,136,255,.4), 0 0 18px rgba(22,136,255,.16); }
.quad-cell-header {
  position: absolute;
  z-index: 6;
  left: 8px;
  right: 8px;
  top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}
.quad-label { border-radius: 4px; background: rgba(5,9,12,.84); border: 1px solid rgba(255,255,255,.12); padding: 4px 7px; color: var(--green); font-size: 10px; font-weight: 800; }
.quad-full-button {
  pointer-events: auto;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 5px;
  background: rgba(5,9,12,.84);
  color: #f3f6f8;
  cursor: pointer;
}
.quad-full-button:hover { border-color: var(--blue); color: #8bc8ff; }
.quad-cell-status {
  position: absolute;
  z-index: 5;
  left: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px;
  padding: 3px 7px;
  background: rgba(5,9,12,.82);
  color: #93a0aa;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .05em;
  pointer-events: none;
}
.quad-sync-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 7px rgba(255,173,22,.55); }
.quad-cell.synced .quad-sync-dot { background: var(--green); box-shadow: 0 0 7px rgba(34,214,95,.65); }
.quad-cell.drifting .quad-sync-dot { background: var(--amber); }
.quad-cell.unsynced .quad-sync-dot { background: var(--red); box-shadow: 0 0 7px rgba(239,52,71,.65); }
.quad-video, .quad-video .vjs-tech { pointer-events: none; }

.timeline-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 58px;
  align-items: center;
  gap: 8px;
  padding: 0 9px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: #080d11;
  color: #9ca8b1;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.timeline-row > span:last-child { text-align: right; }
.timeline-wrap { position: relative; height: 18px; display: flex; align-items: center; }
#timeline {
  width: 100%;
  height: 3px;
  margin: 0;
  appearance: none;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--green) var(--timeline-progress, 0%), #27313a var(--timeline-progress, 0%));
  outline: none;
  cursor: pointer;
}
#timeline::-webkit-slider-thumb { appearance: none; width: 13px; height: 13px; border-radius: 50%; background: var(--green); border: 2px solid #0a1116; box-shadow: 0 0 0 1px rgba(34,214,95,.35); }
#timeline::-moz-range-thumb { width: 13px; height: 13px; border: 2px solid #0a1116; border-radius: 50%; background: var(--green); }
.tag-markers { position: absolute; inset: 0; pointer-events: none; }
.timeline-marker { position: absolute; top: 1px; width: 7px; height: 7px; border-radius: 2px; background: var(--amber); transform: translateX(-50%); box-shadow: 0 0 7px rgba(255,173,22,.55); }
.timeline-marker.goal { background: var(--green); }
.timeline-marker.offside { background: var(--purple); }
.timeline-marker.penalty { background: var(--red); }
.timeline-marker.quad { outline: 1px solid #bd8cff; outline-offset: 2px; }

.control-deck {
  min-width: 0;
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #0d141a, #080d11);
  box-shadow: var(--shadow);
  scrollbar-width: thin;
}
.control-group {
  position: relative;
  min-width: max-content;
  padding: 22px 10px 8px;
  display: flex;
  align-items: center;
  gap: 7px;
  border-right: 1px solid #1b2730;
}
.control-group:last-child { border-right: 0; }
.group-title {
  position: absolute;
  top: 6px;
  left: 11px;
  color: #74818c;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
}
.deck-button {
  width: 54px;
  height: 58px;
  border: 1px solid #2b3944;
  border-radius: 6px;
  background: linear-gradient(180deg, #111a21, #0b1116);
  color: #edf2f4;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.deck-button i { font-size: 16px; }
.deck-button small { font-size: 9px; font-weight: 700; white-space: nowrap; }
.deck-button:hover { transform: translateY(-2px); border-color: #536574; background: #152029; }
.deck-button:active, .deck-button.active { transform: translateY(0); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.deck-button.blue { border-color: rgba(22,136,255,.5); background: linear-gradient(180deg, #0d3154, #0a2036); }
.deck-button.green { border-color: rgba(34,214,95,.5); background: linear-gradient(180deg, #12552b, #0a2b18); }
.deck-button.red { border-color: rgba(239,52,71,.5); background: linear-gradient(180deg, #5a1720, #300c12); }
.deck-button.amber { border-color: rgba(255,173,22,.5); background: linear-gradient(180deg, #573809, #2b1b04); color: #ffc04a; }
.tag-button { border-color: rgba(22,136,255,.8); background: linear-gradient(180deg, #0d3d70, #0a2543); box-shadow: 0 0 16px rgba(22,136,255,.12); }
.deck-button.mini { width: 38px; }
.speed-readout { width: 62px; height: 58px; display: flex; align-items: center; justify-content: center; border: 1px solid #22303a; border-radius: 6px; background: #070c10; color: #d7e5ee; font-size: 12px; font-variant-numeric: tabular-nums; }
.utility-group { flex: 1; }

.side-rail { min-width: 0; min-height: 0; display: grid; grid-template-rows: minmax(160px, 1fr) auto 286px; gap: 8px; }
.rail-card {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #0c1319, #080d11);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.rail-heading { min-height: 54px; display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid #18242d; }
.rail-heading.compact { min-height: 45px; }
.rail-heading h2 { margin: 2px 0 0; font-size: 13px; }
.eyebrow { color: #697782; font-size: 8px; font-weight: 900; letter-spacing: .12em; }
.text-button { border: 0; background: transparent; color: #9aa7b0; font-size: 10px; cursor: pointer; }
.events-list { height: calc(100% - 54px); overflow-y: auto; padding: 6px; }
.event-item { position: relative; display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 9px; align-items: center; padding: 8px; border: 1px solid transparent; border-radius: 7px; cursor: pointer; transition: background .15s ease, border-color .15s ease; }
.event-item:hover { background: #111a21; border-color: #273640; }
.event-item:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.event-item.active { background: rgba(22,136,255,.12); border-color: rgba(57,213,255,.65); box-shadow: inset 3px 0 0 var(--blue), 0 0 14px rgba(22,136,255,.12); }
.event-item.active .event-copy strong { color: #fff; }
.event-symbol { width: 38px; height: 38px; border-radius: 6px; display: grid; place-items: center; background: #1c2730; color: var(--amber); font-size: 14px; }
.event-symbol.goal { color: var(--green); background: rgba(34,214,95,.1); }
.event-symbol.offside { color: var(--purple); background: rgba(155,85,255,.1); }
.event-symbol.penalty { color: var(--red); background: rgba(239,52,71,.1); }
.event-copy { min-width: 0; }
.event-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.event-copy span { display: block; color: var(--muted); font-size: 9px; margin-top: 2px; }
.event-meta { text-align: right; }
.event-meta strong { display: block; color: #dbe4e9; font-size: 10px; font-variant-numeric: tabular-nums; }
.event-meta span { display: inline-block; margin-top: 3px; border-radius: 3px; background: rgba(22,136,255,.16); color: #45a6ff; padding: 2px 4px; font-size: 8px; font-weight: 900; }
.event-item.quad-tag .event-meta span { background: rgba(155,85,255,.16); color: #bd8cff; }
.event-item.quad-tag .event-symbol { box-shadow: inset 0 0 0 1px rgba(155,85,255,.28); }
.event-delete { position: absolute; right: 5px; top: 4px; opacity: 0; width: 19px; height: 19px; padding: 0; border: 0; border-radius: 3px; background: #3b1016; color: #ff6372; cursor: pointer; }
.event-item:hover .event-delete { opacity: 1; }
.empty-state { height: 100%; min-height: 100px; display: flex; flex-direction: column; gap: 8px; align-items: center; justify-content: center; color: #65737e; font-size: 10px; }
.empty-state i { font-size: 24px; }

.cameras-card { min-height: 96px; }
.camera-grid { padding: 9px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.camera-chip { min-width: 0; height: 32px; border: 1px solid #283640; border-radius: 5px; background: #0a1015; color: #a9b5bd; cursor: pointer; font-size: 9px; font-weight: 800; }
.camera-chip:hover { border-color: #486071; color: #fff; }
.camera-chip.active { border-color: rgba(34,214,95,.6); background: rgba(34,214,95,.09); color: var(--green); box-shadow: inset 0 0 0 1px rgba(34,214,95,.09); }
.camera-number { display: none; }

.wheel-card { padding-bottom: 10px; }
.frame-wheel-wrap {
  height: 196px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 46px;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 2px;
}
.frame-side-button {
  height: 64px;
  border: 1px solid #2a3944;
  border-radius: 8px;
  background: #0b1217;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: border-color .15s ease, color .15s ease, transform .15s ease;
}
.frame-side-button strong {
  font-size: 18px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.frame-side-button small { color: var(--muted); font-size: 7px; }
.frame-side-button:hover { border-color: var(--blue); color: #8bc8ff; transform: translateY(-1px); }
.frame-wheel {
  --ring-rotation: 0deg;
  --wheel-size: 176px;
  position: relative;
  width: min(var(--wheel-size), 100%);
  aspect-ratio: 1 / 1;
  margin: auto;
  border-radius: 50%;
  outline: none;
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.frame-wheel:active { cursor: grabbing; }
.wheel-glow {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: conic-gradient(from -48deg, var(--green) 0 62deg, #39d5ff 62deg 192deg, #166caa 192deg 270deg, #26323a 270deg 360deg);
  filter: drop-shadow(0 0 8px rgba(34,214,95,.38)) drop-shadow(0 0 10px rgba(22,136,255,.28));
  transform: rotate(var(--ring-rotation));
  transition: transform .16s cubic-bezier(.22,.8,.3,1), filter .16s ease;
}
.wheel-glow::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: #071016;
}
.wheel-ticks {
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  transform: rotate(var(--ring-rotation));
  transition: transform .16s cubic-bezier(.22,.8,.3,1);
}
.wheel-tick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1px;
  height: 7px;
  background: #d6e0e5;
  opacity: .78;
}
.wheel-tick.major { width: 2px; height: 12px; background: #fff; opacity: 1; }
.wheel-pointer {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: -1px;
  width: 3px;
  height: 20px;
  transform: translateX(-50%);
  border-radius: 2px;
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
}
.wheel-center {
  position: absolute;
  z-index: 3;
  inset: 36px;
  border: 1px solid #34434e;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #111c24, #070c10 65%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 12px 10px 10px;
  overflow: hidden;
  text-align: center;
  box-shadow: inset 0 0 26px rgba(0,0,0,.55);
}
.wheel-center span { color: #9aa7b0; font-size: 9px; letter-spacing: .08em; }
.wheel-center strong {
  width: 100%;
  margin: 1px 0 0;
  font-size: 34px;
  line-height: .92;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.04em;
  white-space: nowrap;
}
.wheel-center strong.digits-5 { font-size: 24px; }
.wheel-center strong.digits-6 { font-size: 20px; }
.wheel-center strong.digits-7,
.wheel-center strong.digits-8,
.wheel-center strong.digits-9 { font-size: 18px; }
.wheel-center small {
  margin-top: 4px;
  color: #adb8bf;
  font-size: 10px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  white-space: nowrap;
}
.frame-wheel.stepping .wheel-glow { filter: drop-shadow(0 0 13px rgba(34,214,95,.65)) drop-shadow(0 0 14px rgba(22,136,255,.48)); }
.frame-wheel.stepping .wheel-center { animation: wheelPulse .2s ease; }
@keyframes wheelPulse { 50% { transform: scale(.975); border-color: #5d788a; } }
.wheel-actions { display: grid; grid-template-columns: 54px 1fr 54px; gap: 6px; padding: 2px 10px 0; }
.wheel-actions button { height: 30px; border: 1px solid #2a3944; border-radius: 5px; background: #0a1116; cursor: pointer; font-size: 9px; }
.wheel-actions button:hover { border-color: #4c6373; }
.wheel-help { margin: 6px 0 0; text-align: center; color: #64727c; font-size: 8px; }

.statusbar { min-width: 0; display: flex; align-items: center; gap: 20px; padding: 0 14px; border-top: 1px solid var(--line-soft); background: #05090c; color: #74818b; font-size: 9px; }
.statusbar strong { color: #aeb8bf; font-weight: 600; }
.connected { color: var(--green); font-weight: 800; }
.connected i { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px rgba(34,214,95,.6); }
.status-spacer { flex: 1; }
.logout-link { color: #a9b4bb; text-decoration: none; }
.logout-link:hover { color: #fff; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 18px; background: rgba(0,0,0,.72); backdrop-filter: blur(6px); }
.var-modal { width: min(520px, 100%); overflow: hidden; border: 1px solid #2b3b46; border-radius: 10px; background: #0b1217; box-shadow: 0 30px 80px rgba(0,0,0,.65); }
.small-modal { width: min(380px, 100%); }
.var-modal > header, .var-modal > footer { display: flex; align-items: center; justify-content: space-between; padding: 13px 15px; border-bottom: 1px solid #1d2932; }
.var-modal > footer { justify-content: flex-end; gap: 8px; border-top: 1px solid #1d2932; border-bottom: 0; }
.var-modal h2 { margin: 2px 0 0; font-size: 16px; }
.modal-close { width: 30px; height: 30px; border: 1px solid #2c3a44; border-radius: 5px; background: #111920; cursor: pointer; }
.modal-body { padding: 15px; }
.tag-context { display: flex; align-items: center; justify-content: space-between; padding: 9px 10px; margin-bottom: 12px; border: 1px solid #23313b; border-radius: 6px; background: #070c10; }
.tag-context span { color: var(--green); font-size: 10px; font-weight: 900; }
.tag-context strong { font-variant-numeric: tabular-nums; font-size: 12px; }
.quick-tags { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 12px; }
.quick-tags button { min-height: 36px; border: 1px solid #2b3943; border-radius: 5px; background: #111920; cursor: pointer; font-size: 10px; }
.quick-tags button:hover, .quick-tags button.active { border-color: var(--blue); background: rgba(22,136,255,.12); color: #80c1ff; }
.field-label { display: block; margin: 10px 0 5px; color: #9ca8b1; font-size: 10px; font-weight: 700; }
.var-input { width: 100%; border: 1px solid #2b3944; border-radius: 6px; outline: none; background: #070c10; color: #f4f7f9; padding: 10px; resize: vertical; }
.var-input:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(22,136,255,.1); }
.pin-input { text-align: center; font-size: 24px; letter-spacing: .35em; }
.modal-copy { color: #8f9ba4; font-size: 11px; }
.form-error { color: #ff6675; font-size: 10px; }
.primary-button, .secondary-button { min-height: 36px; border-radius: 5px; padding: 0 14px; cursor: pointer; font-size: 11px; font-weight: 800; }
.primary-button { border: 1px solid #1679d5; background: #1263ad; }
.secondary-button { border: 1px solid #2d3b45; background: #111920; }

.toast-stack { position: fixed; z-index: 150; right: 14px; bottom: 46px; display: flex; flex-direction: column; gap: 7px; }
.toast { min-width: 240px; max-width: 360px; padding: 10px 12px; border: 1px solid #2a3944; border-left: 3px solid var(--green); border-radius: 6px; background: #0c141a; box-shadow: 0 16px 40px rgba(0,0,0,.45); font-size: 11px; animation: toastIn .2s ease; }
.toast.error { border-left-color: var(--red); }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }


@media (max-width: 680px) {
  .quad-view { padding-top: 39px; }
  .quad-toolbar { height: 28px; gap: 8px; font-size: 8px; }
  .quad-toolbar button { height: 22px; padding: 0 7px; }
  .quad-cell-header { left: 5px; right: 5px; top: 5px; }
  .quad-cell-status { left: 5px; bottom: 5px; }
  .quad-full-button { width: 32px; height: 32px; }
}

@media (max-width: 520px) {
  .quad-grid { grid-template-columns: 1fr; grid-template-rows: repeat(4, minmax(180px, 1fr)); overflow-y: auto; }
  .quad-toolbar span:not(.quad-sync-lock) { display: none; }
  .quad-view { overflow: hidden; }
}

/* Authentication and settings */
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(22,136,255,.18), transparent 30%),
    radial-gradient(circle at bottom right, rgba(34,214,95,.12), transparent 28%),
    radial-gradient(circle at top, #15232e, #070b0e 45%, #030506);
}
.auth-shell {
  width: min(1040px, 100%);
  display: grid;
  grid-template-columns: minmax(300px, 1.05fr) minmax(340px, .95fr);
  border: 1px solid #26343e;
  border-radius: 18px;
  overflow: hidden;
  background: rgba(8, 13, 18, .92);
  box-shadow: 0 30px 80px rgba(0,0,0,.55);
  backdrop-filter: blur(14px);
}
.auth-hero {
  position: relative;
  padding: 34px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    linear-gradient(160deg, rgba(10,20,30,.98), rgba(6,11,15,.94)),
    radial-gradient(circle at 20% 20%, rgba(22,136,255,.2), transparent 34%);
  border-right: 1px solid #1c2832;
}
.auth-hero::after {
  content: "";
  position: absolute;
  right: -60px;
  bottom: -60px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(34,214,95,.12), rgba(34,214,95,0));
  pointer-events: none;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.auth-logo { width: 170px; max-width: 100%; display: block; }
.auth-version {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid #2a3944;
  background: rgba(11,18,23,.9);
  color: #c8d1d7;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
}
.auth-copy {
  position: relative;
  z-index: 1;
  margin-top: 28px;
}
.auth-kicker { color: #52a9ff; font-size: 11px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.auth-heading { margin: 12px 0 10px; font-size: clamp(30px, 4vw, 44px); line-height: 1.02; }
.auth-copy p { max-width: 36ch; color: #9fb0bc; font-size: 14px; line-height: 1.6; }
.auth-points {
  display: grid;
  gap: 10px;
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
}
.auth-points li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: #dbe4ea;
  font-size: 13px;
}
.auth-points i {
  color: var(--green);
  margin-top: 2px;
}
.auth-statusbar {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid #1b2731;
  color: #80909b;
  font-size: 11px;
}
.auth-statusbar strong { display: block; color: #f4f7f9; font-size: 12px; margin-top: 3px; }
.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px;
  background: linear-gradient(180deg, rgba(10,16,21,.98), rgba(7,11,15,.95));
}
.auth-panel-head { margin-bottom: 20px; }
.auth-panel-head h1 { margin: 0; font-size: 26px; }
.auth-subtitle { color: var(--muted); font-size: 13px; margin: 8px 0 0; line-height: 1.55; }
.auth-form { display: grid; gap: 14px; }
.auth-field { display: block; }
.auth-field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
  color: #aab5bd;
  font-size: 10px;
  letter-spacing: .12em;
  font-weight: 800;
}
.auth-field-label small { color: #6f7d87; font-size: 10px; letter-spacing: normal; }
.auth-input-wrap { position: relative; }
.auth-input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #72808a;
  pointer-events: none;
}
.auth-field input {
  width: 100%;
  min-height: 50px;
  border: 1px solid #2a3944;
  border-radius: 10px;
  background: #070c10;
  color: #fff;
  padding: 0 48px 0 42px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.auth-field input:hover { border-color: #384955; }
.auth-field input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(22,136,255,.12); background: #0a1116; }
.auth-password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #97a4ae;
  cursor: pointer;
}
.auth-password-toggle:hover { border-color: #2d3b45; background: rgba(255,255,255,.03); }
.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: #8a98a2;
  font-size: 12px;
}
.auth-meta { display: inline-flex; align-items: center; gap: 8px; }
.auth-meta-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px rgba(34,214,95,.6);
}
.caps-warning {
  min-height: 16px;
  color: #ffb454;
  font-size: 11px;
}
.auth-submit {
  width: 100%;
  min-height: 50px;
  margin-top: 2px;
  border: 1px solid #1679d5;
  border-radius: 10px;
  background: linear-gradient(180deg, #1688ff, #1062b0);
  font-weight: 800;
  letter-spacing: .08em;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
  box-shadow: 0 14px 24px rgba(22,136,255,.2);
}
.auth-submit:hover { transform: translateY(-1px); filter: brightness(1.03); }
.auth-submit:active { transform: translateY(0); }
.auth-error, .settings-message { border-radius: 10px; padding: 12px 14px; margin-bottom: 2px; font-size: 12px; }
.auth-error { border: 1px solid rgba(239,52,71,.35); background: rgba(239,52,71,.1); color: #ff8d98; }
.auth-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #1c2831;
  color: #68757f;
  font-size: 11px;
  flex-wrap: wrap;
}
.auth-footer strong { color: #aeb8bf; }
.settings-shell { width: min(1020px, 100%); max-height: calc(100vh - 36px); overflow: auto; border: 1px solid #26343e; border-radius: 16px; background: #0a1116; box-shadow: var(--shadow); }
.settings-header { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 22px; border-bottom: 1px solid #1d2932; background: rgba(10,17,22,.96); backdrop-filter: blur(8px); }
.settings-header h1 { margin: 2px 0 0; font-size: 20px; }
.settings-content { padding: 22px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.settings-field { display: block; }
.settings-field.full { grid-column: 1 / -1; }
.settings-field span { display: block; margin-bottom: 7px; color: #9da9b2; font-size: 10px; letter-spacing: .1em; font-weight: 800; }
.settings-field input { width: 100%; min-height: 44px; border: 1px solid #2a3944; border-radius: 8px; background: #070c10; color: #fff; padding: 0 12px; }
.settings-field input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(22,136,255,.12); }
.settings-help { grid-column: 1 / -1; padding: 10px 12px; border: 1px solid #26343e; border-radius: 8px; background: #070c10; color: #8897a2; font-size: 11px; line-height: 1.5; }
.settings-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.settings-message.success { border: 1px solid rgba(34,214,95,.35); background: rgba(34,214,95,.08); color: #75ef9e; }
.settings-message.error { border: 1px solid rgba(239,52,71,.35); background: rgba(239,52,71,.08); color: #ff8d98; }
@media (max-width: 1250px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 270px; }
  .side-rail { grid-template-rows: minmax(150px, 1fr) auto 260px; }
  .frame-wheel-wrap { height: 174px; grid-template-columns: 40px minmax(0, 1fr) 40px; gap: 6px; }
  .frame-wheel { --wheel-size: 160px; }
  .wheel-ticks { inset: 10px; }
  .wheel-center { inset: 32px; padding: 10px 8px 8px; }
  .wheel-center strong { font-size: 28px; }
  .wheel-center strong.digits-5 { font-size: 22px; }
  .wheel-center strong.digits-6 { font-size: 19px; }
  .wheel-center strong.digits-7,
  .wheel-center strong.digits-8,
  .wheel-center strong.digits-9 { font-size: 17px; }
  .control-group { padding-left: 7px; padding-right: 7px; gap: 5px; }
  .deck-button { width: 49px; }
}

@media (hover: none), (pointer: coarse) {
  .top-action, .icon-action, .deck-button, .camera-chip, .frame-side-button, .wheel-actions button, .secondary-button, .primary-button { min-height: 40px; }
  .control-group { gap: 8px; }
  .timeline-scrubber, input[type="range"] { min-height: 24px; }
  .timeline-row { padding-top: 2px; }
  .frame-wheel { touch-action: none; }
}

@media (max-width: 1080px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-hero { border-right: 0; border-bottom: 1px solid #1c2832; min-height: 320px; }
}

@media (max-width: 980px) {
  .var-body { overflow: auto; }
  .var-app { height: auto; min-height: 100vh; grid-template-rows: 58px auto 34px; }
  .topbar { grid-template-columns: auto 1fr; }
  .review-status { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .review-stage { min-height: 720px; }
  .side-rail { grid-template-rows: 260px auto 290px; }
  .settings-shell { max-height: none; }
}

@media (max-width: 680px) {
  .topbar-actions .top-action span { display: none; }
  .top-action { width: 38px; padding: 0; justify-content: center; }
  .workspace { padding: 4px; }
  .review-stage { min-height: 620px; grid-template-rows: minmax(0, 1fr) 28px 94px; }
  .control-group { padding-top: 21px; }
  .deck-button { width: 46px; height: 54px; }
  .statusbar span:not(.connected):not(.status-spacer), .statusbar a { display: none; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-field.full { grid-column: auto; }
  .quick-tags { grid-template-columns: 1fr 1fr; }
  .auth-body { padding: 12px; }
  .auth-hero, .auth-panel { padding: 20px; }
  .auth-heading { font-size: 28px; }
  .auth-logo { width: 150px; }
  .auth-footer, .auth-row, .settings-header, .settings-actions { align-items: stretch; }
  .settings-header { flex-direction: column; }
}


/* Simple operator login */
.simple-auth-body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: clamp(14px, 3vw, 28px);
  background:
    radial-gradient(circle at 50% 0%, rgba(22,136,255,.13), transparent 34%),
    linear-gradient(180deg, #081018, #030609 72%);
}
.simple-login-card {
  width: min(420px, 100%);
  padding: clamp(24px, 5vw, 34px);
  border: 1px solid #263641;
  border-radius: 16px;
  background: rgba(8, 14, 19, .96);
  box-shadow: 0 28px 70px rgba(0,0,0,.52);
  backdrop-filter: blur(12px);
}
.simple-login-header {
  text-align: center;
  margin-bottom: 24px;
}
.simple-login-logo {
  display: block;
  width: 164px;
  max-width: 64%;
  margin: 0 auto 20px;
}
.simple-login-header h1 {
  margin: 0;
  font-size: clamp(22px, 5vw, 28px);
  line-height: 1.15;
}
.simple-login-header p {
  margin: 8px 0 0;
  color: #8796a1;
  font-size: 13px;
}
.simple-login-form {
  display: grid;
  gap: 15px;
}
.simple-login-field {
  display: block;
}
.simple-login-field > span {
  display: block;
  margin-bottom: 7px;
  color: #aeb9c1;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
}
.simple-input-wrap {
  position: relative;
}
.simple-input-wrap > i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #6f7f8a;
  pointer-events: none;
}
.simple-input-wrap input {
  width: 100%;
  min-height: 50px;
  border: 1px solid #2a3b47;
  border-radius: 10px;
  background: #060b0f;
  color: #fff;
  padding: 0 48px 0 42px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.simple-input-wrap input:hover {
  border-color: #3b505f;
}
.simple-input-wrap input:focus {
  border-color: var(--blue);
  background: #091117;
  box-shadow: 0 0 0 3px rgba(22,136,255,.13);
}
.simple-password-toggle {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #8997a1;
  cursor: pointer;
}
.simple-password-toggle:hover,
.simple-password-toggle:focus-visible {
  background: #111a20;
  color: #fff;
  outline: none;
}
.simple-login-submit {
  width: 100%;
  min-height: 50px;
  margin-top: 2px;
  border: 1px solid #1679d5;
  border-radius: 10px;
  background: linear-gradient(180deg, #1688ff, #1062b0);
  color: #fff;
  font-weight: 800;
  letter-spacing: .04em;
  cursor: pointer;
  box-shadow: 0 12px 22px rgba(22,136,255,.18);
  transition: transform .15s ease, filter .15s ease, opacity .15s ease;
}
.simple-login-submit:hover { transform: translateY(-1px); filter: brightness(1.04); }
.simple-login-submit:active { transform: translateY(0); }
.simple-login-submit:disabled { opacity: .65; cursor: wait; }
.simple-login-card .caps-warning {
  min-height: 16px;
  margin-top: -5px;
  color: #ffb454;
  font-size: 11px;
}
.simple-login-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid #1d2932;
  color: #6f7e89;
  font-size: 11px;
}
.simple-online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 9px rgba(34,214,95,.62);
}
@media (max-width: 480px) {
  .simple-auth-body { padding: 10px; }
  .simple-login-card { padding: 22px 18px; border-radius: 13px; }
  .simple-login-logo { width: 148px; margin-bottom: 17px; }
  .simple-login-header { margin-bottom: 20px; }
}
@media (hover: none), (pointer: coarse) {
  .simple-input-wrap input,
  .simple-login-submit { min-height: 54px; }
  .simple-password-toggle { width: 42px; height: 42px; }
}
