:root {
  color-scheme: dark;
  --bg: #0d1117;
  --bg-soft: #111827;
  --panel: #161b22;
  --panel-strong: #1f2937;
  --border: #30363d;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --accent: #8cc63f;
  --accent-strong: #b6f268;
  --accent-soft: rgba(140, 198, 63, 0.14);
  --danger: #f59e0b;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(140, 198, 63, 0.16), transparent 32rem),
    linear-gradient(180deg, #0f172a 0%, var(--bg) 28rem);
  color: var(--text);
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

.hero {
  padding: 1.25rem clamp(1rem, 4vw, 4rem) 3rem;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 4rem;
}

.topbar a {
  color: var(--muted);
  text-decoration: none;
}

.topbar a:hover {
  color: var(--text);
}

.brand {
  margin-right: auto;
  color: var(--text) !important;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(20rem, 0.8fr);
  gap: clamp(1.5rem, 4vw, 4rem);
  align-items: end;
}

.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.05;
}

h1 {
  max-width: 56rem;
  font-size: clamp(2.5rem, 7vw, 5.8rem);
  letter-spacing: -0.06em;
}

h2 {
  font-size: clamp(1.35rem, 2.5vw, 2rem);
}

h3 {
  font-size: clamp(1.35rem, 2vw, 2rem);
}

.lede {
  max-width: 50rem;
  color: #d1d5db;
  font-size: clamp(1rem, 1.5vw, 1.3rem);
  line-height: 1.7;
}

.hero-actions,
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.hero-actions a,
.card-actions a {
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  padding: 0.72rem 1rem;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 900;
}

.hero-actions a:hover,
.card-actions a:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.hero-actions .primary-link,
.card-actions .primary-link {
  border-color: var(--accent);
  background: var(--accent);
  color: #07110b;
}

.search-panel,
.panel,
.video-card {
  border: 1px solid var(--border);
  background: rgba(22, 27, 34, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.search-panel {
  padding: 1.25rem;
  border-radius: 1.25rem;
}

.search-panel label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  font-weight: 800;
}

.search-row {
  display: flex;
  gap: 0.75rem;
}

.search-row input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: #0b1220;
  color: var(--text);
  outline: none;
  padding: 0.9rem 1rem;
}

.search-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.search-row button,
.chapter-button,
.text-button {
  cursor: pointer;
}

.search-row button {
  border: 0;
  border-radius: 0.8rem;
  background: var(--accent);
  color: #07110b;
  font-weight: 900;
  padding: 0 1.15rem;
}

#search-help {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(17rem, 22rem) minmax(0, 1fr);
  gap: 1.5rem;
  padding: 0 clamp(1rem, 4vw, 4rem) 4rem;
}

.sidebar {
  position: sticky;
  top: 1rem;
  align-self: start;
  display: grid;
  gap: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.panel {
  border-radius: 1rem;
  padding: 1rem;
}

.panel h2 {
  margin-bottom: 1rem;
  font-size: 1rem;
}

.panel-heading,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.taxonomy-toggle {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  margin: 0;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.taxonomy-toggle-label {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.05;
}

.taxonomy-toggle-hint {
  display: none;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.chapters-panel.is-collapsed .taxonomy {
  display: none;
}

.chapters-panel .panel-heading {
  margin-bottom: 1rem;
}

.chapters-panel.is-collapsed .panel-heading {
  margin-bottom: 0;
}

@media (min-width: 981px) {
  .taxonomy-toggle {
    pointer-events: none;
  }

  .chapters-panel.is-collapsed .taxonomy {
    display: grid;
  }

  .chapters-panel.is-collapsed .panel-heading {
    margin-bottom: 1rem;
  }
}

.stats {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem 1rem;
  margin: 0;
}

.stats dt {
  color: var(--muted);
}

.stats dd {
  margin: 0;
  font-weight: 900;
}

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

.chapter-group h3 {
  margin-bottom: 0.5rem;
  color: #e5e7eb;
  font-size: 0.95rem;
}

.chapter-group p {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.subchapter-list {
  display: grid;
  gap: 0.5rem;
}

.chapter-button {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: #0b1220;
  color: var(--text);
  padding: 0.7rem;
  text-align: left;
}

.chapter-button:hover,
.chapter-button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.chapter-button span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.content {
  min-width: 0;
}

.section-heading {
  margin-bottom: 1rem;
}

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

.text-button {
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font-weight: 800;
}

.active-filter {
  margin: 0 0 1rem;
  border: 1px solid var(--accent);
  border-radius: 1rem;
  background: var(--accent-soft);
  color: #dcfce7;
  padding: 0.8rem 1rem;
}

.hidden {
  display: none !important;
}

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

.video-card {
  display: grid;
  grid-template-columns: minmax(18rem, 0.78fr) minmax(0, 1fr);
  align-items: start;
  overflow: hidden;
  border-radius: 1.25rem;
}

.video-embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background:
    linear-gradient(135deg, rgba(140, 198, 63, 0.18), transparent),
    #060a12;
}

.video-embed iframe,
.video-thumb,
.members-only-thumb {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
}

.video-poster {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  overflow: hidden;
}

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

.video-play-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(6, 10, 18, 0.08), rgba(6, 10, 18, 0.42));
}

.video-play-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 4.25rem;
  height: 4.25rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(7, 17, 11, 0.72);
  color: var(--accent-strong);
  font-size: 1.35rem;
  line-height: 1;
  transition: transform 0.15s ease, background 0.15s ease;
}

