/* -- Reset ------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* -- Variables --------------------------------------------- */
:root {
  --bg: #FDFBF7;
  --bg-card: #FFFFFF;
  --bg-alt: #F7F4EF;
  --bg-hero: linear-gradient(135deg, #2D2926 0%, #44403C 100%);
  --text: #2D2926;
  --text-secondary: #78716C;
  --text-inverse: #FDFBF7;
  --accent: #B8860B;
  --accent-hover: #96700A;
  --accent-light: #FEF3C7;
  --accent-subtle: #F5E6CF;
  --border: #E7E5E4;
  --border-light: #F0EEEB;
  --link: #5B7B6F;
  --link-hover: #3D5A4F;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
  --radius: 10px;
  --radius-sm: 6px;
  --font-serif: 'Crimson Pro', Georgia, 'Times New Roman', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --max-w: 1120px;
  --content-w: 700px;
}

/* -- Base -------------------------------------------------- */
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; transition: color .15s; }
a:hover { color: var(--link-hover); }
img { max-width: 100%; height: auto; display: block; }

/* -- Header ------------------------------------------------ */
.site-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(253,251,247,0.92);
}
.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
}
.site-logo {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.site-logo:hover { color: var(--accent); }
.header-nav { display: flex; align-items: center; gap: 1.5rem; }
.header-nav a { font-size: 0.875rem; color: var(--text-secondary); font-weight: 500; }
.header-nav a:hover { color: var(--accent); }
.header-search {
  display: flex; align-items: center;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 0.375rem 0.75rem;
  gap: 0.5rem;
  transition: border-color .15s, box-shadow .15s;
}
.header-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.header-search input {
  border: none; background: none; outline: none;
  font-size: 0.875rem; font-family: var(--font-sans);
  color: var(--text); width: 180px;
}
.header-search input::placeholder { color: var(--text-secondary); }
.header-search svg { flex-shrink: 0; color: var(--text-secondary); }

/* -- Hero -------------------------------------------------- */
.hero {
  background: var(--bg-hero);
  color: var(--text-inverse);
  padding: 4rem 1.5rem;
  text-align: center;
}
.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 600;
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}
.hero p {
  font-size: 1.1rem;
  opacity: 0.85;
  max-width: 560px;
  margin: 0 auto 2rem;
  line-height: 1.7;
}
.hero-stats {
  display: flex; justify-content: center; gap: 2.5rem;
  font-size: 0.875rem; opacity: 0.7;
}
.hero-stats strong { display: block; font-size: 1.5rem; opacity: 1; font-weight: 700; }

/* -- Container --------------------------------------------- */
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 1.5rem; }

/* -- Feed Cards (homepage) --------------------------------- */
.feeds-section { padding: 3rem 0 4rem; }
.feeds-section h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  text-align: center;
  color: var(--text);
}
.feeds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}
.feed-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
  display: flex; flex-direction: column;
}
.feed-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
a.feed-card { color: inherit; text-decoration: none; }
.feed-card-header {
  padding: 1.5rem 1.5rem 1rem;
  display: flex; align-items: flex-start; gap: 1rem;
}
.feed-card-emoji { font-size: 2rem; line-height: 1; flex-shrink: 0; }
.feed-card-header h3 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
}
.feed-card-header h3 a { color: var(--text); }
.feed-card-header h3 a:hover { color: var(--accent); }
.feed-card-body {
  padding: 0 1.5rem 1.5rem;
  flex: 1;
}
.feed-card-body p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1rem;
}
.feed-card-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex; gap: 1rem;
}
.feed-card-meta span {
  display: flex; align-items: center; gap: 0.3rem;
}
.feed-card-meta .subscribe {
  margin-left: auto;
  color: var(--accent);
  transition: color .15s;
}
.feed-card-meta .subscribe:hover { color: var(--accent-hover); }

/* -- Feed Page --------------------------------------------- */
.feed-header {
  padding: 2.5rem 0 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}
.feed-header h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.feed-header p {
  color: var(--text-secondary);
  max-width: var(--content-w);
  line-height: 1.7;
}
.season-section { margin-bottom: 2.5rem; }
.season-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent-light);
}
.episode-list { list-style: none; }
.episode-item {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  margin-bottom: 0.5rem;
  background: var(--bg-card);
  transition: border-color .15s, box-shadow .15s;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem 1rem;
  align-items: start;
}
.episode-item:hover {
  border-color: var(--accent-light);
  box-shadow: var(--shadow-sm);
}
.episode-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.4;
}
.episode-title a { color: var(--text); }
.episode-title a:hover { color: var(--accent); }
.episode-desc {
  grid-column: 1 / -1;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}
