/* Court Replay — design system
 *
 * Adapted from the claude.ai/design "Court Replay" handoff bundle.
 * Light theme is :root default; [data-theme="dark"] flips to the dark
 * palette. Accent is "hard-court blue", deeper on light, airier on dark.
 */

:root {
  /* Light palette (default) */
  --bg: #f6f7f5;
  --bg-2: #eef0ec;
  --surface: #ffffff;
  --surface-2: #f3f5f1;
  --surface-3: #e8ece6;
  --border: #e3e7df;
  --border-2: #d4dacf;
  --text: #0e1311;
  --text-2: #2a302c;
  --muted: #5d6862;
  --muted-2: #8a948e;

  /* Accent — sage, deeper for light theme */
  --accent: #3d7a55;
  --accent-ink: #ffffff;
  --accent-soft: rgba(61, 122, 85, 0.10);
  --accent-line: rgba(61, 122, 85, 0.28);

  /* Status */
  --warn: #b6791f;
  --danger: #c0392b;
  --info: #2d6cdf;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --shadow-1: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 1px 2px rgba(20, 30, 20, 0.05);
  --shadow-2: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 10px 30px rgba(20, 30, 20, 0.08);

  --font-sans: 'Geist', ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-serif: 'Instrument Serif', ui-serif, Georgia, serif;
}

[data-theme="dark"] {
  --bg: #0b0e0c;
  --bg-2: #0e1311;
  --surface: #131815;
  --surface-2: #181e1a;
  --surface-3: #1e2520;
  --border: #232a25;
  --border-2: #2c342e;
  --text: #eef2ef;
  --text-2: #c7cec9;
  --muted: #8a948e;
  --muted-2: #5f6a64;

  --accent: #9dd4b0;
  --accent-ink: #091410;
  --accent-soft: rgba(157, 212, 176, 0.10);
  --accent-line: rgba(157, 212, 176, 0.32);

  --warn: #f6c26b;
  --danger: #ef6b6b;
  --info: #7cb4ff;

  --shadow-1: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body { min-height: 100vh; overflow-x: hidden; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
input, textarea, select { font-family: inherit; }

::selection { background: var(--accent); color: var(--accent-ink); }

/* ───────── App shell ───────── */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  letter-spacing: -0.01em;
  font-size: 15px;
  color: var(--text);
}
.brand-mark {
  width: 22px;
  height: 22px;
  border: 1.25px solid var(--text);
  border-radius: 3px;
  position: relative;
  display: inline-block;
}
.brand-mark::before {
  content: ""; position: absolute; inset: 0;
  border-top: 1.25px solid var(--text);
  top: 50%;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 0;
  border-left: 1.25px solid var(--text);
  left: 50%;
}
.brand-dot { color: var(--accent); }

.nav-screens {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}
.nav-screens a, .nav-screens button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: -0.005em;
  transition: color 120ms ease, background 120ms ease;
  text-decoration: none;
}
.nav-screens a:hover, .nav-screens button:hover { color: var(--text-2); }
.nav-screens a.active, .nav-screens button.active {
  background: var(--surface-3);
  color: var(--text);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-username {
  font-size: 12px;
  color: var(--muted);
}

.nav-toggle {
  display: none;
  appearance: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
}
.nav-toggle:hover { background: var(--surface-2); }
.nav-toggle-bars,
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  content: "";
  display: block;
  width: 18px;
  height: 1.5px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 160ms ease, opacity 160ms ease;
}
.nav-toggle-bars { position: relative; }
.nav-toggle-bars::before { position: absolute; left: 0; top: -6px; }
.nav-toggle-bars::after  { position: absolute; left: 0; top:  6px; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars::before { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars::after  { transform: translateY(-6px) rotate(-45deg); }

.nav-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 16px;
  margin-top: 8px;
  min-width: 220px;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
  z-index: 60;
}
.nav-menu.open { display: flex; }
.nav-menu a {
  color: var(--text-2);
  text-decoration: none;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 8px;
}
.nav-menu a:hover { background: var(--surface-2); color: var(--text); }
.nav-menu a.active { background: var(--surface-3); color: var(--text); }
.nav-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}
.nav-menu-user {
  font-size: 12px;
  color: var(--muted);
  padding: 4px 12px 6px;
  word-break: break-all;
}
.nav-menu .btn { width: 100%; justify-content: center; margin-top: 4px; }

