:root {
  color-scheme: light;
  --ink: #092f33;
  --muted: #5a6f70;
  --deep: #005866;
  --reef: #0c9488;
  --water: #77cfc4;
  --foam: #f7fbf7;
  --mist: #e5f1ea;
  --sand: #f6f0dc;
  --gold: #f4b626;
  --gold-deep: #9a6a00;
  --line: #bed5ca;
  --danger: #c94432;
  --shadow: 0 20px 48px rgb(6 55 59 / 14%);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: linear-gradient(180deg, #edf7f0 0%, #fbfcf8 44%, #eef5ef 100%);
  color: var(--ink);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 2rem);
  background: var(--deep);
  border-bottom: 4px solid var(--gold);
  color: white;
}

.title-stack {
  flex: 1 1 280px;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: color-mix(in srgb, currentColor 76%, transparent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.25rem;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
  line-height: 1.15;
  letter-spacing: 0;
}

.subtitle {
  margin-bottom: 0;
  color: rgb(255 255 255 / 82%);
  font-size: 0.95rem;
}

.review-selector {
  display: grid;
  flex: 0 1 760px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.review-option {
  min-width: 0;
  padding: 0.55rem 0.65rem;
  border: 1px solid rgb(255 255 255 / 28%);
  border-radius: 7px;
  background: rgb(255 255 255 / 9%);
  color: white;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.review-option.is-active {
  border-color: var(--gold);
  background: rgb(244 182 38 / 18%);
  box-shadow: inset 0 -3px 0 var(--gold);
}

.review-option-title,
.review-option-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-option-title {
  font-size: 0.82rem;
  font-weight: 900;
}

.review-option-meta {
  margin-top: 0.12rem;
  color: rgb(255 255 255 / 78%);
  font-size: 0.7rem;
  font-weight: 700;
}

.results-link:focus-visible,
.review-option:focus-visible,
.timeline-graph:focus-visible,
button:focus-visible,
video:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.review-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: clamp(0.75rem, 2vw, 1.5rem);
}

.stage {
  display: grid;
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 250 / 94%);
  box-shadow: var(--shadow);
}

.race-ribbon {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.9rem;
  align-items: center;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--mist) 62%, white);
}

.race-ribbon[hidden] {
  display: none;
}

.race-ribbon-content {
  min-width: 0;
}

.race-ribbon h2 {
  margin: 0 0 0.45rem;
  font-size: clamp(1rem, 2.4vw, 1.25rem);
}

.race-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.race-chip {
  display: inline-flex;
  gap: 0.3rem;
  align-items: baseline;
  max-width: 100%;
  padding: 0.28rem 0.48rem;
  border: 1px solid color-mix(in srgb, var(--line) 76%, white);
  border-radius: 6px;
  background: rgb(255 255 250 / 86%);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.race-chip strong {
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.race-crew {
  margin: 0.5rem 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.results-link {
  flex: 0 0 auto;
  padding: 0.55rem 0.75rem;
  border: 1px solid color-mix(in srgb, var(--deep) 32%, white);
  border-radius: 7px;
  color: var(--deep);
  background: rgb(255 255 250 / 82%);
  font-size: 0.86rem;
  font-weight: 900;
  text-decoration: none;
}

.video-frame {
  position: relative;
  background: #001f23;
}

video {
  display: block;
  width: 100%;
  max-height: min(72vh, 840px);
  background: #001f23;
}

.video-pulse-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}

.video-pulse {
  position: absolute;
  inset: 10px;
  border: 4px solid rgba(44, 180, 145, 0.92);
  border-radius: 8px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 253, 240, 0.78),
    0 0 0 0 rgba(44, 180, 145, 0.38);
  opacity: 0;
  animation: videoPulse 780ms ease-out forwards;
}

.video-pulse.combo,
.video-pulse.change {
  border-color: rgba(252, 185, 0, 0.96);
  box-shadow:
    inset 0 0 0 1px rgba(255, 253, 240, 0.82),
    0 0 0 0 rgba(252, 185, 0, 0.42);
}

@keyframes videoPulse {
  0% {
    opacity: 0;
    transform: scale(0.992);
  }

  18% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    box-shadow:
      inset 0 0 0 1px rgba(255, 253, 240, 0.22),
      0 0 0 16px rgba(44, 180, 145, 0);
    transform: scale(1.006);
  }
}

.timeline-card {
  padding: 0.75rem;
  background: color-mix(in srgb, var(--sand) 82%, white);
  border-top: 1px solid rgb(0 88 102 / 20%);
}

