/* ============================================================
   刻本 — woodblock-print / seal design tokens
   A Chinese sermon-teaching archive: rice-paper ground, ink text,
   a single cinnabar (印章红) accent reserved for the brand seal + the
   live playing state. System sans throughout — no webfont fetched
   (robust + legible inside China / WeChat).
   ============================================================ */
:root {
  --paper: #f4f1ea;      /* page ground — warm rice paper */
  --paper-2: #ece6da;    /* inset pills / subtle fills */
  --card: #fffefb;       /* card surface, a hair warmer than white */
  --ink: #20242e;        /* primary text + primary actions */
  --ink-700: #161922;    /* hover / pressed */
  --ink-900: #0e1016;    /* deepest */
  --ink-soft: #5d6373;   /* secondary / meta text */
  --line: #e4ddd0;       /* hairlines, card borders */
  --cinnabar: #b23a31;   /* THE accent: seal + live state only */
  --cinnabar-700: #97302a;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", "PingFang SC",
    "Microsoft YaHei", sans-serif;
}

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

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  padding-bottom: 120px; /* Space for sticky player */
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem 2rem 2rem;
}

/* Header */
.header {
  background: var(--card);
  padding: 15px 0;
  box-shadow: none;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2rem;
}

.header-content {
  display: flex;
  align-items: center;
  gap: 15px;
}

.header-link {
  display: flex;
  align-items: center;
  gap: 15px;
  text-decoration: none;
  color: inherit;
  transition: opacity 0.2s;
}

.header-link:hover {
  opacity: 0.8;
}

/* Brand mark rendered as a vermilion seal (印章): a stamped square with
   an inset hairline, the way a seal sits on a classic printed text. */
.logo {
  width: 52px;
  height: 52px;
  background: var(--cinnabar);
  border-radius: 6px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55),
    inset 0 0 0 3px var(--cinnabar);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
}

.header-text h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 0;
  color: var(--ink);
}

.header-auth-buttons {
  margin-left: auto;
  display: flex;
  gap: 10px;
  align-items: center;
}

.login-link {
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--ink) 0%, var(--ink-700) 100%);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s;
}

.login-link:hover {
  background: linear-gradient(135deg, var(--ink-700) 0%, var(--ink-900) 100%);
}

.login-link-active {
  background: var(--ink-900);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
  position: relative;
}

.login-link-active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 3px;
  background: white;
  border-radius: 2px 2px 0 0;
}

.login-link-active:hover {
  background: var(--ink-900);
}

/* Nav Dropdown */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-trigger {
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--ink) 0%, var(--ink-700) 100%);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s;
  cursor: pointer;
  border: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-dropdown-trigger:hover {
  background: linear-gradient(135deg, var(--ink-700) 0%, var(--ink-900) 100%);
}