/* ───────── Buttons ───────── */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 120ms ease;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.2;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; transform: none; filter: none; }
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface); color: var(--text); }
.btn-quiet {
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
}
.btn-quiet:hover { color: var(--text); background: var(--surface); }
.btn-lg { padding: 13px 20px; font-size: 14.5px; border-radius: 10px; }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 6px; }
.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: color-mix(in oklab, var(--danger) 35%, var(--border));
}
.btn-danger:hover {
  background: color-mix(in oklab, var(--danger) 12%, transparent);
  color: var(--danger);
}

.icon-btn {
  appearance: none;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  border-radius: 8px;
  cursor: pointer;
  transition: all 120ms ease;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-2); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }
.icon-btn:disabled:hover { color: var(--text-2); border-color: var(--border); }

/* ───────── Surfaces & primitives ───────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border: 1px solid var(--border-2);
  border-radius: 4px;
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.serif { font-family: var(--font-serif); font-weight: 400; letter-spacing: -0.01em; }
.mono { font-family: var(--font-mono); }

.dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 999px;
  background: var(--muted);
  vertical-align: middle;
}
.dot.live { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.dot.proc { background: var(--warn); box-shadow: 0 0 0 4px color-mix(in oklab, var(--warn) 18%, transparent); }
.dot.up   { background: var(--info); box-shadow: 0 0 0 4px color-mix(in oklab, var(--info) 18%, transparent); }
.dot.err  { background: var(--danger); box-shadow: 0 0 0 4px color-mix(in oklab, var(--danger) 18%, transparent); }

.placeholder {
  background:
    repeating-linear-gradient(135deg,
      color-mix(in oklab, var(--surface-2) 100%, transparent) 0 8px,
      color-mix(in oklab, var(--surface-3) 100%, transparent) 8px 16px);
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* Court visual (decorative placeholder for thumbnails) */
.court {
  position: relative;
  background: linear-gradient(180deg,
    color-mix(in oklab, var(--accent) 22%, var(--bg)) 0%,
    color-mix(in oklab, var(--accent) 10%, var(--bg)) 100%);
  border-radius: var(--radius);
  overflow: hidden;
}
.court::before {
  content: "";
  position: absolute;
  inset: 14% 18%;
  border: 1.5px solid rgba(255, 255, 255, 0.65);
}
.court::after {
  content: "";
  position: absolute;
  left: 18%; right: 18%;
  top: 50%;
  border-top: 1.5px solid rgba(255, 255, 255, 0.65);
}
.court-net {
  position: absolute;
  left: 18%; right: 18%;
  top: 50%;
  height: 1px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.85) 0 2px, transparent 2px 6px);
  transform: translateY(-0.5px);
}
.court-glass {
  position: absolute;
  inset: 14% 18%;
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  pointer-events: none;
  border-radius: 1px;
}
.court-service-l, .court-service-r {
  position: absolute;
  top: 28%; bottom: 28%;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  border-top: 0; border-bottom: 0;
}
.court-service-l { left: 18%; right: 50%; border-left: 0; }
.court-service-r { right: 18%; left: 50%; border-right: 0; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

/* ───────── Layout helpers ───────── */
.page {
  padding: 32px 28px 80px;
  max-width: 1440px;
  margin: 0 auto;
}
.page-wide {
  padding: 24px 28px 80px;
  max-width: 1600px;
  margin: 0 auto;
}
.page-narrow {
  padding: 32px 28px 80px;
  max-width: 860px;
  margin: 0 auto;
}

/* Headings */
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.02em; font-weight: 500; }
p { margin: 0; }

.h-display {
  font-size: clamp(40px, 6vw, 78px);
  line-height: 0.98;
  letter-spacing: -0.035em;
  font-weight: 500;
}
.h1 { font-size: 36px; line-height: 1.05; letter-spacing: -0.025em; font-weight: 500; }
.h2 { font-size: 24px; line-height: 1.2; letter-spacing: -0.02em; font-weight: 500; }
.h3 { font-size: 18px; line-height: 1.25; letter-spacing: -0.015em; font-weight: 500; }

