:root,
[data-theme="dark"] {
  --bg: #0b1017;
  --bg-elevated: #121a24;
  --bg-soft: #172131;
  --text: #e8eef7;
  --muted: #8b9bb0;
  --border: rgba(255,255,255,.08);
  --accent: #3dd6c6;
  --accent-2: #f0b429;
  --danger: #ff6b7a;
  --ok: #3ecf8e;
  --shadow: 0 20px 50px rgba(0,0,0,.35);
  --radius: 14px;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --display: "Space Grotesk", "IBM Plex Sans", sans-serif;
  --header-h: 64px;
}

[data-theme="light"] {
  --bg: #f4f7fb;
  --bg-elevated: #ffffff;
  --bg-soft: #e8eef6;
  --text: #132033;
  --muted: #5b6b7f;
  --border: rgba(19,32,51,.1);
  --accent: #0f9f92;
  --accent-2: #c48900;
  --shadow: 0 16px 40px rgba(19,32,51,.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { width: min(1120px, calc(100% - 2rem)); margin-inline: auto; }
.sr-only, .skip-link {
  position: absolute; left: -9999px;
}
.skip-link:focus { left: 1rem; top: 1rem; z-index: 100; background: var(--accent); color: #041015; padding: .5rem 1rem; }

.site-header {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  min-height: var(--header-h); gap: 1rem;
}
.brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
  letter-spacing: -.02em;
  text-decoration: none;
}
.site-nav { display: flex; align-items: center; gap: 1rem; }
.site-nav a { color: var(--muted); font-weight: 500; text-decoration: none; }
.site-nav a:hover { color: var(--text); }
.nav-toggle { display: none; background: transparent; border: 1px solid var(--border); color: var(--text); border-radius: 10px; padding: .4rem .65rem; }
.theme-toggle {
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--text);
  border-radius: 999px; width: 2.2rem; height: 2.2rem; cursor: pointer;
}

.hero {
  position: relative;
  padding: clamp(3rem, 8vw, 6rem) 0 3rem;
  overflow: hidden;
}
.hero__bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(61,214,198,.18), transparent 55%),
    radial-gradient(ellipse 70% 50% at 90% 20%, rgba(240,180,41,.12), transparent 50%),
    linear-gradient(180deg, var(--bg-soft), var(--bg));
}
.hero__content { position: relative; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; font-weight: 600; margin: 0 0 .75rem; }
.hero__brand {
  font-family: var(--display);
  font-size: clamp(2.8rem, 8vw, 5rem);
  line-height: .95;
  margin: 0 0 .75rem;
  letter-spacing: -.04em;
}
.hero__tagline { font-size: clamp(1.25rem, 3vw, 1.75rem); margin: 0 0 .5rem; font-weight: 600; }
.hero__sub { color: var(--muted); margin: 0 0 1.75rem; max-width: 36rem; }

.search-hero, .search-bar {
  display: flex; gap: .75rem; flex-wrap: wrap;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .4rem .4rem .4rem 1.1rem;
  box-shadow: var(--shadow);
  max-width: 720px;
}
.search-hero input, .search-bar input {
  flex: 1; min-width: 180px; border: 0; background: transparent; color: var(--text);
  font: inherit; outline: none; padding: .7rem 0;
}
.stat-row {
  display: grid; grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 1rem; margin-top: 2rem; max-width: 640px;
}
.stat-row strong { display: block; font-family: var(--display); font-size: 1.4rem; }
.stat-row span { color: var(--muted); font-size: .85rem; }

