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

:root {
  --bg: #0a1628;
  --surface: #0f2240;
  --surface-hover: #132a50;
  --border: #1a3560;
  --text: #d8e8f8;
  --text-muted: #6888aa;
  --accent: #00d4aa;
  --accent-hover: #00b890;
  --accent-dim: rgba(0, 212, 170, 0.1);
  --player-bg: #061020;
  --green: #00d4aa;
  --sidebar-w: 260px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 90px;
}

/* ============================================
   MOBILE HEADER (hidden on desktop)
   ============================================ */
.mobile-header {
  display: none;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 40;
  display: flex;
  flex-direction: column;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-close {
  display: none;
}

.sidebar .logo {
  text-decoration: none;
  display: block;
  margin-bottom: 0.25rem;
}

.logo-img {
  height: 32px;
  width: auto;
  display: block;
}

.sidebar .tagline {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-bottom: 2rem;
  line-height: 1.4;
}

.sidebar-nav-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 0.25rem;
  text-decoration: none;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
}

.sidebar-item:hover { background: var(--surface-hover); }
.sidebar-item.active { background: var(--accent-dim); color: var(--accent); }
.sidebar-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 2rem;
}

.sidebar-overlay {
  display: none;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
#app {
  margin-left: var(--sidebar-w);
  max-width: 860px;
  padding: 2rem 2.5rem;
  width: 100%;
}

/* ============================================
   CONTINUE LISTENING
   ============================================ */
.continue-section { margin-bottom: 2.5rem; }

.section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.continue-card {
  background: linear-gradient(135deg, var(--surface), var(--surface-hover));
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all 0.2s;
}

.continue-card:hover {
  box-shadow: 0 0 24px rgba(0, 212, 170, 0.12);
}

.continue-play {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.continue-play svg { fill: #0a1628; width: 18px; height: 18px; }
.continue-info { flex: 1; min-width: 0; }

.continue-title {
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.continue-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.continue-progress {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 0.5rem;
  overflow: hidden;
}

.continue-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}

/* ============================================
   TOPIC CARDS
   ============================================ */
.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.topic-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.topic-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.2s;
}

.topic-card:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.topic-card:hover::before { opacity: 1; }

.topic-card.coming-soon { opacity: 0.4; cursor: default; }
.topic-card.coming-soon:hover { background: var(--surface); border-color: var(--border); }
.topic-card.coming-soon:hover::before { opacity: 0; }

.topic-card-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.6rem;
}

.topic-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--accent-dim);
}

.topic-icon svg { width: 18px; height: 18px; }

.topic-card-header h2 {
  font-size: 1rem;
  font-weight: 700;
}

.topic-card p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.topic-card .meta {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 600;
}

.coming-soon-badge {
  font-size: 0.65rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  font-weight: 500;
}

/* ============================================
   STATS BAR
   ============================================ */
.stats-bar {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stats-bar span { display: flex; align-items: center; gap: 0.3rem; }
.stats-bar svg { width: 14px; height: 14px; fill: var(--text-muted); }

/* ============================================
   TOPIC DETAIL
   ============================================ */
.topic-header { margin-bottom: 1.5rem; }

.back-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.back-link:hover { color: var(--accent-hover); }
.back-link svg { width: 14px; height: 14px; fill: currentColor; }

.topic-detail-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topic-icon-lg {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--accent-dim);
}

.topic-icon-lg svg { width: 24px; height: 24px; }

.topic-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.topic-header .desc {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.5rem;
  line-height: 1.5;
}

/* ============================================
   EPISODE LIST
   ============================================ */
.episode-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.episode-item {
  background: var(--surface);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  transition: background 0.15s;
  border: none;
  border-left: 3px solid transparent;
}

.episode-item:hover {
  background: var(--surface-hover);
  border-left-color: var(--accent);
}

.episode-item.active {
  background: var(--surface-hover);
  border-left-color: var(--accent);
}

.episode-item.listened { border-left-color: var(--green); }
.episode-item.listened .ep-num { color: var(--green); }