.episode-duration {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  padding-top: 0.15rem;
}

/* -- Episode Page ------------------------------------------ */
.episode-header { padding: 2.5rem 0 1.5rem; }
.episode-header h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.75rem;
}
.episode-meta {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}
.episode-meta span { display: flex; align-items: center; gap: 0.35rem; }

/* Audio player */
.audio-player {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 2rem;
}
.audio-player audio {
  width: 100%;
  height: 40px;
}
.audio-source {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.audio-source a { color: var(--text-secondary); text-decoration: underline; }

/* Description */
.episode-description {
  margin-bottom: 2rem;
  line-height: 1.8;
  color: var(--text);
}
.episode-description p { margin-bottom: 1rem; }
.episode-description p:last-child { margin-bottom: 0; }

/* Tags */
.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 2rem; }
.tag {
  display: inline-block;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  transition: background .15s, color .15s;
}
.tag:hover { background: var(--accent); color: white; }

/* Transcript */
.transcript-section {
  border-top: 1px solid var(--border);
  padding-top: 2rem;
  margin-bottom: 3rem;
}
.transcript-section h2 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: var(--text);
}
.transcript-text {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  line-height: 2;
  color: #3D3835;
  max-width: var(--content-w);
}
.transcript-text p {
  margin-bottom: 1.25rem;
  text-indent: 0;
}
.transcript-text em { font-style: italic; }
.transcript-unavailable {
  color: var(--text-secondary);
  font-style: italic;
  padding: 2rem;
  text-align: center;
  background: var(--bg-alt);
  border-radius: var(--radius);
}
.transcript-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.transcript-header h2 { margin-bottom: 0; }
.btn-pdf {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.8rem; font-weight: 500;
  color: var(--accent);
  background: var(--accent-light);
  padding: 0.35rem 0.85rem;
  border-radius: 100px;
  transition: background .15s, color .15s;
}
.btn-pdf:hover { background: var(--accent); color: white; }
.transcript-downloads { display: flex; gap: 0.5rem; }

/* Episode navigation */
.episode-nav {
  display: flex; justify-content: space-between;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
  gap: 1rem;
}
.episode-nav a {
  font-size: 0.875rem;
  color: var(--text-secondary);
  display: flex; align-items: center; gap: 0.35rem;
  max-width: 45%;
}
.episode-nav a:hover { color: var(--accent); }
.episode-nav .next { margin-left: auto; text-align: right; }

/* -- Breadcrumb -------------------------------------------- */
.breadcrumb {
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 1rem 0 0;
}
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span { margin: 0 0.4rem; opacity: 0.5; }

