:root {
  --bg: #0f0f12;
  --surface: #18181c;
  --border: #2a2a30;
  --text: #e4e4e7;
  --muted: #71717a;
  --accent: #a78bfa;
  --accent-hover: #c4b5fd;
}

/* Light theme */
html[data-theme="light"] {
  --bg: #f4f4f5;
  --surface: #ffffff;
  --border: #e4e4e7;
  --text: #18181b;
  --muted: #71717a;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
}
html[data-theme="light"] .filter-chip--search { background: #7c3aed; color: #fff; }
html[data-theme="light"] .filter-chip--event { background: #059669; color: #fff; }
html[data-theme="light"] .filter-chip--speaker { background: #2563eb; color: #fff; }
html[data-theme="light"] .filter-chip--location { background: #d97706; color: #fff; }
html[data-theme="light"] .filter-chip--tag { background: #db2777; color: #fff; }
html[data-theme="light"] .filter-chip--dateFrom,
html[data-theme="light"] .filter-chip--dateTo { background: #64748b; color: #fff; }
html[data-theme="light"] .filter-chip--scripture { background: #7c3aed; color: #fff; }
html[data-theme="light"] .filter-chip--talkType { background: #0891b2; color: #fff; }

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
}
.header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}
.subtitle {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.theme-toggle {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}
.theme-toggle:hover {
  background: var(--border);
  border-color: var(--muted);
}
.theme-toggle:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2);
}

.search-bar-wrap {
  margin-top: 1.25rem;
  max-width: 100%;
}
.search-bar {
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}
.search-bar::placeholder {
  color: var(--muted);
}
.search-bar:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.2);
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  min-height: 0;
}
.active-filters:empty {
  display: none;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem 0.35rem 0.65rem;
  background: var(--accent);
  color: #0f0f12;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
}
.filter-chip--search { background: #a78bfa; color: #0f0f12; }
.filter-chip--event { background: #34d399; color: #022c22; }
.filter-chip--speaker { background: #60a5fa; color: #0c1929; }
.filter-chip--location { background: #fbbf24; color: #422006; }
.filter-chip--tag { background: #f472b6; color: #451225; }
.filter-chip--dateFrom,
.filter-chip--dateTo { background: #94a3b8; color: #0f172a; }
.filter-chip--scripture { background: #c084fc; color: #1e1b4b; }
.filter-chip--talkType { background: #22d3ee; color: #083344; }
.filter-chip-label {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.filter-chip-count {
  font-weight: 700;
  opacity: 0.9;
  margin-left: 0.2em;
}
.filter-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  padding: 0;
  background: rgba(0, 0, 0, 0.2);
  border: none;
  border-radius: 50%;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.filter-chip-remove:hover {
  background: rgba(0, 0, 0, 0.35);
}
.filter-chip-remove:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.4);
}

.main {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.5rem;
  padding: 1.5rem 2rem;
  padding-bottom: 5rem;
  max-width: 1400px;
  margin: 0 auto;
}

@media (max-width: 768px) {
  .main {
    grid-template-columns: 1fr;
    padding: 1rem;
  }
  .header {
    padding: 1rem;
  }
  .search-bar {
    font-size: 1rem;
    padding: 0.75rem 1rem;
  }
  .active-filters {
    margin-top: 0.75rem;
  }
  .filters {
    order: -1;
  }
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.filters label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.filters select {
  width: 100%;
  padding: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  min-height: 2.5rem;
}
.filters select[multiple] {
  min-height: 80px;
}
.filters select[multiple] option {
  padding: 0.25rem 0;
}
.filters input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
}
.filters button {
  padding: 0.5rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}
.filters button:hover {
  background: var(--border);
}

.results-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.results-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.15s, background 0.15s;
}
.result-card:hover {
  border-color: var(--accent);
}
.result-card-main {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
}
.result-card-content {
  flex: 1;
  min-width: 0;
}
.result-card-play-btn {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: var(--border);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.result-card-play-btn:hover {
  background: var(--muted);
}
.result-card-play-btn.playing {
  background: var(--accent);
  color: var(--bg);
}
.result-card h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
}
.result-card .meta {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.result-card .tags {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.result-card .tag {
  padding: 0.2rem 0.5rem;
  background: var(--bg);
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--muted);
}
.result-card-detail {
  display: none;
  padding: 0 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: -0.5rem;
}
.result-card--expanded .result-card-detail {
  display: block;
}
.result-card-detail-option {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  cursor: pointer;
}
.result-card-scripture-refs {
  margin-bottom: 0.75rem;
}
.result-card-scripture-refs[hidden] {
  display: none !important;
}
.result-card-scripture-refs-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
}
.result-card-scripture-refs-toggle:hover {
  text-decoration: underline;
}
.result-card-scripture-refs-toggle::before {
  content: "▶";
  font-size: 0.65rem;
  transition: transform 0.2s;
}
.result-card-scripture-refs-toggle[aria-expanded="true"]::before {
  transform: rotate(90deg);
}
.result-card-scripture-refs-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
  margin-left: 1rem;
}
.result-card-scripture-refs-list[hidden] {
  display: none !important;
}
.result-card-scripture-ref-link {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  color: var(--accent);
  background: rgba(167, 139, 250, 0.15);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.result-card-scripture-ref-link:hover {
  background: rgba(167, 139, 250, 0.25);
}
.result-card-transcript .scripture-ref--highlight {
  animation: scripture-ref-flash 1.5s ease-out;
}
@keyframes scripture-ref-flash {
  0% { background: rgba(167, 139, 250, 0.5); }
  100% { background: transparent; }
}
.result-card-transcript {
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 320px;
  overflow: auto;
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 0.75rem;
}
.result-card-transcript .scripture-ref {
  background: rgba(167, 139, 250, 0.25);
  padding: 0.1em 0.2em;
  border-radius: 3px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.result-card-transcript .scripture-ref:hover {
  background: rgba(167, 139, 250, 0.4);
}
.result-card-slides {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.result-card-slides a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}
.result-card-slides a:hover {
  color: var(--accent-hover);
}

.player {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 2rem;
  overflow: auto;
}
.player[hidden] {
  display: none !important;
}
.player-inner {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  padding: 1.5rem 2rem;
}
.close-player-top {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2.25rem;
  height: 2.25rem;
  min-height: 2.25rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
  border-radius: 6px;
}
.player h2 {
  margin: 0;
  padding-right: 2.5rem;
  font-size: 1.25rem;
}
.player-meta {
  margin: 0.5rem 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.modal-player-wrap {
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
}
.modal-player-wrap .page-player-progress-wrap {
  margin-bottom: 0.35rem;
}
.modal-player-wrap .page-player-time {
  margin-bottom: 0.5rem;
}
.modal-player-wrap .page-player-controls {
  margin-top: 0.25rem;
}

.player-transcript-wrap {
  margin-bottom: 1rem;
}
.player-transcript-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: var(--muted);
  cursor: pointer;
}
.player-transcript-toggle input {
  width: 1rem;
  height: 1rem;
  min-width: 1rem;
  cursor: pointer;
}
.player-transcript {
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 280px;
  overflow: auto;
  padding: 1rem;
  background: var(--bg);
  border-radius: 8px;
}
.player-transcript .scripture-ref {
  background: rgba(167, 139, 250, 0.25);
  padding: 0.1em 0.2em;
  border-radius: 3px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.player-transcript .scripture-ref:hover {
  background: rgba(167, 139, 250, 0.4);
}
.player-slides {
  margin-bottom: 1rem;
}
.player-slides a {
  color: var(--accent);
  text-decoration: none;
  margin-right: 1rem;
}
.player-slides a:hover {
  color: var(--accent-hover);
}
.close-player {
  padding: 0.5rem 1rem;
  min-height: 44px;
  background: var(--border);
  border: none;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}
.close-player:hover {
  background: var(--muted);
}

@media (max-width: 480px) {
  .player-inner {
    padding: 1rem;
    max-height: 95vh;
  }
  .player {
    padding: 0.5rem;
  }
}

/* Page player (fixed bar on the page) */
.page-player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.75rem 1.25rem 1rem;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}
.page-player[hidden] {
  display: none !important;
}
.page-player-inner {
  max-width: 900px;
  margin: 0 auto;
}
.page-player-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.page-player-brand {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.page-player-title {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.page-player-actions {
  flex-shrink: 0;
}
.page-player-btn {
  width: 2rem;
  height: 2rem;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.page-player-btn:hover {
  background: var(--border);
  color: var(--accent);
}
.page-player-progress-wrap {
  margin-bottom: 0.35rem;
}
.page-player-progress {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 3px;
}
.page-player-progress::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
.page-player-progress::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}
.page-player-time {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.page-player-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.page-player-play {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: var(--accent);
  color: #0f0f12;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}
.page-player-play:hover {
  background: var(--accent-hover);
}
.page-player-play.playing {
  padding-left: 0.15rem;
}
.page-player-skip {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--border);
  color: var(--text);
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}
.page-player-skip:hover {
  background: var(--muted);
}
.page-player-volume-wrap {
  flex: 1;
  min-width: 80px;
  max-width: 120px;
}
.page-player-volume {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 2px;
}
.page-player-volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
}
.page-player-volume::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
  border: none;
}
.page-player-speed {
  min-width: 2.5rem;
  height: 2rem;
  padding: 0 0.5rem;
  border-radius: 6px;
  background: var(--border);
  color: var(--text);
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.page-player-speed:hover {
  background: var(--muted);
}