.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }

/* Chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-2);
  font-family: var(--font-mono);
}
.chip-accent {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
}
.chip-warn {
  background: color-mix(in oklab, var(--warn) 15%, var(--surface-2));
  border-color: color-mix(in oklab, var(--warn) 35%, var(--border));
  color: var(--warn);
}
.chip-danger {
  background: color-mix(in oklab, var(--danger) 12%, var(--surface-2));
  border-color: color-mix(in oklab, var(--danger) 35%, var(--border));
  color: var(--danger);
}

.hr { height: 1px; background: var(--border); border: 0; margin: 0; }

/* Subtle grid background */
.bg-grid {
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 56px 56px;
  background-position: -1px -1px;
}

/* Form inputs */
.input,
.field input,
.field textarea,
.field select,
.ac-input {
  appearance: none;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 11px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13.5px;
  width: 100%;
}
.input:focus,
.field input:focus,
.field textarea:focus,
.field select:focus,
.ac-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow-2);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.hidden { display: none; }

/* Animations */
@keyframes pulse-soft {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}
.pulse { animation: pulse-soft 2s ease-in-out infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1.2s linear infinite; }

/* Editorial mode (display headers) */
[data-direction="editorial"] .h-display {
  font-family: var(--font-serif);
  font-weight: 400;
  letter-spacing: -0.025em;
}

/* Utility */
.row { display: flex; align-items: center; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 12px; }
.between { justify-content: space-between; }
.grow { flex: 1; }
.center { display: flex; align-items: center; justify-content: center; }
.hidden { display: none !important; }

/* ───────────────────────────────────────────────────────────────────────── */
/* Landing                                                                   */
/* ───────────────────────────────────────────────────────────────────────── */
.landing { display: flex; flex-direction: column; }

.hero {
  position: relative;
  padding: 60px 28px 110px;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 60px;
  align-items: end;
  overflow: hidden;
}
.hero-bg { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.hero-court {
  position: absolute;
  right: -10%;
  bottom: 0;
  width: 70%;
  aspect-ratio: 2 / 1;
  opacity: 0.08;
}
.hero-fade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    var(--bg) 0%, transparent 30%, transparent 60%, var(--bg) 100%);
}
.hero-content {
  position: relative;
  z-index: 1;
  max-width: 720px;
}
.hero-sub {
  font-size: 19px;
  line-height: 1.5;
  color: var(--text-2);
  margin-top: 28px;
  max-width: 560px;
}
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 36px;
  font-size: 11.5px;
  color: var(--muted);
}

.hero-preview {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: transform 200ms ease, border-color 200ms ease;
  box-shadow: var(--shadow-2);
}
.hero-preview:hover { transform: translateY(-3px); border-color: var(--border-2); }
.hp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.hp-thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  background: #000;
}
.hp-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 60%, rgba(0, 0, 0, 0.7) 100%);
}
.hp-rally-strip {
  position: absolute;
  left: 12px; right: 12px; bottom: 10px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 32px;
}
.hp-rally { flex: 1; border-radius: 1px; min-height: 4px; }
.hp-rallies { padding: 6px 4px 6px; }
.hp-rally-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
}
.hp-rally-item:last-child { border-bottom: 0; }

/* Value props */
.values {
  padding: 100px 28px 60px;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  border-top: 1px solid var(--border);
}
.values-head { display: flex; flex-direction: column; gap: 14px; margin-bottom: 60px; }
.value-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.value-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.value-mock {
  padding: 24px;
  aspect-ratio: 5 / 3;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.value-text { padding: 22px 24px 26px; }
.value-text .eyebrow { color: var(--accent); }
.value-text .h2 { margin-top: 8px; margin-bottom: 10px; }

.vm-detect { display: flex; flex-direction: column; gap: 6px; }
.vm-d-bar { display: flex; align-items: flex-end; gap: 2px; height: 80px; }
.vm-d-seg { flex: 1; border-radius: 1px; min-height: 4px; }

.vm-library {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.vm-l-cell {
  position: relative;
  aspect-ratio: 16 / 10;
  background: #000;
  border-radius: 4px;
  overflow: hidden;
}
.vm-l-active {
  position: absolute;
  inset: 0;
  border: 2px solid var(--accent);
  border-radius: 4px;
  box-shadow: 0 0 0 1px var(--accent), 0 0 14px var(--accent-soft);
}

.vm-share {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
}
.vm-share-link {
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-2);
}
.vm-share-arrow { font-size: 22px; color: var(--accent); }
.vm-share-viewer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  padding: 8px;
}
.vm-share-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 4px;
  overflow: hidden;
}

