:root {
  color-scheme: dark;
  --bg: #0d1112;
  --ink: #f4f7f8;
  --muted: #a8b0b5;
  --line: #2c3337;
  --panel: #151a1c;
  --panel-raised: #1b2226;
  --accent: #0b82c6;
  --accent-dark: #0870ad;
  --accent-hot: #ff6427;
  --accent-yellow: #d9f20f;
  --warn: #f49b22;
  --shadow: rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

[hidden] {
  display: none !important;
}

body {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.025) 25%, transparent 25%) 0 0 / 28px 28px,
    linear-gradient(315deg, rgba(255, 255, 255, 0.018) 25%, transparent 25%) 0 0 / 28px 28px,
    var(--bg);
  color: var(--ink);
  font-family: "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 56px) 18px;
  border-bottom: 1px solid #050708;
  background:
    linear-gradient(180deg, #151a1b 0%, #0d1112 100%);
  box-shadow: 0 8px 22px var(--shadow);
}

.topbar-main {
  display: grid;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-yellow);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(34px, 5vw, 64px);
  line-height: 1;
  color: #fff;
  font-family: Rockwell, "Roboto Slab", Georgia, serif;
  font-weight: 900;
  text-shadow: 0 3px 0 #000, 0 10px 18px var(--shadow);
  text-transform: uppercase;
}

h2 {
  font-size: 22px;
  color: #fff;
  font-weight: 900;
}

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stats span {
  min-width: 130px;
  padding: 12px 14px;
  border: 1px solid #263239;
  background: #111719;
  box-shadow: inset 0 4px 0 var(--accent);
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
}

.stats strong {
  display: block;
  font-size: 28px;
  line-height: 1;
  color: var(--accent-yellow);
}

main {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: rgba(13, 17, 18, 0.92);
  padding: 22px clamp(18px, 4vw, 56px) 56px;
}

.view-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

#searchView,
#transcriptsView {
  min-height: 0;
}

#searchView {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.view-button {
  min-height: 42px;
  border: 1px solid #2d373c;
  border-radius: 6px;
  background: #111719;
  color: #f4f7f8;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  padding: 9px 14px;
  text-transform: uppercase;
  box-shadow: 0 3px 0 #050708;
}

.view-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 3px 0 #063f62;
}

.search-panel {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(320px, 440px);
  gap: 14px;
  margin-bottom: 18px;
  border: 1px solid #0a6ea8;
  border-radius: 8px;
  background: linear-gradient(180deg, #0b82c6 0, #0b82c6 7px, #151a1c 7px);
  box-shadow: 0 8px 20px var(--shadow);
  padding: 18px;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #d8e0e4;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #364146;
  border-radius: 6px;
  background: #0c1011;
  color: var(--ink);
  font: inherit;
  padding: 8px 10px;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.45);
}

input:focus,
select:focus {
  border-color: var(--accent-yellow);
  outline: 2px solid rgba(217, 242, 15, 0.25);
  outline-offset: 1px;
}

.search-label input {
  min-height: 54px;
  font-size: 22px;
  font-weight: 900;
}

.message {
  margin-bottom: 18px;
  border-left: 4px solid var(--warn);
  background: #2a1d0e;
  padding: 12px 14px;
  color: #ffd08b;
}

.episode-title {
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}

.episode-title:hover {
  text-decoration: underline;
}

.time {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.excerpt {
  margin: 7px 0 0;
  color: #d4dadd;
  font-size: 15px;
  line-height: 1.55;
}

.results {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 12px;
  padding-right: 4px;
}

.result-card,
.empty-state {
  border: 1px solid #293236;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 20px var(--shadow);
  padding: 16px;
}

.result-card h2 {
  font-size: 20px;
  margin-top: 8px;
  text-transform: none;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: #d5dce0;
  font-size: 13px;
  font-weight: 900;
}

.result-meta span {
  border: 1px solid #3a4449;
  background: #222a2e;
  border-radius: 999px;
  padding: 4px 8px;
}

.match-line {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.match-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.match-item {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.match-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: #d4dadd;
  font-size: 13px;
  font-weight: 900;
}

mark {
  background: var(--accent-yellow);
  color: #121515;
  padding: 0 2px;
}

.episodes {
  margin-top: 32px;
}

.episode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.episode-card {
  border: 1px solid #293236;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 20px var(--shadow);
  padding: 14px;
}

.episode-card strong {
  display: block;
  margin-bottom: 8px;
}

.episode-card p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 13px;
}

.transcripts-view {
  flex: 1 1 0;
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  min-height: 0;
}

.transcript-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  max-height: 100%;
  min-height: 0;
}

.transcript-sidebar h2 {
  margin-bottom: 12px;
  border-bottom: 4px solid var(--accent);
  padding-bottom: 8px;
  text-transform: uppercase;
}

.episode-list {
  display: grid;
  gap: 8px;
  max-height: none;
  overflow: auto;
  padding-right: 4px;
}

.episode-list-item {
  width: 100%;
  border: 1px solid #293236;
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  padding: 12px;
  text-align: left;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.25);
}

.episode-list-item.active {
  border-color: var(--accent);
  background: var(--panel-raised);
  box-shadow: inset 5px 0 0 var(--accent-yellow), 0 5px 14px rgba(0, 0, 0, 0.25);
}

.episode-list-item strong,
.episode-list-item span {
  display: block;
}

.episode-list-item strong {
  margin-bottom: 6px;
  line-height: 1.3;
}

.episode-list-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.reader-shell {
  display: flex;
  flex-direction: column;
  max-height: 100%;
  min-height: 0;
  border: 1px solid #293236;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 20px var(--shadow);
  overflow: hidden;
}

.reader-heading {
  border-bottom: 1px solid #293236;
  background: linear-gradient(180deg, #0b82c6 0, #0b82c6 7px, #1b2226 7px);
  padding: 16px;
}

.reader-heading p {
  margin: 0 0 6px;
  color: var(--accent-yellow);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.reader-heading h2 {
  line-height: 1.25;
}

.transcript-lines {
  display: grid;
  gap: 0;
  overflow: auto;
  padding: 6px 16px 16px;
}

.transcript-line {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 12px;
  margin: 0;
  border-bottom: 1px solid #252d31;
  padding: 9px 0;
  line-height: 1.55;
}

.transcript-line .time {
  color: var(--accent-yellow);
  font-size: 13px;
  font-weight: 800;
}

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: #0b0f10;
}

::-webkit-scrollbar-thumb {
  background: #3a4449;
  border: 3px solid #0b0f10;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  main {
    height: auto;
    min-height: calc(100vh - 310px);
    overflow: visible;
  }

  #searchView,
  .results {
    overflow: visible;
  }

  .stats {
    justify-content: stretch;
    width: 100%;
  }

  .stats span {
    flex: 1;
  }

  .search-panel,
  .filters {
    grid-template-columns: 1fr;
  }

  .transcripts-view {
    height: auto;
    grid-template-columns: 1fr;
  }

  .transcript-sidebar {
    position: static;
  }

  .episode-list {
    max-height: 320px;
  }

  .reader-shell {
    max-height: none;
  }

  .transcript-lines {
    overflow: visible;
  }

  .transcript-line {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}
