:root {
  color-scheme: dark;
  --bg: #09090d;
  --sidebar: #0e0e14;
  --surface: #13131b;
  --surface-2: #191822;
  --surface-3: #201e2b;
  --border: #2a2936;
  --line: #2a2936;
  --text: #f8f7fb;
  --muted: #aaa7b5;
  --purple: #8b5cf6;
  --purple-2: #c4b5fd;
  --green: #7ee2a8;
  --yellow: #f4c86a;
  --danger: #fb7185;
  --radius: 14px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(circle at 100% 0, rgba(139, 92, 246, .09), transparent 28rem), var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
button, select, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
a { color: var(--purple-2); }
[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  left: 16px;
  top: -80px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 8px;
  color: #09090d;
  background: #fff;
}
.skip-link:focus { top: 16px; }

.app-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 24px 16px 18px;
  border-right: 1px solid var(--border);
  background: var(--sidebar);
}
.brand-wrap { padding: 2px 12px 27px; }
.brand {
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 30px;
  line-height: 1;
  letter-spacing: 1.2px;
}
.brand-sub { margin-top: 5px; color: var(--muted); font-size: 12px; letter-spacing: 2px; }
.nav { display: grid; gap: 4px; }
.nav-item {
  position: relative;
  min-height: 44px;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  font-weight: 650;
}
.nav-item:hover, .nav-item:focus-visible { color: var(--text); background: var(--surface-2); outline: none; }
.nav-item.active { color: var(--text); background: rgba(139, 92, 246, .12); box-shadow: inset 3px 0 var(--purple); }
.sidebar-footer { display: grid; gap: 8px; margin-top: auto; padding: 16px 10px 0; border-top: 1px solid var(--border); }
.system-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.status-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.status-dot.warning { background: var(--yellow); }
.status-dot.error { background: var(--danger); }
.version { color: #777483; font-size: 12px; }

.main-wrap { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 70px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(9, 9, 13, .94);
  backdrop-filter: blur(12px);
}
.topbar h1 { margin: 0; font-size: 24px; line-height: 1.2; letter-spacing: -.02em; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.profile-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 5px 11px 5px 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  background: var(--surface);
}
.profile-btn:hover, .profile-btn:focus-visible { border-color: #4b475d; outline: none; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; color: var(--purple-2); background: #252036; font-weight: 800; }
.profile-copy { display: grid; gap: 1px; text-align: left; }
.profile-copy strong { font-size: 14px; }
.profile-copy small { color: var(--muted); font-size: 13px; }

#main { width: min(1440px, 100%); padding: 26px 28px 56px; }
.view { display: none; }
.view.active { display: block; }
h2, h3, h4, p { margin-top: 0; }
h2 { margin-bottom: 9px; font-size: clamp(24px, 3vw, 32px); line-height: 1.15; letter-spacing: -.025em; }
h3 { margin-bottom: 0; font-size: 18px; line-height: 1.3; }
.eyebrow { margin: 0 0 6px; color: var(--purple-2); text-transform: uppercase; font-size: 13px; font-weight: 750; letter-spacing: 1.15px; }
.muted { color: var(--muted); line-height: 1.65; }
.tiny-copy { font-size: 14px; }
.error-copy { color: #fda4af; line-height: 1.6; }

.panel {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
}
.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 28px; }
.hero .muted { margin-bottom: 0; }
.connect-panel { display: grid; place-items: start; min-height: 0; max-width: 780px; padding: clamp(24px, 5vw, 48px); }
.connect-panel .muted { max-width: 620px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

.primary-btn, .ghost-btn, .text-btn, .icon-btn, .length-btn {
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 700;
}
.primary-btn { color: #fff; background: var(--purple); }
.primary-btn:hover, .primary-btn:focus-visible { background: #9b74f7; outline: none; }
.ghost-btn, .icon-btn { color: var(--text); border-color: var(--border); background: var(--surface); }
.ghost-btn:hover, .ghost-btn:focus-visible, .icon-btn:hover, .icon-btn:focus-visible { border-color: #4b475d; background: var(--surface-3); outline: none; }
.text-btn { min-height: 40px; padding-inline: 4px; color: var(--purple-2); background: transparent; }
.text-btn:hover, .text-btn:focus-visible { color: #ddd3ff; outline: none; text-decoration: underline; }
.button-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

.score-orb {
  display: grid;
  min-width: 132px;
  padding: 16px 18px;
  border-left: 3px solid var(--purple);
  border-radius: 10px;
  background: var(--surface);
}
.score-orb span { font-size: 31px; font-weight: 800; line-height: 1.1; letter-spacing: -.03em; }
.score-orb small { color: var(--muted); font-size: 14px; }
.score-orb em { display: none; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.stat-card { display: grid; gap: 3px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.stat-card span { color: var(--muted); font-size: 14px; }
.stat-card strong { font-size: 28px; line-height: 1.2; }
.stat-card small { color: #85818f; font-size: 13px; }

.baseline-panel, .history-panel, .evidence-panel, .review-section { margin-top: 14px; }
.two-col { display: grid; grid-template-columns: 1.15fr .85fr; gap: 14px; margin-top: 14px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.section-head h2, .section-head h3 { margin: 0; }
.pill { display: inline-flex; align-items: center; min-height: 30px; padding: 4px 9px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); background: rgba(9, 9, 13, .5); font-size: 13px; white-space: nowrap; }

.timeline { position: relative; height: 145px; margin: 8px 0 16px; overflow: hidden; border-left: 1px solid var(--border); border-bottom: 1px solid var(--border); background: linear-gradient(to right, rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(to top, rgba(255,255,255,.035) 1px, transparent 1px); background-size: 12.5% 100%, 100% 25%; }
.timeline-fill { position: absolute; inset: 0; }
.timeline-point { position: absolute; width: 12px; height: 12px; padding: 0; border: 2px solid var(--surface); border-radius: 50%; background: var(--purple); transform: translate(-50%, 50%); }
.timeline-point.marker { border-radius: 2px; color: var(--yellow); background: var(--yellow); transform: translate(-50%, 50%) rotate(45deg); }
.timeline-point:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; color: var(--muted); font-size: 13px; }
.legend span { display: flex; align-items: center; gap: 7px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--purple); }
.legend-dot.marker { border-radius: 2px; background: var(--yellow); transform: rotate(45deg); }

.moment-list { display: grid; gap: 8px; }
.moment-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; width: 100%; padding: 13px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); background: var(--surface); text-align: left; }
.moment-card:hover, .moment-card.active { border-color: #5f5680; background: var(--surface-3); }
.moment-card:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
.moment-card h4 { margin: 0; font-size: 15px; line-height: 1.35; }
.moment-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 7px; color: var(--muted); font-size: 13px; }
.moment-score { display: grid; place-items: center; min-width: 48px; height: 48px; border: 1px solid #474158; border-radius: 9px; color: var(--purple-2); background: #17151e; font-size: 17px; font-weight: 800; }
.confidence { font-weight: 750; }
.confidence.very-high { color: var(--green); }
.confidence.high { color: var(--purple-2); }
.confidence.medium { color: var(--yellow); }

.baseline-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.baseline-metric { display: flex; flex-direction: column; gap: 5px; min-width: 0; padding: 13px; border: 1px solid var(--border); border-radius: 10px; background: rgba(9, 9, 13, .35); }
.baseline-metric span { color: var(--muted); font-size: 13px; }
.baseline-metric strong { font-size: 23px; line-height: 1.2; letter-spacing: -.02em; }
.baseline-metric small { color: #8e8a98; font-size: 13px; }
.baseline-metric .trend { font-style: normal; font-weight: 700; }
.trend.positive { color: var(--green); }
.trend.negative { color: #fda4af; }
.trend.neutral { color: var(--muted); }
.baseline-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; color: var(--muted); font-size: 13px; }
.baseline-footer a { color: inherit; }
.baseline-warning, .baseline-error { margin-top: 10px; padding: 10px 12px; border-radius: 9px; font-size: 13px; }
.baseline-warning { border: 1px solid rgba(244, 200, 106, .38); color: #f8daa0; background: rgba(244, 200, 106, .07); }
.baseline-error { border: 1px solid rgba(251, 113, 133, .38); color: #fda4af; background: rgba(251, 113, 133, .07); }

.history-list { display: flex; flex-direction: column; gap: 7px; margin-top: 12px; }
.history-row { display: grid; grid-template-columns: minmax(0, 1.7fr) repeat(4, minmax(80px, .55fr)); align-items: center; gap: 12px; padding: 11px 12px; border-bottom: 1px solid var(--border); }
.history-row:last-child { border-bottom: 0; }
.history-title { min-width: 0; }
.history-title strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-title span, .history-cell span { display: block; margin-top: 3px; color: var(--muted); font-size: 13px; }
.history-cell strong { font-size: 15px; }
.history-empty { padding: 8px 0; color: var(--muted); }

.stream-selector { margin-bottom: 14px; }
.video-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.video-card { overflow: hidden; padding: 0; border: 1px solid var(--border); border-radius: 10px; color: var(--text); background: var(--surface); text-align: left; }
.video-card:hover, .video-card.active { border-color: #675c8d; background: var(--surface-3); }
.video-card:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
.video-card img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #0c0c11; }
.video-card-body { display: grid; gap: 5px; padding: 13px; }
.video-card-body strong { font-size: 15px; line-height: 1.35; }
.video-card-body span { color: var(--muted); font-size: 13px; }

.review-layout { display: grid; grid-template-columns: minmax(300px, .8fr) minmax(420px, 1.2fr); align-items: start; gap: 14px; }
.moment-browser { max-height: 750px; overflow: auto; }
.detail-panel { position: sticky; top: 88px; min-height: 560px; }
.detail-hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.detail-hero h2 { margin-bottom: 8px; font-size: 27px; }
.big-score { color: var(--purple-2); font-size: 38px; font-weight: 800; }
.big-score small { color: var(--muted); font-size: 13px; }
.detail-section { padding: 18px 0; border-bottom: 1px solid var(--border); }
.detail-section:last-child { padding-bottom: 0; border-bottom: 0; }
.evidence-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.evidence-item { padding: 12px; border: 1px solid var(--border); border-radius: 9px; background: rgba(9, 9, 13, .35); }
.evidence-item span { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .7px; }
.evidence-item strong { display: block; margin-top: 5px; font-size: 18px; }
.clip-lengths { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.length-btn { color: var(--muted); border-color: var(--border); background: var(--surface); }
.length-btn.active { color: #fff; border-color: var(--purple); background: rgba(139, 92, 246, .14); }
.action-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.action-grid .primary-btn, .span-action { grid-column: 1 / -1; }
.field { display: grid; gap: 8px; margin-top: 16px; color: var(--muted); font-size: 14px; }
.inline-field { margin-top: 10px; }
.select, .text-input { min-height: 44px; width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; color: var(--text); background: #0f0f15; }
.select:focus, .text-input:focus { border-color: var(--purple); outline: 2px solid rgba(139, 92, 246, .22); }

.clip-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.clip-card { overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.clip-image { position: relative; overflow: hidden; aspect-ratio: 16 / 9; background: #0c0c11; }
.clip-image img { display: block; width: 100%; height: 100%; object-fit: cover; }
.clip-image .pill { position: absolute; right: 10px; bottom: 10px; color: #fff; background: rgba(9, 9, 13, .9); }
.clip-thumb { position: relative; display: grid; place-items: center; aspect-ratio: 16 / 9; color: var(--purple-2); background: #17151f; font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif; font-size: 28px; letter-spacing: 1px; }
.clip-body { padding: 14px; }
.clip-body h3 { margin-bottom: 7px; font-size: 16px; }
.clip-body p { margin-bottom: 12px; color: var(--muted); font-size: 13px; }
.clip-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.span-2 { grid-column: 1 / -1; }
.account-profile { display: flex; align-items: center; gap: 12px; margin: 12px 0 14px; }
.account-profile img { width: 50px; height: 50px; border-radius: 10px; }
.account-profile div { display: grid; gap: 3px; }
.account-profile span { color: var(--muted); font-size: 13px; }
.coverage-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.coverage, .privacy-grid > div { display: grid; gap: 6px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: rgba(9, 9, 13, .35); }
.coverage span, .privacy-grid span { color: var(--muted); font-size: 13px; line-height: 1.5; }
.coverage.active { border-left: 3px solid var(--green); }
.coverage.future { border-left: 3px solid var(--yellow); }
.privacy-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 100; max-width: min(420px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 9px; color: #111116; background: var(--text); font-size: 14px; font-weight: 700; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .18s ease; }
.toast.show { opacity: 1; transform: none; }
.mobile-menu { display: none; }

@media (max-width: 1120px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .baseline-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .two-col, .review-layout { grid-template-columns: 1fr; }
  .detail-panel { position: static; min-height: 0; }
  .video-grid, .clip-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .coverage-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -270px; width: 250px; transition: left .18s ease; }
  .sidebar.open { left: 0; box-shadow: 16px 0 48px rgba(0, 0, 0, .45); }
  .mobile-menu { display: inline-flex; align-items: center; justify-content: center; }
  .topbar { padding: 10px 16px; }
  #main { padding: 20px 16px 40px; }
  .settings-grid, .privacy-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .history-row { grid-template-columns: minmax(0, 1fr) repeat(2, minmax(70px, .35fr)); }
  .history-cell.optional { display: none; }
}

@media (max-width: 600px) {
  .profile-copy { display: none; }
  .top-actions > .ghost-btn { display: none; }
  .panel { padding: 16px; }
  .hero { grid-template-columns: 1fr; }
  .score-orb { width: 100%; }
  .stats-grid, .baseline-grid, .video-grid, .clip-grid, .coverage-grid, .evidence-grid, .action-grid { grid-template-columns: 1fr; }
  .two-col { display: block; }
  .two-col > .panel + .panel { margin-top: 14px; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .hero-actions { display: grid; }
  .history-row { grid-template-columns: minmax(0, 1fr) 72px; }
  .history-cell.mobile-hide { display: none; }
  .detail-hero { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