.timeline-graph {
  min-height: 210px;
  border: 1px solid color-mix(in srgb, var(--line) 72%, white);
  border-radius: 8px;
  background: rgb(255 255 244 / 78%);
  cursor: crosshair;
  touch-action: manipulation;
}

.timeline-graph svg {
  display: block;
  width: 100%;
  height: 100%;
}

.grid-line {
  stroke: rgb(0 88 102 / 13%);
  shape-rendering: crispEdges;
}

.axis text {
  fill: var(--muted);
  font-size: 0.72rem;
}

.axis path,
.axis line {
  stroke: rgb(0 88 102 / 30%);
}

.credible-band {
  fill: color-mix(in srgb, var(--water) 34%, transparent);
}

.median-line {
  fill: none;
  stroke: var(--deep);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.observed-dot {
  fill: color-mix(in srgb, var(--reef) 62%, white);
  opacity: 0.5;
}

.stroke-line {
  stroke: var(--reef);
  stroke-width: 1px;
  opacity: 0.5;
  shape-rendering: crispEdges;
}

.change-line {
  stroke: var(--gold);
  stroke-width: 2px;
  opacity: 0.95;
  shape-rendering: crispEdges;
}

.change-dot {
  fill: var(--gold);
  stroke: white;
  stroke-width: 2px;
}

.change-number {
  fill: var(--gold-deep);
  font-size: 0.72rem;
  font-weight: 800;
  text-anchor: middle;
}

.playhead-line {
  stroke: var(--deep);
  stroke-width: 2px;
  pointer-events: none;
}

.playhead-label {
  fill: var(--deep);
  font-size: 0.78rem;
  font-weight: 800;
  text-anchor: middle;
  paint-order: stroke;
  stroke: rgb(255 255 244 / 92%);
  stroke-width: 5px;
}

.seek-capture {
  pointer-events: all;
}

.empty-message {
  color: var(--muted);
  padding: 2rem;
  text-align: center;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.summary-card,
.change-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 250 / 92%);
  box-shadow: 0 8px 22px rgb(6 55 59 / 8%);
}

.summary-card {
  padding: 1rem;
}

.summary-value {
  display: block;
  color: var(--ink);
  font-size: clamp(1.6rem, 4vw, 2.45rem);
  font-weight: 900;
  line-height: 1;
}

.summary-label {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 1rem;
}

.panel {
  padding: 1rem;
}

.panel-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.change-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.change-card {
  padding: 0.9rem;
}

.change-card h3 {
  margin: 0 0 0.65rem;
  font-size: 1rem;
}

.stat-row,
.metadata-list div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.4rem 0;
  border-top: 1px solid color-mix(in srgb, var(--line) 56%, transparent);
}

.stat-row:first-of-type,
.metadata-list div:first-of-type {
  border-top: 0;
}

.stat-row span,
.metadata-list dt {
  color: var(--muted);
  font-size: 0.82rem;
}

.stat-row strong,
.metadata-list dd {
  margin: 0;
  color: var(--ink);
  font-weight: 800;
  text-align: right;
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.85rem;
}

.tag {
  padding: 0.3rem 0.55rem;
  border: 1px solid color-mix(in srgb, var(--reef) 34%, white);
  border-radius: 999px;
  color: var(--deep);
  background: color-mix(in srgb, var(--water) 15%, white);
  font-size: 0.78rem;
  font-weight: 700;
}

.notes-block {
  margin: 0.9rem 0 0;
  padding-top: 0.9rem;
  border-top: 1px solid color-mix(in srgb, var(--line) 56%, transparent);
  color: var(--muted);
  line-height: 1.55;
}

.crew-panel {
  margin-top: 1rem;
}

.crew-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem;
}

.crew-seat {
  padding: 0.75rem;
  border: 1px solid color-mix(in srgb, var(--line) 70%, white);
  border-radius: 8px;
  background: color-mix(in srgb, var(--mist) 44%, white);
}

.crew-seat span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.crew-seat strong {
  display: block;
  margin-top: 0.2rem;
}

@media (max-width: 860px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .title-stack {
    flex-basis: auto;
  }

  .review-selector {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-grid,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .race-ribbon {
    grid-template-columns: 1fr;
  }

  .results-link {
    width: 100%;
    text-align: center;
  }
}

@media (max-width: 560px) {
  .review-shell {
    padding: 0.5rem;
  }

  .timeline-card,
  .panel,
  .summary-card {
    padding: 0.75rem;
  }

  .timeline-graph {
    min-height: 190px;
  }

  .review-selector {
    grid-template-columns: 1fr;
  }

  .race-crew {
    white-space: normal;
  }

  .stat-row,
  .metadata-list div {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.2rem;
  }

  .stat-row strong,
  .metadata-list dd {
    text-align: left;
  }
}