.nav-dropdown-trigger.has-active {
  background: var(--ink-900);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.nav-dropdown-trigger .arrow {
  font-size: 10px;
  transition: transform 0.2s;
}

.nav-badge {
  display: inline-block;
  min-width: 18px;
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: 999px;
  background: #dc3545;
  color: white;
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.nav-dropdown.open .nav-dropdown-trigger .arrow {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  min-width: 180px;
  z-index: 1000;
  display: none;
  overflow: hidden;
}

.nav-dropdown.open .nav-dropdown-menu {
  display: block;
}

.nav-dropdown-menu a {
  display: block;
  padding: 10px 16px;
  color: #374151;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s;
  white-space: nowrap;
}

.nav-dropdown-menu a:hover {
  background: #f3f4f6;
}

.nav-dropdown-menu a.active {
  background: #eef2ff;
  color: var(--ink);
  font-weight: 600;
}

/* Page Header (Admin Pages) */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.page-header h2 {
  margin: 0;
}

.page-nav {
  display: flex;
  gap: 10px;
}

/* Search and Filters - Option C Layout */
.controls-wrapper {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 20px;
  padding: 15px 20px;
}

/* Main row: search + filter toggle button */
.controls-main-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.controls-main-row .search-box {
  flex: 1;
  min-width: 0;
}

/* Filter toggle button */
.filter-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.filter-toggle-btn:hover {
  border-color: var(--ink);
  background: #f8fafc;
}

/* Semantic search trigger (primary action) */
.semantic-search-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 18px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.semantic-search-btn:hover {
  background: var(--ink-700);
  border-color: var(--ink-700);
}

.semantic-search-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.filter-badge {
  padding: 2px 6px;
  background: var(--ink);
  color: white;
  border-radius: 10px;
  font-size: 11px;
  display: none;
}

.filter-badge.active {
  display: inline;
}

.filter-arrow {
  color: #a0aec0;
  transition: transform 0.2s ease;
}

.controls-wrapper.expanded .filter-arrow {
  transform: rotate(180deg);
}

/* Collapsible filters */
.filters-collapsible {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, margin-top 0.3s ease, opacity 0.3s ease;
  opacity: 0;
  margin-top: 0;
}

.controls-wrapper.expanded .filters-collapsible {
  max-height: 200px;
  margin-top: 15px;
  opacity: 1;
}

.filters-collapsible .filter-select {
  flex: 1;
  min-width: 120px;
}

.search-box {
  flex: 1;
  min-width: 250px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  background: var(--card);
  color: var(--ink);
}

.search-box input:focus {
  outline: none;
  border-color: var(--ink);
}

.filter-select {
  padding: 12px 35px 12px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  background: white;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.filter-select:focus {
  outline: none;
  border-color: var(--ink);
}

/* Card Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
  margin-bottom: 30px;
}

.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 18px 20px;
  box-shadow: 0 1px 2px rgba(32, 36, 46, 0.04);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  cursor: pointer;
}

@media (hover: hover) {
  .card:hover {
    transform: translateY(-2px);
    border-color: #d8cfbe;
    box-shadow: 0 6px 18px rgba(32, 36, 46, 0.08);
  }
}

/* Live: the playing card is marked in cinnabar, the one accent colour */
.card.playing {
  border-color: var(--cinnabar);
  box-shadow: 0 4px 16px rgba(178, 58, 49, 0.16);
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 8px;
  line-height: 1.4;
  color: var(--ink);
}

.card-link {
  display: block;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.card-link:hover .card-title,
.card-link:focus-visible .card-title {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.card-link:focus-visible,
.resource-page-link:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
  border-radius: 4px;
}

.card-description {
  color: #666;
  font-size: 14px;
  margin-bottom: 15px;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tags {
  display: flex;
  gap: 8px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

.tag {
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 12px;
  background: #f0f0f0;
  color: #666;
}

.tag.video {
  background: #e3f2fd;
  color: #1976d2;
}

.tag.audio {
  background: #f3e5f5;
  color: #7b1fa2;
}

/* Combined series tag (mainSeries · subSeries) — a ledger marker: flat
   label with a cinnabar spine on its left edge rather than a soft pill. */
.card-series {
  margin-bottom: 6px;
}

.series-tag {
  display: inline-block;
  max-width: 100%;
  padding: 3px 10px;
  background: var(--paper-2);
  color: var(--ink-soft);
  border-left: 3px solid var(--cinnabar);
  border-radius: 0 4px 4px 0;
  font-size: 12.5px;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Meta: date · speaker, set typographically (no emoji), middot-joined */
.card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--ink-soft);
}

.card-meta span {
  display: inline-flex;
  align-items: center;
}

.card-meta span + span::before {
  content: "·";
  margin: 0 8px;
  color: #b9ac95;
}

.card-meta .meta-speaker {
  font-weight: 500;
  color: var(--ink);
}

.card-match-snippet {
  margin: -4px 0 14px;
  padding: 10px 12px;
  border-left: 3px solid var(--cinnabar);
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.55;
  border-radius: 0 6px 6px 0;
}

/* AI Summary on Card */
.card-ai-summary {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px;
  margin-bottom: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.card-ai-summary:hover {
  background: var(--paper-2);
}

.card-ai-summary .ai-icon {
  flex-shrink: 0;
  font-size: 16px;
}

.card-ai-summary .ai-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* AI Summary Modal */
.ai-summary-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3000;
}

.ai-summary-modal.open {
  display: block;
}

.ai-summary-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.ai-summary-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 700px;
  max-height: 85vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: aiSummarySlideIn 0.3s ease;
}

@keyframes aiSummarySlideIn {
  from {
    opacity: 0;
    transform: translate(-50%, -45%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

.ai-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  gap: 12px;
}

.ai-summary-title-section {
  flex: 1;
  min-width: 0;
}

.ai-summary-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-summary-subtitle {
  margin: 2px 0 0 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
}

.ai-summary-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  font-size: 16px;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.ai-summary-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.ai-summary-body {
  padding: 20px;
  max-height: calc(85vh - 80px);
  overflow-y: auto;
  overscroll-behavior: contain; /* Prevent scroll chaining to background */
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

/* Lock body scroll when modal is open */
body.modal-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

.ai-summary-section {
  margin-bottom: 20px;
}

.ai-summary-section:last-child {
  margin-bottom: 0;
}

.ai-summary-section-title {
  font-size: 13px;
  font-weight: 600;
  color: #8b5cf6;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 8px 0;
}

.ai-summary-excerpt {
  background: #f8f5ff;
  border-left: 4px solid #8b5cf6;
  padding: 12px 16px;
  font-size: 15px;
  line-height: 1.6;
  color: #333;
  border-radius: 0 8px 8px 0;
}

.ai-summary-full {
  font-size: 14px;
  line-height: 1.7;
  color: #444;
  white-space: pre-wrap;
}

.ai-summary-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 12px;
  color: #666;
  padding-top: 12px;
  border-top: 1px solid #eee;
}

.ai-summary-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-summary-loading {
  text-align: center;
  padding: 40px 20px;
  color: #666;
}

.ai-summary-error {
  text-align: center;
  padding: 40px 20px;
  color: #dc3545;
}

/* Audio Summary Player in Modal */
.ai-summary-audio-section {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-left: 4px solid #0ea5e9;
  padding: 16px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 20px;
}

.ai-summary-audio-section .ai-summary-section-title {
  color: #0369a1;
}

.ai-summary-audio-player {
  width: 100%;
  height: 40px;
  border-radius: 4px;
}

/* Section header with inline listen button */
.ai-summary-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

/* Listen Audio Button - pill style */
.ai-summary-listen-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  color: #fff;
  border: none;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.ai-summary-listen-btn:hover {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  transform: scale(1.02);
}

.ai-summary-listen-btn:active {
  transform: scale(0.98);
}

.ai-summary-listen-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.ai-summary-listen-btn .listen-icon {
  font-size: 14px;
}

/* Playing state - green */
.ai-summary-listen-btn.playing {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
}

@media (max-width: 600px) {
  .ai-summary-content {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
    transform: none;
    animation: aiSummarySlideUp 0.3s ease;
  }

  @keyframes aiSummarySlideUp {
    from {
      opacity: 0;
      transform: translateY(100%);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .ai-summary-header {
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .ai-summary-body {
    padding: 16px;
    max-height: none;
    height: calc(100vh - 56px); /* Full height minus header */
    overflow-y: auto;
  }
}

.play-button {
  width: 100%;
  padding: 12px;
  background: #000;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.play-button:hover {
  background: #333;
}

.download-button {
  width: 100%;
  padding: 12px;
  background: var(--ink);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  margin-top: 8px;
}

.download-button:hover {
  background: var(--ink-700);
}

.play-button.playing {
  background: var(--ink);
}

.play-button .icon {
  font-size: 16px;
}

/* Sticky Player - Compact Redesign */
.player {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(150%);
  width: calc(100% - 4rem);
  max-width: calc(1400px - 4rem);
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 24px;
  padding: 12px 20px;
  box-shadow: 
    0 10px 40px rgba(0, 0, 0, 0.1),
    0 4px 12px rgba(0, 0, 0, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  color: #333;
  transition: transform 0.5s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 3100; /* Above AI summary modal (z-index: 3000) */
}

.player.active {
  transform: translateX(-50%) translateY(0);
}

.player-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

/* Close button - top right overlay */
.close-player {
  position: absolute;
  top: 0;
  right: 0;
  background: transparent;
  border: none;
  color: #718096;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.2s;
  z-index: 10;
}

.close-player:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #4a5568;
}

/* Header row: Title only (no speed control) */
.player-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-right: 24px; /* Space for close button */
}

.player-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.player-title {
  font-size: 15px;
  font-weight: 600;
  color: #1a202c;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-subtitle {
  font-size: 12px;
  color: #718096;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Speed control in controls row */
.speed-control {
  display: flex;
  align-items: center;
}

.player-button.speed-button {
  width: auto;
  min-width: 52px;
  height: 32px;
  padding: 0 12px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.05);
}

.player-button.speed-button:hover {
  background: rgba(0, 0, 0, 0.1);
  transform: scale(1.05);
}

/* Progress bar - full width */
.player-progress {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: #d1d5db;
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  margin-bottom: 6px;
  transition: height 0.2s;
}

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

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ink) 0%, var(--ink) 100%);
  border-radius: 3px;
  width: 0%;
  position: relative;
  box-shadow: 0 0 10px rgba(32, 36, 46, 0.5);
  transition: width 0.1s linear;
}

.progress-fill::after {
  content: '';
  position: absolute;
  right: -5px;
  top: 50%;
  transform: translateY(-50%) scale(0);
  width: 12px;
  height: 12px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}

.progress-bar:hover .progress-fill::after {
  transform: translateY(-50%) scale(1);
}

.progress-time {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #718096;
  font-variant-numeric: tabular-nums;
}

/* Controls row */
.player-controls-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  position: relative;
  min-height: 60px;
}

.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

/* Volume on left, speed on right, share on left (mobile only) */
.volume-control {
  position: absolute;
  left: 0;
}

.speed-control {
  position: absolute;
  right: 0;
}

.playback-mode-control {
  position: absolute;
  right: 66px;
  display: flex;
  align-items: center;
}

.share-control {
  position: absolute;
  left: 0;
  display: none; /* Hidden on desktop */
}

.share-button.sharing {
  animation: sharePulse 0.3s ease;
}

@keyframes sharePulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.15);
    background: rgba(32, 36, 46, 0.1);
  }
}

@keyframes fadeInOut {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(10px);
  }
  10%, 90% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
}

