:root {
  --color-bg: #0f172a;
  --color-bg-secondary: #1e293b;
  --color-text: #f1f5f9;
  --color-text-muted: #94a3b8;
  --color-accent: #3b82f6;
  --color-accent-hover: #2563eb;
  --color-border: #334155;
  --max-width: 1200px;
}

/* Accessibility - Skip Link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-accent);
  color: white;
  padding: 0.5rem 1rem;
  z-index: 100;
  text-decoration: none;
  border-radius: 0 0 0.25rem 0;
}

.skip-link:focus {
  top: 0;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
}

body {
  min-height: 100vh;
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem;
}

h1, h2, h3, h4 {
  line-height: 1.3;
  margin-bottom: 0.5em;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }

p {
  margin-bottom: 1rem;
}

.card {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--color-accent);
  color: white;
  border-radius: 0.25rem;
  border: none;
  cursor: pointer;
  font-size: 1rem;
}

.btn:hover {
  background: var(--color-accent-hover);
  text-decoration: none;
}

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

.btn-secondary:hover {
  background: var(--color-bg-secondary);
  border-color: var(--color-accent);
}

.video-container {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  margin-bottom: 1.5rem;
  border-radius: 0.5rem;
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.audio-player {
  width: 100%;
  margin: 1rem 0;
}

.topics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}

.topic-tag {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* Search Section */
.search-section {
  margin-bottom: 1rem;
}

.search-container {
  position: relative;
  max-width: 500px;
  margin: 0 auto;
}

.search-input {
  width: 100%;
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  font-size: 1rem;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  color: var(--color-text);
  outline: none;
  transition: border-color 0.2s;
}

.search-input::placeholder {
  color: var(--color-text-muted);
}

.search-input:focus {
  border-color: var(--color-accent);
}

.search-clear {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}

.search-clear:hover {
  color: var(--color-text);
}

.no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-text-muted);
}

.no-results p {
  margin-bottom: 1rem;
}

/* Filter Section */
.filter-section {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.filter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.filter-clear {
  background: none;
  border: none;
  color: var(--color-accent);
  cursor: pointer;
  font-size: 0.875rem;
}

.filter-clear:hover {
  text-decoration: underline;
}

.filter-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filter-tag {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  padding: 0.375rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.filter-tag:hover {
  border-color: var(--color-accent);
  color: var(--color-text);
}

.filter-tag.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: white;
}

.filter-tag.active .filter-count {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.filter-count {
  background: var(--color-border);
  padding: 0.125rem 0.375rem;
  border-radius: 0.75rem;
  font-size: 0.7rem;
}

.filter-more {
  font-style: italic;
}

.filter-status {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--color-accent);
}

.episode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.episode-card {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.episode-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.episode-card img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
}

.episode-thumb {
  position: relative;
}

.episode-thumb img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
}

.content-badges {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  display: flex;
  gap: 0.25rem;
}

.badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 0.25rem;
  font-size: 0.875rem;
}

.episode-card-content {
  padding: 1rem;
}

.episode-number {
  color: var(--color-accent);
  font-weight: bold;
  font-size: 0.875rem;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 1.5rem;
}

.tab {
  padding: 0.75rem 1.5rem;
  border: none;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 1rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

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

.tab.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Mobile tabs - horizontal scroll */
@media (max-width: 640px) {
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    padding: 0.75rem 1rem;
    white-space: nowrap;
    flex-shrink: 0;
  }
}

.summary-content {
  line-height: 1.8;
}

.summary-content h2 {
  margin-top: 1.5rem;
}

.summary-content ul {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

/* PDF Viewer */
.pdf-container {
  padding: 1rem 0;
}

.pdf-embed {
  position: relative;
  width: 100%;
  height: 600px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  overflow: hidden;
}

.pdf-viewer {
  width: 100%;
  height: 100%;
  border: none;
}

.pdf-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  .pdf-embed {
    height: 400px;
  }
}

/* Episode Navigation */
.episode-nav {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

.nav-link {
  display: flex;
  flex-direction: column;
  padding: 1rem;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s;
  flex: 1;
  max-width: 40%;
}

.nav-link:hover {
  background: var(--color-bg);
  border-color: var(--color-accent);
  text-decoration: none;
}

.nav-prev {
  text-align: left;
}

.nav-next {
  text-align: right;
}

.nav-home {
  flex: 0 0 auto;
  max-width: none;
  align-items: center;
  justify-content: center;
}

.nav-placeholder {
  flex: 1;
  max-width: 40%;
  visibility: hidden;
}

.nav-direction {
  font-size: 0.875rem;
  color: var(--color-accent);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.nav-episode {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

@media (max-width: 768px) {
  .episode-nav {
    flex-wrap: wrap;
  }

  .nav-link {
    max-width: 100%;
  }

  .nav-home {
    order: -1;
    width: 100%;
    margin-bottom: 0.5rem;
  }

  .nav-prev, .nav-next {
    flex: 1 1 45%;
  }

  .nav-placeholder {
    display: none;
  }
}
