:root {
  --bg: #0b0d12;
  --bg-2: #141821;
  --card: #1a1f2c;
  --border: #262d3d;
  --text: #e8ecf4;
  --muted: #8a93a6;
  --accent: #4cc9ff;
  --gold: #ffd76b;
  --hit: #4ade80;
  --miss: #ef4444;
  --red: #ff4757;
  --black: #2f3542;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.25rem 2rem;
  background: linear-gradient(180deg, #151926 0%, #0b0d12 100%);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.brand h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand h1 span { color: var(--accent); font-weight: 300; }
.brand p {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}
.brand .vibe-note {
  margin-top: 0.1rem;
  font-size: 0.7rem;
  font-style: italic;
  color: var(--gold);
  opacity: 0.75;
  letter-spacing: 0.01em;
}

nav { display: flex; gap: 0.25rem; flex-wrap: wrap; }
nav button {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
}
nav button:hover { color: var(--text); background: var(--bg-2); }
nav button.active {
  color: var(--text);
  background: var(--card);
  border-color: var(--border);
}

main { padding: 2rem; max-width: 1400px; margin: 0 auto; }

.tab { display: none; }
.tab.active { display: block; }

.subhead { margin-bottom: 1.5rem; }
.subhead h2 {
  margin: 0 0 0.25rem 0;
  font-size: 1.5rem;
  font-weight: 600;
}
.muted { color: var(--muted); margin: 0; font-size: 0.9rem; }

/* Inline warning banner — friendlier than a modal, bright enough to
   be noticed but not loud enough to dominate the page. */
.warn-banner {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.4rem 0.8rem;
  background: rgba(255, 215, 107, 0.12);
  border: 1px solid rgba(255, 215, 107, 0.4);
  border-radius: 6px;
  color: var(--gold);
  font-size: 0.85rem;
}

/* -------- Clip grid -------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
}

.clip-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.15s, border-color 0.15s;
  cursor: pointer;
}
.clip-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.clip-thumb {
  aspect-ratio: 16/9;
  background: #000;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.clip-thumb video,
.clip-thumb .clip-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.clip-thumb .play-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 56px;
  height: 56px;
  background: rgba(0, 0, 0, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.3rem;
  pointer-events: none;
}
.clip-thumb .score-badge {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  background: rgba(0, 0, 0, 0.7);
  color: var(--gold);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  backdrop-filter: blur(4px);
}

.clip-body { padding: 1rem; }
.clip-time {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  font-variant-numeric: tabular-nums;
}
.clip-text {
  font-size: 0.9rem;
  max-height: 5rem;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}
.clip-stats {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  font-size: 0.75rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}
.clip-stats b { color: var(--text); font-weight: 600; }

/* Host chip — compact avatar + name, usable in clip cards and shot rows. */
.host-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}
.host-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.55rem 0.2rem 0.2rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--text);
}
.host-chip.unknown {
  color: var(--muted);
  font-style: italic;
}

/* -------- Avatar wrap (stacked: letter + image on top) --------
   Works the same everywhere; size/border is set per-variant below.
   If the <img> fails to load its own onerror hides it, revealing the
   letter bubble that's always rendered behind it. */
.avatar-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg-2);
  color: var(--muted);
  font-weight: 600;
  flex-shrink: 0;
}
.avatar-wrap .avatar-init {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}
.avatar-wrap .avatar-img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Small chip avatar (inline with host name). */
.avatar-chip {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--border);
  font-size: 0.7rem;
}

/* Big host-card avatar. */
.avatar-big {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  font-size: 1.5rem;
}

/* Host grid — big profile cards */
.hosts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.25rem;
}
.host-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}
.host-card-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.host-card-head h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}
.host-card-head .sub {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.15rem;
}
.host-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.host-metric {
  background: var(--bg-2);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  text-align: center;
}
.host-metric .v {
  font-size: 1rem;
  font-weight: 700;
  display: block;
  font-variant-numeric: tabular-nums;
}
.host-metric .k {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}
.host-subsection {
  margin-top: 0.75rem;
}
.host-subsection h4 {
  margin: 0 0 0.4rem 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.host-subsection ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.host-subsection li {
  display: flex;
  justify-content: space-between;
  padding: 0.15rem 0;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.host-subsection li span.c { color: var(--muted); }

/* -------- Called Shots -------- */
.summary-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.summary-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
}
.summary-card .v {
  font-size: 1.5rem;
  font-weight: 700;
  display: block;
}
.summary-card .k { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

.shot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: border-color 0.15s;
}
.shot-row:hover { border-color: var(--accent); }
.shot-row.hit { border-left: 3px solid var(--hit); }
.shot-row.miss { border-left: 3px solid var(--miss); }

.shot-call, .shot-result {
  font-family: "SF Mono", monospace;
  font-weight: 700;
  font-size: 1.25rem;
  width: 48px;
  text-align: center;
}
.shot-verdict {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}
.shot-verdict.hit { color: var(--hit); }
.shot-verdict.miss { color: var(--miss); }
.shot-ctx {
  flex: 1;
  color: var(--muted);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shot-ts {
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* -------- Search -------- */
#q {
  width: 100%;
  padding: 0.9rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 1rem;
}
#q:focus { outline: none; border-color: var(--accent); }

.result {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: border-color 0.15s;
}
.result:hover { border-color: var(--accent); }
.result-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
  font-variant-numeric: tabular-nums;
}
.result-text { font-size: 0.95rem; }
.result-text mark {
  background: var(--gold);
  color: #000;
  padding: 0 2px;
  border-radius: 3px;
}

/* -------- Stats -------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}
.stats-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
}
.stats-card h3 {
  margin: 0 0 0.75rem 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.bars {
  list-style: none;
  padding: 0;
  margin: 0;
}
.bars li {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.bar-track {
  position: relative;
  height: 1.2rem;
  background: var(--bg-2);
  border-radius: 4px;
  overflow: hidden;
}
.bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, #4cc9ff22, var(--accent));
  border-radius: 4px;
}
.bar-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
  font-size: 0.8rem;
  mix-blend-mode: normal;
}
.bar-count {
  color: var(--muted);
  font-weight: 600;
  min-width: 2rem;
  text-align: right;
}

/* -------- Overlay -------- */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  backdrop-filter: blur(4px);
}
#overlay.hidden { display: none; }
.overlay-inner {
  background: var(--card);
  border-radius: 12px;
  max-width: 900px;
  width: 100%;
  overflow: hidden;
  position: relative;
}
#overlay-video {
  width: 100%;
  max-height: 70vh;
  background: #000;
  display: block;
}
#overlay-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  z-index: 2;
}
#overlay-close:hover { background: rgba(0, 0, 0, 0.85); }

/* Prev/next clip nav inside the overlay. Sits on the left/right edge of
   the video area, big enough to hit on mobile, fades unless hovered. */
.overlay-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 0.5rem;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  border: none;
  width: 44px;
  height: 60px;
  border-radius: 6px;
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  opacity: 0.55;
  transition: opacity 0.15s, background 0.15s;
}
.overlay-nav.overlay-nav-right { left: auto; right: 0.5rem; }
.overlay-nav:hover { opacity: 1; background: rgba(0, 0, 0, 0.85); }

/* Action row beneath the video — currently just the combine button, with
   room to add more (share, download, etc.) later. */
#overlay-actions {
  padding: 0 1.25rem 1rem;
  display: flex;
  gap: 0.5rem;
}
#overlay-combine {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
#overlay-combine:hover {
  border-color: var(--accent);
  background: var(--card);
}
#overlay-meta {
  padding: 1rem 1.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.empty {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--muted);
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: 10px;
}