.player-button {
  background: transparent;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #4a5568;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-size: 16px;
}

.player-button:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #2d3748;
  transform: scale(1.05);
}

.player-button:active {
  transform: scale(0.95);
}

.player-button.play-pause {
  width: 52px;
  height: 52px;
  background: var(--ink);
  color: white;
  box-shadow: 0 4px 12px rgba(32, 36, 46, 0.3);
  font-size: 20px;
}

.player-button.play-pause:hover {
  background: var(--ink-700);
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(32, 36, 46, 0.5);
}

.player-button.play-pause:active {
  transform: scale(0.95);
}

/* Skip button sizing */
.player-button.skip-button {
  width: 44px;
  height: 44px;
}

/* Skip button animation */
.player-button.skip-button.skipping {
  animation: skipPulse 0.3s ease;
}

@keyframes skipPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.15);
    background: rgba(32, 36, 46, 0.1);
  }
}

/* Volume control */
.volume-control {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.volume-slider {
  width: 60px;
  height: 4px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  transition: height 0.2s;
}

.volume-slider:hover {
  height: 6px;
}

.volume-fill {
  height: 100%;
  background: #718096;
  border-radius: 2px;
  width: 100%;
}

.close-player {
  background: rgba(0, 0, 0, 0.05);
  border: none;
  color: #718096;
  cursor: pointer;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  margin-left: 8px;
  transition: all 0.2s;
}

.close-player:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #4a5568;
}

