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

:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --border: #e2e0db;
  --text: #1a1a1a;
  --text-muted: #6b6860;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --priority: #d97706;
  --podcast: #7c3aed;
  --substack: #e05c2e;
  --blog: #2563eb;
  --newsletter: #059669;
  --danger: #dc2626;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

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

/* ── Navbar ────────────────────────────────────────────────────────────────── */
.navbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.3px;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}

.nav-links a {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}

.nav-links a:hover, .nav-links a.active {
  color: var(--text);
  background: var(--bg);
}

.nav-actions { flex-shrink: 0; }

/* Hamburger button — hidden on desktop */
.nav-hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
  color: var(--text);
  line-height: 1;
}

/* Mobile nav dropdown — hidden by default */
.nav-mobile-menu {
  display: none;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
}
.btn-secondary:hover { border-color: var(--text-muted); }

.btn-sm {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.btn-sm:hover { background: var(--border); }
.btn-sm:disabled { opacity: 0.6; cursor: default; }

.btn-xs {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  margin-right: 4px;
}

.btn-link {
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
}
.btn-link--secondary { color: var(--text-muted); }

.btn-danger-sm {
  background: transparent;
  color: var(--danger);
  border: 1px solid transparent;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}
.btn-danger-sm:hover { border-color: var(--danger); background: #fef2f2; }

/* ── Source type colours ───────────────────────────────────────────────────── */
.source-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.type-substack  { background: #fde8df; color: var(--substack); }
.type-blog      { background: #dbeafe; color: var(--blog); }
.type-newsletter{ background: #d1fae5; color: var(--newsletter); }
.type-podcast   { background: #ede9fe; color: var(--podcast); }

.source-type-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.type-dot.type-substack  { background: var(--substack); }
.type-dot.type-blog      { background: var(--blog); }
.type-dot.type-newsletter{ background: var(--newsletter); }
.type-dot.type-podcast   { background: var(--podcast); }

/* ── Feed layout ───────────────────────────────────────────────────────────── */
.feed-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 0;
  max-width: 1200px;
  margin: 0 auto;
  min-height: calc(100vh - 52px);
}

.sidebar {
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  position: sticky;
  top: 52px;
  height: calc(100vh - 52px);
  overflow-y: auto;
}

.sidebar-section { margin-bottom: 24px; }
.sidebar-section h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.filter-group { display: flex; flex-wrap: wrap; gap: 6px; }
.type-filters { display: flex; flex-wrap: wrap; gap: 6px; }

.filter-chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.filter-chip:hover, .filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  text-decoration: none;
}

.source-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.source-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
.source-item:hover { background: var(--bg); text-decoration: none; }
.source-item.active { background: #dbeafe; color: var(--accent); }

.priority-star { color: var(--priority); font-size: 12px; }

/* Source list toggle — only visible on mobile */
.source-list-toggle { display: none; }

.feed-main { padding: 24px 32px; }

.feed-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.feed-header h2 { font-size: 20px; font-weight: 700; }
.item-count { font-size: 13px; color: var(--text-muted); }
.transcription-badge {
  font-size: 12px;
  background: #ede9fe;
  color: var(--podcast);
  padding: 3px 10px;
  border-radius: 20px;
}

/* ── Feed cards ────────────────────────────────────────────────────────────── */
.feed-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.feed-card--podcast { border-left: 3px solid var(--podcast); }

.feed-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.feed-date, .read-time {
  font-size: 12px;
  color: var(--text-muted);
}

.feed-card-title {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 10px;
}
.feed-card-title a { color: var(--text); }
.feed-card-title a:hover { color: var(--accent); text-decoration: none; }

.feed-card-summary {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 10px;
  line-height: 1.6;
}
.pending-summary { font-style: italic; }

.feed-card-points {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.feed-card-points li {
  font-size: 13px;
  color: var(--text-muted);
  padding-left: 16px;
  position: relative;
}
.feed-card-points li::before {
  content: "·";
  position: absolute;
  left: 4px;
  color: var(--accent);
  font-weight: 700;
}

.feed-card-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.tag {
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 20px;
  color: var(--text-muted);
}

.feed-card-actions {
  display: flex;
  gap: 16px;
  padding-top: 10px;
  border-top: 1px solid var(--bg);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

/* ── Sources page ──────────────────────────────────────────────────────────── */
.sources-layout { max-width: 960px; margin: 0 auto; padding: 32px; }

.sources-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.sources-header h2 { font-size: 22px; font-weight: 700; }

.add-source-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}
.add-source-form h3 { margin-bottom: 16px; font-size: 16px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.form-group input, .form-group select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--bg);
}
.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: var(--accent);
}
.form-group--checks { flex-direction: row; align-items: center; gap: 16px; }
.form-group--checks label {
  display: flex; align-items: center; gap: 6px;
  cursor: pointer; font-size: 14px; color: var(--text);
}
.hint { font-size: 11px; color: var(--text-muted); }

.form-actions { display: flex; gap: 10px; }

.sources-group { margin-bottom: 32px; }
.sources-group-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.count-badge {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1px 7px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.paid-badge {
  font-size: 10px;
  background: #fef3c7;
  color: #92400e;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
}

.sources-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.sources-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.sources-table td {
  padding: 10px 14px;
  font-size: 14px;
  border-bottom: 1px solid var(--bg);
}
.sources-table tr:last-child td { border-bottom: none; }
.sources-table tr:hover td { background: var(--bg); }

.priority-toggle {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--border);
  cursor: pointer;
  padding: 4px 8px;
}
.priority-toggle.priority-high { color: var(--priority); }
.priority-toggle.priority-medium { color: #6b7280; }
.priority-toggle.priority-low { color: #d1d5db; }

/* ── Writing assistant ─────────────────────────────────────────────────────── */
.assistant-layout {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.assistant-controls h2 { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.assistant-desc { color: var(--text-muted); font-size: 14px; margin-bottom: 20px; }

.assistant-source-filter {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.assistant-source-filter label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: block;
}

.source-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
  max-height: 200px;
  overflow-y: auto;
}

.source-check {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  user-select: none;
}
.source-check input { cursor: pointer; }
.source-check:has(input:checked) {
  background: #dbeafe;
  border-color: var(--accent);
  color: var(--accent);
}

.assistant-input-area textarea {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  background: var(--surface);
}
.assistant-input-area textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.assistant-submit-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.query-status { font-size: 13px; color: var(--text-muted); }

.assistant-results {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.results-synthesis {
  font-size: 15px;
  line-height: 1.7;
  margin-bottom: 24px;
}
.results-synthesis h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 20px 0 8px;
  color: var(--text);
}
.results-synthesis h3:first-child { margin-top: 0; }

.results-sources h4 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.results-sources ul { list-style: none; }
.results-sources li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--bg);
  font-size: 13px;
}
.source-type-label { font-size: 14px; flex-shrink: 0; }
.source-meta { color: var(--text-muted); }

/* ── Touch & active states (all sizes) ────────────────────────────────────── */
.btn-primary:active { background: var(--accent-hover); }
.btn-secondary:active { border-color: var(--text-muted); background: var(--bg); }
.btn-sm:active { background: var(--border); }
.btn-xs:active { background: var(--bg); }
.btn-danger-sm:active { border-color: var(--danger); background: #fef2f2; }
.filter-chip:active { background: var(--accent); border-color: var(--accent); color: white; }
.nav-links a:active { color: var(--text); background: var(--bg); }
.source-item:active { background: var(--bg); }
.priority-toggle:active { transform: scale(1.3); }

/* ── Mobile responsive ─────────────────────────────────────────────────────── */
@media (max-width: 768px) {

  /* Navbar: compact top bar with hamburger */
  .navbar {
    height: 48px;
    padding: 0 12px;
    gap: 8px;
  }
  .nav-brand { flex: 1; font-size: 15px; }

  /* Hide desktop nav links and sync button */
  .nav-links { display: none; }
  .nav-actions { display: none; }

  /* Show hamburger */
  .nav-hamburger { display: block; }

  /* Mobile dropdown menu — overlays everything */
  .nav-mobile-menu {
    display: none;
    position: fixed;
    top: 48px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface);
    z-index: 200;
    flex-direction: column;
    padding: 8px 0;
    overflow-y: auto;
  }
  .nav-mobile-menu.open {
    display: flex;
  }
  .nav-mobile-menu a,
  .nav-mobile-menu button {
    display: block;
    padding: 16px 20px;
    font-size: 17px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    width: 100%;
  }
  .nav-mobile-menu a:active,
  .nav-mobile-menu button:active {
    background: var(--bg);
  }
  .nav-mobile-menu a.active {
    color: var(--accent);
    background: #dbeafe;
  }
  .nav-mobile-menu .menu-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
  }

  /* Feed: single column, compact filter bar */
  .feed-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
  }
  .sidebar-section {
    margin-bottom: 0;
    flex-shrink: 0;
  }
  .sidebar-section h3 {
    margin-bottom: 4px;
    font-size: 10px;
  }

  /* Filter chips — bigger touch targets but compact layout */
  .filter-chip {
    font-size: 13px;
    padding: 8px 12px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
  }
  .filter-group, .type-filters {
    flex-wrap: wrap;
    gap: 6px;
  }

  /* Source list: hidden by default, toggle to show */
  .sidebar .source-list-section {
    display: none;
    width: 100%;
  }
  .sidebar .source-list-section.show {
    display: block;
  }
  .sidebar .source-list {
    max-height: 250px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
  }
  .source-item {
    padding: 10px 12px;
    min-height: 44px;
    font-size: 14px;
  }
  /* Toggle button for source list */
  .source-list-toggle {
    display: inline-flex;
    align-items: center;
    font-size: 13px;
    padding: 8px 12px;
    min-height: 36px;
    border-radius: 20px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
  }
  .source-list-toggle:active {
    background: var(--border);
  }

  .feed-main { padding: 12px; }

  .feed-header { flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
  .feed-header h2 { font-size: 17px; }

  /* Cards */
  .feed-card { padding: 14px 14px 12px; }
  .feed-card-title { font-size: 16px; }
  .feed-card-summary { font-size: 14px; }
  .feed-card-meta { gap: 6px; }

  /* Bigger tap targets for action links */
  .feed-card-actions { padding-top: 12px; gap: 12px; }
  .feed-card-actions .btn-link {
    font-size: 14px;
    padding: 10px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: inline-block;
    text-decoration: none;
  }
  .feed-card-actions .btn-link:active {
    background: var(--border);
  }

  /* Sources page — card layout instead of table */
  .sources-layout { padding: 12px; }
  .sources-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .sources-header .btn-primary { width: 100%; padding: 12px; font-size: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-group input, .form-group select {
    padding: 12px;
    font-size: 16px;  /* prevents iOS zoom on focus */
  }

  .sources-table th { display: none; }
  .sources-table, .sources-table tbody, .sources-table tr, .sources-table td {
    display: block;
    width: 100%;
  }
  .sources-table tr {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    position: relative;
  }
  .sources-table td {
    padding: 4px 0;
    border-bottom: none;
    font-size: 15px;
  }
  /* Name cell — prominent */
  .sources-table td:first-child {
    font-weight: 600;
    font-size: 16px;
    padding-bottom: 6px;
  }
  /* Author cell */
  .sources-table td:nth-child(2) {
    font-size: 13px;
    color: var(--text-muted);
  }
  /* Items count */
  .sources-table td:nth-child(3)::before {
    content: "Items: ";
    color: var(--text-muted);
    font-size: 13px;
  }
  .sources-table td:nth-child(3) {
    font-size: 13px;
    color: var(--text-muted);
  }
  /* Priority toggle — bigger */
  .priority-toggle {
    font-size: 24px;
    padding: 8px 12px;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  /* Action buttons — bigger touch targets */
  .sources-table .btn-xs,
  .sources-table .btn-danger-sm {
    font-size: 14px;
    padding: 10px 16px;
    min-height: 44px;
    margin-right: 8px;
  }
  /* Actions cell — flex row */
  .sources-table td:last-child {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 8px;
  }

  .sources-group { overflow-x: visible; }

  /* Edit modal */
  .modal-close {
    font-size: 28px;
    padding: 8px 12px;
    min-width: 44px;
    min-height: 44px;
  }

  /* Writing assistant */
  .assistant-layout { padding: 12px; gap: 16px; }
  .assistant-controls h2 { font-size: 18px; }
  .source-checkboxes { max-height: 150px; }
  .source-check {
    font-size: 14px;
    padding: 8px 12px;
    min-height: 40px;
  }
  .assistant-input-area textarea { font-size: 16px; }  /* prevents iOS zoom */
  .assistant-submit-row { flex-wrap: wrap; }
  .assistant-submit-row .btn-primary { width: 100%; padding: 14px; font-size: 16px; }

  /* Status page */
  .status-layout { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-number { font-size: 28px; }
  .stat-card { padding: 14px; }

  /* Activity list — stack on mobile */
  .activity-list li {
    flex-wrap: wrap;
    gap: 4px;
    padding: 10px 0;
  }
  .activity-source {
    width: 100%;
    white-space: normal;
  }
}

/* ── Status page ───────────────────────────────────────────────────────────── */
.status-layout { max-width: 800px; margin: 0 auto; padding: 32px; }
.status-layout h2 { font-size: 22px; font-weight: 700; margin-bottom: 24px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.stat-card--active { border-left: 3px solid var(--accent); }
.stat-card--error  { border-left: 3px solid var(--danger); }
.stat-number { font-size: 36px; font-weight: 700; line-height: 1; }
.stat-label  { font-size: 14px; color: var(--text-muted); margin-top: 4px; }
.stat-sub    { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.status-actions { margin-bottom: 24px; }
.status-actions .hint { font-size: 13px; color: var(--text-muted); margin-top: 6px; }

.recent-activity h3 { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.activity-list { list-style: none; }
.activity-list li {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--bg);
  font-size: 13px;
}
.activity-source {
  font-weight: 600;
  flex-shrink: 0;
  width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.activity-title { color: var(--text-muted); flex: 1; }
.activity-time { flex-shrink: 0; color: var(--text-muted); }

/* ── Topics page ─────────────────────────────────────────────────────────── */
.topics-layout { max-width: 960px; margin: 0 auto; padding: 32px; }
.hidden { display: none !important; }

.topic-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.topic-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}
.topic-card-title h3 { font-size: 17px; font-weight: 700; }
.topic-slug {
  font-size: 12px;
  color: var(--text-muted);
  font-family: monospace;
}
.topic-card-actions { display: flex; gap: 6px; align-items: center; }
.topic-patterns { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.topic-catchall { font-size: 13px; color: var(--text-muted); font-style: italic; margin-bottom: 12px; }
.topic-edit-form { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 12px; }

.topic-gold-section { border-top: 1px solid var(--bg); margin-top: 12px; padding-top: 12px; }
.topic-gold-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.topic-gold-label .hint { font-weight: 400; text-transform: none; letter-spacing: 0; }
.topic-gold-grid { display: flex; flex-wrap: wrap; gap: 6px; }

.gold-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  padding: 5px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  user-select: none;
}
.gold-toggle .gold-star { color: var(--border); font-size: 12px; }
.gold-toggle--active {
  background: #fef3c7;
  border-color: var(--priority);
  color: #78350f;
}
.gold-toggle--active .gold-star { color: var(--priority); }

.form-group--full { grid-column: 1 / -1; }

/* ── Digest page ──────────────────────────────────────────────────────────── */
.digest-layout {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 32px;
}

.digest-header {
  margin-bottom: 28px;
}
.digest-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.digest-section { margin-bottom: 28px; }

.section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  cursor: default;
}
.section-label--notable { color: var(--priority); border-bottom-color: var(--priority); }
.section-label--rest { cursor: pointer; user-select: none; }

.digest-topic-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 4px;
  margin-bottom: 20px;
  position: sticky;
  top: 52px;
  background: var(--bg);
  z-index: 10;
  padding-top: 8px;
}
.digest-topic-nav::-webkit-scrollbar { display: none; }

.digest-topic-pill {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
  font-family: inherit;
}
.digest-topic-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.digest-topic-pill--active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.digest-topic-header {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--accent);
}
.digest-topic-header--other {
  color: var(--text-muted);
  border-bottom-color: var(--border);
  cursor: pointer;
  user-select: none;
}
.digest-topic-header--other::after { content: " \25BE"; }
details[open] .digest-topic-header--other::after { content: " \25B4"; }

/* Top story cards — full display */
.digest-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.digest-card--top { border-left: 3px solid var(--accent); }
.digest-card--notable { border-left: 3px solid var(--priority); }
.digest-card--podcast { border-left-color: var(--podcast); }
.digest-card--gold { border-left: 3px solid var(--priority); }

.digest-card-author {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.digest-card-author-name { font-weight: 400; color: var(--text-muted); }

.gold-indicator {
  color: var(--priority);
  font-size: 13px;
}
.gold-indicator--sm { font-size: 11px; }

.digest-more { margin-top: 4px; }
.digest-row-source {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}
.digest-row--gold { border-left: 2px solid var(--priority); padding-left: 10px; }

.digest-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.digest-card-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 6px;
}
.digest-card-title a { color: var(--text); }
.digest-card-title a:hover { color: var(--accent); text-decoration: none; }

.digest-card-summary {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 4px;
}

.digest-card-novelty {
  font-size: 13px;
  color: var(--priority);
  font-style: italic;
  margin-bottom: 4px;
}

.digest-signals {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.signal-chip {
  font-size: 10px;
  background: #fef3c7;
  color: #92400e;
  padding: 2px 7px;
  border-radius: 20px;
  text-transform: lowercase;
}

/* Worth a Look — compact rows */
.digest-row {
  padding: 10px 14px;
  border-bottom: 1px solid var(--bg);
}
.digest-row--podcast { border-left: 3px solid var(--podcast); }

.digest-row-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.digest-row-title {
  font-size: 14px;
  font-weight: 500;
  flex: 1;
}
.digest-row-title a { color: var(--text); }
.digest-row-title a:hover { color: var(--accent); text-decoration: none; }

.digest-row-summary {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
}

.digest-row--compact { padding: 8px 14px; }
.digest-row--compact .digest-row-title { font-size: 13px; }

.digest-collapse summary { list-style: none; }
.digest-collapse summary::-webkit-details-marker { display: none; }
.digest-collapse summary::after { content: " \25BE"; }
.digest-collapse[open] summary::after { content: " \25B4"; }

/* Cluster: "Also covered by" attribution row */
.digest-cluster {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
}
.digest-cluster-label {
  color: var(--text-muted);
  flex-shrink: 0;
}
.digest-cluster-item {
  color: var(--text-muted);
}
.digest-cluster-item a {
  color: var(--text-muted);
  text-decoration: underline;
}
.digest-cluster-item + .digest-cluster-item::before {
  content: "·";
  margin-right: 6px;
}

/* Filtered / hidden counts */
.digest-more-hidden {
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 14px;
  font-style: italic;
}
.count-badge--muted {
  background: var(--bg);
  color: var(--text-muted);
  margin-left: 6px;
}
.digest-filtered-note {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 8px;
  font-style: italic;
}

.digest-footer {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  padding: 16px 0;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

/* ── Search page ──────────────────────────────────────────────────────────── */
.search-layout {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px;
}

.search-header {
  margin-bottom: 20px;
}
.search-header h2 { font-size: 22px; font-weight: 700; }
.search-desc { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

.search-controls {
  margin-bottom: 20px;
}
.search-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  font-family: inherit;
  background: var(--surface);
  margin-bottom: 12px;
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-filters {
  display: flex;
  align-items: center;
  gap: 10px;
}
.search-filters .filter-group {
  display: flex;
  gap: 8px;
  flex: 1;
}
.search-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--bg);
  cursor: pointer;
}

.search-status {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 14px;
}

.search-results {}

.search-result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.search-result-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.search-result-type {
  font-size: 12px;
  color: var(--text-muted);
}
.search-result-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.search-result-snippet {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Weekly page ──────────────────────────────────────────────────────────── */
.weekly-layout {
  max-width: 800px;
  margin: 0 auto;
  padding: 32px;
}

.weekly-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.weekly-header h2 { font-size: 22px; font-weight: 700; }

.weekly-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.weekly-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
}
.weekly-content h2 {
  font-size: 19px;
  font-weight: 700;
  margin: 32px 0 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--accent);
  color: var(--text);
}
.weekly-content h2:first-child { margin-top: 0; }
.weekly-content h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 24px 0 8px;
  color: var(--text);
}
.weekly-content h3:first-child { margin-top: 0; }
.weekly-content p {
  margin: 0 0 12px;
}
.weekly-content ul, .weekly-content ol {
  padding-left: 22px;
  margin: 8px 0 16px;
}
.weekly-content li {
  margin-bottom: 8px;
  line-height: 1.6;
}
.weekly-content li p {
  margin: 0;
}
.weekly-content strong {
  color: var(--text);
  font-weight: 600;
}
.weekly-content em {
  color: var(--text-muted);
}
.weekly-content blockquote {
  border-left: 3px solid var(--accent);
  margin: 12px 0;
  padding: 8px 16px;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.weekly-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.weekly-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.weekly-tab {
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.weekly-tab:hover { border-color: var(--accent); color: var(--accent); }
.weekly-tab--active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.weekly-tab-panel { }
.weekly-tab-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.weekly-archive {
  margin-top: 32px;
}
.weekly-archive h3 {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.weekly-archive-list {
  list-style: none;
}
.weekly-archive-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--bg);
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Mobile: digest, search, weekly ───────────────────────────────────────── */
@media (max-width: 768px) {
  .digest-layout { padding: 14px 12px; }
  .digest-header h1 { font-size: 20px; }
  .digest-card { padding: 14px; }
  .digest-card-title { font-size: 15px; }
  .digest-topic-nav {
    top: 48px;
    margin-left: -12px;
    margin-right: -12px;
    padding-left: 12px;
    padding-right: 12px;
  }
  .digest-topic-header {
    position: sticky;
    top: 108px; /* 48px navbar + ~60px pill nav */
    background: var(--bg);
    z-index: 9;
    padding: 8px 0 6px;
    margin: 0 -12px 10px;
    padding-left: 12px;
  }

  .topics-layout { padding: 12px; }
  .topic-gold-grid { gap: 8px; }
  .gold-toggle { font-size: 14px; padding: 8px 12px; min-height: 40px; }

  .search-layout { padding: 14px 12px; }
  .search-input { font-size: 16px; padding: 12px; }
  .search-filters { flex-wrap: wrap; }
  .search-filters .btn-primary { width: 100%; padding: 12px; font-size: 16px; }
  .search-select { flex: 1; min-width: 0; font-size: 16px; padding: 10px; }
  .search-result { padding: 12px; }

  .weekly-layout { padding: 14px 12px; }
  .weekly-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .weekly-header .btn-primary { width: 100%; padding: 12px; font-size: 16px; }
  .weekly-content { padding: 16px; }
  .weekly-tabs { flex-wrap: nowrap; overflow-x: auto; gap: 8px; padding-bottom: 8px; }
  .weekly-tab { font-size: 15px; padding: 8px 16px; min-height: 40px; }
}

/* ── Web Clipper ──────────────────────────────────────────────────────────── */
.clip-layout {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px;
}
.clip-header { margin-bottom: 24px; }
.clip-header h2 { font-size: 22px; font-weight: 700; }
.clip-desc { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

.clip-form { margin-bottom: 24px; }
.clip-input-row {
  display: flex;
  gap: 10px;
}
.clip-input-row .search-input { flex: 1; margin-bottom: 0; }
.clip-input-row .btn-primary { flex-shrink: 0; }

.clip-result { margin-bottom: 24px; }

.clip-bookmarklet {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.clip-bookmarklet h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }

/* ── Prediction Markets ──────────────────────────────────────────────────── */
.markets-layout {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px;
}
.markets-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.markets-header h2 { font-size: 22px; font-weight: 700; }
.markets-actions { display: flex; gap: 8px; }

.markets-section { margin-bottom: 32px; }

.markets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.market-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.market-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.market-platform {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.platform-polymarket { background: #e0e7ff; color: #3730a3; }
.platform-kalshi { background: #fce7f3; color: #9d174d; }

.market-probability {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
}
.market-question {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  margin-bottom: 8px;
}
.market-question a { color: var(--text); }
.market-question a:hover { color: var(--accent); text-decoration: none; }

.market-category {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.market-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--bg);
}
.market-volume {
  font-size: 12px;
  color: var(--text-muted);
}

.market-digest {
  margin-top: 12px;
}

.resolved-list { }
.resolved-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg);
  font-size: 14px;
}
.resolved-question { flex: 1; }
.resolved-outcome {
  font-weight: 600;
  color: var(--accent);
}

/* Source type: web_clip */
.type-web_clip { background: #f0fdf4; color: #166534; }
.type-dot.type-web_clip { background: #166534; }

/* ── Mobile: clip, markets ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .clip-layout { padding: 14px 12px; }
  .clip-input-row { flex-direction: column; }
  .clip-input-row .btn-primary { width: 100%; padding: 12px; font-size: 16px; }

  .markets-layout { padding: 14px 12px; }
  .markets-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .markets-actions { width: 100%; }
  .markets-actions .btn-sm { flex: 1; padding: 10px; font-size: 15px; }
  .markets-grid { grid-template-columns: 1fr; }
  .market-card { padding: 14px; }
}

/* nav-brand as link reset */
.nav-brand { text-decoration: none; color: var(--text); }

/* ── Transcript viewer ───────────────────────────────────────────────────── */
.transcript-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 24px;
}

.transcript-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.transcript-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 0.85rem;
}

.transcript-source-badge {
  background: var(--bg);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.transcript-title {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 8px;
}

.transcript-original-link {
  color: var(--accent);
  font-size: 0.9rem;
  text-decoration: none;
}
.transcript-original-link:hover { text-decoration: underline; }

.transcript-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.btn-copy-claude {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-copy-claude:hover { background: var(--accent-hover); }
.btn-copy-claude:active { transform: scale(0.97); }

.copy-feedback {
  font-size: 0.85rem;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.3s;
}

.transcript-body {
  line-height: 1.75;
  font-size: 1rem;
  color: var(--text);
}

.transcript-chunk {
  margin-bottom: 16px;
}

.transcript-timestamp {
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.6;
  margin-right: 6px;
  user-select: none;
}

.transcript-raw {
  white-space: pre-wrap;
  font-size: 0.95rem;
  line-height: 1.7;
}

.transcript-link {
  font-size: 0.8rem;
  display: inline-block;
  margin-top: 6px;
}

/* Transcript mobile */
@media (max-width: 600px) {
  .transcript-page { padding: 16px 14px; }
  .transcript-title { font-size: 1.25rem; }
  .transcript-body { font-size: 0.95rem; line-height: 1.65; }
  .transcript-chunk { margin-bottom: 14px; }
  .btn-copy-claude { padding: 10px 18px; font-size: 15px; }
}
