:root {
  --bg: #fafaf7;
  --fg: #1a1a1a;
  --muted: #6a6a6a;
  --line: #e3e3df;
  --accent: #1f6feb;
  --left: #2563eb;
  --right: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --surface: #ffffff;
  --surface-2: #f0efeb;
  --surface-3: #f7f6f0;
  --notice-bg: #fbf8ec;
  --notice-border: #ecd9a8;
  --err-bg: #fff2f2;
  --warn-bg: #fff8e6;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #14151a;
  --fg: #e6e6e3;
  --muted: #9a9a93;
  --line: #2c2e36;
  --accent: #4d9aff;
  --left: #5b8def;
  --right: #f0635a;
  --ok: #34c759;
  --warn: #e0a23a;
  --err: #f0635a;
  --surface: #1c1d23;
  --surface-2: #24262e;
  --surface-3: #20222a;
  --notice-bg: #2a2616;
  --notice-border: #5c4f22;
  --err-bg: #2f1c1c;
  --warn-bg: #2c2613;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--fg);
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); font-size: 0.9em; }
.error { color: var(--err); }
.inline { display: inline; }
.linkbtn { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font: inherit; }
button, .primary { padding: 0.4em 0.9em; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
button:hover { background: var(--surface-2); }
button.primary, .primary { background: var(--accent); color: white; border-color: var(--accent); }
button.primary:hover { background: #1858c4; }
pre.code, code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; }
pre.code { background: #1f1f1f; color: #e9e9e9; padding: 1em; border-radius: 6px; overflow-x: auto; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], textarea {
  padding: 0.4em 0.6em; border: 1px solid var(--line); border-radius: 4px; font: inherit;
}

/* nav */
.topnav { display: flex; gap: 0.9em; padding: 0.7em 1.2em; border-bottom: 1px solid var(--line); background: var(--surface); align-items: center; flex-wrap: wrap; font-size: 0.88em; }
.topnav .brand {
  font-family: ui-serif, "Iowan Old Style", "Charter", "Source Serif Pro", Georgia, serif;
  font-weight: 500;
  font-size: 1.15em;
  letter-spacing: 0.01em;
  margin-right: 0.6em;
}
.topnav .brand em { font-weight: 400; font-style: italic; }
.topnav .brand .brand-slash { color: var(--muted); margin: 0 0.35em; font-weight: 400; }
.topnav a, .topnav .linkbtn { color: var(--fg); }
.theme-toggle { margin-left: auto; font-size: 0.9em; }
main { max-width: 1280px; margin: 0 auto; padding: 1.5em 1.2em; }

/* feed */
.feed-header h1 { margin: 0 0 0.2em; }
.feed-controls { display: flex; align-items: flex-end; justify-content: space-between; gap: 1em; flex-wrap: wrap; margin: 1em 0 0.2em; border-bottom: 1px solid var(--line); padding-bottom: 0.4em; }
.feed-controls .category-tabs { margin: 0; padding: 0; border-bottom: none; flex: 1 1 auto; }
.sort-form { display: flex; align-items: center; gap: 0.5em; font-size: 0.9em; flex: 0 0 auto; }
.sort-form .sort-label { color: var(--muted, #777); }
.sort-form select { padding: 0.3em 0.5em; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--fg); font-size: 0.9em; }
.category-tabs { display: flex; gap: 0.4em; flex-wrap: wrap; margin: 1em 0 0.2em; padding-bottom: 0.4em; border-bottom: 1px solid var(--line); }
.cat-tab { padding: 0.35em 0.9em; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); font-size: 0.9em; text-transform: capitalize; }
.cat-tab:hover { background: var(--surface-2); text-decoration: none; }
.cat-tab.active { background: var(--accent); color: white; border-color: var(--accent); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1em; margin-top: 1em; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; }
.card .thumb img { width: 100%; height: 160px; object-fit: cover; display: block; }
.card-body { padding: 0.8em 0.9em; display: flex; flex-direction: column; gap: 0.4em; }
.card-meta { display: flex; gap: 0.6em; align-items: center; font-size: 0.85em; }
.card-meta .source { font-weight: 600; }
.card-meta .category { background: var(--surface-3); padding: 0.05em 0.4em; border-radius: 3px; font-size: 0.8em; color: var(--muted); }
.card-title { margin: 0; font-size: 1.05em; line-height: 1.3; }
.card-title a { color: var(--fg); }
.summary { margin: 0; color: var(--muted); font-size: 0.9em; }
.byline { font-size: 0.8em; }
.empty { color: var(--muted); padding: 2em; text-align: center; }
.load-more { grid-column: 1/-1; text-align: center; padding: 1em; }

/* News Near You (/local) */
.local-place-form { display: flex; align-items: center; gap: 0.6em; flex-wrap: wrap; margin: 0.8em 0 0.6em; padding-bottom: 0.6em; border-bottom: 1px solid var(--line); font-size: 0.9em; }
.local-place-form label { color: var(--muted); }
.local-place-form input[type="text"] { padding: 0.35em 0.6em; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--fg); min-width: 14em; }
.local-place-form select { padding: 0.3em 0.5em; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--fg); }
.local-place-form button { padding: 0.35em 0.9em; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); color: var(--fg); cursor: pointer; }
.local-place-form button:hover { background: var(--surface-3); }
.local-empty, .local-unresolved, .local-thin { padding: 1em 0; font-style: italic; }
.local-header { margin: 0.6em 0 0.2em; }