/* How it works */
.how {
  padding: 80px 28px;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}
.how-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.how-step {
  padding: 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* CTA card */
.cta-section {
  padding: 60px 28px 100px;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}
.cta-card {
  display: grid;
  grid-template-columns: 1.4fr auto;
  gap: 40px;
  align-items: center;
  padding: 48px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  position: relative;
  overflow: hidden;
}
.cta-card::before {
  content: "";
  position: absolute;
  right: -8%; bottom: -40%;
  width: 50%;
  aspect-ratio: 2 / 1;
  background: radial-gradient(ellipse, var(--accent-soft) 0%, transparent 70%);
  z-index: 0;
}
.cta-card > * { position: relative; z-index: 1; }

/* Footer */
.footer {
  padding: 50px 28px 40px;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 40px;
}
.footer-cols {
  display: grid;
  grid-template-columns: repeat(3, 140px);
  gap: 20px;
}
.footer-cols ul {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text-2);
  font-size: 13px;
}
.footer-cols li:hover { color: var(--text); cursor: pointer; }

/* ───────────────────────────────────────────────────────────────────────── */
/* Upload                                                                    */
/* ───────────────────────────────────────────────────────────────────────── */
.upload-screen { display: flex; flex-direction: column; gap: 32px; }
.up-head { margin-bottom: 0; }
.up-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: flex-start;
}

.dropzone {
  background: var(--surface);
  border: 1px dashed var(--border-2);
  border-radius: var(--radius-lg);
  min-height: 420px;
  transition: all 200ms ease;
  overflow: hidden;
}
.dropzone.over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone.active {
  border-style: solid;
  border-color: var(--border);
}

.dz-idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 40px 50px;
  height: 100%;
}
.dz-icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.dz-hint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 40px;
  padding: 8px 14px;
  background: var(--bg-2);
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--muted);
}

.dz-active { padding: 28px 28px 30px; }
.dz-file {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.dz-thumb {
  position: relative;
  width: 84px;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
}
.dz-file-meta { flex: 1; min-width: 0; }
.dz-status { display: flex; }

.dz-phases {
  display: grid;
  grid-template-columns: 1fr 30px 1fr 30px 1fr;
  align-items: center;
  gap: 0;
  padding: 24px 0;
}
.dz-phase { display: flex; align-items: flex-start; gap: 12px; }
.dz-phase-dot {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.dz-phase.current .dz-phase-dot,
.dz-phase.done .dz-phase-dot {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.dz-phase-line {
  height: 1px;
  background: var(--border);
  margin-top: 13px;
}
.dz-phase-line.done { background: var(--accent); }

.dz-bar {
  height: 6px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}
.dz-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 200ms ease;
}

.dz-done-cta {
  display: flex;
  gap: 10px;
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.up-side { display: flex; flex-direction: column; gap: 12px; }
.up-privacy-list {
  list-style: none;
  padding: 12px 16px 16px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-2);
}
.up-privacy-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

/* Resume banner (existing upload flow) */
.resume-banner {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  background: color-mix(in oklab, var(--warn) 12%, var(--surface));
  border: 1px solid color-mix(in oklab, var(--warn) 35%, var(--border));
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
}

/* ───────────────────────────────────────────────────────────────────────── */
/* Library                                                                   */
/* ───────────────────────────────────────────────────────────────────────── */
.library-screen { display: flex; flex-direction: column; gap: 24px; }
.lib-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.lib-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 80px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.lib-empty-court {
  position: relative;
  width: 320px;
  aspect-ratio: 2 / 1;
  opacity: 0.6;
}

.lib-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.lib-search {
  flex: 1;
  min-width: 240px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
}
.lib-search input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13.5px;
}
.lib-search input::placeholder { color: var(--muted); }

.lib-list { display: flex; flex-direction: column; gap: 8px; }
.lib-row {
  display: grid;
  grid-template-columns: 200px 1fr auto auto;
  align-items: center;
  gap: 24px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 120ms ease;
  text-decoration: none;
  color: inherit;
}
.lib-row:hover { border-color: var(--border-2); }
.lib-row.processing { opacity: 0.85; }
.lib-thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
}
.lib-thumb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.lib-thumb-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(0, 0, 0, 0.5) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.95);
  opacity: 0;
  transition: opacity 120ms ease;
}
.lib-row:hover .lib-thumb-overlay { opacity: 1; }
.lib-thumb-processing {
  position: absolute;
  left: 8px; right: 8px; bottom: 8px;
}
.lib-thumb-bar {
  height: 3px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  overflow: hidden;
}
.lib-thumb-bar-fill {
  height: 100%;
  background: var(--warn);
  border-radius: 999px;
}
.lib-thumb-dur {
  position: absolute;
  bottom: 6px; right: 8px;
  font-size: 10.5px;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  padding: 2px 5px;
  border-radius: 3px;
}
.lib-info { min-width: 0; }
.lib-stats {
  display: flex;
  gap: 28px;
  padding-right: 12px;
}
.lib-actions {
  display: flex;
  gap: 6px;
}