/* Loading State */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: #666;
}

.loading-spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--ink);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: #666;
}

.empty-state-icon {
  font-size: 64px;
  margin-bottom: 20px;
  opacity: 0.5;
}

.semantic-empty {
  max-width: 520px;
  margin: 60px auto;
  padding: 32px 20px;
  text-align: center;
  color: #4a5568;
}

.semantic-empty p {
  margin: 0 0 18px;
  font-size: 15px;
  line-height: 1.6;
}

.semantic-return-button {
  padding: 10px 22px;
  border: none;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.semantic-return-button:hover {
  background: var(--ink-700);
}

/* Load More Button */
.load-more-container {
  text-align: center;
  margin: 40px 0;
  padding: 20px;
}

.load-more-info {
  font-size: 14px;
  color: #666;
  margin-bottom: 15px;
}

.load-more-button {
  padding: 12px 40px;
  background: var(--ink);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

.load-more-button:hover:not(:disabled) {
  background: var(--ink-700);
}

.load-more-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Speed Control */
.speed-control {
  display: flex;
  align-items: center;
  margin-left: 8px;
}

.player-button.speed-button {
  width: auto;
  min-width: 48px;
  height: 32px;
  padding: 0 10px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.05);
}

.player-button.speed-button:hover {
  background: rgba(0, 0, 0, 0.1);
  transform: scale(1.05);
}

.player-button.playback-mode-button {
  width: auto;
  min-width: 64px;
  height: 32px;
  padding: 0 10px;
  border-radius: 16px;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.05);
}

.player-button.playback-mode-button:hover,
.player-button.playback-mode-button.active {
  background: rgba(32, 36, 46, 0.12);
  color: #4c51bf;
}

.playback-mode-icon {
  font-size: 10px;
  line-height: 1;
}

/* Speed Menu Modal */
.speed-menu {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.speed-menu-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.2s ease;
}

.speed-menu-content {
  position: relative;
  background: white;
  border-radius: 16px;
  padding: 0;
  min-width: 280px;
  max-width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.3s ease;
  overflow: hidden;
}

.speed-menu-header {
  padding: 20px;
  font-size: 18px;
  font-weight: 600;
  color: #333;
  text-align: center;
  border-bottom: 1px solid #eee;
}

.speed-menu-options {
  padding: 10px 0;
}

.speed-option {
  width: 100%;
  padding: 16px 24px;
  background: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background 0.2s;
  gap: 15px;
}

.speed-option:hover {
  background: var(--paper);
}

.speed-option.active {
  background: #f0f4ff;
}

.speed-option.active .speed-check {
  opacity: 1;
}

.speed-value {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  min-width: 50px;
}

.speed-label {
  flex: 1;
  font-size: 14px;
  color: #666;
  text-align: left;
}

