/* ── Typography & base ────────────────────────────────────────────────────── */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;
  --text:       #111;
  --muted:      #666;
  --border:     #ddd;
  --accent:     #0057b8;
  --bg:         #fff;
  --surface:    #fff;
  --tag-bg:     #f0f0f0;
  --radius:     4px;
}

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

html { font-size: 16px; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* ── Header ───────────────────────────────────────────────────────────────── */
.site-header {
  border-bottom: 2px solid var(--text);
  padding: .75rem 0;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 100;
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
}

.site-title {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: bold;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -.02em;
}

.site-nav { display: flex; gap: 1rem; }
.site-nav a {
  font-size: .9rem;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  padding-bottom: 1px;
}
.site-nav a:hover       { color: var(--text); }
.site-nav a.active      { color: var(--text); border-bottom-color: var(--text); }

.updated-at { font-size: .8rem; color: var(--muted); }

.header-meta { margin-left: auto; display: flex; align-items: center; gap: .75rem; }

.download-link {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .8rem;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: .2rem .5rem;
}
.download-link:hover { color: var(--text); border-color: var(--text); text-decoration: none; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.site-main {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

/* ── Prose (rendered markdown) ────────────────────────────────────────────── */
.prose       { font-size: 1rem;  line-height: 1.75; }
.prose-sm    { font-size: .875rem; line-height: 1.6; }

.prose p, .prose-sm p     { margin-bottom: .75em; }
.prose p:last-child,
.prose-sm p:last-child    { margin-bottom: 0; }

.prose h1, .prose h2, .prose h3 {
  font-family: var(--font-serif);
  font-weight: bold;
  margin: 1.25em 0 .4em;
  line-height: 1.3;
}
.prose h1 { font-size: 1.5rem; }
.prose h2 { font-size: 1.2rem; }
.prose h3 { font-size: 1rem;  }

.prose ul, .prose ol,
.prose-sm ul, .prose-sm ol {
  padding-left: 1.4em;
  margin-bottom: .75em;
}
.prose li, .prose-sm li   { margin-bottom: .25em; }

.prose strong, .prose-sm strong { font-weight: 600; }
.prose em,     .prose-sm em     { font-style: italic; }

.prose a, .prose-sm a { color: var(--accent); }

.prose code, .prose-sm code {
  font-family: "SF Mono", Consolas, monospace;
  font-size: .85em;
  background: var(--tag-bg);
  padding: .1em .3em;
  border-radius: 3px;
}

/* ── Digest ───────────────────────────────────────────────────────────────── */
.digest-section {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 0;
  margin-bottom: 2.5rem;
}

.digest-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.digest-title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: bold;
}

.digest-controls { display: flex; align-items: center; gap: .75rem; margin-left: auto; }

.digest-time { font-size: .8rem; color: var(--muted); margin-top: 1rem; }

/* Audio */
.audio-player { display: flex; align-items: center; gap: .4rem; }
.audio-label  { font-size: .85rem; color: var(--muted); }

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 30px; height: 30px;
  display: inline-flex;
  align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text);
  transition: background .1s;
  flex-shrink: 0;
}
.btn-icon:hover   { background: var(--tag-bg); }
.btn-icon.playing { background: var(--text); color: var(--bg); }

/* ── Section headings ─────────────────────────────────────────────────────── */
.section-heading {
  font-size: .75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 1.25rem;
}

/* ── Theme navigation ─────────────────────────────────────────────────────── */
.theme-nav {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.theme-pill {
  font-size: .78rem;
  padding: .2rem .6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  transition: border-color .1s, color .1s;
}
.theme-pill:hover { border-color: var(--text); color: var(--text); text-decoration: none; }
.theme-pill--muted { }
.theme-pill--small { font-size: .72rem; padding: .15rem .45rem; }

/* ── Theme groups ─────────────────────────────────────────────────────────── */
.themes-section { }
.theme-group    { margin-bottom: 3rem; }

.theme-heading {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}

.theme-badge {
  font-size: .9rem;
  font-weight: 700;
  font-family: var(--font-serif);
}
.theme-badge--muted { color: var(--muted); }
.theme-count { font-size: .8rem; color: var(--muted); }

/* ── Card grid ────────────────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.card {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  border: 1px solid var(--border);
}

.card-meta {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.card-source {
  font-size: .72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.card-date { font-size: .72rem; color: var(--muted); }

.card-title {
  font-size: .95rem;
  font-weight: 600;
  line-height: 1.35;
}
.card-title a { color: var(--text); text-decoration: none; }
.card-title a:hover { color: var(--accent); }

.card-summary { flex: 1; color: var(--muted); }

.card-tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .2rem; }
.tag {
  font-size: .7rem;
  padding: .1rem .4rem;
  background: var(--tag-bg);
  border-radius: 3px;
  color: var(--muted);
}

/* ── Feed list ────────────────────────────────────────────────────────────── */
.feed-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.feed-count { font-size: .85rem; }

.feed-list { display: flex; flex-direction: column; }

.feed-item {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.feed-item--pending { opacity: .65; }

.feed-item-meta {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
}

.feed-item-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
}
.feed-item-title a { color: var(--text); text-decoration: none; }
.feed-item-title a:hover { color: var(--accent); }

.feed-item-summary { color: var(--muted); }

/* ── Play button (per item) ───────────────────────────────────────────────── */
.btn-play-item { margin-top: auto; align-self: flex-start; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
.tts-toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius);
  padding: .5rem .9rem;
  font-size: .82rem;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  z-index: 200;
  max-width: 280px;
}
.tts-toast.show { opacity: 1; transform: translateY(0); }

/* ── Utilities ────────────────────────────────────────────────────────────── */
.muted       { color: var(--muted); }
.empty-state { padding: 3rem 0; text-align: center; color: var(--muted); }

/* ── Footer ───────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.25rem;
  text-align: center;
  font-size: .8rem;
  color: var(--muted);
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .header-inner   { gap: .75rem; }
  .updated-at     { display: none; }
  .card-grid      { grid-template-columns: 1fr; }
  .digest-section { padding: 1rem 0; }
  .site-main      { padding: 1.25rem .75rem 3rem; }
}
