:root {
  --bg: #0b1020;
  --bg-elevated: rgba(11, 17, 32, 0.88);
  --bg-panel: rgba(13, 21, 38, 0.92);
  --line: rgba(148, 163, 184, 0.18);
  --line-strong: rgba(125, 211, 252, 0.32);
  --text: #e7edf7;
  --muted: #9fb0c8;
  --accent: #7dd3fc;
  --accent-warm: #f6ad55;
  --shadow: 0 24px 80px rgba(2, 6, 23, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(125, 211, 252, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(246, 173, 85, 0.12), transparent 24%),
    linear-gradient(180deg, #09101f 0%, #0b1020 100%);
  color: var(--text);
  overflow-y: auto;
}

.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 0;
  min-height: 100vh;
  padding: 28px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(8, 15, 30, 0.98), rgba(8, 15, 30, 0.9)),
    #0a1222;
  backdrop-filter: blur(14px);
}

.sidebar-header {
  margin-bottom: 28px;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--accent);
}

h1,
h2 {
  margin: 0;
  font-family: "Fraunces", serif;
  font-weight: 700;
  letter-spacing: -0.03em;
}

h1 {
  font-size: clamp(2rem, 3vw, 2.8rem);
  line-height: 0.95;
}

h2 {
  font-size: clamp(1.4rem, 2vw, 1.9rem);
}

.content {
  padding: 28px;
  display: grid;
  gap: 24px;
  min-width: 0;
  align-content: start;
}

.live-stack {
  display: grid;
  gap: 24px;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
  min-width: 0;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.live-stage,
.timeline-section {
  display: grid;
  gap: 10px;
}

.chart-wrap {
  position: relative;
  height: min(30vh, 250px);
  min-height: 190px;
}

#timeline-chart {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.preview-meta,
.empty-state,
.preview-status,
.preview-card figcaption,
.stream-link-row span {
  color: var(--muted);
}

.preview-meta {
  font-size: 0.84rem;
  line-height: 1.2;
}

.live-stage {
  justify-items: center;
}

.live-stage-labels {
  display: grid;
  gap: 4px;
}

.live-stage-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.live-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(125, 211, 252, 0.3);
  background: rgba(125, 211, 252, 0.12);
  color: #dff7ff;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.live-chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(125, 211, 252, 0.12);
}

.back-to-live {
  border: 1px solid rgba(125, 211, 252, 0.28);
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(125, 211, 252, 0.1);
  color: #eefbff;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.back-to-live:hover {
  background: rgba(125, 211, 252, 0.18);
  border-color: rgba(125, 211, 252, 0.4);
}

.live-stage[data-mode="manual"] #rolling-preview-kicker,
.live-stage[data-mode="manual"] #rolling-preview-live-chip {
  display: none;
}

label {
  display: block;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

select {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(2, 6, 23, 0.9);
  color: var(--text);
  font: inherit;
}

.preview-grid {
  display: grid;
  gap: 12px;
}

.preview-card {
  margin: 0;
}

.preview-card figcaption {
  margin-bottom: 8px;
  font-size: 0.84rem;
}

.preview img,
.preview-card-panel video,
.clip-card video {
  width: 100%;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(2, 6, 23, 0.92);
}

.preview-card-panel video {
  aspect-ratio: 16 / 9;
}

.preview-card-panel {
  position: relative;
  width: min(100%, 690px);
}

.preview-card-panel video {
  display: block;
  margin-top: 0;
}

.preview-status {
  min-height: 1.25rem;
  width: min(100%, 690px);
  text-align: left;
  font-size: 0.88rem;
}

.empty-state {
  width: min(100%, 690px);
  font-size: 0.88rem;
}

.video-overlay {
  position: absolute;
  inset: 14px 14px auto 14px;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.video-overlay > * {
  pointer-events: auto;
}

.video-overlay .live-stage-labels,
.video-overlay .live-stage-actions {
  padding: 5px 9px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 12px;
  background: rgba(6, 12, 24, 0.34);
  backdrop-filter: blur(8px);
}

.video-overlay .live-stage-labels {
  gap: 2px;
  width: fit-content;
}

.video-overlay .panel-kicker {
  margin: 0;
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  opacity: 0.88;
}

.video-overlay .preview-meta {
  font-size: 0.72rem;
  line-height: 1.15;
}

.timeline-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.timeline-legend {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend-swatch {
  display: inline-block;
  width: 20px;
  height: 10px;
  border-radius: 999px;
  border: 2px solid currentColor;
}

.legend-swatch-motion {
  color: #38bdf8;
}

.legend-swatch-activity {
  color: #f59e0b;
}

.range-toggle {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(8, 15, 30, 0.72);
  backdrop-filter: blur(8px);
}

.range-button {
  border: 0;
  padding: 7px 11px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.84rem;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}

.range-button:hover {
  color: var(--text);
}

.range-button.is-active {
  background: rgba(125, 211, 252, 0.14);
  color: #eefbff;
}

.explainer-panel {
  display: grid;
  gap: 12px;
}

.explainer-panel p {
  margin: 0;
  max-width: 75ch;
  line-height: 1.6;
  color: #d3ddec;
}

.stream-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

a {
  color: #fff3db;
  text-decoration: none;
  border-bottom: 1px solid rgba(246, 173, 85, 0.45);
}

a:hover {
  color: white;
  border-bottom-color: var(--accent-warm);
}

#clips {
  display: grid;
  gap: 16px;
}

.clip-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: rgba(2, 6, 23, 0.5);
}

.clip-card video {
  margin-top: 12px;
}

.observation-row {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.observation-row:first-child {
  border-top: 0;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(2, 6, 23, 0.75);
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
}

#observations {
  max-height: 45vh;
  overflow: auto;
  padding-right: 8px;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .timeline-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .content,
  .sidebar {
    padding: 18px;
  }

  .panel {
    border-radius: 18px;
    padding: 18px;
  }

  .chart-wrap {
    min-height: 180px;
  }

  .timeline-toolbar {
    justify-content: flex-start;
  }

  .video-overlay {
    inset: 10px 10px auto 10px;
    flex-direction: row;
    align-items: flex-start;
  }

  .live-stage-actions {
    justify-content: flex-start;
  }

  .video-overlay .live-stage-labels,
  .video-overlay .live-stage-actions {
    padding: 7px 10px;
  }

  .range-toggle {
    border-radius: 22px;
  }
}
