:root {
  --bg: #f6f2ec;
  --bg-accent-1: rgba(204, 251, 241, 0.85);
  --bg-accent-2: rgba(253, 230, 138, 0.8);
  --bg-top: #fbf7f2;
  --bg-bottom: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f6;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #475569;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: #ccfbf1;
  --danger: #b91c1c;
  --danger-strong: #7f1d1d;
  --danger-soft: rgba(185, 28, 28, 0.08);
  --warning: #c2410c;
  --success: #15803d;
  --grid-color: rgba(148, 163, 184, 0.25);
  --gridline: rgba(148, 163, 184, 0.18);
  --glass: rgba(255, 255, 255, 0.9);
  --overlay-bg: rgba(15, 23, 42, 0.85);
  --overlay-bg-end: rgba(15, 23, 42, 0);
  --upload-glow: rgba(204, 251, 241, 0.4);
  --upload-glow-clear: rgba(255, 255, 255, 0);
  --video-bg: #0f172a;
  --toast-bg: #0f172a;
  --toast-text: #f8fafc;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 24px 60px -32px rgba(15, 23, 42, 0.45), 0 16px 28px -20px rgba(15, 23, 42, 0.2);
  --shadow-soft: 0 12px 24px -18px rgba(15, 23, 42, 0.18);
  --font-sans: "Space Grotesk", "Sora", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", "JetBrains Mono", monospace;
}

:root[data-theme="dark"] {
  --bg: #0b0f14;
  --bg-accent-1: rgba(45, 212, 191, 0.18);
  --bg-accent-2: rgba(56, 189, 248, 0.16);
  --bg-top: #0b0f14;
  --bg-bottom: #0f172a;
  --surface: #0f172a;
  --surface-2: #111827;
  --surface-3: #0b1220;
  --border: #1f2937;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #2dd4bf;
  --accent-strong: #0f766e;
  --accent-soft: rgba(45, 212, 191, 0.16);
  --danger: #f87171;
  --danger-strong: #ef4444;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --warning: #fb923c;
  --success: #4ade80;
  --grid-color: rgba(148, 163, 184, 0.18);
  --gridline: rgba(148, 163, 184, 0.12);
  --glass: rgba(15, 23, 42, 0.85);
  --overlay-bg: rgba(2, 6, 23, 0.85);
  --overlay-bg-end: rgba(2, 6, 23, 0);
  --upload-glow: rgba(45, 212, 191, 0.16);
  --upload-glow-clear: rgba(15, 23, 42, 0);
  --video-bg: #05070c;
  --toast-bg: #111827;
  --toast-text: #e2e8f0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(1000px 520px at 8% -10%, var(--bg-accent-1), transparent 60%),
    radial-gradient(900px 520px at 92% -20%, var(--bg-accent-2), transparent 55%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  display: flex;
  flex-direction: column;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(var(--grid-color) 0.5px, transparent 0.5px);
  background-size: 26px 26px;
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}

.page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.reveal {
  animation: reveal 0.7s ease both;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.header {
  width: 100%;
  margin: 0;
  padding: 1.75rem 3rem;
  border-radius: 0 0 calc(var(--radius) + 8px) calc(var(--radius) + 8px);
  background: var(--glass);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.5rem;
  backdrop-filter: blur(12px);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  font-family: var(--font-sans);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  color: var(--text);
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.theme-toggle:hover {
  transform: translateY(-1px);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
}

.theme-state {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.2), 0 10px 20px -14px rgba(15, 118, 110, 0.45);
}

.logo-text h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 0.3rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
}

.subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.meta-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pill {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.35rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.tab {
  padding: 0.55rem 1.35rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.tab:hover {
  color: var(--text);
  background: var(--surface-2);
}

.tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  box-shadow: 0 8px 16px -12px rgba(15, 118, 110, 0.7);
}

.tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.main {
  flex: 1;
  width: 100%;
  margin: 1.5rem 0 2rem;
  padding: 0 3rem 2.5rem;
}

.panel {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

.panel.active {
  display: block;
  animation: panelIn 0.4s ease both;
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.panel-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--accent);
}

.panel-head h2 {
  margin: 0 0 0.4rem;
  font-size: 1.7rem;
}

.panel-subtitle {
  margin: 0;
  color: var(--text-muted);
  max-width: 560px;
}

.panel-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.75rem;
  border: 1px solid rgba(15, 118, 110, 0.18);
}

.upload-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 1.5rem;
  align-items: stretch;
}