/* ───────────────────────────────────────────────────────────────────────── */
/* Match detail                                                              */
/* ───────────────────────────────────────────────────────────────────────── */
.match-detail { display: flex; flex-direction: column; gap: 20px; }
.md-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.seg {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 1px;
}
.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.seg button:hover { color: var(--text-2); }
.seg button.active {
  background: var(--surface-3);
  color: var(--text);
}

.video-player {
  background: #000;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}
.video-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
}
.video-stage video,
.video-stage .video-js {
  width: 100%;
  height: 100%;
  display: block;
}

.md-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 2px 6px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.rally-grid {
  display: grid;
  gap: 14px;
  padding: 14px 0 0;
}
.rally-grid.d-compact {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.rally-grid.d-comfortable {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.rally-grid.d-showcase {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.rally-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 120ms ease, transform 120ms ease;
  text-decoration: none;
  color: inherit;
}
.rally-card:hover { border-color: var(--border-2); }
.rally-card:hover .rc-play-hover { opacity: 1; }
.rally-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 24px var(--accent-soft);
}
.rally-card.selected { border-color: var(--accent); }

.rc-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #000;
}
.rc-thumb-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.4) 0%, transparent 30%, transparent 70%, rgba(0, 0, 0, 0.6) 100%);
}
.rc-thumb-top {
  position: absolute;
  top: 6px; left: 8px; right: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.rc-thumb-bot {
  position: absolute;
  bottom: 6px; right: 8px;
}
.rc-num {
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.95);
  background: rgba(0, 0, 0, 0.55);
  padding: 2px 5px;
  border-radius: 3px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.rc-duration {
  font-size: 11px;
  color: #fff;
  background: rgba(0, 0, 0, 0.65);
  padding: 2px 6px;
  border-radius: 3px;
}
.rc-select {
  position: absolute;
  top: 6px; right: 8px;
  width: 18px; height: 18px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.5);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-ink);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 120ms ease;
}
.rally-card:hover .rc-select,
.rally-card.selected .rc-select { opacity: 1; }
.rc-select.checked {
  background: var(--accent);
  border-color: var(--accent);
}

.rc-play-hover {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  opacity: 0;
  transition: opacity 120ms ease;
  pointer-events: none;
}