.speed-check {
  font-size: 18px;
  color: var(--ink);
  opacity: 0;
  transition: opacity 0.2s;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Share Menu Modal */
.share-menu {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.share-menu-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.2s ease;
}

.share-menu-content {
  position: relative;
  background: white;
  border-radius: 16px;
  padding: 0;
  min-width: 320px;
  max-width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.3s ease;
  overflow: hidden;
}

.share-menu-header {
  padding: 20px;
  font-size: 18px;
  font-weight: 600;
  color: #333;
  text-align: center;
  border-bottom: 1px solid #eee;
}

.share-menu-options {
  padding: 10px 0;
}

.share-option {
  width: 100%;
  padding: 18px 24px;
  background: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background 0.2s;
}

.share-option:hover {
  background: var(--paper);
}

.share-option-content {
  display: flex;
  align-items: center;
  gap: 15px;
  flex: 1;
}

.share-option-icon {
  font-size: 24px;
  width: 32px;
  text-align: center;
}

.share-option-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.share-option-label {
  font-size: 16px;
  font-weight: 500;
  color: #333;
}

.share-option-desc {
  font-size: 13px;
  color: #666;
}

.share-check {
  font-size: 20px;
  color: #cbd5e0;
}

/* Responsive */
@media (max-width: 768px) {
  .cards-grid {
    grid-template-columns: 1fr;
  }

  .controls {
    flex-direction: column;
  }

  .search-box {
    width: 100%;
  }

  /* Give the search field its own full-width row; semantic + filter wrap
     below it so the input isn't crushed to a few characters on phones */
  .controls-main-row .search-box {
    flex: 1 1 100%;
  }

  .semantic-search-btn,
  .filter-toggle-btn {
    flex: 1 1 0;
    justify-content: center;
  }

  /* Compact player responsive */
  .player {
    padding: 10px 16px;
    width: calc(100% - 4rem);
  }

  .player-content {
    gap: 6px;
  }

  .player-header {
    padding-right: 28px;
  }

  .player-title {
    font-size: 14px;
  }

  .player-subtitle {
    font-size: 11px;
  }

  .player-button.play-pause {
    width: 46px;
    height: 46px;
  }

  .player-button {
    width: 32px;
    height: 32px;
  }

  .volume-control {
    display: none; /* Hide volume on mobile */
  }

  .share-control {
    display: flex; /* Show share on mobile */
    align-items: center;
  }

  /* On narrow screens the absolutely-positioned control groups collide
     (the skip-forward "30" button overlapped the playback-mode "单集"
     button). Lay everything out as a single evenly-spaced flex row so the
     groups flow side by side without overlapping. */
  .player-controls-row {
    justify-content: space-between;
    gap: 4px;
    min-height: 56px;
  }

  .share-control,
  .player-controls,
  .playback-mode-control,
  .speed-control {
    position: static;
    left: auto;
    right: auto;
    transform: none;
  }

  .share-control {
    order: 1;
  }
  .player-controls {
    order: 2;
    gap: 4px;
  }
  .playback-mode-control {
    order: 3;
  }
  .speed-control {
    order: 4;
    margin-left: 0;
  }

  .player-button.skip-button {
    width: 32px;
    height: 32px;
  }

  .player-button.playback-mode-button {
    min-width: 48px;
    height: 32px;
    padding: 0 7px;
    font-size: 12px;
  }

  .player-button.speed-button {
    min-width: 42px;
    padding: 0 7px;
    font-size: 12px;
  }

  /* Hide prev/next on mobile, keep skip buttons */
  .prev-next-btn {
    display: none;
  }

  .load-more-button {
    width: 100%;
    max-width: 300px;
  }

  /* Hierarchical Layout Responsive */
  .nav-bar {
    gap: 10px;
  }

  .breadcrumb {
    justify-content: flex-start;
    flex-wrap: wrap;
  }


  .list-view {
    padding: 0;
  }
}

/* ========================================
   Hierarchical Layout Styles
   ======================================== */

/* Navigation Bar */
.nav-bar {
  position: sticky;
  top: 0;
  background: white;
  padding: 12px 20px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  z-index: 500;
  transition: box-shadow 0.3s ease;
}

.nav-bar.scrolled {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  border-radius: 0 0 12px 12px;
}

/* Back Button */
.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: none;
  color: #718096;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  margin-right: 5px;
}

.back-btn:hover {
  background: #f7fafc;
  color: #2d3748;
  border-radius: 6px;
}

.back-icon {
  font-size: 18px;
}

/* Breadcrumb */
.breadcrumb {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #718096;
  overflow-x: auto;
  white-space: nowrap;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.breadcrumb-link {
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s;
  padding: 4px 8px;
  border-radius: 4px;
}

.breadcrumb-link:hover {
  color: var(--ink-700);
  background: #f7fafc;
}

.breadcrumb-current {
  color: #2d3748;
  font-weight: 500;
}

.breadcrumb-separator {
  color: #cbd5e0;
  user-select: none;
}

/* List View Container */
.list-view {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

/* List Items */
.list-item {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #f7fafc;
  cursor: pointer;
  transition: all 0.2s;
  gap: 12px;
}

.list-item:last-child {
  border-bottom: none;
}

.list-item:hover {
  background: #f7fafc;
}

.list-item:active {
  background: #edf2f7;
}

/* Series/Subseries List Items */
.series-item,
.subseries-item {
  justify-content: space-between;
}

.series-item-main,
.subseries-item-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.series-icon,
.subseries-icon {
  font-size: 20px;
  width: 24px;
  text-align: center;
}

.series-name,
.subseries-name {
  font-size: 16px;
  font-weight: 500;
  color: #2d3748;
}

.series-count,
.subseries-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  background: #edf2f7;
  color: #4a5568;
  font-size: 13px;
  font-weight: 600;
  border-radius: 14px;
}

.series-chevron,
.subseries-chevron {
  color: #cbd5e0;
  font-size: 18px;
  transition: transform 0.2s;
}

.series-item:hover .series-chevron,
.subseries-item:hover .subseries-chevron {
  transform: translateX(4px);
  color: #a0aec0;
}

/* Resource List Items */
.resource-item {
  display: flex;
  align-items: center;
  gap: 15px;
}

.resource-item.playing {
  background: #f0f4ff;
}

.resource-item.playing .resource-play-btn {
  background: var(--ink);
  color: white;
}

.resource-play-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  background: #edf2f7;
  border: none;
  color: #4a5568;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.resource-play-btn:hover {
  background: var(--ink);
  color: white;
  transform: scale(1.05);
}

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

.resource-title {
  font-size: 15px;
  font-weight: 500;
  color: #2d3748;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-meta {
  display: flex;
  align-items: center;
  gap: 15px;
  font-size: 13px;
  color: #718096;
}

.resource-date,
.resource-duration {
  display: flex;
  align-items: center;
  gap: 5px;
}

.resource-date::before {
  content: '📅';
  font-size: 12px;
}