.upload-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--shadow-soft);
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.7rem 2rem;
  text-align: center;
  cursor: pointer;
  background: linear-gradient(180deg, var(--upload-glow), var(--upload-glow-clear));
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
  transform: translateY(-2px);
}

.upload-content {
  pointer-events: none;
}

.upload-icon {
  color: var(--accent);
  display: inline-flex;
  margin-bottom: 0.85rem;
}

.upload-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.upload-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.35rem 0 0;
}

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

.support-item {
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.support-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.2rem;
}

.support-value {
  font-size: 0.85rem;
  color: var(--text);
}

.controls {
  display: grid;
  gap: 1rem;
}

.preset-group {
  display: grid;
  gap: 0.5rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px dashed var(--border);
}

.preset-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-muted);
}

.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease;
}

.chip:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.control {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.control span {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.control input {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.control input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.control-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.control-footnote {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.control-checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.6rem;
}

.control-checkbox input[type="checkbox"] {
  width: auto;
}

.control-checkbox span {
  font-size: 0.9rem;
}

.btn {
  padding: 0.65rem 1.6rem;
  border: none;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  box-shadow: 0 12px 20px -14px rgba(15, 118, 110, 0.8);
}

.btn.primary:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.secondary:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
  padding: 0.5rem 1rem;
  font-weight: 500;
}

.btn.ghost:hover:not(:disabled) {
  background: var(--surface-2);
}

.progress {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.progress-track {
  height: 8px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #14b8a6);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
}

#progress-pct {
  font-family: var(--font-mono);
  color: var(--text);
}

.hidden {
  display: none !important;
}

.results {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.one-line-summary {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--accent);
  box-shadow: var(--shadow-soft);
}

.one-line-summary.normal {
  border-left-color: var(--success);
}

.one-line-summary.anomaly {
  border-left-color: var(--danger);
}

.analysis-message {
  padding: 1rem 1.25rem;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--accent);
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.analysis-message .message-title {
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.analysis-message .message-detail {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.results-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.stat-card {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.stat-card strong {
  font-size: 1.4rem;
  color: var(--text);
}

.chart-wrap {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.chart-title {
  display: grid;
  gap: 0.15rem;
}

.chart-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.chart-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.range-control {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.range-control input[type="range"] {
  accent-color: var(--accent);
}

.range-value {
  font-family: var(--font-mono);
  color: var(--text);
}

.score-chart {
  --bar-width: 3px;
  --bar-gap: 1px;
  height: 160px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 0.75rem;
  display: flex;
  align-items: flex-end;
  gap: var(--bar-gap, 2px);
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-gutter: stable;
  scrollbar-color: var(--border) transparent;
}

.score-chart::-webkit-scrollbar {
  height: 8px;
}

.score-chart::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

.score-chart::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(to top, var(--gridline) 1px, transparent 1px);
  background-size: 100% 25%;
  pointer-events: none;
}

.score-bar {
  flex: 0 0 var(--bar-width, 4px);
  width: var(--bar-width, 4px);
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  border-radius: 4px;
  transform-origin: bottom;
  animation: barGrow 0.4s ease both;
  animation-delay: calc(var(--i, 0) * 18ms);
  z-index: 1;
}

.score-bar.anomaly {
  background: linear-gradient(180deg, var(--danger), var(--danger-strong));
}

@keyframes barGrow {
  from {
    transform: scaleY(0.4);
    opacity: 0.6;
  }
  to {
    transform: scaleY(1);
    opacity: 1;
  }
}

.gallery-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.frame-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 1rem;
}

.frame-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  cursor: pointer;
  animation: cardIn 0.35s ease both;
  animation-delay: calc(var(--i, 0) * 35ms);
}

.frame-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-soft);
  border-color: rgba(15, 118, 110, 0.4);
}

.frame-card.anomaly {
  border-color: rgba(185, 28, 28, 0.6);
}

.frame-card img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  display: block;
}

.frame-card .caption {
  padding: 0.6rem 0.75rem;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.frame-card.anomaly .caption {
  color: var(--danger);
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.live-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 1.5rem;
  align-items: start;
}

.live-video-wrap {
  position: relative;
  background: var(--video-bg);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16/10;
  max-height: 480px;
  border: 1px solid rgba(15, 23, 42, 0.3);
  box-shadow: var(--shadow-soft);
}

.live-video-wrap video,
.live-video-wrap canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.live-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(to bottom, var(--overlay-bg), var(--overlay-bg-end));
  color: #fff;
  pointer-events: none;
}

.live-overlay .status {
  font-weight: 600;
  font-size: 0.95rem;
}

.live-overlay .status.normal {
  color: #bbf7d0;
}

.live-overlay .status.anomaly {
  color: #fecaca;
  animation: alertPulse 0.8s ease-in-out infinite;
}

@keyframes alertPulse {
  50% {
    opacity: 0.75;
  }
}

.live-overlay .score {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #e2e8f0;
}

.live-overlay-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.how-it-works {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.how-it-works summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  list-style: none;
}

.how-it-works summary::-webkit-details-marker {
  display: none;
}

.how-it-works summary::after {
  content: "+";
  float: right;
  color: var(--text-muted);
}

.how-it-works[open] summary::after {
  content: "-";
}

.how-it-works-body {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.how-it-works-body p {
  margin: 0 0 0.6rem 0;
}

.how-it-works-body strong {
  color: var(--text);
}

.live-controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.live-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.live-controls .control input {
  width: 100%;
}

.live-stats {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.live-info {
  padding: 0.75rem 1rem;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.live-info strong {
  color: var(--text);
}

.alerts-list {
  margin-top: 1rem;
  max-height: 200px;
  overflow-y: auto;
}

.alerts-list:empty::before {
  content: "No alerts yet. Live alerts will appear here.";
  display: block;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  color: var(--text-muted);
  background: var(--surface-2);
}

.alert-item {
  padding: 0.6rem 0.85rem;
  background: var(--danger-soft);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-sm);
  margin-bottom: 0.6rem;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  color: var(--danger);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(6px);
  cursor: pointer;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  z-index: 1;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: var(--shadow);
}

.lightbox-close {
  position: absolute;
  top: -2.5rem;
  right: 0;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem;
  opacity: 0.9;
}

.lightbox-close:hover {
  opacity: 1;
}

.lightbox-caption {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  font-size: 0.9rem;
  font-family: var(--font-mono);
  color: #e2e8f0;
  max-width: 560px;
  text-align: center;
}

.lightbox-caption .event-type {
  color: #fecaca;
  font-weight: 600;
}

.toast {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  background: var(--toast-bg);
  color: var(--toast-text);
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border-left: 4px solid var(--accent);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 320px;
  font-size: 0.9rem;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.toast.error {
  border-left-color: var(--danger);
}

.footer {
  padding: 1.5rem 2rem 2rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

.footer p {
  margin: 0;
}

@media (max-width: 1024px) {
  .header {
    padding: 1.25rem 1.5rem;
  }

  .main {
    padding: 0 1.5rem 2rem;
  }

  .live-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .header {
    align-items: flex-start;
  }

  .header-controls {
    width: 100%;
  }

  .tabs {
    width: 100%;
    justify-content: space-between;
  }

  .panel {
    padding: 1.4rem;
  }

  .upload-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