.ep-num {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.ep-play-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.ep-play-btn:hover { background: var(--accent-hover); }
.ep-play-btn svg { fill: #0a1628; width: 12px; height: 12px; }

.ep-info { flex: 1; min-width: 0; }

.ep-title {
  font-size: 0.9rem;
  font-weight: 600;
}

.ep-summary {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ep-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.35rem;
}

.ep-duration {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.ep-docs-link {
  font-size: 0.7rem;
  color: var(--accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: color 0.15s;
}

.ep-docs-link:hover { color: var(--accent-hover); }
.ep-docs-link svg { width: 12px; height: 12px; fill: currentColor; }

.ep-listened-badge {
  font-size: 0.65rem;
  color: var(--green);
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.ep-listened-badge svg { width: 12px; height: 12px; fill: var(--green); }

.ep-progress-bar {
  height: 2px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 0.4rem;
  overflow: hidden;
}

.ep-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s;
}

/* ============================================
   PLAYER
   ============================================ */
.player {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-w);
  right: 0;
  background: var(--player-bg);
  border-top: 1px solid var(--border);
  padding: 0.6rem 2rem;
  z-index: 100;
}

.player.hidden { display: none; }

.player-inner {
  max-width: 860px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.skip-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color 0.15s;
}

.skip-btn:hover { color: var(--text); }
.skip-btn svg { fill: currentColor; }

.play-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.play-btn:hover { background: var(--accent-hover); }
.play-btn svg { fill: #0a1628; }
.play-btn .hidden { display: none; }

.player-info { flex: 1; min-width: 0; }

.player-title {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  margin-bottom: 0.3rem;
}

.progress-wrap { position: relative; }

.progress-bar {
  position: relative;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  cursor: pointer;
  touch-action: none;
}

.progress-bar::before {
  content: '';
  position: absolute;
  top: -12px;
  bottom: -12px;
  left: 0;
  right: 0;
}

.progress-bar:hover { height: 6px; }

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  pointer-events: none;
  width: 0%;
}

.progress-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}

.progress-bar:hover .progress-thumb { opacity: 1; }

.time-display {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.speed-select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.4rem;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.speed-select:hover, .speed-select:focus {
  color: var(--text);
  border-color: var(--accent);
}

.speed-select option { background: var(--surface); color: var(--text); }

/* ============================================
   FOOTER
   ============================================ */
.mobile-footer {
  display: none;
}

.twitter-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.75rem;
  transition: color 0.15s;
}

.twitter-link:hover { color: var(--accent); }
.twitter-link svg { fill: currentColor; }

.kbd-hint {
  position: fixed;
  bottom: 70px;
  right: 1.5rem;
  font-size: 0.65rem;
  color: var(--text-muted);
  opacity: 0.4;
  pointer-events: none;
}

/* ============================================
   TABLET BREAKPOINT (768-1024px)
   ============================================ */
@media (max-width: 1024px) and (min-width: 769px) {
  :root { --sidebar-w: 220px; }
  .sidebar { padding: 1.25rem; }
  #app { padding: 1.5rem 2rem; }
}

/* ============================================
   MOBILE BREAKPOINT (<= 768px)
   ============================================ */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  /* Show mobile header */
  .mobile-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
  }

  .mobile-header .logo {
    text-decoration: none;
  }

  .mobile-header .logo-img {
    height: 28px;
  }

  .header-spacer { flex: 1; }

  .menu-toggle {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    flex-shrink: 0;
    transition: background 0.15s;
  }

  .menu-toggle:hover { background: var(--surface-hover); }

  /* Sidebar becomes slide-out drawer */
  .sidebar {
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 60;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--border);
    cursor: pointer;
    color: var(--text-muted);
    transition: background 0.15s;
    flex-shrink: 0;
  }

  .sidebar-close:hover { background: var(--surface-hover); color: var(--text); }

  /* Overlay */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 55;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }

  .sidebar-overlay.visible {
    display: block;
  }

  /* Main content full width */
  #app {
    margin-left: 0;
    padding: 1.25rem 1rem;
  }

  /* Player full width */
  .player {
    left: 0;
    padding: 0.5rem 1rem;
  }

  /* Skip buttons visible on mobile */
  .skip-btn { width: 40px; height: 40px; }
  .kbd-hint { display: none; }

  /* Topic grid single column */
  .topics-grid { grid-template-columns: 1fr; }

  /* Stats bar wrap */
  .stats-bar {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  /* Episode items stack vertically */
  .episode-item {
    flex-wrap: wrap;
    padding: 0.875rem 1rem;
    gap: 0.5rem;
  }

  .ep-num { width: 18px; }

  .ep-summary {
    -webkit-line-clamp: 1;
  }

  .ep-meta {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* Topic header */
  .topic-header h1 {
    font-size: 1.25rem;
  }

  .topic-header .desc {
    font-size: 0.8rem;
  }

  /* Continue card */
  .continue-play {
    width: 42px;
    height: 42px;
  }

  .continue-title {
    font-size: 0.85rem;
  }

  /* Show mobile footer */
  .mobile-footer {
    display: block;
    margin-left: 0;
    padding: 2rem 1rem;
    text-align: center;
    border-top: 1px solid var(--border);
  }

  .mobile-footer p {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
  }

  /* Player: stack title+progress full-width on top, controls below */
  .player-inner {
    flex-wrap: wrap;
    gap: 0.4rem;
    position: relative;
  }

  .player-info {
    order: -1;
    flex: none;
    width: 100%;
  }

  .player-title { font-size: 0.75rem; }
  .time-display { font-size: 0.6rem; }

  .player-controls {
    flex: none;
    width: 100%;
    justify-content: center;
  }

  .play-btn { width: 36px; height: 36px; border-radius: 8px; }

  .speed-select {
    position: absolute;
    right: 0;
    bottom: 0.4rem;
  }

  /* Make progress bar easier to grab on touch */
  .progress-bar { height: 6px; border-radius: 3px; }
  .progress-fill { border-radius: 3px; }
  .progress-thumb { opacity: 1; width: 16px; height: 16px; }
}

/* ============================================
   SMALL MOBILE (<= 380px)
   ============================================ */
@media (max-width: 380px) {
  #app { padding: 1rem 0.75rem; }

  .topic-card { padding: 1rem; }
  .topic-card-header h2 { font-size: 0.9rem; }
  .topic-card p { font-size: 0.75rem; }

  .episode-item { padding: 0.75rem; }
  .ep-title { font-size: 0.85rem; }
  .ep-play-btn { width: 30px; height: 30px; }

  .continue-card { padding: 0.75rem 1rem; gap: 0.75rem; }
  .continue-play { width: 38px; height: 38px; border-radius: 10px; }

  .player { padding: 0.4rem 0.75rem; }
}