.resource-duration::before {
  content: '⏱️';
  font-size: 12px;
}

/* Section Headers (for mixed subseries + resources view) */
.list-section-header {
  padding: 12px 20px;
  background: #f7fafc;
  border-bottom: 1px solid #edf2f7;
  font-size: 13px;
  font-weight: 600;
  color: #718096;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Download Button in List View */
.resource-download-btn,
.resource-page-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 8px;
  background: #f7fafc;
  color: #4a5568;
  text-decoration: none;
  font-size: 18px;
  transition: all 0.2s;
  margin-left: 8px;
}

.resource-page-link {
  width: auto;
  padding: 0 10px;
  font-size: 13px;
  white-space: nowrap;
  flex-shrink: 0;
}

.resource-download-btn:hover,
.resource-page-link:hover {
  background: var(--ink);
  color: white;
  transform: scale(1.05);
}

/* Video Element in List View */
.resource-video {
  flex-shrink: 0;
  margin-right: 12px;
}

/* ========================================
   WeChat Browser Prompt Overlay
   ======================================== */

.wechat-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10001;
  background: white;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0;
}

.wechat-top-bar {
  width: 100%;
  background: #ff6b00;
  color: white;
  padding: 20px 30px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: relative;
  min-height: 140px;
}

.wechat-step-1 {
  font-size: 22px;
  font-weight: 400;
  margin-top: 40px;
  margin-left: 20px;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.wechat-dots-icon {
  display: inline-flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  padding: 2px 6px;
  margin: 0 4px;
  vertical-align: middle;
}

.wechat-dots-icon svg {
  width: 20px;
  height: 20px;
}

.wechat-arrow {
  position: absolute;
  top: 15px;
  right: 25px;
  animation: float 2s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.wechat-content-body {
  width: 100%;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: white;
}

.wechat-step-2 {
  font-size: 22px;
  color: #333;
  margin-bottom: 30px;
  line-height: 1.6;
  text-align: left;
  align-self: flex-start;
  margin-left: 30px;
  max-width: 90%;
}

.wechat-step-2 strong {
  font-weight: 600;
  color: #000;
}

.wechat-screenshot {
  width: 100%;
  max-width: 400px;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  margin-top: 20px;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  /* Reclaim horizontal space on small phones so the player's six controls
     (share / skip-back / play / skip-forward / playback-mode / speed) fit
     on one row without crowding. */
  .player {
    width: calc(100% - 2rem);
    padding: 10px 12px;
  }

  .wechat-step-1 {
    font-size: 18px;
    margin-top: 30px;
    margin-left: 10px;
  }
  
  .wechat-step-2 {
    font-size: 18px;
    margin-bottom: 20px;
    margin-left: 20px;
  }
  
  .wechat-menu-simulation {
    gap: 8px;
    padding: 15px;
  }
  
  .wechat-icon-box {
    width: 48px;
    height: 48px;
  }
}

/* ============ MEDIA BUNDLE CARD STYLES ============ */

/* Single part buttons (side by side) */
.media-buttons-single {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

/* Desktop: Stack vertically when both audio-row (with download) and video button exist */
@media (min-width: 601px) {
  .media-buttons-single:has(.audio-row):has(.video-btn) {
    flex-direction: column;
    gap: 10px;
  }

  .media-buttons-single:has(.audio-row):has(.video-btn) .audio-row {
    width: 100%;
  }

  .media-buttons-single:has(.audio-row):has(.video-btn) .video-btn {
    width: 100%;
  }
}

/* Single part with BOTH audio + video: two peer actions on one row
   (mirrors a multi-part speaker row). Higher specificity than the
   column-forcing rules above, so it stays a row at every width. */
.media-buttons-single.both {
  flex-direction: row;
  gap: 8px;
}

.media-buttons-single.both .media-btn {
  flex: 1;
}

.media-buttons-single.both .download-icon-btn {
  flex: 0 0 auto;
}

/* Download icon matches the height of the play/video button beside it,
   so every button in a single-part row lines up exactly */
.audio-row .download-icon-btn,
.media-buttons-single.both .download-icon-btn {
  align-self: stretch;
  height: auto;
}

.media-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 16px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}

/* In the both-row, let the labels size the buttons (no shrink-to-wrap) */
.media-buttons-single.both .media-btn {
  min-width: 0;
  padding-left: 12px;
  padding-right: 12px;
}

.media-btn .icon {
  font-size: 14px;
}

/* Primary action: solid ink, quiet but unmistakable */
.audio-btn {
  background: var(--ink);
  color: #fff;
}

.audio-btn:hover {
  background: var(--ink-700);
}

/* Secondary media: outline, so audio (filled) vs video (outline) read as
   a clear primary/secondary pair instead of two saturated blocks */
.video-btn {
  background: var(--card);
  border-color: var(--ink);
  color: var(--ink);
}

.video-btn:hover {
  background: var(--ink);
  color: #fff;
}

/* Audio row wrapper for inline download (single-part) */
.audio-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.audio-row .media-btn {
  flex: 1;
}

/* Compact download icon button */
.download-icon-btn {
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  color: var(--ink-soft);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.download-icon-btn:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

/* ============ MULTI-PART: one row per speaker ============
   Each speaker's name appears once, with audio / video / download grouped
   as chips beside it — replaces the old three mode-rows that repeated names */
.media-parts {
  margin-top: 14px;
  border-top: 1px solid var(--line);
}

.speaker-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.speaker-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.speaker-row-head {
  margin-bottom: 9px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
}

.speaker-row-actions {
  display: flex;
  gap: 8px;
}

/* Audio + video share the remaining width; download keeps its compact size */
.speaker-row-actions .part-chip {
  flex: 1;
  min-width: 0;
}

.speaker-row-actions .dl-chip {
  flex: 0 0 auto;
}

.part-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 38px;
  padding: 0 12px;
  white-space: nowrap;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.part-chip .chip-icon {
  font-size: 11px;
}

/* Audio is the primary action: filled ink. Video is secondary: outline. */
.audio-chip {
  background: var(--ink);
  color: #fff;
}

.audio-chip:hover {
  background: var(--ink-700);
}

.video-chip:hover {
  background: var(--ink);
  color: #fff;
}

/* Download: compact icon-only square */
.dl-chip {
  padding: 0 12px;
  border-color: var(--line);
  color: var(--ink-soft);
  font-size: 16px;
}

.dl-chip:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

/* Live state matches the rest of the card */
.part-chip.playing {
  background: var(--cinnabar);
  border-color: var(--cinnabar);
  color: #fff;
  animation: pulse 2s ease-in-out infinite;
}

.part-chip.playing:hover {
  background: var(--cinnabar-700);
}

/* Playing state — cinnabar marks "live", matching the card border.
   Applies to single-part .media-btn and multi-part .part-chip. */
.media-btn.playing {
  background: var(--cinnabar);
  border-color: var(--cinnabar);
  color: #fff;
  animation: pulse 2s ease-in-out infinite;
}

.media-btn.playing:hover {
  background: var(--cinnabar-700);
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* ============ VIDEO PLAYER MODAL ============ */

.video-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
}

.video-modal.open {
  display: block;
}

.video-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
}

.video-modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #1a1a1a;
  border-radius: 12px;
  width: 90%;
  max-width: 900px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: videoModalSlideIn 0.3s ease;
}

@keyframes videoModalSlideIn {
  from {
    opacity: 0;
    transform: translate(-50%, -45%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

.video-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #222;
  gap: 12px;
}

.video-modal-title-section {
  flex: 1;
  min-width: 0;
}

.video-modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-modal-subtitle {
  margin: 2px 0 0 0;
  font-size: 13px;
  color: #aaa;
}

.video-modal-part-indicator {
  background: var(--ink);
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.video-modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  font-size: 16px;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.video-modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.video-modal-player-area {
  background: #000;
}

.video-modal-video {
  width: 100%;
  max-height: 70vh;
  display: block;
}

/* Video modal control bar */
.video-modal-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  padding: 16px;
  background: #1a1a1a;
}

.video-control-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  transition: all 0.2s ease;
}

.video-control-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.video-control-btn:active {
  transform: scale(0.95);
}

.video-control-btn.skipping {
  animation: videoSkipPulse 0.3s ease;
}

@keyframes videoSkipPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.15);
    background: rgba(32, 36, 46, 0.3);
  }
}