/* -- Search Page ------------------------------------------- */
.search-page { padding: 2.5rem 0 4rem; }
.search-page h1 {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  margin-bottom: 1.5rem;
}
.search-input-large {
  width: 100%;
  max-width: 600px;
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  font-size: 1rem;
  font-family: var(--font-sans);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2378716C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 0.75rem center;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search-input-large:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.search-info {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: 1rem 0;
}
.search-results { list-style: none; margin-top: 1rem; }
.search-result-item {
  border-bottom: 1px solid var(--border-light);
  padding: 1.25rem 0;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.search-result-title a { color: var(--text); }
.search-result-title a:hover { color: var(--accent); }
.search-result-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}
.search-result-excerpt {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* -- Footer ------------------------------------------------ */
.source-dana { font-size: .9em; color: var(--text-secondary); border-top: 1px solid var(--border);
  margin-top: .8em; padding-top: .6em; }
.site-footer {
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.site-footer a { color: var(--text-secondary); text-decoration: underline; }
.site-footer a:hover { color: var(--accent); }

/* -- Responsive -------------------------------------------- */
@media (max-width: 768px) {
  .header-inner { height: 48px; }
  .header-nav { gap: 1rem; }
  .header-search input { width: 120px; }
  .hero { padding: 2.5rem 1.25rem; }
  .hero-stats { gap: 1.5rem; }
  .feeds-grid { grid-template-columns: 1fr; }
  .episode-item { grid-template-columns: 1fr; }
  .episode-duration { order: -1; }
  .episode-nav { flex-direction: column; }
  .episode-nav a { max-width: 100%; }
}
@media (max-width: 480px) {
  .header-search { display: none; }
  .hero h1 { font-size: 1.75rem; }
  .feed-card-header { padding: 1.25rem 1.25rem 0.75rem; }
  .feed-card-body { padding: 0 1.25rem 1.25rem; }
}

/* -- Rankings page ----------------------------------------- */
.rankings-banner { padding: 0 0 1.5rem; }
.rankings-banner .container { max-width: var(--max-w); }
.rankings-banner-link {
  display: block; text-align: center; font-weight: 600; color: var(--text);
  background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent-subtle) 100%);
  border: 1px solid var(--accent-subtle); border-radius: var(--radius);
  padding: .9rem 1.25rem; transition: all .15s;
}
.rankings-banner-link:hover { color: var(--text); border-color: var(--accent); box-shadow: var(--shadow-md); }
.rankings-page { max-width: var(--max-w); }
.rankings-head { text-align: center; padding: 2.5rem 0 .5rem; }
.rankings-head h1 { font-family: var(--font-serif); font-size: 2rem; }
.rankings-head p { color: var(--text-secondary); max-width: 720px; margin: .75rem auto 0; }
.tabs { margin-top: 1.5rem; }
.tab-btn-row { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-bottom: 1.25rem; }
.tabs-sub .tab-btn-row { margin-bottom: 1rem; }
.tab-btn { font-family: var(--font-sans); font-size: .9rem; font-weight: 500; color: var(--text-secondary);
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 999px; padding: .5rem 1rem;
  cursor: pointer; transition: all .15s; }
.tab-btn:hover { border-color: var(--accent); color: var(--text); }
.tab-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tabs-sub .tab-btn { font-size: .82rem; padding: .35rem .8rem; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.rank-note { color: var(--text-secondary); font-size: .9rem; text-align: center; max-width: 760px; margin: 0 auto 1rem; }
.rank-list { list-style: none; display: flex; flex-direction: column; gap: .5rem; max-width: 900px; margin: 0 auto; }
.rank-row { display: grid; grid-template-columns: 2.2rem auto 1fr; gap: .85rem; align-items: start;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .85rem 1rem; box-shadow: var(--shadow-sm); }
.rank-row.compare { grid-template-columns: 2.2rem 3.6rem 3.6rem 3rem 1fr; }
.rank-num { font-family: var(--font-serif); font-size: 1.1rem; font-weight: 700; color: var(--text-secondary);
  text-align: right; padding-top: .1rem; }
.rank-score { text-align: center; }
.score-badge { display: inline-block; font-weight: 700; font-size: 1.05rem; color: var(--text);
  background: var(--accent-light); border: 1px solid var(--accent-subtle); border-radius: var(--radius-sm);
  padding: .15rem .5rem; min-width: 2.6rem; }
.rank-score .sub { display: block; font-size: .68rem; color: var(--text-secondary); margin-top: .25rem; white-space: nowrap; }
.rank-main { min-width: 0; }
.rank-title { font-weight: 600; }
.rank-teacher { color: var(--accent-hover); }
.rank-retreat { display: inline-block; font-size: .7rem; color: var(--text-secondary); border: 1px solid var(--border);
  border-radius: 999px; padding: .02rem .45rem; margin-left: .35rem; vertical-align: middle; }
.rank-talklink { color: var(--link); font-weight: 600; }
.rank-talklink:hover { color: var(--link-hover); text-decoration: underline; }
.rank-why { color: var(--text-secondary); font-size: .86rem; line-height: 1.5; margin-top: .25rem; }
.rank-delta { font-weight: 700; font-size: 1.05rem; text-align: center; padding-top: .1rem; }
.delta-up { color: #2F855A; }
.delta-down { color: #C05621; }
.delta-zero { color: var(--text-secondary); }
@media (max-width: 560px) {
  .rank-row { grid-template-columns: 1.6rem auto 1fr; gap: .5rem; padding: .7rem; }
  .rank-row.compare { grid-template-columns: 1.6rem 3rem 3rem 2.4rem 1fr; }
  .score-badge { font-size: .92rem; min-width: 2.2rem; padding: .12rem .35rem; }
}