.rc-meta { padding: 10px 12px 11px; }
.rc-meta-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.rc-time { font-size: 11.5px; color: var(--muted); }
.rc-frames { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Rally list view (alternative to rally-grid).
 *
 * Wrap pattern: a static column-label header sits OUTSIDE the scroll
 * container so it's always visible without needing position: sticky
 * (which had cross-browser quirks with the flex column layout). */
.rally-list-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-2);
}
.rally-list-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.rally-list-head .rl-num,
.rally-list-head .rl-time,
.rally-list-head .rl-length,
.rally-list-head .rl-comment-h,
.rally-list-head .rl-actions-h {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.rl-actions-h {
  margin-left: auto;
}
.rally-list {
  max-height: clamp(420px, 65vh, 780px);
  overflow-y: auto;
}
.rl-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  cursor: pointer;
  transition: background 120ms ease;
  color: inherit;
  text-decoration: none;
}
.rl-row:last-child { border-bottom: 0; }
.rl-row:hover { background: var(--surface); }
.rl-row.active {
  background: var(--accent-soft);
}
.rl-num {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  width: 56px;
  flex-shrink: 0;
}
.rl-time {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-2);
  width: 96px;
  flex-shrink: 0;
}
.rl-length {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-2);
  width: 76px;
  flex-shrink: 0;
}
.rl-row.active .rl-num,
.rl-row.active .rl-time,
.rl-row.active .rl-length { color: var(--accent); }
.rl-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}
/* Hidden rallies stay in the owner's list (still clickable) but read as
 * de-emphasized; the data columns dim while the action buttons stay legible. */
.rl-row.hidden-rally .rl-num,
.rl-row.hidden-rally .rl-time,
.rl-row.hidden-rally .rl-length,
.rl-row.hidden-rally .rl-comment-cell { opacity: 0.4; }
.rl-row.hidden-rally .rl-hide { color: var(--accent); }
/* Comment text fills the row's free space and truncates; the full note is
 * available on hover (title attr) and in the editor below the player. */
.rl-comment-cell {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12.5px;
  color: var(--text-2);
}
.rl-comment-cell.empty::before {
  content: "—";
  color: var(--muted);
}
.rl-comment-h {
  flex: 1;
  min-width: 0;
}

/* Per-rally comment editor, between the player and the rally list. */
.rally-comment {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
}
.rally-comment textarea {
  flex: 1;
  resize: none;
  overflow: hidden;
  min-height: 38px;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
}
.rally-comment textarea:focus {
  outline: none;
  border-color: var(--border-2);
}
.rally-comment #rally-comment-status {
  font-size: 12px;
  white-space: nowrap;
  padding-top: 11px;
}

/* Full-match collapsible (above the rally section). Hidden by default; the
 * rally view is the primary view, the full match is opt-in. */
.full-match-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.full-match-toggle {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
  text-align: left;
}
.full-match-toggle:hover { border-color: var(--border-2); background: var(--surface-2); }
.full-match-toggle svg { color: var(--accent); flex-shrink: 0; }

/* Inline rally player block (under primary player) */
.rally-now {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-2);
}
.rally-now .chip { background: var(--surface); }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 20px 12px;
}
.modal-body {
  padding: 0 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.share-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
}
.share-link input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
  min-width: 0;
}

/* ───────────────────────────────────────────────────────────────────────── */
/* Shared match                                                              */
/* ───────────────────────────────────────────────────────────────────────── */
.shared-match {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.sm-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: color-mix(in oklab, var(--bg) 85%, transparent);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}
.sm-main {
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
  padding: 36px 28px 48px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.sm-context { display: flex; flex-direction: column; }
.sm-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  color: var(--accent);
  font-size: 13px;
}
.sm-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px;
  border-top: 1px solid var(--border);
  gap: 16px;
  flex-wrap: wrap;
}

/* ───────────────────────────────────────────────────────────────────────── */
/* Account                                                                   */
/* ───────────────────────────────────────────────────────────────────────── */
.account-screen { display: flex; flex-direction: column; gap: 24px; }
.ac-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  align-items: flex-start;
}
.ac-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 80px;
}
.ac-nav-item {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: transparent;
  border: 0;
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 13.5px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}
.ac-nav-item:hover { background: var(--surface); }
.ac-nav-item.active {
  background: var(--surface);
  color: var(--text);
  border-left: 2px solid var(--accent);
  padding-left: 10px;
}

