:root {
  --bg: #0a0a0c;
  --surface: #131316;
  --surface-2: #1a1a20;
  --surface-3: #20202a;
  --text: #f3f4f6;
  --muted: #a1a1aa;
  --accent: #7dd3fc;
  --accent-2: #c084fc;
  --accent-3: #34d399;
  --border: #2a2a33;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.24);
  --thumb-height: 168px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: 'IBM Plex Sans', sans-serif;
  background: radial-gradient(circle at top, #151528 0%, #0a0a0c 60%);
  color: var(--text);
}

.shell {
  max-width: 1160px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 12px;
  background: #ffffff;
  padding: 4px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.brand strong,
.brand span,
.topnav a,
.filter-btn,
#sort-select,
.tag,
.year,
.authors,
.episode-date,
.episode-topic,
.timeline-year {
  font-family: 'IBM Plex Mono', monospace;
}

.brand div {
  display: grid;
}

.brand span {
  color: var(--muted);
  font-size: 12px;
}

.topnav {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.topnav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
}

.hero {
  display: grid;
  grid-template-columns: 1.55fr 0.95fr;
  gap: 20px;
  align-items: stretch;
  padding: 14px 0 28px;
}

.hero-copy,
.hero-panel,
.info-card,
.card,
.toolbar,
.episode-card,
.collection-card,
.timeline-item {
  background: rgba(19, 19, 22, 0.94);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: 24px;
}

.hero-panel {
  padding: 18px;
  display: grid;
  gap: 12px;
}

.stats-panel {
  grid-template-columns: repeat(2, 1fr);
}

.stat {
  background: var(--surface-2);
  border-radius: 14px;
  padding: 14px;
}

.stat strong {
  display: block;
  font-size: 1.45rem;
  margin-bottom: 4px;
}

.stat span {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  font-family: 'IBM Plex Mono', monospace;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2.3rem, 5vw, 4rem);
  line-height: 1.02;
}

.lede,
.section-head p,
.info-card p,
.card p,
.footer p,
.collection-card p,
.timeline-meta {
  color: var(--muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 12px;
  text-decoration: none;
  color: #06131a;
  background: var(--accent);
  font-weight: 700;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.info-grid,
.collections-grid,
.paper-grid,
.episodes-grid,
.quality-grid,
.review-grid,
.featured-grid,
.editorial-grid {
  display: grid;
  gap: 16px;
}

.info-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin: 8px 0 28px;
}

.collections-grid,
.paper-grid,
.episodes-grid,
.quality-grid,
.review-grid,
.featured-grid,
.editorial-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.info-card,
.card,
.episode-card,
.collection-card,
.timeline-item {
  padding: 16px;
}

.stack-section {
  margin-top: 30px;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.toolbar {
  padding: 14px;
  margin-bottom: 16px;
  position: sticky;
  top: 10px;
  z-index: 20;
  backdrop-filter: blur(10px);
}

.quick-toggles {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--muted);
  background: #0f0f14;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
}

.thumb-controls {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #0f0f14;
}

.thumb-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.thumb-preset {
  border: 1px solid var(--border);
  background: #14141a;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 12px;
  font-family: 'IBM Plex Mono', monospace;
}

.thumb-preset.active {
  color: #06131a;
  background: var(--accent);
  border-color: var(--accent);
}

.thumb-controls label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-family: 'IBM Plex Mono', monospace;
}

.thumb-controls input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.toggle-pill input {
  accent-color: var(--accent);
}

.toolbar-row {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 10px;
  margin-bottom: 12px;
}

#search,
#sort-select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0f0f14;
  color: var(--text);
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-btn {
  border: 1px solid var(--border);
  background: #0f0f14;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 11px;
  cursor: pointer;
  font-size: 12px;
}

.filter-btn.active {
  color: #06131a;
  background: var(--accent);
  border-color: var(--accent);
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.meaning-row,
.prompt-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.status-badge,
.meaning-tag,
.prompt-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
}

.status-direct {
  color: var(--accent-3);
  background: rgba(52, 211, 153, 0.08);
}

.status-strong {
  color: #06131a;
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  border-color: transparent;
}

.status-public {
  color: #dbeafe;
  background: rgba(96, 165, 250, 0.14);
}

.status-review {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.08);
}