.video-speed-btn {
  border-radius: 8px;
  width: auto;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  min-width: 60px;
}

.video-speed-btn:hover {
  background: rgba(32, 36, 46, 0.3);
}

.video-share-btn {
  position: relative;
}

.video-share-btn.sharing {
  transform: scale(0.95);
}

.video-share-menu {
  z-index: 10020;
}

/* Responsive video controls */
@media (max-width: 600px) {
  .video-modal-controls {
    gap: 16px;
    padding: 12px;
  }

  .video-control-btn {
    width: 44px;
    height: 44px;
  }

  .video-control-btn svg {
    width: 20px;
    height: 20px;
  }

  .video-speed-btn {
    padding: 8px 12px;
    font-size: 13px;
    min-width: 50px;
  }
}

/* Download button in grid cards */
.download-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  background: white;
  color: #4a5568;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.download-btn .icon {
  font-size: 16px;
}

.download-btn:hover {
  background: #4a5568;
  border-color: #4a5568;
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(74, 85, 104, 0.3);
}

/* Video modal responsive */
@media (max-width: 600px) {
  .video-modal-content {
    width: 100%;
    max-width: none;
    max-height: 100vh;
    border-radius: 0;
  }

  .video-modal-header {
    padding: 12px 16px;
  }

  .video-modal-title {
    font-size: 14px;
  }

  .video-modal-video {
    max-height: 50vh;
  }

  .media-buttons-single {
    flex-direction: column;
  }

  /* Audio row stays horizontal with download icon on mobile */
  .audio-row {
    width: 100%;
    flex-direction: row;
  }

  .download-icon-btn {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
  }
}

/* ========================================
   Document Links Section
   ======================================== */

/* Course handout (课件) — a supplementary link, so it rides on the meta
   row, pushed to the right, rather than claiming its own row + divider */
