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

:root {
  --font:        -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono:   "SFMono-Regular", Consolas, monospace;

  --bg:          #f5f5f4;
  --surface:     #ffffff;
  --border:      #e5e7eb;
  --border-light:#f0f0ee;

  --text:        #111827;
  --text-muted:  #6b7280;
  --text-light:  #9ca3af;

  --accent:      #1d4ed8;        /* links, interactive */
  --accent-hover:#1e40af;

  /* sell-side left border */
  --sell-side:   #1d4ed8;
  /* independent left border */
  --independent: #059669;

  /* relevance badge palette */
  --rel-1: #d1d5db; --rel-1-text: #374151;
  --rel-2: #fde68a; --rel-2-text: #92400e;
  --rel-3: #fbbf24; --rel-3-text: #78350f;
  --rel-4: #f97316; --rel-4-text: #fff;
  --rel-5: #dc2626; --rel-5-text: #fff;

  --radius:      6px;
  --shadow:      0 1px 3px rgba(0,0,0,.08);
  --shadow-md:   0 2px 8px rgba(0,0,0,.10);
}

html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ── Site header ──────────────────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: 900px; margin: 0 auto;
  padding: 0 1.5rem;
  height: 52px;
  display: flex; align-items: center; justify-content: space-between;
}
.site-title { font-weight: 700; font-size: 1rem; color: var(--text); letter-spacing: -.01em; }
.header-nav { display: flex; gap: 1.5rem; font-size: .875rem; }
.header-nav a { color: var(--text-muted); }
.header-nav a:hover { color: var(--text); text-decoration: none; }

/* ── Main content ─────────────────────────────────────────────────────────── */
.main-content { max-width: 900px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

/* ── Login page ───────────────────────────────────────────────────────────── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2.5rem 2rem; width: 100%; max-width: 360px;
  box-shadow: var(--shadow-md); text-align: center;
}
.login-title { font-size: 1.4rem; font-weight: 700; margin-bottom: .25rem; }
.login-subtitle { color: var(--text-muted); font-size: .875rem; margin-bottom: 1.75rem; }
.login-form { display: flex; flex-direction: column; gap: .75rem; }
.login-input {
  width: 100%; padding: .625rem .875rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 1rem; font-family: var(--font);
  outline: none; transition: border-color .15s;
}
.login-input:focus { border-color: var(--accent); }
.login-input--error { border-color: #dc2626; }
.login-error { color: #dc2626; font-size: .8125rem; text-align: left; }
.login-btn {
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius);
  padding: .625rem; font-size: 1rem; font-family: var(--font);
  cursor: pointer; transition: background .15s;
}
.login-btn:hover { background: var(--accent-hover); }

/* ── Digest header ────────────────────────────────────────────────────────── */
.digest-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; gap: .5rem;
  margin-bottom: 2rem;
}
.digest-date { font-size: 1.5rem; font-weight: 700; }
.digest-stats { color: var(--text-muted); font-size: .875rem; margin-top: .2rem; }
.digest-nav { display: flex; gap: 1rem; align-items: center; padding-top: .25rem; }
.nav-link { font-size: .875rem; color: var(--text-muted); white-space: nowrap; }
.nav-link:hover { color: var(--text); text-decoration: none; }

/* ── Section titles ───────────────────────────────────────────────────────── */
.section-title {
  font-size: .6875rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-muted);
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}

/* ── Thematic overlap ─────────────────────────────────────────────────────── */
.thematic-overlap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem 1.5rem;
  margin-bottom: 2rem; box-shadow: var(--shadow);
}
.thematic-overlap--empty { color: var(--text-muted); font-size: .875rem; }
.themes-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: .75rem;
}
.theme-item {
  font-size: .875rem; line-height: 1.6;
  padding-left: 1.25rem; position: relative;
}
.theme-item::before {
  content: "·"; position: absolute; left: 0;
  color: var(--text-light); font-weight: 700; font-size: 1.1rem;
}
.theme-item { color: var(--text-muted); }
.theme-item strong { color: var(--text); }
.no-overlap-note { font-size: .875rem; color: var(--text-muted); font-style: italic; }

/* ── Card list ────────────────────────────────────────────────────────────── */
.card-list { display: flex; flex-direction: column; gap: .875rem; }