/* lean dot: --lean ranges -1..+1 */
.lean-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: hsl(calc(220 - (var(--lean) + 1) * 110), 80%, 55%);
}

/* thumbs (subtle, hover-revealed) */
[x-cloak] { display: none !important; }
.thumbs { margin-left: auto; display: inline-flex; gap: 0.15em; opacity: 0.25; transition: opacity 0.15s ease; }
.card:hover .thumbs { opacity: 0.75; }
.thumbs:focus-within { opacity: 1; }
.thumb-btn {
  background: none; border: none; padding: 0 0.25em;
  font-size: 0.85em; line-height: 1; color: var(--muted); cursor: pointer;
  border-radius: 3px;
}
.thumb-btn:hover { background: var(--surface-2); color: var(--fg); }
.thumb-btn.active.up { color: var(--ok); opacity: 1; }
.thumb-btn.active.down { color: var(--err); opacity: 1; }
.thumbs:has(.thumb-btn.active) { opacity: 1; }
.source-prompt {
  margin-top: 0.4em; padding: 0.5em 0.6em; background: var(--notice-bg); border: 1px solid var(--notice-border);
  border-radius: 4px; font-size: 0.85em; display: flex; gap: 0.6em; align-items: center; flex-wrap: wrap;
}
.source-prompt .linkbtn { padding: 0; }

/* feature bars on card */
.feature-bars { display: flex; gap: 0.5em; font-size: 0.7em; color: var(--muted); }
.feature-bars span { display: flex; align-items: center; gap: 4px; flex: 1; }
.feature-bars b { font-weight: 600; }
.feature-bars i { display: inline-block; height: 4px; background: var(--accent); border-radius: 2px; flex: 1; }
.feature-bars span > i { background: linear-gradient(to right, var(--accent) var(--w, 50%), var(--line) var(--w, 50%)); }

/* auth */
.auth-form { max-width: 380px; margin: 3em auto; background: var(--surface); padding: 2em; border: 1px solid var(--line); border-radius: 8px; }
.auth-form label { display: block; margin: 0.6em 0; }
.auth-form input { width: 100%; }
.auth-form button { margin-top: 0.8em; width: 100%; }