.video-poster:hover .video-play-button,
.video-poster:focus-visible .video-play-button {
  transform: scale(1.06);
  background: rgba(7, 17, 11, 0.88);
}

.members-only-placeholder {
  position: absolute;
  inset: 0;
  display: block;
  color: inherit;
  text-decoration: none;
  overflow: hidden;
}

.members-only-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem;
  background:
    linear-gradient(180deg, rgba(6, 10, 18, 0.28), rgba(6, 10, 18, 0.72)),
    radial-gradient(circle at center, transparent 20%, rgba(6, 10, 18, 0.45) 100%);
  text-align: center;
}

.members-only-label {
  border: 1px solid rgba(245, 158, 11, 0.5);
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.members-only-cta {
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: #07110b;
  padding: 0.72rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 900;
}

.members-only-placeholder:hover .members-only-cta,
.members-only-placeholder:focus-visible .members-only-cta {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.members-only-placeholder:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: -2px;
}

.video-body {
  padding: 1.25rem;
}

.video-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.badge {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #0b1220;
  color: #d1d5db;
  padding: 0.28rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 800;
}

.badge.warning {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
}

.summary {
  color: #d1d5db;
  line-height: 1.65;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1.25rem 0 1rem;
}

.tag {
  border-radius: 999px;
  background: var(--panel-strong);
  color: #d1d5db;
  padding: 0.3rem 0.55rem;
  font-size: 0.78rem;
}

.matching-chapters {
  display: grid;
  gap: 0.55rem;
  margin: 1rem 0;
}

.chapter-link {
  display: block;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.75rem;
  color: var(--text);
  text-decoration: none;
}

.chapter-link:hover {
  border-color: var(--accent);
}

.chapter-link time {
  color: var(--accent-strong);
  font-weight: 900;
}

details {
  margin-top: 1rem;
}

summary {
  cursor: pointer;
  color: var(--accent-strong);
  font-weight: 800;
}

.snippet {
  border-left: 3px solid var(--accent);
  color: #d1d5db;
  line-height: 1.6;
  padding-left: 0.9rem;
}

mark {
  border-radius: 0.25rem;
  background: rgba(182, 242, 104, 0.28);
  color: var(--text);
  padding: 0 0.15rem;
}

@media (max-width: 980px) {
  .hero {
    padding: 1rem clamp(1rem, 4vw, 2rem) 1.5rem;
  }

  .hero-grid,
  .video-card {
    grid-template-columns: 1fr;
  }

  .hero-grid {
    gap: 1.25rem;
    align-items: stretch;
  }

  h1 {
    font-size: clamp(1.85rem, 9vw, 3rem);
  }

  .lede {
    font-size: 1rem;
    line-height: 1.55;
  }

  .hero-actions {
    margin-top: 1rem;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.65rem;
    margin-bottom: 1.5rem;
  }

  .brand {
    margin-right: 0;
  }

  .layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-bottom: 3rem;
  }

  .sidebar {
    display: contents;
    position: static;
    max-height: none;
    overflow: visible;
  }

  .chapters-panel {
    order: 1;
  }

  .content {
    order: 2;
  }

  .stats-panel {
    order: 3;
  }

  .taxonomy-toggle-hint {
    display: block;
  }

  .taxonomy-toggle {
    min-height: 2.75rem;
    border: 1px solid var(--border);
    border-radius: 0.8rem;
    background: #0b1220;
    padding: 0.7rem 0.85rem;
  }

  .chapters-panel:not(.is-collapsed) .taxonomy-toggle {
    border-color: var(--accent);
    background: var(--accent-soft);
  }

  .chapters-panel .panel-heading {
    align-items: stretch;
    gap: 0.65rem;
    margin-bottom: 0;
  }

  .chapters-panel:not(.is-collapsed) .panel-heading {
    margin-bottom: 1rem;
  }

  .chapters-panel .text-button {
    align-self: center;
    min-height: 2.75rem;
    padding: 0 0.5rem;
  }

  .taxonomy {
    max-height: min(60vh, 28rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 0.15rem;
  }

  .chapter-button {
    min-height: 2.85rem;
    padding: 0.85rem;
  }

  .active-filter {
    scroll-margin-top: 0.75rem;
  }

  #results-section {
    scroll-margin-top: 0.75rem;
  }
}

@media (max-width: 620px) {
  .search-row,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .search-row button {
    min-height: 2.8rem;
  }

  .topbar {
    flex-wrap: wrap;
    flex-direction: row;
  }

  .brand {
    flex: 1 1 100%;
  }

  body {
    overflow-x: hidden;
  }
}
