:root {
  --bg: #111318;
  --panel: #1a1d24;
  --border: #2a2e37;
  --text: #eef0f4;
  --muted: #9aa1ad;
  --accent: #4da3ff;
  --accent-text: #05111f;
  --warn: #ffb24d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100vh; }

.app-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  padding-top: max(16px, env(safe-area-inset-top));
}
.app-header h1 { font-size: 20px; margin: 0 0 2px; }
.subtitle { margin: 0; color: var(--muted); font-size: 13px; }

main {
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  max-width: 640px;
  margin: 0 auto;
}

.screen { display: none; flex-direction: column; gap: 12px; }
.screen.active { display: flex; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.card h2 {
  font-size: 13px;
  margin: 0 0 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.guide { margin: 0 0 12px; padding-left: 20px; line-height: 1.5; font-size: 15px; }
.guide li + li { margin-top: 4px; }

.diagram {
  margin: 0 0 12px;
  padding: 10px;
  background: #000;
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  text-align: center;
}

.note { margin: 0; font-size: 13px; color: var(--warn); line-height: 1.4; }
.muted { color: var(--muted); font-size: 14px; margin: 0; }

/* Large touch targets: minimum 56px tall, full width */
.status { margin: 0 0 10px; font-size: 16px; font-weight: 600; }
.status.ok { color: #4dd48a; }
.status.error { color: #ff6b6b; }

.details { list-style: none; margin: 0 0 10px; padding: 0; }
.details li {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}
.details li span { color: var(--muted); }

#intake-blockers p { color: #ff6b6b; font-size: 14px; margin: 0 0 8px; }

[hidden] { display: none !important; }

button:disabled, .big-btn:disabled { opacity: 0.4; }

.big-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  background: var(--panel);
  color: var(--text);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.big-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.big-btn:active { opacity: 0.8; }
.big-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Stage 3: player */
.player-card { display: flex; flex-direction: column; gap: 10px; }
#player-video {
  width: 100%;
  max-height: 60vh;
  background: #000;
  border-radius: 8px;
  object-fit: contain;
}
.readout { margin: 0; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
#timeline { width: 100%; height: 36px; accent-color: var(--accent); }
.frame-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.frame-btn {
  min-height: 56px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.frame-btn:active { opacity: 0.8; }
.frame-btn:disabled { opacity: 0.35; }
.warning { margin: 0; color: var(--warn); font-size: 14px; line-height: 1.4; }

/* Stage 5: footage checks */
.check { display: flex; gap: 12px; align-items: flex-start; }
.check .icon {
  flex: 0 0 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  background: var(--border);
  color: var(--text);
}
.check.ok .icon { background: #1e5e3d; color: #4dd48a; }
.check.warn .icon { background: #5e4216; color: var(--warn); }
.check.block .icon { background: #5e1e1e; color: #ff6b6b; }
.check-detail { color: var(--muted); font-size: 13px; margin-top: 2px; line-height: 1.4; }
.check strong { font-size: 15px; }
.status.warn { color: var(--warn); }
.block-msg { color: #ff6b6b; font-size: 14px; margin: 0 0 8px; }
#check-list .check { padding: 10px 0; border-bottom: 1px solid var(--border); }
#check-list .check:last-child { border-bottom: none; }
/* Check rows reuse .details li for borders only; they must not space-between like key/value rows */
#check-list li.check { display: flex; justify-content: flex-start; gap: 12px; align-items: flex-start; }
#check-list li.check > div { flex: 1; text-align: left; }
#check-list li.check .icon { color: inherit; }
#check-list li.check span:first-child { color: inherit; }

/* Stage 5: the single video element, shown in the check preview and in the player */
.video-slot:empty { display: none; }
.video-slot video {
  display: block;
  width: 100%;
  max-height: 60vh;
  background: #000;
  border-radius: 8px;
  object-fit: contain;
}
.preview-card { padding: 8px; }
.preview-card .video-slot video { max-height: 35vh; }

.check.pending .icon { background: var(--border); color: var(--muted); }

/* Stage 6: calibration overlay sits exactly over the video picture */
#player-slot { position: relative; }
#marker-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}
.calib-card { display: flex; flex-direction: column; gap: 10px; }
.calib-card h2 { margin: 0; }
.calib-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.calib-row .big-btn.selected { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.field-label { font-size: 14px; color: var(--muted); }
.text-input {
  min-height: 56px;
  width: 100%;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 18px;
}
.text-input:focus { outline: 3px solid var(--accent); outline-offset: 1px; }

/* Footage notes on the player */
#footage-notes {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #1f1a12;
}
.notes-title { margin: 0 0 6px; font-size: 13px; color: var(--warn); text-transform: uppercase; letter-spacing: 0.05em; }
.notes-list { margin: 0 0 6px; padding-left: 18px; font-size: 14px; line-height: 1.5; }
#footage-notes .note { font-size: 12px; }

/* Stage 6 (fix): a real file input covers the whole button, so the tap opens the picker directly */
.file-btn { position: relative; overflow: hidden; cursor: pointer; }
.file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 16px; /* stops iPhone zooming on focus */
}

/* Stage 6: press-and-hold magnifier */
.loupe {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 3px solid #ffffff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 2;
  background: #000;
}

/* Stage 7-9: jump marking and the jumps list */
.jump-card { display: flex; flex-direction: column; gap: 10px; }
.jump-card h2 { margin: 0; }
#jump-result { margin: 0; text-align: center; min-height: 1.3em; color: #4dd48a; }

.jumps-card { display: flex; flex-direction: column; gap: 10px; }
.jumps-card h2 { margin: 0; }
.jumps-table { width: 100%; border-collapse: collapse; }
.jumps-table th {
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
}
.jumps-table td { padding: 12px 4px; border-bottom: 1px solid var(--border); font-size: 16px; }
.jump-row { cursor: pointer; }
.jump-row:active { background: var(--panel); }
.jump-row .edit-link { color: var(--accent); text-align: right; width: 50px; }
#jumps-summary { font-weight: 600; color: var(--text); }