/* ── Episode card ─────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card--description-only { border-left: 3px solid var(--text-light); }
.card--error { border-left: 3px solid #dc2626; opacity: .75; }

.card-face {
  padding: 1rem 1.25rem;
  cursor: pointer;
  position: relative;
  user-select: none;
}
.card-face:hover { background: #fafaf9; }

.card-face-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: .35rem;
}
.card-meta { display: flex; align-items: center; gap: .625rem; flex-wrap: wrap; }
.card-number { font-size: .75rem; font-weight: 700; color: var(--text-light); margin-right: .4em; }
.podcast-name { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }

/* Transcript source tag */
.transcript-tag {
  font-size: .6875rem; font-weight: 500;
  padding: .1em .45em; border-radius: 3px;
  letter-spacing: .02em;
}
.transcript-tag--podscan          { background: #dbeafe; color: #1e40af; }
.transcript-tag--podscan-partial  { background: #fef3c7; color: #92400e; }
.transcript-tag--description-only { background: #f3f4f6; color: #4b5563; }

/* Score legend */
.score-legend {
  display: flex; align-items: center; flex-wrap: wrap; gap: .5rem;
  font-size: .75rem; color: var(--text-muted);
  margin-bottom: 1.5rem;
}
.score-legend-label { font-weight: 600; color: var(--text-muted); margin-right: .25rem; }
.score-legend-desc { color: var(--text-muted); margin-right: .75rem; }

/* Relevance badge */
.relevance-badge {
  font-size: .6875rem; font-weight: 700;
  width: 1.5rem; height: 1.5rem;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.relevance-1 { background: var(--rel-1); color: var(--rel-1-text); }
.relevance-2 { background: var(--rel-2); color: var(--rel-2-text); }
.relevance-3 { background: var(--rel-3); color: var(--rel-3-text); }
.relevance-4 { background: var(--rel-4); color: var(--rel-4-text); }
.relevance-5 { background: var(--rel-5); color: var(--rel-5-text); }

.episode-title { font-size: 1rem; font-weight: 600; margin-bottom: .35rem; line-height: 1.35; }
.episode-title-link { color: inherit; }
.episode-title-link:hover .episode-title { color: var(--accent); text-decoration: none; }

.card-details-line {
  font-size: .8125rem; color: var(--text-muted);
  margin-bottom: .625rem;
  display: flex; flex-wrap: wrap; gap: .25rem; align-items: baseline;
}
.sep { color: var(--text-light); }
.participants { color: var(--text-muted); }

.description-only-warning {
  font-size: .8125rem; color: #92400e;
  background: #fef3c7; border-radius: 4px;
  padding: .375rem .625rem; margin-bottom: .625rem;
}

/* Key takeaways on card face */
.key-takeaways {
  list-style: none; margin: .5rem 0 .625rem;
  display: flex; flex-direction: column; gap: .35rem;
}
.key-takeaways li {
  font-size: .875rem; line-height: 1.55;
  padding-left: 1rem; position: relative;
}
.key-takeaways li::before {
  content: "·"; position: absolute; left: 0;
  color: var(--text-light); font-weight: 700;
}
/* Bold-phrase format: **phrase** text */
.key-takeaways li strong { color: var(--text); }
.detail-list li strong { color: var(--text); }

/* Thematic tags */
.tag-list { display: flex; flex-wrap: wrap; gap: .375rem; margin-top: .5rem; }
.tag {
  font-size: .6875rem; padding: .15em .5em;
  background: var(--border-light); color: var(--text-muted);
  border-radius: 3px; letter-spacing: .02em;
}

/* Expand button */
.expand-btn {
  position: absolute; bottom: .75rem; right: 1rem;
  background: none; border: none; cursor: pointer;
  color: var(--text-light); font-size: .75rem;
  padding: .25rem; transition: color .15s;
}
.expand-btn:hover { color: var(--text-muted); }
.expand-icon { display: inline-block; transition: transform .2s; }
.card.is-expanded .expand-icon { transform: rotate(180deg); }

/* Card body (expanded details) */
.card-body {
  border-top: 1px solid var(--border-light);
  padding: 1rem 1.25rem 1.25rem;
}
.detail-section + .detail-section { margin-top: 1rem; }
.detail-heading {
  font-size: .6875rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-muted);
  margin-bottom: .4rem;
}
.detail-section p { font-size: .875rem; line-height: 1.65; }
.detail-list {
  list-style: none;
  display: flex; flex-direction: column; gap: .4rem;
}
.detail-list li {
  font-size: .875rem; line-height: 1.55;
  padding-left: 1rem; position: relative;
}
.detail-list li::before {
  content: "–"; position: absolute; left: 0; color: var(--text-light);
}
.detail-list--quotes li::before { content: "\201C"; }
.detail-list--quotes li { font-style: italic; }

/* ── Also published ───────────────────────────────────────────────────────── */
.also-published-section { margin-top: 2.5rem; }
.also-published-list { list-style: none; display: flex; flex-direction: column; }
.also-published-item {
  font-size: .875rem; padding: .5rem 0;
  border-bottom: 1px solid var(--border-light);
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem;
}
.also-title { font-weight: 500; }
.also-thesis { color: var(--text-muted); font-size: .8125rem; }

/* ── Archive ──────────────────────────────────────────────────────────────── */
.archive-header { margin-bottom: 2rem; }
.archive-title { font-size: 1.5rem; font-weight: 700; }
.archive-subtitle { color: var(--text-muted); font-size: .875rem; margin-top: .25rem; }
.archive-list { list-style: none; display: flex; flex-direction: column; }
.archive-item { border-bottom: 1px solid var(--border-light); }
.archive-link {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  padding: .75rem 0; color: var(--text);
}
.archive-link:hover { color: var(--accent); text-decoration: none; }
.archive-date { font-weight: 500; }
.archive-stats { font-size: .8125rem; color: var(--text-muted); white-space: nowrap; }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state { color: var(--text-muted); padding: 2rem 0; font-size: .9375rem; }

/* ── Episodes section spacing ─────────────────────────────────────────────── */
.episodes-section { margin-bottom: 2rem; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .header-inner { padding: 0 1rem; }
  .main-content { padding: 1.25rem 1rem 3rem; }
  .digest-header { flex-direction: column; }
  .card-face { padding: .875rem 1rem; }
  .card-body { padding: .875rem 1rem 1rem; }
}