.ac-main {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.ac-section { padding: 28px 28px 16px; display: flex; flex-direction: column; gap: 4px; }
.ac-section-head { margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.ac-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}
.ac-row:last-child { border-bottom: 0; }
.ac-row-label { display: flex; flex-direction: column; gap: 4px; }
.ac-input { width: 280px; max-width: 100%; }

.ac-danger-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px;
  border: 1px solid color-mix(in oklab, var(--danger) 35%, var(--border));
  background: color-mix(in oklab, var(--danger) 6%, var(--bg-2));
  border-radius: var(--radius);
  flex-wrap: wrap;
}

/* Avatar circle helper */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: oklch(35% 0.08 210);
  color: oklch(92% 0.06 210);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 12px;
  border: 1px solid oklch(40% 0.05 210 / 0.5);
}

/* ───────────────────────────────────────────────────────────────────────── */
/* Clip export                                                               */
/* ───────────────────────────────────────────────────────────────────────── */
.export-screen { display: flex; flex-direction: column; gap: 28px; }
.ex-head {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  flex-wrap: wrap;
}
.ex-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: flex-start;
}
.ex-picker {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.ex-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}
.ex-rally-list {
  max-height: 620px;
  overflow-y: auto;
}
.ex-rally {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 120ms ease;
}
.ex-rally-comment {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Hidden rallies: unchecked by default, dimmed, and tagged so it's clear
 * why they're excluded — still selectable if the user opts in. */
.ex-rally-hidden .ex-rally-num,
.ex-rally-hidden > div:nth-child(2) > div:first-child { opacity: 0.5; }
.ex-rally-hidden-tag {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 9.5px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
}
.ex-rally:last-child { border-bottom: 0; }
.ex-rally:hover { background: var(--surface-2); }
.ex-rally.selected { background: color-mix(in oklab, var(--accent-soft) 70%, var(--surface)); }
.ex-rally.playing {
  box-shadow: inset 2px 0 0 var(--accent);
}
.ex-rally.playing .ex-rally-num,
.ex-rally.playing .rally-num-text {
  color: var(--accent);
}

/* Export preview pane — mini player above the rally list */
.ex-preview {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}
.ex-preview-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.ex-preview-stage video {
  width: 100%;
  height: 100%;
  display: block;
}
.ex-preview-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  letter-spacing: 0.04em;
  pointer-events: none;
  z-index: 1;
}
.ex-preview-meta {
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--muted);
}

/* Make the checkbox a larger hit target without changing visuals: the .ex-check
 * stays 18×18 visually but the click area inflates with negative margin + padding. */
.ex-check {
  margin: -8px;
  padding: 8px;
  box-sizing: content-box;
}
.ex-rally-num {
  width: 40px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--font-mono);
}
.ex-rally.selected .ex-rally-num { color: var(--accent); }
.ex-rally-pos {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 50%;
  font-weight: 500;
  font-size: 11px;
}
.ex-rally-thumb {
  position: relative;
  width: 56px;
  aspect-ratio: 16 / 10;
  border-radius: 4px;
  overflow: hidden;
}
.ex-check {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid var(--border-2);
  background: var(--bg-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-ink);
  flex-shrink: 0;
}
.ex-check.checked {
  background: var(--accent);
  border-color: var(--accent);
}

.ex-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 80px;
}
.ex-mode-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 12px 12px;
}
.ex-mode-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--bg-2);
}
.ex-mode-opt input { display: none; }
.ex-mode-opt.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.ex-mode-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--surface-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}
.ex-mode-opt.active .ex-mode-icon {
  background: var(--accent);
  color: var(--accent-ink);
}

.ex-set {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  gap: 10px;
  flex-wrap: wrap;
}
.ex-set label {
  color: var(--text-2);
  font-weight: 500;
}