.card-documents {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.document-item {
  display: inline-flex;
  gap: 6px;
}

.document-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.2s;
}

.document-link:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.document-link:active {
  transform: translateY(1px);
}

@media (max-width: 600px) {
  .card-documents {
    width: 100%;
    margin-left: 0;
    margin-top: 8px;
    justify-content: flex-start;
  }
}

/* ─── Mobile (≤768px) — compact admin header + hamburger drawer ─── */
@media (max-width: 768px) {
  /* Reserve space for the fixed header on every page that doesn't manage
     its own layout (front page, manage-files, etc.). The transcription
     editor opts out via its own body { padding-top: 0 !important } in
     transcription-editor.css and reserves space via #transcription-editor. */
  body {
    padding-top: 48px;
  }

  /* Compact, fixed header — out of normal flow so editor can reclaim space */
  .header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 30;
    margin-bottom: 0;
    padding: 0;
    height: 48px;
    transform: translateY(0);
    transition: transform 200ms cubic-bezier(0.32, 0.72, 0, 1);
  }

  .header.is-hidden {
    transform: translateY(-100%);
  }

  .header .container {
    height: 100%;
    padding: 0 12px;
  }

  .header-content {
    height: 100%;
    gap: 8px;
    align-items: center;
  }

  /* Logo: smaller on mobile */
  .logo {
    width: 32px;
    height: 32px;
    font-size: 18px;
    border-radius: 8px;
  }

  /* Title: smaller, drop "圣则家园-" prefix via JS (see auth-header.js) */
  .header-text h1 {
    font-size: 14px;
    line-height: 1.2;
  }

  /* Default desktop nav items — hidden on mobile (they live in the drawer) */
  .header-auth-buttons > a,
  .header-auth-buttons > .nav-dropdown {
    display: none !important;
  }

  .header--visitor .header-auth-buttons > a {
    display: inline-flex !important;
    align-items: center;
    padding: 4px 8px;
    font-size: 13px;
    line-height: 1.2;
  }

  .header--visitor .header-auth-buttons > a[hidden] {
    display: none !important;
  }

  .header--visitor .header-auth-buttons {
    gap: 6px;
    margin-left: auto;
  }

  /* Narrow phones: logo + title + four nav labels don't fit one row, so
     every label wrapped to 3+1 characters. Drop the title (the logo still
     links home), keep labels on one line, and let the strip scroll if an
     enlarged system font still overflows. */
  @media (max-width: 420px) {
    .header--visitor .header-text {
      display: none;
    }

    .header--visitor .header-auth-buttons {
      gap: 4px;
      min-width: 0;
      overflow-x: auto;
      scrollbar-width: none;
    }

    .header--visitor .header-auth-buttons::-webkit-scrollbar {
      display: none;
    }

    .header--visitor .header-auth-buttons > a {
      flex-shrink: 0;
      padding: 4px 6px;
      white-space: nowrap;
    }
  }

  /* Hamburger button (created by auth-header.js) */
  .header-hamburger {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-left: auto;
    background: transparent;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    color: #374151;
    flex-shrink: 0;
  }

  .header-hamburger[aria-expanded="true"] {
    background: #f3f4f6;
  }

  /* Drawer: slide-down panel below the header */
  .header-drawer {
    position: fixed;
    top: 48px;
    left: 0;
    right: 0;
    z-index: 29;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    max-height: calc(100dvh - 48px);
    overflow-y: auto;
    display: none;
  }

  .header-drawer.is-open {
    display: block;
  }

  .header-drawer a,
  .header-drawer button {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 12px 16px;
    border: none;
    background: transparent;
    text-align: left;
    font-size: 15px;
    color: #374151;
    text-decoration: none;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
  }

  .header-drawer a:hover,
  .header-drawer button:hover {
    background: #f9fafb;
  }

  .header-drawer a.active {
    background: #eef2ff;
    color: var(--ink-700);
    font-weight: 600;
  }

  .header-drawer-section {
    font-size: 12px;
    color: #6b7280;
    padding: 12px 16px 6px;
    background: #f9fafb;
    border-bottom: 1px solid #f3f4f6;
  }

  /* Backdrop covers content when drawer open */
  .header-drawer-backdrop {
    position: fixed;
    top: 48px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 28;
    background: rgba(0, 0, 0, 0.2);
  }

  /* Default state for hamburger when CSS is loaded but JS hasn't created
     the button yet — no-op (JS-created buttons inherit visibility). */
}

/* Hide hamburger on desktop — it gets created by JS unconditionally and
   shown only on mobile via the @media block above. */
.header-hamburger,
.header-drawer,
.header-drawer-backdrop {
  display: none;
}
/* Independent original files used by the backend-selected drive presentation. */
.drive-visitor-folder {
  display: block;
  width: 100%;
  margin: .6rem 0;
  padding: 1rem;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  text-align: left;
  font-size: 1rem;
}
.drive-visitor-file {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid #e5e7eb;
}
.drive-visitor-actions { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.drive-visitor-actions audio { max-width: 280px; height: 36px; }
.drive-share-unavailable { padding: 2rem; text-align: center; color: #6b7280; }