/* onboarding */
.onboarding { max-width: 720px; margin: 2em auto; }
.presets { display: flex; flex-direction: column; gap: 0.8em; margin-top: 1em; }
.preset-card { display: flex; gap: 1em; align-items: center; padding: 1em; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.preset-card h3 { margin: 0 0 0.2em; }
.preset-card input[type=radio] { transform: scale(1.4); }

/* algo page */
.algo { display: grid; grid-template-columns: 1fr 360px; gap: 1.5em; }
.algo-header { grid-column: 1/-1; display: flex; align-items: center; gap: 1em; }
.tabs { display: flex; gap: 0.4em; }
.tabs button { padding: 0.3em 0.8em; }
.tabs button.active { background: var(--accent); color: white; border-color: var(--accent); }
.features { display: flex; flex-direction: column; gap: 0.8em; background: var(--surface); padding: 1em; border: 1px solid var(--line); border-radius: 8px; }
.feature-row { display: grid; grid-template-columns: 12em 1fr 1fr 1fr; gap: 0.8em; align-items: center; padding: 0.5em 0; border-bottom: 1px dashed var(--line); }
.feature-row:last-child { border-bottom: none; }
.feature-name { font-weight: 600; }
.slider { display: flex; flex-direction: column; gap: 0.2em; font-size: 0.8em; color: var(--muted); }
.slider input[type=range] { width: 100%; }
.slider input[type=range]:disabled { opacity: 0.4; }
.slider output { display: inline-block; min-width: 2.6em; font-variant-numeric: tabular-nums; color: var(--fg); align-self: flex-end; }
.slider.direction .scale-ends { display: flex; justify-content: space-between; font-style: normal; font-size: 0.75em; }
.slider.direction .scale-ends i { font-style: normal; }
.slider.threshold input[type=checkbox] { vertical-align: middle; margin-right: 0.2em; }
.checkboxes { display: flex; gap: 0.8em; flex-wrap: wrap; }
.algo-actions { margin-top: 1em; display: flex; gap: 1em; align-items: center; }
.preview { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 1em; position: sticky; top: 1em; height: fit-content; }
.preview-list { padding-left: 1.2em; margin: 0; }
.preview-list li { margin: 0.5em 0; font-size: 0.9em; }
.preview-meta { display: flex; gap: 0.5em; font-size: 0.8em; color: var(--muted); align-items: center; }
.preview-meta .score { margin-left: auto; font-variant-numeric: tabular-nums; }
.algo section { background: transparent; }
.nl-builder { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 1em 1.2em; margin-bottom: 1.2em; }
.nl-builder p.muted { margin: 0.3em 0 0.6em; }
.nl-builder textarea { width: 100%; box-sizing: border-box; margin-bottom: 0.6em; padding: 0.6em; border: 1px solid var(--line); border-radius: 6px; font: inherit; resize: vertical; }
.nl-builder .nl-notes { color: var(--ok); margin: 0.7em 0 0; font-size: 0.92em; }
.nl-builder .nl-error { color: var(--err); margin: 0.7em 0 0; font-size: 0.92em; }

/* firehose */
.firehose-header { display: flex; justify-content: space-between; align-items: center; gap: 1em; }
.firehose-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.firehose-table th, .firehose-table td { padding: 0.4em 0.6em; text-align: left; font-size: 0.88em; border-bottom: 1px solid var(--line); }
.firehose-table th { background: var(--surface-3); }
.firehose-table tr:last-child td { border-bottom: none; }
.score-cell { font-variant-numeric: tabular-nums; }
.bar { display: inline-block; width: 80px; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; vertical-align: middle; }
.bar i { display: block; height: 100%; background: var(--accent); }
.bar.lean { background: linear-gradient(to right, #fee2e2, #f1f5f9 50%, #dbeafe); position: relative; }
.bar.lean i { background: black; width: 3px; height: 8px; transform: translateX(calc((var(--v) + 1) * 38px)); }

/* admin */
.admin { display: grid; grid-template-columns: 180px 1fr; gap: 1.5em; }
.admin-nav { display: flex; flex-direction: column; gap: 0.3em; }
.admin-nav h2 { margin: 0 0 0.5em; }
.admin-nav a { padding: 0.3em 0.5em; border-radius: 4px; color: var(--fg); }
.admin-nav a:hover { background: var(--surface-2); }
.admin-main { background: var(--surface); padding: 1.5em; border: 1px solid var(--line); border-radius: 8px; min-height: 60vh; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0.8em; }
.stat { background: var(--surface-3); padding: 1em; border-radius: 6px; }
.stat b { display: block; font-size: 1.5em; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 0.85em; }
.data-table { width: 100%; border-collapse: collapse; margin-top: 1em; font-size: 0.9em; }
.data-table th, .data-table td { padding: 0.4em 0.5em; border-bottom: 1px solid var(--line); text-align: left; }
.data-table tr.inactive { opacity: 0.4; }
.paywall-cell { font-variant-numeric: tabular-nums; }
.paywall-cell.paywall-na { color: var(--muted); }
.paywall-cell.paywall-low { color: var(--ok); }
.paywall-cell.paywall-mid { color: var(--warn); }
.paywall-cell.paywall-high { color: var(--err); }
.feed-add { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4em; margin: 0.5em 0; }
.feature-edit { padding: 0.6em; border-bottom: 1px solid var(--line); }
.feature-edit .row { display: flex; gap: 0.5em; align-items: center; flex-wrap: wrap; }
.feature-edit textarea { width: 100%; margin-top: 0.4em; }
.lean-hist { display: flex; flex-direction: column; gap: 4px; }
.lean-bar { display: flex; align-items: center; gap: 0.5em; font-family: monospace; font-size: 0.85em; }
.lean-bar .bucket { width: 3em; }
.lean-bar i { display: inline-block; height: 14px; background: var(--accent); border-radius: 2px; }
.lean-bar .count { color: var(--muted); }
.log-error { background: var(--err-bg); }
.log-warn { background: var(--warn-bg); }
.ok { color: var(--ok); }
.fail { color: var(--err); }

/* reader view (/read/<id>) */
.reader {
  max-width: 720px;
  margin: 2em auto 4em;
  padding: 0 1em;
  font-family: ui-serif, "Iowan Old Style", "Charter", "Source Serif Pro", Georgia, serif;
}
.reader-head { margin-bottom: 1.5em; }
.reader-meta { display: flex; gap: 0.8em; align-items: center; font-size: 0.85em; color: var(--muted); margin-bottom: 0.6em; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.reader-source { color: var(--fg); font-weight: 600; }
.reader-meta .category { background: var(--surface-3); padding: 0.1em 0.5em; border-radius: 3px; font-size: 0.9em; }
.reader-title { font-size: 2em; font-weight: 600; line-height: 1.2; margin: 0 0 0.4em; }
.reader-byline { font-style: italic; font-size: 0.95em; }
.reader-hero { margin: 1.5em 0; }
.reader-hero img { width: 100%; max-height: 420px; object-fit: cover; border-radius: 6px; }
.reader-body { font-size: 1.1em; line-height: 1.7; }
.reader-body p { margin: 0 0 1em; }
.reader-stat { margin-top: 2em; font-size: 0.85em; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.reader-fallback { background: var(--surface-3); padding: 1.2em; border-radius: 6px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--muted); }
.reader-foot { margin-top: 2.5em; padding-top: 1.2em; border-top: 1px solid var(--line); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.reader-original { font-weight: 500; }
.card-meta .reader-link { color: var(--muted); margin-left: auto; font-size: 0.85em; }
.card-meta .reader-link:hover { color: var(--accent); }

/* admin > discovery */
.discovery-actions { display: flex; flex-wrap: wrap; gap: 0.4em; align-items: center; }
.discovery-actions form { display: inline-flex; gap: 0.3em; flex-wrap: wrap; align-items: center; }
.discovery-actions input { padding: 0.25em 0.4em; border: 1px solid var(--line); border-radius: 4px; font-size: 0.9em; }

/* horizontally-scrolling table wrapper (used by firehose on narrow viewports) */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* mobile (≤640px): collapse multi-column layouts, enlarge tap targets */
@media (max-width: 640px) {
  main { padding: 1em 0.8em; }

  .topnav {
    flex-wrap: wrap;
    gap: 0.5em 0.9em;
    padding: 0.6em 0.8em;
    font-size: 0.95em;
  }
  .topnav .brand { margin-right: 0.2em; width: 100%; }

  .feed-header h1 { font-size: 1.4em; }
  .feed-controls { gap: 0.5em; }
  .feed-controls .category-tabs { width: 100%; }
  .sort-form { width: 100%; justify-content: flex-end; }
  .category-tabs { gap: 0.3em; }
  .cat-tab { padding: 0.45em 0.9em; font-size: 0.95em; }

  .cards { grid-template-columns: 1fr; gap: 0.8em; }
  .card .thumb img { height: 180px; }
  .card-meta { flex-wrap: wrap; gap: 0.4em 0.6em; }
  .thumbs { margin-left: auto; opacity: 0.9; }
  .thumb-btn { padding: 0.25em 0.5em; font-size: 1em; }
  .card-meta .reader-link { margin-left: 0; }

  /* algo: stack sidebar under main; per-feature row stacks too */
  .algo { grid-template-columns: 1fr; gap: 1em; }
  .algo-header { flex-wrap: wrap; gap: 0.5em; }
  .preview { position: static; }
  .feature-row {
    grid-template-columns: 1fr;
    gap: 0.4em;
    padding: 0.8em 0;
  }
  .feature-name { font-size: 1em; }
  .slider { font-size: 0.85em; }
  .tabs button { padding: 0.5em 1em; }

  /* firehose: wrap header, give the table a horizontal scrollbar */
  .firehose-header { flex-wrap: wrap; justify-content: flex-start; }
  .firehose-header h1 { width: 100%; margin: 0; }
  #firehose-feed { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .firehose-table { font-size: 0.85em; min-width: 640px; }
  .firehose-table th, .firehose-table td { padding: 0.35em 0.4em; }

  /* admin: stack nav above content; tighten cramped sub-grids */
  .admin { grid-template-columns: 1fr; gap: 1em; }
  .admin-nav { flex-direction: row; flex-wrap: wrap; gap: 0.2em 0.4em; }
  .admin-nav h2 { width: 100%; margin: 0 0 0.2em; }
  .admin-main { padding: 1em; }
  .feed-add { grid-template-columns: 1fr 1fr; }
  .data-table { font-size: 0.85em; display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  .auth-form { margin: 1em auto; padding: 1.2em; }
  .onboarding { margin: 1em auto; }
  .preset-card { flex-direction: column; align-items: stretch; gap: 0.4em; }
}

/* dossier link on feed cards */
.card-meta .dossier-link {
  color: var(--muted);
  font-size: 0.8em;
  padding: 0.05em 0.5em;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.card-meta .dossier-link:hover { color: var(--accent); border-color: var(--accent); }

/* story dossier page (/story/<id>) */
.dossier { max-width: 1200px; margin: 1.5em auto 4em; padding: 0 1em; }
.dossier-head { margin-bottom: 1.2em; }
.dossier-meta { display: flex; gap: 0.8em; align-items: center; font-size: 0.85em; color: var(--muted); margin-bottom: 0.4em; }
.dossier-meta .category { background: var(--surface-3); padding: 0.1em 0.5em; border-radius: 3px; font-size: 0.9em; }
.dossier-title { font-family: ui-serif, "Iowan Old Style", "Charter", "Source Serif Pro", Georgia, serif; font-size: 1.8em; font-weight: 600; line-height: 1.25; margin: 0; }
.dossier-framing { background: var(--surface-3); border-left: 3px solid var(--accent); padding: 1em 1.2em; margin: 1.2em 0 1.5em; border-radius: 0 6px 6px 0; }
.dossier-framing p { margin: 0; font-size: 1.02em; line-height: 1.55; }
.dossier-framing.muted { border-left-color: var(--line); }
.dossier-framing-label { font-size: 0.8em; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 0 0 0.4em; }
.dossier-columns { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1em; }
.dossier-col { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 0.8em; }
.dossier-col-head { font-size: 0.95em; font-weight: 600; margin: 0 0 0.6em; padding-bottom: 0.4em; border-bottom: 1px solid var(--line); }
.dossier-col-left .dossier-col-head { color: #2a6fa8; }
.dossier-col-center .dossier-col-head { color: var(--muted); }
.dossier-col-right .dossier-col-head { color: #b04a3a; }
.dossier-card { padding: 0.6em 0; border-bottom: 1px dashed var(--line); }
.dossier-card:last-child { border-bottom: none; }
.dossier-card-meta { display: flex; gap: 0.5em; align-items: center; font-size: 0.8em; color: var(--muted); margin-bottom: 0.3em; }
.dossier-card-meta .source { color: var(--fg); font-weight: 600; }
.dossier-card-title { font-size: 1em; font-weight: 600; line-height: 1.3; margin: 0 0 0.3em; }
.dossier-card-lead { font-size: 0.9em; line-height: 1.5; margin: 0 0 0.4em; color: var(--fg); }
.dossier-card-foot { font-size: 0.82em; }
.dossier-empty { font-size: 0.9em; padding: 0.4em 0; }
@media (max-width: 800px) {
  .dossier-columns { grid-template-columns: 1fr; }
}

/* discussion links (Techmeme-style) — feed card */
.discussion { font-size: 0.82em; color: var(--muted); margin-top: 0.4em; line-height: 1.5; }
.discussion-label { font-weight: 600; margin-right: 0.3em; }
.discussion a { color: var(--muted); }
.discussion a:hover { color: var(--accent); }
.discussion-sep { color: var(--line); }

/* discussion panel — story dossier */
.dossier-discussion { background: var(--surface-3); border-left: 3px solid var(--line); padding: 0.8em 1.2em; margin: 0 0 1.5em; border-radius: 0 6px 6px 0; }
.dossier-discussion .discussion-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4em 1.2em; }
.dossier-discussion .discussion-list li { font-size: 0.9em; }
.dossier-discussion .discussion-list a { font-weight: 600; }
.dossier-discussion .discussion-list .muted { font-size: 0.85em; margin-left: 0.3em; }

/* onboarding interview (cold-start) */
.onboarding-interview .ob-step { margin: 1.6em 0; padding-bottom: 1.4em; border-bottom: 1px solid var(--line); }
.onboarding-interview .ob-step:last-of-type { border-bottom: 0; }
.onboarding-interview h2 { font-size: 1.05em; margin: 0 0 0.2em; }
.onboarding-interview .ob-grid, .onboarding-interview .ob-lean { display: flex; flex-wrap: wrap; gap: 0.6em; margin-top: 0.8em; }
.onboarding-interview .ob-chip { display: flex; align-items: center; gap: 0.5em; padding: 0.55em 0.9em; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.onboarding-interview .ob-chip:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.onboarding-interview .ob-chip.ob-source { border-radius: 8px; }
.onboarding-interview .ob-actions { display: flex; align-items: center; gap: 1em; margin-top: 1.6em; }
@media (max-width: 640px) {
  .onboarding-interview .ob-grid, .onboarding-interview .ob-lean { flex-direction: column; }
  .onboarding-interview .ob-chip { border-radius: 8px; }
}

/* save / bookmark (roadmap Pri 6) — matches the thumb-btn visual language */
.save-btn {
  background: none; border: none; padding: 0 0.25em;
  font-size: 0.95em; line-height: 1; color: var(--muted); cursor: pointer;
  border-radius: 3px; opacity: 0.35; transition: opacity 0.15s ease, color 0.15s ease;
}
.card:hover .save-btn { opacity: 0.75; }
.save-btn:hover { background: var(--surface-2); color: var(--fg); opacity: 1; }
.save-btn.active { color: var(--accent); opacity: 1; }
/* multiple saved algorithm profiles */
.profile-switch { display: flex; align-items: center; gap: 0.5em; font-size: 0.9em; flex: 0 0 auto; }
.profile-switch .sort-label { color: var(--muted, #777); }
.profile-switch select { padding: 0.3em 0.5em; border: 1px solid var(--line); border-radius: 6px; background: white; color: var(--fg); font-size: 0.9em; }
.algo-actions .save-as { display: flex; align-items: center; gap: 0.4em; }
.algo-actions .save-as input { padding: 0.35em 0.5em; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.profile-list { list-style: none; margin: 0.5em 0 0; padding: 0; }
.profile-row { display: flex; align-items: center; justify-content: space-between; gap: 1em; flex-wrap: wrap; padding: 0.6em 0; border-bottom: 1px solid var(--line); }
.profile-row.active { font-weight: 600; }
.profile-name .badge { font-style: normal; font-weight: 600; font-size: 0.72em; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); margin-left: 0.5em; }
.profile-actions { display: flex; align-items: center; gap: 0.6em; flex-wrap: wrap; }
.profile-actions form.inline { display: flex; align-items: center; gap: 0.3em; }
.profile-actions input[type=text] { padding: 0.3em 0.5em; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: 0.9em; }
.profile-actions .linkbtn.danger { color: #b3261e; }

/* trending topics page */
.trending { max-width: 760px; margin: 0 auto; }
.trending-head h1 { margin: 0 0 0.2em; }
.trending-head p { margin: 0 0 1.2em; }
.trending-empty { padding: 2em 0; }
.trending-list { list-style: none; margin: 0; padding: 0; counter-reset: trending; }
.trending-topic { padding: 0.9em 0; border-bottom: 1px solid var(--line); }
.trending-topic-head { display: flex; align-items: baseline; gap: 0.6em; }
.trending-rank { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 1.5em; }
.trending-label { font-weight: 600; font-size: 1.05em; flex: 0 1 auto; }
.trending-heat { flex: 1; max-width: 120px; height: 4px; align-self: center; border-radius: 2px; background: linear-gradient(to right, var(--accent) var(--w, 0%), #e3e3df var(--w, 0%)); }
.trending-stats { margin: 0.25em 0 0 2.1em; }
.trending-stories { list-style: none; margin: 0.4em 0 0 2.1em; padding: 0; }
.trending-stories li { font-size: 0.92em; margin: 0.2em 0; }
.trending-stories a { font-weight: 600; }
.trending-stories .muted { margin-left: 0.4em; }

/* across-the-spectrum in-feed (the "+N angles" inline expansion) */
.spectrum-peek:empty { display: none; }
.spectrum-box { background: #f7f6f0; border: 1px solid var(--line); border-radius: 6px; padding: 0.6em 0.8em; margin-top: 0.5em; }
.spectrum-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.4em; }
.spectrum-label { font-size: 0.72em; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.spectrum-hide { font-size: 0.78em; }
.spectrum-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5em; }
.spectrum-item { border-left: 3px solid var(--line); padding: 0.1em 0 0.1em 0.6em; }
.spectrum-item.spectrum-left { border-left-color: var(--left); }
.spectrum-item.spectrum-right { border-left-color: var(--right); }
.spectrum-item.spectrum-center { border-left-color: var(--muted); }
.spectrum-item-meta { display: flex; gap: 0.5em; align-items: center; font-size: 0.78em; color: var(--muted); margin-bottom: 0.15em; }
.spectrum-item-meta .source { color: var(--fg); font-weight: 600; }
.spectrum-item-title { display: block; font-size: 0.92em; font-weight: 600; line-height: 1.3; color: var(--fg); }
.spectrum-item-title:hover { color: var(--accent); }
.spectrum-item-lead { font-size: 0.82em; line-height: 1.45; margin: 0.15em 0 0; color: #444; }
.spectrum-empty { font-size: 0.82em; margin: 0.2em 0; }
.spectrum-full { display: inline-block; margin-top: 0.5em; font-size: 0.82em; font-weight: 600; }

/* compact / density toggle (Techmeme-style) — scoped to home feed via #feed-cards.
   Toggled via [data-density="compact"] on <html> (localStorage-persisted, no FOUC). */
.density-toggle { font-size: 0.9em; }
:root[data-density="compact"] #feed-cards { grid-template-columns: 1fr; gap: 0.25em; }
:root[data-density="compact"] #feed-cards .card { border-radius: 4px; }
:root[data-density="compact"] #feed-cards .card .thumb,
:root[data-density="compact"] #feed-cards .card .summary,
:root[data-density="compact"] #feed-cards .card .feature-bars,
:root[data-density="compact"] #feed-cards .card .byline { display: none; }
:root[data-density="compact"] #feed-cards .card-body { padding: 0.45em 0.7em; gap: 0.15em; }
:root[data-density="compact"] #feed-cards .card-title { font-size: 0.98em; line-height: 1.3; }
:root[data-density="compact"] #feed-cards .card-meta { font-size: 0.8em; gap: 0.5em; }
:root[data-density="compact"] #feed-cards .discussion { margin-top: 0.15em; font-size: 0.78em; }

/* full-text search (roadmap "Search across articles") */
.nav-search { margin: 0; display: flex; }
.nav-search input { width: 14em; max-width: 40vw; padding: 0.3em 0.6em; font-size: 0.9em; }
.search-page-form { display: flex; gap: 0.6em; margin: 1em 0 0.4em; }
.search-page-form input[type="search"] { flex: 1; }
.search-card .card-title { margin-bottom: 0.1em; }
@media (max-width: 640px) {
  .nav-search { width: 100%; order: 99; }
  .nav-search input { width: 100%; max-width: none; }
}

/* why-this-article ranking explainer (roadmap "Why This Article") */
.card-meta .why-link { background: none; border: none; padding: 0; font: inherit; font-size: 0.85em; color: var(--muted); cursor: pointer; }
.card-meta .why-link:hover { color: var(--accent); }
.why-panel:empty { display: none; }
.card-meta .tldr-link { background: none; border: none; padding: 0; font: inherit; font-size: 0.85em; color: var(--muted); cursor: pointer; }
.card-meta .tldr-link:hover { color: var(--accent); }
.tldr-panel:empty { display: none; }
.tldr-box { background: var(--surface-3); border: 1px solid var(--line); border-radius: 6px; padding: 0.6em 0.8em; margin-top: 0.5em; }
.tldr-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.4em; }
.tldr-label { font-size: 0.72em; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.tldr-list { list-style: disc; margin: 0; padding-left: 1.1em; display: flex; flex-direction: column; gap: 0.35em; }
.tldr-list li { font-size: 0.92em; line-height: 1.4; color: var(--fg); }
.tldr-empty { font-size: 0.85em; margin: 0; }
.reader-tldr { margin: 1em 0 1.5em; }
.why-box { background: var(--surface-3); border: 1px solid var(--line); border-radius: 6px; padding: 0.6em 0.8em; margin-top: 0.5em; }
.why-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.4em; }
.why-label { font-size: 0.72em; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.why-hide { font-size: 0.78em; }
.why-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.55em; }
.why-item-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6em; }
.why-name { font-size: 0.9em; font-weight: 600; color: var(--fg); }
.why-points { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent); }
.why-bar { height: 4px; border-radius: 2px; background: var(--line); margin: 0.2em 0 0.15em; }
.why-bar i { display: block; height: 100%; width: var(--w, 0%); background: var(--accent); border-radius: 2px; }
.why-detail { font-size: 0.78em; }
.why-recency { font-size: 0.8em; margin-top: 0.5em; }
.why-total { display: flex; align-items: baseline; gap: 0.5em; margin-top: 0.5em; padding-top: 0.4em; border-top: 1px solid var(--line); font-size: 0.9em; }
.why-more { margin-top: 0.5em; font-size: 0.85em; }
.why-more summary { cursor: pointer; color: var(--muted); }
.why-list-rest { margin-top: 0.4em; gap: 0.25em; }
.why-item-row { display: flex; justify-content: space-between; gap: 0.6em; font-size: 0.85em; }
.why-empty { font-size: 0.82em; margin: 0.2em 0; }
.why-tune { display: inline-block; margin-top: 0.5em; font-size: 0.82em; font-weight: 600; }

/* Tune-from-this-article: "more / less like this" weight-nudge preview on a
   feed card. Reuses the why-panel surface conventions. */
.card-meta .tune-links { display: inline-flex; gap: 0.6em; }
.card-meta .tune-link { background: none; border: none; padding: 0; font: inherit; font-size: 0.85em; color: var(--muted); cursor: pointer; }
.card-meta .tune-link:hover { color: var(--accent); }
.tune-panel:empty { display: none; }
.tune-box { background: var(--surface-3); border: 1px solid var(--line); border-radius: 6px; padding: 0.6em 0.8em; margin-top: 0.5em; }
.tune-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.4em; }
.tune-label { font-size: 0.72em; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.tune-hide { font-size: 0.78em; }
.tune-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.3em; }
.tune-item { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6em; font-size: 0.9em; }
.tune-name { font-weight: 600; color: var(--fg); }
.tune-delta { font-variant-numeric: tabular-nums; font-weight: 600; }
.tune-delta.up { color: var(--ok); }
.tune-delta.down { color: var(--err); }
.tune-accept { margin-top: 0.55em; font-size: 0.85em; }
.tune-note { font-size: 0.78em; margin: 0.45em 0 0; }
.tune-empty { font-size: 0.82em; margin: 0.2em 0; }
.tune-undo { margin-top: 0.5em; font-size: 0.82em; font-weight: 600; }

/* Per-algorithm keyword mute/boost panel on /algo. Mirrors the
   /terms layout but lives inside the algorithm builder so each profile
   can carry its own keywords. */
.algo form.add-keyword { display: flex; gap: .5rem; margin: .25rem 0 .5rem; flex-wrap: wrap; align-items: center; }
.algo form.add-keyword input[type=text] { flex: 1; min-width: 240px; padding: .55rem .7rem; border: 1px solid #ccc; border-radius: 4px; font: inherit; }
.algo form.add-keyword select,
.algo form.add-keyword input[type=number] { padding: .55rem .5rem; border: 1px solid #ccc; border-radius: 4px; font: inherit; }
.algo form.add-keyword input[type=number] { width: 5.5rem; }
.algo form.add-keyword button { padding: .55rem 1rem; border: 0; background: #222; color: #fff; border-radius: 4px; cursor: pointer; }
.algo .kw-error { padding: .6rem .8rem; border-radius: 4px; margin-bottom: 1rem; background: #fdecea; color: #61231b; }
.algo .kw-cap { color: #888; font-size: .82rem; text-align: right; margin-bottom: 1rem; }
.algo .kw-cols { display: flex; gap: 2rem; flex-wrap: wrap; }
.algo .kw-col { flex: 1; min-width: 280px; }
.algo .kw-col h2 { font-size: 1rem; font-weight: 600; margin: 0 0 .5rem; }
.algo .kw-col .hint { color: #888; font-size: .82rem; margin: 0 0 .8rem; }
.algo .kw-col ul { list-style: none; padding: 0; margin: 0; }
.algo .kw-col li { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .45rem .2rem; border-bottom: 1px solid #eee; }
.algo .kw-col .term { font-size: .95rem; }
.algo .kw-col .wt { color: #2e7d32; font-size: .8rem; margin-left: .4rem; }
.algo .kw-col .empty { color: #888; font-style: italic; padding: .8rem 0; }
.algo .features-keywords { margin-top: 0.8em; }
.algo .feature-keywords { grid-template-columns: 12em 1fr; align-items: start; }
.algo .feature-keywords .kw-body { min-width: 0; }
.algo .kw-lede { color: var(--muted); font-size: 0.88em; margin: 0 0 0.8em; line-height: 1.4; }
.algo .kw-inline-count { color: var(--muted); font-weight: 400; font-size: 0.85em; }
.algo .nl-proposed-keywords { margin: 0.4em 0 1em; }
.algo .nl-kw-chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.5em; }
.algo .nl-kw-chips li { display: inline-flex; align-items: center; gap: 0.5em; padding: 0.3em 0.6em; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 0.9em; }
.algo .nl-kw-chips li.mute { border-color: #d9a; }
.algo .nl-kw-chips li.boost { border-color: #9c9; }
.algo .nl-kw-chips .wt { color: var(--muted); font-size: 0.82em; }
.algo .nl-kw-chips .linkbtn { color: var(--err); font-size: 0.82em; }

/* shareable algorithm gallery (roadmap "Shareable algorithm gallery") */
.gallery { max-width: 880px; margin: 0 auto; padding: 0 1em; }
.gallery-head h1 { margin: 0 0 0.2em; }
.gallery-lede { margin: 0 0 1.5em; color: var(--muted); }
.gallery-controls { display: flex; gap: 0.6em; align-items: center; flex-wrap: wrap; margin-bottom: 1em; }
.gallery-controls input[type="search"] { flex: 1; min-width: 200px; padding: 0.4em 0.6em; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: var(--surface-1, white); color: var(--fg); }
.gallery-sort { display: flex; align-items: center; gap: 0.4em; font-size: 0.9em; }
.gallery-sort select { padding: 0.3em 0.5em; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-1, white); color: var(--fg); font-size: 0.9em; }
.gallery-apply { padding: 0.4em 0.9em; border: 1px solid var(--line); background: var(--surface-2, #f7f6f0); color: var(--fg); border-radius: 6px; cursor: pointer; font: inherit; }
.gallery-publish { margin: 0 0 1.5em; padding: 0.6em 0.8em; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2, #f7f6f0); }
.gallery-publish summary { cursor: pointer; font-weight: 600; }
.gallery-publish-form { display: flex; flex-direction: column; gap: 0.5em; margin-top: 0.7em; }
.gallery-publish-form label { display: flex; flex-direction: column; gap: 0.2em; font-size: 0.9em; }
.gallery-publish-form input[type=text], .gallery-publish-form textarea { padding: 0.45em 0.6em; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: var(--surface-1, white); color: var(--fg); }
.gallery-publish-form button { align-self: flex-start; padding: 0.5em 1em; border: 0; background: var(--accent, #222); color: #fff; border-radius: 6px; cursor: pointer; }
.gallery-hint { font-size: 0.9em; }
.gallery-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.8em; }
.gallery-card { border: 1px solid var(--line); border-radius: 8px; padding: 0.9em 1em; background: var(--surface-1, white); }
.gallery-card-head { display: flex; justify-content: space-between; gap: 1em; align-items: flex-start; flex-wrap: wrap; }
.gallery-card-name { margin: 0; font-size: 1.05em; font-weight: 600; }
.gallery-badge { font-size: 0.7em; font-weight: 600; padding: 0.1em 0.4em; border-radius: 3px; background: var(--surface-2, #f7f6f0); color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-left: 0.4em; vertical-align: middle; }
.gallery-badge-adopted { background: var(--accent, #2e7d32); color: white; }
.gallery-card-stats { display: flex; gap: 0.9em; font-size: 0.82em; color: var(--muted); white-space: nowrap; }
.gallery-card-stats strong { color: var(--fg); font-variant-numeric: tabular-nums; }
.gallery-card-desc { margin: 0.5em 0 0.6em; color: var(--fg); font-size: 0.95em; }
.gallery-card-weights { list-style: none; margin: 0.4em 0 0.6em; padding: 0; display: flex; gap: 0.8em; flex-wrap: wrap; font-size: 0.82em; }
.gallery-card-weights li { background: var(--surface-2, #f7f6f0); padding: 0.2em 0.55em; border-radius: 4px; display: flex; gap: 0.4em; }
.gallery-card-weights .w-val { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.gallery-card-actions { display: flex; gap: 1em; align-items: center; margin-top: 0.5em; flex-wrap: wrap; }
.gallery-adopt { padding: 0.45em 0.9em; border: 0; background: var(--accent, #222); color: #fff; border-radius: 6px; cursor: pointer; font: inherit; text-decoration: none; display: inline-block; }
.gallery-unpublish { color: #b71c1c; }
.gallery-empty { padding: 2em 0; text-align: center; }
.gallery-copy, .gallery-share-email { font-size: 0.9em; }
.gallery-card:target { box-shadow: 0 0 0 2px var(--accent); }

/* Ask your feed */
.ask-cap { color: var(--muted); font-size: 0.85em; margin-left: 0.4em; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.alert { border-left: 3px solid var(--line); padding: 0.6em 0.9em; margin: 1em 0; background: var(--card-bg, #fafafa); }
.alert-warn { border-left-color: #c98a00; }
.alert-error { border-left-color: #b71c1c; }
.ask-chat { display: flex; flex-direction: column; gap: 1.4em; margin: 1em 0; }
.ask-empty { text-align: left; padding: 1em 0; }
.ask-empty em { font-style: italic; }
.ask-turn { border-left: 3px solid var(--accent, #222); padding: 0.4em 0 0.6em 0.9em; }
.ask-turn-nocoverage { border-left-color: var(--muted, #888); }
.ask-question-label { display: block; color: var(--muted); font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.2em; }
.ask-question { font-weight: 600; margin: 0 0 0.7em; }
.ask-answer p { margin: 0 0 0.7em; line-height: 1.5; }
.ask-citations { margin: 0.8em 0 0; padding-left: 1.4em; font-size: 0.9em; color: var(--muted); }
.ask-citations li { margin-bottom: 0.2em; }
.ask-citations a { color: inherit; text-decoration: underline; }
.ask-form { margin-top: 1.2em; display: flex; flex-direction: column; gap: 0.6em; }
.ask-form textarea { width: 100%; padding: 0.6em; border: 1px solid var(--line); border-radius: 6px; font: inherit; resize: vertical; min-height: 4.5em; }
.ask-form-row { display: flex; align-items: center; gap: 1em; }
.ask-form-row button { padding: 0.5em 1.2em; }
.ask-spinner { color: var(--muted); font-size: 0.9em; display: none; }
.htmx-request .ask-spinner { display: inline; }
.ask-new { margin-left: auto; font-size: 0.9em; color: var(--muted); }