.meaning-tag {
  color: var(--accent);
  background: rgba(125, 211, 252, 0.08);
}

.prompt-chip {
  color: var(--text);
  background: #0f0f14;
  cursor: pointer;
}

.prompt-chip:hover {
  border-color: var(--accent);
}

.tag,
.year,
.authors {
  font-size: 12px;
}

.tag {
  color: #06131a;
  background: var(--accent);
  padding: 4px 8px;
  border-radius: 999px;
}

.year,
.authors {
  color: var(--accent-2);
}

.thumb-wrap {
  position: relative;
  margin: -16px -16px 12px;
  height: var(--thumb-height);
  overflow: hidden;
  border-radius: 18px 18px 0 0;
  background: #0f0f14;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  transition: height 160ms ease, opacity 160ms ease, transform 180ms ease;
}

.thumb-wrap:hover {
  transform: translateY(-1px);
}

html[data-thumbs='hidden'] .thumb-wrap {
  display: none;
}

.thumb,
.thumb-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border: 0;
}

.thumb-wrap.is-previewing .thumb {
  opacity: 0;
}

.thumb-overlay {
  position: absolute;
  inset: auto 12px 12px 12px;
  display: flex;
  justify-content: flex-start;
  pointer-events: none;
}

.preview-play {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(8, 12, 18, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f8fafc;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
}

.thumb-preview {
  position: absolute;
  inset: 0;
}

.card-actions,
.episode-actions,
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.card-actions a,
.episode-actions a,
.detail-btn {
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  background: transparent;
}

.detail-btn {
  cursor: pointer;
}

.pagination {
  align-items: center;
  justify-content: center;
  margin-top: 18px;
}

.page-btn,
.page-info {
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  background: transparent;
  font-family: 'IBM Plex Mono', monospace;
}

.page-btn {
  cursor: pointer;
}

.page-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.related-block {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.related-btn {
  cursor: pointer;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 20;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
}

.modal-panel {
  position: relative;
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: rgba(19, 19, 22, 0.98);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--text);
  width: 36px;
  height: 36px;
  cursor: pointer;
}

.featured-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.featured-grid .collection-card {
  grid-column: span 4;
  border-color: rgba(125, 211, 252, 0.35);
}

.featured-grid .lead-card {
  grid-column: span 6;
  padding: 18px;
  background: linear-gradient(180deg, rgba(125, 211, 252, 0.14), rgba(19, 19, 22, 0.98));
  border-color: rgba(192, 132, 252, 0.55);
}

.featured-grid .lead-card h3 {
  font-size: 1.32rem;
  line-height: 1.2;
}

.featured-grid .lead-card .thumb-wrap {
  height: calc(var(--thumb-height) + 36px);
}

.editorial-card {
  background: linear-gradient(180deg, rgba(52, 211, 153, 0.06), rgba(19, 19, 22, 0.96));
}

.rail-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.rail-list li {
  color: var(--muted);
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.rail-filter-btn {
  margin-top: 12px;
}

.rank-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: 4px 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #081018;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 700;
}

.views-pill {
  color: var(--muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
}

.curator-note {
  color: var(--text);
}

.collection-card h3 {
  margin-bottom: 8px;
}

.collection-meta {
  color: var(--accent-3);
  font-size: 12px;
}

.timeline-grid {
  display: grid;
  gap: 12px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 16px;
  align-items: start;
}

.timeline-year {
  color: var(--accent);
  font-size: 1rem;
}

.episode-topic {
  display: inline-block;
  margin-top: 8px;
  margin-bottom: 10px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
}

.empty {
  padding: 20px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  color: var(--muted);
}

.footer {
  margin-top: 34px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

@media (max-width: 980px) {
  .featured-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .featured-grid .collection-card,
  .featured-grid .lead-card {
    grid-column: span 1;
  }
}

@media (max-width: 860px) {
  .hero,
  .toolbar-row,
  .timeline-item {
    grid-template-columns: 1fr;
  }

  .stats-panel {
    grid-template-columns: repeat(2, 1fr);
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
}