.section { padding: 3rem 0; }
.section-head { display: flex; justify-content: space-between; align-items: end; margin-bottom: 1.25rem; }
.section h2, .page-head h1, .entity-block h2, .timeline h2 {
  font-family: var(--display); letter-spacing: -.02em; margin: 0 0 .75rem;
}
.page-head { padding: 2rem 0 1rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.page-head em { color: var(--accent); font-style: normal; }
.muted { color: var(--muted); }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 40rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border-radius: 999px; border: 1px solid transparent; padding: .7rem 1.15rem;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn--primary { background: var(--accent); color: #041015; }
.btn--primary:hover { filter: brightness(1.05); text-decoration: none; }
.btn--secondary { background: var(--bg-soft); color: var(--text); border-color: var(--border); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn--block { width: 100%; }

.chip-row, .tags { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip, .tag {
  display: inline-flex; padding: .35rem .75rem; border-radius: 999px;
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text);
  font-size: .9rem; text-decoration: none;
}
.tag--topic { border-color: color-mix(in srgb, var(--accent-2) 40%, var(--border)); }

.video-grid, .entity-grid, .channel-grid, .donate-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.video-card, .entity-card, .channel-card, .donate-card, .result-card, .panel, .stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.video-card { overflow: hidden; color: inherit; text-decoration: none; transition: transform .2s ease, border-color .2s; }
.video-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); text-decoration: none; }
.video-card__thumb { position: relative; aspect-ratio: 16/9; background: var(--bg-soft); }
.video-card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.duration {
  position: absolute; right: .5rem; bottom: .5rem;
  background: rgba(0,0,0,.75); color: #fff; font-size: .75rem; padding: .15rem .4rem; border-radius: 6px;
}
.video-card__body { padding: .9rem 1rem 1.1rem; }
.video-card__body h3 { margin: .25rem 0; font-size: 1rem; line-height: 1.35; }
.channel { color: var(--muted); font-size: .85rem; }
.entity-card, .channel-card, .donate-card { padding: 1rem; color: inherit; text-decoration: none; }
.channel-card { display: flex; gap: .85rem; align-items: center; }
.channel-card img { border-radius: 50%; width: 56px; height: 56px; object-fit: cover; }
.entity-card span, .channel-card span { display: block; color: var(--muted); font-size: .85rem; margin-top: .25rem; }

.how-list { margin: 0; padding-left: 1.2rem; color: var(--muted); }
.how-list strong { color: var(--text); }
.how-list li { margin-bottom: .6rem; }

.search-layout { display: grid; grid-template-columns: 220px 1fr; gap: 1.5rem; padding-bottom: 3rem; }
.filters { position: sticky; top: calc(var(--header-h) + 1rem); align-self: start; }
.filters form, .stack-form { display: grid; gap: .75rem; }
.filters label, .stack-form label { display: grid; gap: .35rem; font-size: .9rem; color: var(--muted); }
input, select, textarea {
  width: 100%; border: 1px solid var(--border); background: var(--bg-soft); color: var(--text);
  border-radius: 10px; padding: .65rem .75rem; font: inherit;
}
.result-card { display: grid; grid-template-columns: 220px 1fr; gap: 1rem; padding: 1rem; margin-bottom: 1rem; }
.result-card--compact { display: block; padding: 1rem; margin-bottom: .75rem; }
.result-card__thumb { position: relative; border-radius: 10px; overflow: hidden; background: var(--bg-soft); }
.result-card__thumb img { width: 100%; height: 100%; object-fit: cover; aspect-ratio: 16/9; }
.result-meta { display: flex; gap: .75rem; color: var(--muted); font-size: .85rem; }
.result-card h2 { margin: .35rem 0; font-size: 1.15rem; }
.result-card h2 a { color: inherit; text-decoration: none; }
.snippet { color: var(--muted); }
.timestamp { color: var(--accent-2); }
.why { font-size: .85rem; }
.result-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }

.video-layout { display: grid; grid-template-columns: 1fr 280px; gap: 1.5rem; padding-bottom: 3rem; }
.player-embed { aspect-ratio: 16/9; background: #000; border-radius: var(--radius); overflow: hidden; }
.timeline { display: grid; gap: .5rem; margin-top: 1.5rem; }
.timeline-item {
  display: grid; grid-template-columns: 72px 1fr; gap: .75rem; text-align: left;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 12px;
  padding: .85rem 1rem; color: inherit; cursor: pointer; font: inherit;
}
.timeline-item:hover { border-color: var(--accent); }
.channel-hero { display: flex; gap: 1rem; align-items: start; }
.channel-hero img { border-radius: 50%; }
.stack { display: grid; gap: 2rem; padding-bottom: 3rem; }
.pagination { display: flex; gap: .4rem; flex-wrap: wrap; margin: 1.5rem 0; }
.pagination a {
  min-width: 2.2rem; height: 2.2rem; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; border: 1px solid var(--border); color: var(--text); text-decoration: none;
}
.pagination a.is-active { background: var(--accent); color: #041015; border-color: transparent; }

.site-footer { border-top: 1px solid var(--border); padding: 2.5rem 0 2rem; margin-top: 2rem; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 2rem; }
.footer-grid a { display: block; color: var(--muted); margin-bottom: .35rem; }
.footer-copy { margin-top: 1.5rem; font-size: .85rem; }

.player-modal[hidden] { display: none; }
.player-modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; }
.player-modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.72); }
.player-modal__panel {
  position: relative; width: min(900px, calc(100% - 2rem));
  aspect-ratio: 16/9; background: #000; border-radius: 12px; overflow: hidden; z-index: 1;
}
.player-modal__close {
  position: absolute; top: .5rem; right: .5rem; z-index: 2;
  border: 0; background: rgba(0,0,0,.6); color: #fff; width: 2rem; height: 2rem; border-radius: 50%; cursor: pointer;
}
#yt-player, #yt-player-page { width: 100%; height: 100%; }

.ad-slot { margin: 1.25rem 0; min-height: 0; }
.donate-page { padding-bottom: 3rem; }
.thank-you { margin-top: 2rem; color: var(--accent); font-weight: 600; }

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .site-nav {
    display: none; position: absolute; right: 1rem; top: calc(var(--header-h) - .25rem);
    flex-direction: column; align-items: stretch; background: var(--bg-elevated);
    border: 1px solid var(--border); border-radius: 12px; padding: .75rem; min-width: 180px;
  }
  .site-nav.is-open { display: flex; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .search-layout, .video-layout, .result-card, .footer-grid { grid-template-columns: 1fr; }
  .filters { position: static; }
  .search-hero, .search-bar { border-radius: 18px; }
}