.ex-summary {
  background: var(--bg-2);
  padding: 14px 16px;
  margin-top: 6px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toggle {
  appearance: none;
  width: 36px; height: 20px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  transition: background 120ms ease;
  padding: 0;
}
.toggle-thumb {
  position: absolute;
  top: 1px; left: 1px;
  width: 16px; height: 16px;
  background: var(--text);
  border-radius: 50%;
  transition: transform 160ms ease;
}
.toggle.on {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle.on .toggle-thumb {
  background: var(--accent-ink);
  transform: translateX(16px);
}

.ex-render {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 440px;
}
.ex-render-card {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 30px 30px 26px;
}
.ex-render-stage {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  font-size: 11px;
  color: var(--muted-2);
  flex-wrap: wrap;
}
.ex-render-stage span {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
}
.ex-render-stage span.done {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}
.ex-render-stage span.current {
  color: var(--text);
  background: var(--surface-3);
  border-color: var(--border-2);
}

.ex-done {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 480px;
}
.ex-done-card {
  width: 100%;
  max-width: 640px;
  padding: 50px 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.ex-done-icon {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent-line);
}
.ex-done-preview {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 40px;
  width: 100%;
  max-width: 480px;
}
.ex-done-thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: 4px;
  overflow: hidden;
  background: #000;
}
.ex-done-more {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

/* ───────────────────────────────────────────────────────────────────────── */
/* Auth screens                                                              */
/* ───────────────────────────────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, var(--accent-soft) 0%, transparent 70%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-2);
}
.auth-head { display: flex; flex-direction: column; gap: 6px; text-align: center; margin-bottom: 24px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card .field { width: 100%; }
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.auth-providers { display: flex; flex-direction: column; gap: 10px; }
.auth-apple {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}
.auth-apple:hover { filter: brightness(1.05); }
.auth-error {
  padding: 10px 12px;
  background: color-mix(in oklab, var(--danger) 10%, var(--surface));
  border: 1px solid color-mix(in oklab, var(--danger) 35%, var(--border));
  border-radius: 8px;
  color: var(--danger);
  font-size: 13px;
}

/* ───────────────────────────────────────────────────────────────────────── */
/* Admin                                                                     */
/* ───────────────────────────────────────────────────────────────────────── */
.admin-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  font-size: 13.5px;
}
.admin-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  padding: 12px 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}
.admin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
}
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table .link-btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--accent);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  padding: 0;
  margin-right: 14px;
}
.admin-table .link-btn:hover { text-decoration: underline; }
.admin-table .link-btn.danger { color: var(--danger); }

/* ───────────────────────────────────────────────────────────────────────── */
/* Responsive                                                                */
/* ───────────────────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .hero { grid-template-columns: 1fr; gap: 40px; padding: 40px 28px 60px; }
  .hero-preview { max-width: 420px; }
  .value-grid { grid-template-columns: 1fr; }
  .how-grid { grid-template-columns: repeat(2, 1fr); }
  .cta-card { grid-template-columns: 1fr; gap: 24px; padding: 32px; }
  .footer { grid-template-columns: 1fr; }
  .up-grid, .ex-grid { grid-template-columns: 1fr; }
  .lib-row { grid-template-columns: 160px 1fr auto; }
  .lib-stats { display: none; }
  .ac-layout { grid-template-columns: 1fr; }
  .ac-nav { flex-direction: row; flex-wrap: wrap; position: static; }
  .ex-side { position: static; }
}

@media (max-width: 720px) {
  .topnav { padding: 12px 16px; }
  .nav-screens { display: none; }
  .nav-username, .nav-logout-desktop { display: none; }
  .nav-toggle { display: inline-flex; }
  .page, .page-narrow, .page-wide { padding: 24px 16px 60px; }
  .sm-main { padding: 24px 16px 36px; }
  .lib-row {
    grid-template-columns: 120px 1fr;
    gap: 14px;
  }
  .lib-actions { grid-column: 1 / -1; }
  .ac-row { grid-template-columns: 1fr; align-items: flex-start; }
  .ac-input { width: 100%; }
  .dz-phases { grid-template-columns: 1fr; gap: 12px; }
  .dz-phase-line { display: none; }
  .h-display { font-size: clamp(36px, 8vw, 56px); }
  .h1 { font-size: 28px; }
  .h2 { font-size: 20px; }
  .auth-card { padding: 28px 22px; }
}

/* Htmx (kept from original) */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }
.htmx-request.htmx-indicator { display: inline-block; }
