:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --bg-alt: #f4f5f7;
  --fg: #1a1d21;
  --fg-muted: #5b6270;
  --border: #d7dbe1;
  --accent: #5b3df6;
  --accent-fg: #ffffff;
  --pill-bg: #ece9fe;
  --pill-fg: #4a2fd6;
  --link: #4432c7;
  --row-hover: #f0eefe;
  --code-bg: #f4f5f7;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181d;
    --bg-alt: #1e2126;
    --fg: #e7e9ee;
    --fg-muted: #9aa1ac;
    --border: #2e323a;
    --accent: #8b7bff;
    --accent-fg: #14121f;
    --pill-bg: #2a2450;
    --pill-fg: #c3b8ff;
    --link: #a89bff;
    --row-hover: #232040;
    --code-bg: #1e2126;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--link); }

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
  color: var(--fg);
}

.main-nav {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.main-nav a {
  text-decoration: none;
  color: var(--fg-muted);
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  font-size: 0.92rem;
}

.main-nav a.active {
  color: var(--accent);
  background: var(--pill-bg);
  font-weight: 600;
}

#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
  width: 100%;
  flex: 1;
}

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: 0.82rem;
  padding: 1rem;
  text-align: center;
}

.site-footer p { max-width: 700px; margin: 0 auto; }

.loading, .error, .empty {
  color: var(--fg-muted);
  padding: 2rem 0;
  text-align: center;
}

.error { color: #d64545; }

h1, h2, h3 { line-height: 1.25; }

.page-title {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}

.page-title .count {
  color: var(--fg-muted);
  font-size: 0.95rem;
  font-weight: 400;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1rem 0;
  padding: 0.85rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: var(--fg-muted);
}

.filters input[type="search"],
.filters select {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  min-width: 9rem;
}

.filters input[type="search"] {
  min-width: 14rem;
}

.filters .clear-link {
  align-self: flex-end;
  font-size: 0.82rem;
  padding: 0.45rem 0.2rem;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9rem;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--bg-alt);
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th button.sort-btn {
  all: unset;
  cursor: pointer;
  display: block;
  padding: 0.55rem 0.75rem;
  color: var(--fg);
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
}

th button.sort-btn:hover { color: var(--accent); }

th .sort-indicator { color: var(--accent); margin-left: 0.2rem; }

tbody td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--row-hover); }

.pill {
  display: inline-block;
  background: var(--pill-bg);
  color: var(--pill-fg);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

.pill.dim { opacity: 0.55; }

.tag-list { display: flex; flex-wrap: wrap; gap: 0.3rem; }

.speaker-links a, .session-links a { display: inline-block; }

.speaker-cell {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.session-room {
  margin-top: auto;
  padding-top: 0.4rem;
  font-size: 0.78rem;
}

tbody tr.row-stripe-b { background: var(--bg-alt); }
tbody tr.row-stripe-b:hover { background: var(--row-hover); }

.muted { color: var(--fg-muted); }

.video-count-link { font-size: 0.78rem; text-decoration: none; }
.video-count-link:hover { text-decoration: underline; }

.detail-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  background: var(--bg-alt);
  margin-top: 0.75rem;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  color: var(--fg-muted);
  font-size: 0.88rem;
  margin: 0.4rem 0 1rem;
}

.detail-desc {
  white-space: pre-line;
  margin: 1rem 0;
}

.back-link {
  display: inline-block;
  margin-bottom: 0.75rem;
  font-size: 0.88rem;
  text-decoration: none;
}

.match-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  margin-top: 0.6rem;
  background: var(--bg);
}

.match-card .video-title { font-weight: 600; }
.match-card .match-meta { font-size: 0.8rem; color: var(--fg-muted); margin-top: 0.25rem; }
.match-card .match-notes { font-size: 0.85rem; margin-top: 0.4rem; }

.explore-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1rem 0;
}

.btn {
  display: inline-block;
  text-decoration: none;
  background: var(--accent);
  color: var(--accent-fg);
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
}

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

code, .code-block {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--code-bg);
  border-radius: 6px;
}

code { padding: 0.1rem 0.35rem; font-size: 0.85em; }

.code-block {
  display: block;
  padding: 0.75rem;
  overflow-x: auto;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  margin: 0.5rem 0 1rem;
}

.explore-frame {
  width: 100%;
  height: 75vh;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 1rem;
}

.query-links { display: flex; flex-direction: column; gap: 0.4rem; margin: 0.5rem 0 1rem; }

.update-toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: calc(100vw - 2rem);
  background: var(--bg-alt);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.75rem 0.6rem 1rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  font-size: 0.88rem;
}

/* Stack a second toast (e.g. data-update) above a sticky one (app-update)
   instead of overlapping it — see the .update-toast[data-kind] selector in
   showToast(). */
.update-toast:not(:last-of-type) {
  bottom: calc(1.25rem + 3.2rem);
}

.update-toast .btn { padding: 0.3rem 0.7rem; font-size: 0.82rem; white-space: nowrap; }

.update-toast-dismiss {
  all: unset;
  cursor: pointer;
  color: var(--fg-muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.1rem 0.3rem;
}

.update-toast-dismiss:hover { color: var(--fg); }
