:root {
  --bg: #0e0f12;
  --surface: #16181d;
  --surface-2: #1d2026;
  --line: #262a31;
  --ink: #e9ebef;
  --ink-2: #b7bbc3;
  --muted: #868b94;
  --accent: #ff8a4c;
  --accent-soft: #3a2416;
  --ok: #57c46a;
  --warn: #e5ad3c;
  --danger: #ec6a5e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 30px rgba(0, 0, 0, .25);
  --ui: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --pop: #202429;
  --pop-shadow: 0 10px 34px rgba(0, 0, 0, .55);
  --focus: color-mix(in srgb, var(--accent) 70%, transparent);
  --scrim: rgba(0, 0, 0, .62);
  color-scheme: dark;
}

/* Dark is the designed state; these keep a light system from looking broken. */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f6f4;
    --surface: #ffffff;
    --surface-2: #f0f0ee;
    --line: #e2e2dd;
    --ink: #17191d;
    --ink-2: #4a4f57;
    --muted: #767b83;
    --accent: #d2551c;
    --accent-soft: #fdeee4;
    --shadow: 0 1px 2px rgba(20, 20, 20, .06), 0 8px 24px rgba(20, 20, 20, .07);
    --pop: #ffffff;
    --pop-shadow: 0 10px 34px rgba(20, 20, 20, .16);
    --scrim: rgba(0, 0, 0, .55);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; }

/* ---------- shell ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 56px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  height: 56px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand {
  flex: 0 0 auto;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -.02em;
  text-decoration: none;
  white-space: nowrap;
}
.brand::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 1px;
}
.mainnav { display: flex; gap: 4px; margin-left: auto; }
.mainnav a, .settings-link, .people-link {
  position: relative;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--ink-2);
  font-size: var(--text-md);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.mainnav a:hover, .settings-link:hover, .people-link:hover { color: var(--ink); background: var(--surface-2); }
.mainnav a.on, .settings-link.on, .people-link.on { color: var(--ink); }
.mainnav a.on::after, .settings-link.on::after, .people-link.on::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -9px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}
.settings-link { margin-left: auto; }

.shell { max-width: 1240px; margin: 0 auto; padding: 28px 24px 96px; }

/* ---------- page header ---------- */

.page-head {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin: 4px 0 24px;
}
h1 { margin: 0; font-size: var(--text-3xl); line-height: 1.1; letter-spacing: -.025em; font-weight: 700; }
.sub { margin: 6px 0 0; color: var(--muted); font-size: var(--text-md); }
.pill {
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  font-size: var(--text-xs);
  font-weight: 600;
}
.page-head .search { margin-left: auto; flex: 0 1 320px; }
.feed-add-source { margin-left: auto; padding: 8px 13px; }
.search input { width: 100%; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--text-sm);
  text-decoration: none;
}
.chip:hover { color: var(--ink); border-color: var(--muted); }
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); font-weight: 600; }

.feed-main { min-width: 0; }

/* ---------- day sections and grid ---------- */

.day { margin-bottom: 30px; }
.day-label {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 12px;
  font-size: var(--text-2xs);
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.day-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; align-items: start; }
.sentinel { padding: 24px 0; text-align: center; color: var(--muted); font-size: var(--text-sm); }

/* ---------- card ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-media { display: block; background: var(--surface-2); }
.card-media img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: var(--text-xs);
  margin-bottom: 8px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.card-meta > span { flex: 0 0 auto; }
.card-meta .card-src { flex: 0 1 auto; min-width: 0; max-width: 58%; font-weight: 600; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; }
.sep { opacity: .5; }
.card.is-new { border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.g { width: 14px; height: 14px; fill: currentColor; flex: 0 0 auto; }
.g.lg { width: 20px; height: 20px; }
.card-title { margin: 0 0 8px; font-size: var(--text-lg); line-height: 1.32; font-weight: 600; letter-spacing: -.01em; }
.card-title a { text-decoration: none; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-title a:hover { color: var(--accent); }
.card-excerpt {
  margin: 0 0 14px;
  color: var(--ink-2);
  font-size: var(--text-md);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-kicker { margin: 0 0 3px; color: var(--accent); font-size: var(--text-2xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.card-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grow { flex: 1; }

/* ---------- buttons and forms ---------- */

button, .primary, .primary-link, .ghost {
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: 9px;
  cursor: pointer;
}
.ghost {
  padding: 5px 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.ghost:hover { color: var(--ink); background: var(--surface-2); border-color: var(--line); }
.ghost.danger:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.ghost[disabled] { color: var(--ok); cursor: default; background: transparent; border-color: transparent; }
.primary, .primary-link {
  display: inline-block;
  padding: 10px 16px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #1a0f07;
  font-weight: 600;
  text-decoration: none;
}
.primary:hover, .primary-link:hover { filter: brightness(1.08); }

input, select, textarea {
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--text-md);
  min-width: 0;
}
input::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 1px; border-color: transparent; }
textarea { min-height: 90px; }

.notice {
  margin: 0 0 18px;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: var(--text-md);
}
.notice.ok { border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.notice.bad { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.notice a { color: var(--accent); }

.panel {
  padding: 40px 28px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}
.panel h2 { margin: 0 0 8px; font-size: var(--text-xl); }
.panel p { margin: 0 0 18px; color: var(--muted); font-size: var(--text-md); }
.empty-note { color: var(--muted); font-size: var(--text-md); }

/* ---------- sources ---------- */

.hero-add {
  display: flex;
  gap: 10px;
  padding: 14px;
  margin: 0 0 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.hero-add input { flex: 1; font-size: var(--text-base); padding: 12px 14px; }

.preview {
  padding: 18px;
  margin: 0 0 26px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: var(--radius);
  background: var(--surface);
}
.preview-head { display: flex; align-items: center; gap: 12px; }
.preview-head h2 { margin: 0; font-size: var(--text-lg); }
.preview-head .sub { text-transform: capitalize; }
.preview-list { margin: 14px 0; padding-left: 18px; color: var(--ink-2); font-size: var(--text-md); }
.preview form { margin: 0; }

.source-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.source-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.source-row > .g { margin-top: 3px; color: var(--ink-2); }
.source-row.off { opacity: .6; }
.source-main { min-width: 0; }
.source-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: var(--text-base); }
.source-url { color: var(--muted); font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.source-meta { color: var(--ink-2); font-size: var(--text-sm); margin-top: 6px; }
.health {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--text-2xs);
  font-weight: 600;
  border: 1px solid var(--line);
  color: var(--muted);
  text-transform: lowercase;
}
.health.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.health.degraded { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.health.broken, .health.paused-budget, .health.paused { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.hint { margin: 8px 0 0; color: var(--warn); font-size: var(--text-sm); }
.hint code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.setup-warning { margin: 14px 0; padding: 10px 12px; border-radius: 9px; background: var(--surface-2); color: var(--warn); font-size: var(--text-sm); }
.setup-warning a { color: var(--accent); }
.source-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.source-actions form { margin: 0; }

/* ---------- library ---------- */

.save-form { display: flex; gap: 6px; }
.save-form input { flex: 1; font-size: var(--text-sm); padding: 8px 10px; }
.save-form .primary { padding: 8px 12px; }
.lib-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.lib-row {
  display: flex;
  gap: 14px;
  padding: 14px 12px;
  border-radius: 10px;
  border-bottom: 1px solid var(--line);
}
.lib-row:hover { background: var(--surface); }
.lib-thumb { width: 96px; height: 64px; object-fit: cover; border-radius: 8px; background: var(--surface-2); flex: 0 0 auto; }
.lib-main { min-width: 0; }
.lib-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: var(--text-base); font-weight: 600; text-decoration: none; letter-spacing: -.005em; }
.lib-title:hover { color: var(--accent); }
.lib-meta { color: var(--muted); font-size: var(--text-sm); margin-top: 4px; }
.lib-credit { margin-top: 8px; }
.lib-credit .follow-pill { min-height: 32px; padding: 0 13px; font-size: 13px; }
/* Once followed, the card has nothing left to offer; a failed follow flips back and shows it again. */
.lib-credit:has(.follow-pill[aria-pressed="true"]) { display: none; }
.lib-excerpt { margin: 6px 0 0; color: var(--ink-2); font-size: var(--text-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-foot { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 22px; }
.pager { display: flex; gap: 6px; }
.pager .ghost { border: 1px solid var(--line); }
.backfill { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-wrap: wrap; }
.backfill .hint { margin: 0; color: var(--muted); }

/* ---------- reader (typography lives in design.css → Reading) ---------- */

.reader-wrap { max-width: 720px; margin: 0 auto; }
.back { display: inline-block; margin-bottom: 20px; color: var(--muted); font-size: var(--text-sm); text-decoration: none; }
.back:hover { color: var(--ink); }
.reader-meta { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: var(--text-sm); flex-wrap: wrap; }
.reader-meta a { color: var(--accent); text-decoration: none; }
.embed { position: relative; aspect-ratio: 16 / 9; margin-bottom: 26px; border-radius: var(--radius); overflow: hidden; background: #000; }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.hero { width: 100%; max-width: 100%; border-radius: var(--radius); margin-bottom: 26px; }
.reader-nav { display: flex; gap: 12px; margin-top: 44px; padding-top: 24px; border-top: 1px solid var(--line); }
.reader-link {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
}
.reader-link:hover { border-color: var(--muted); }
.reader-link span { color: var(--muted); font-size: var(--text-xs); }
.reader-link b { font-size: var(--text-md); font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.reader-link.right { text-align: right; }

/* ---------- shared surfaces used by the settings page ---------- */

h2 { font-size: var(--text-xl); letter-spacing: -.015em; }
.byline, small { color: var(--muted); font-size: var(--text-sm); }
.segmented, .filters, .date-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.segmented a, .filters a, .date-strip a, .button {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--text-sm);
  text-decoration: none;
}
.segmented a.active, .filters a.active, .button { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.empty, .settings > section, .settings-form section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px 0;
}
.settings-form label { display: grid; gap: 6px; margin: 14px 0; font-size: var(--text-md); }
.settings-form button, .settings-form .primary { padding: 10px 16px; border: 1px solid var(--accent); background: var(--accent); color: #1a0f07; font-weight: 600; }
.source-table > div { padding: 12px 0; border-bottom: 1px solid var(--line); display: grid; gap: 6px; }
.source-table form, .settings-form form { margin: 0; }
.related { display: block; padding: 13px 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.tldr { font-weight: 600; }
.why { color: var(--muted); font-size: var(--text-xs); margin: 0 0 6px; }

.chat-panel {
  position: fixed;
  z-index: 40;
  top: 0;
  right: 0;
  width: min(430px, 100vw);
  height: 100dvh;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(0, 0, 0, .4);
  padding: 20px;
  display: flex;
  flex-direction: column;
}
.chat-head { display: flex; justify-content: space-between; align-items: center; }
.chat-log { flex: 1; overflow: auto; white-space: pre-wrap; padding: 12px 0; font-size: var(--text-md); }
.chat-prompts { display: flex; gap: 8px; flex-wrap: wrap; }
.chat-prompts button { border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); padding: 5px 9px; }
.chat-form { display: flex; gap: 8px; margin: 0; }
.chat-form input { flex: 1; }

/* ---------- narrow widths ---------- */

@media (max-width: 959px) {
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: 0 0 auto; }
}

@media (max-width: 719px) {
  .topbar-inner, .shell { padding-left: 16px; padding-right: 16px; }
  .mainnav a, .settings-link { padding: 8px 9px; font-size: var(--text-sm); }
  .brand { font-size: var(--text-base); }
  .shell { padding-top: 20px; }
  h1 { font-size: 25px; }
  .page-head { align-items: flex-start; }
  .page-head .search { flex: 1 1 100%; margin-left: 0; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .hero-add { flex-direction: column; padding: 12px; }
  input, select, textarea, .hero-add input, .save-form input, .settings-form input { font-size: 16px; }
  .hero-add .primary { width: 100%; }
  .source-row { grid-template-columns: 20px minmax(0, 1fr); }
  .source-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .lib-thumb { width: 72px; height: 50px; }
  .lib-row { padding: 12px 8px; }
  .backfill { margin-left: 0; }
  .backfill .primary { width: 100%; }
  .reader-nav { flex-direction: column; }
  .reader-link.right { text-align: left; }
  .chat-panel { width: 100vw; padding: 16px; }
}


/* ---------- feed controls ---------- */

.feed-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: -8px 0 20px; }
.feed-controls form { margin: 0; display: flex; }
.segmented {
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}
.seg {
  padding: 6px 15px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: 600;
}
.seg:hover { color: var(--ink); }
.seg.on { background: var(--accent-soft); color: var(--accent); }
.window-chips { gap: 6px; }
.window-chips .chip { font-weight: 500; }
.window-chips .chip.on { font-weight: 600; }
a.pill { text-decoration: none; }
a.pill:hover { filter: brightness(1.12); }
.pill.on { background: var(--surface-2); color: var(--ink-2); border-color: var(--line); }
.learning {
  margin: 0 0 18px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px dashed color-mix(in srgb, var(--accent) 38%, var(--line));
  background: color-mix(in srgb, var(--accent-soft) 55%, transparent);
  color: var(--ink-2);
  font-size: var(--text-md);
}

/* ---------- card additions ---------- */

.card.is-read .card-title a { color: var(--muted); font-weight: 500; }
.card.is-read .card-media img { opacity: .62; }
/* Only the keyboard walker draws a ring; a click on the card never does. */
.card:focus:not(.focused) { outline: none; }
.card.focused { outline: 2px solid var(--focus); outline-offset: 2px; }
.check { color: var(--ok); font-size: var(--text-xs); flex: 0 0 auto; }
.card-media { position: relative; }
.play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--scrim);
  backdrop-filter: blur(2px);
}
.play svg { width: 22px; height: 22px; fill: #fff; margin-left: 2px; }
.media-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--scrim);
  color: #fff;
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: .01em;
}
.reason {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.45;
  display: flex;
  align-items: flex-start;
  gap: 7px;
}
/* The dot sits on the first line, not centred against a wrapped reason. */
.reason::before { content: ""; margin-top: 7px; width: 4px; height: 4px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.reason.exploring { color: var(--accent); }
.reason.exploring::before { background: var(--accent); }
.ghost.save.on { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.ghost.rating { padding-left: 7px; padding-right: 7px; filter: grayscale(.45); }
.ghost.rating.on { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 42%, transparent); filter: none; }
.summary.pending { border-left-color: var(--line); color: var(--muted); }
.summary.pending a { color: var(--accent); }

/* ---------- card menu popover ---------- */

.menu { position: relative; }
.menu-toggle { padding: 5px 8px; font-size: var(--text-base); line-height: 1; }
.menu-pop {
  position: absolute;
  right: 0;
  bottom: calc(100% + 6px);
  z-index: 20;
  min-width: 190px;
  max-width: min(240px, calc(100vw - 48px));
  padding: 5px;
  display: grid;
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--pop);
  box-shadow: var(--pop-shadow);
}
/* A class rule beats the user-agent [hidden] rule, so restate it here. */
.menu-pop[hidden] { display: none; }
.menu-pop button {
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-2);
  font-size: var(--text-sm);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.menu-pop button:hover { background: var(--surface-2); color: var(--ink); }
.menu-pop button.danger:hover { color: var(--danger); }

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  justify-items: center;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--pop);
  box-shadow: var(--pop-shadow);
  color: var(--ink);
  font-size: var(--text-md);
  pointer-events: auto;
  animation: toast-in .18s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.toast-undo {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  font-size: var(--text-md);
  text-decoration: underline;
}

/* ---------- sources: bulk, muted ---------- */

/* Same label treatment as the rail, but this one is never collapsed on mobile. */
.block-title {
  margin: 0 0 10px;
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}
.bulk {
  margin: 0 0 22px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.bulk summary { cursor: pointer; font-size: var(--text-md); font-weight: 600; color: var(--ink-2); }
.bulk summary:hover { color: var(--ink); }
.bulk-form { display: grid; gap: 12px; margin: 14px 0 0; }
.bulk-form label { display: grid; gap: 6px; font-size: var(--text-sm); color: var(--muted); }
.bulk-form .primary { justify-self: start; }
.file-label input { padding: 8px; font-size: var(--text-sm); }
.review { margin: 16px 0 0; }
.review-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 2px; }
.review-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 6px; border-bottom: 1px solid var(--line); }
.review-row input[type=checkbox] { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); flex: 0 0 auto; }
.review-row.bad { opacity: .65; }
.review-main { min-width: 0; flex: 1; }
.review-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: var(--text-md); }
.health.muted { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.new-count { color: var(--accent); font-weight: 600; }
.source-row.added { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); box-shadow: var(--shadow); }
.choices { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.choices form { margin: 0; }

/* ---------- reader additions ---------- */

.worth-it {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--text-md);
}
  .worth-it .ghost { border: 1px solid var(--line); }
  .worth-it button { min-height: 44px; }
.next-unread {
  display: grid;
  gap: 4px;
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--line));
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
}
.next-unread:hover { border-color: var(--accent); }
.next-unread span { color: var(--accent); font-size: var(--text-xs); font-weight: 600; }
.next-unread b { font-size: var(--text-base); font-weight: 600; }

/* ---------- library additions ---------- */

.lib-row { align-items: flex-start; }
.lib-save { margin-left: auto; }

/* ---------- settings additions ---------- */

.weights { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin: 12px 0; }
.weights label { margin: 0; }
.settings-form label.toggle { display: flex; align-items: center; gap: 10px; }
.card > .why summary { cursor: pointer; }
.card > .why p { margin: 4px 0 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

/* ---------- feed health ---------- */

.health-link { color: var(--accent); font-weight: 600; text-decoration: none; }
.health-dot { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--muted); vertical-align: middle; }
.health-dot.good { background: var(--ok); }
.health-dot.watch { background: var(--warn); }
.health-dot.bad { background: var(--danger); }
.monitor { overflow-wrap: anywhere; }
.monitor p { margin: 8px 0; }
.verdicts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 12px 0; }
.verdict { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; font-size: var(--text-sm); }
.verdict .grade { color: var(--muted); font-size: var(--text-2xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.verdict.watch { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.verdict.watch .grade { color: var(--warn); }
.verdict.bad { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.verdict.bad .grade { color: var(--danger); }
.verdict.good { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.verdict.good .grade { color: var(--ok); }
.monitor-table { width: 100%; margin: 12px 0; border-collapse: collapse; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.monitor-table th, .monitor-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.monitor-table th { color: var(--muted); font-size: var(--text-xs); font-weight: 600; }
.monitor-table tr.current td { background: var(--surface-2); }
.monitor-table.jobs .job-warn .job-status { color: var(--warn); }
.monitor-table.jobs .job-error .job-status { color: var(--danger); }
.verdict-word { color: var(--accent); font-size: var(--text-xs); white-space: nowrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 16px; margin: 14px 0; }
.stats dt { color: var(--muted); font-size: var(--text-xs); }
.stats dd { margin: 2px 0 0; }
.spark-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; }
.spark-figure { margin: 0; }
.spark { display: block; width: 100%; height: 48px; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 2; }
.spark-line.s1 { stroke: var(--muted); }
.spark-figure figcaption { color: var(--muted); font-size: var(--text-xs); }
.bars { display: block; width: 100%; max-width: 480px; height: auto; }
.bars rect { fill: var(--accent); }
.bars text { fill: var(--muted); font-size: 10px; }
.legend { color: var(--muted); font-size: var(--text-xs); }
.legend .key { display: inline-block; width: 12px; height: 2px; margin-left: 8px; background: var(--accent); vertical-align: middle; }
.legend .key.s1 { background: var(--muted); }
.monitor-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.monitor-actions form { margin: 0; }
.monitor-actions .settings-form label, .monitor .settings-form .weights label { margin: 0; }
.worst { margin: 8px 0; padding-left: 18px; font-size: var(--text-sm); }
.worst li { margin: 6px 0; }
.untrusted .jev-metrics, .untrusted .worst { opacity: .45; }
@media (max-width: 719px) {
  .monitor-table.versions thead { display: none; }
  .monitor-table.versions tr, .monitor-table.versions td { display: block; }
  .monitor-table.versions tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .monitor-table.versions td { padding: 2px 0; border: 0; }
  .monitor-table.versions td::before { content: attr(data-label) ": "; color: var(--muted); }
}

@media (max-width: 719px) {
  .feed-controls { gap: 8px; }
  .feed-controls .grow { display: none; }
  .segmented, .window-chips { flex: 0 0 auto; }
  .seg { padding: 6px 12px; }
  .toasts { left: 16px; right: 16px; bottom: 16px; transform: none; justify-items: stretch; }
  .toast { justify-content: space-between; }
  button, .primary, .primary-link, .ghost, .chip { min-height: 44px; }
}

/* The narrowest phones: keep the whole top bar on one line. */
@media (max-width: 460px) {
  .topbar-inner { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .mainnav { gap: 0; }
  .mainnav a, .settings-link { padding: 8px 7px; font-size: var(--text-sm); }
  .brand { font-size: var(--text-md); }
  .brand::before { width: 7px; height: 7px; margin-right: 5px; }
}

@media (max-width: 340px) {
  .topbar-inner, .shell { padding-left: 10px; padding-right: 10px; }
  .topbar-inner { gap: 3px; }
  .brand { width: 12px; overflow: hidden; font-size: 0; }
  .brand::before { margin-right: 0; }
  .mainnav a, .settings-link { padding-left: 6px; padding-right: 6px; font-size: var(--text-xs); }
  .feed-controls { margin-left: -2px; margin-right: -2px; }
  .window-chips { gap: 3px; }
  .window-chips .chip { padding-left: 9px; padding-right: 9px; }
  .source-row { padding: 13px 11px; gap: 9px; }
}

/* ---------- sign-in, account and people ---------- */
.auth { max-width: 420px; margin: 8vh auto 0; }
.auth .brand { display: inline-flex; margin-bottom: 28px; font-size: var(--text-xl, 1.4rem); }
.auth h1 { margin: 0 0 8px; }
.auth p { color: var(--ink-2); }
.auth-foot { margin-top: 18px; font-size: var(--text-sm); color: var(--muted); }
.auth-foot a { color: inherit; }
/* Sign in: one calm centred column, and Google's button in its light style instead of a form box. */
.people .panel { margin-top: 16px; }
.people .panel h2 { text-align: left; margin-top: 0; }
.people-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.people-table th, .people-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.people-table th { color: var(--muted); font-weight: 500; }
.people-table form { display: inline; }
.invite-link { display: block; max-width: 100%; overflow-wrap: anywhere; font-family: ui-monospace, monospace; font-size: var(--text-xs, .8rem); }
.table-scroll { overflow-x: auto; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.inline-form label { display: grid; gap: 4px; font-size: var(--text-sm); color: var(--muted); }
.danger { border-color: #c2412d; color: #c2412d; background: transparent; }

/* Settings > Connect your AI */
.connect-label { margin: 14px 0 0; font-size: var(--text-sm); font-weight: 600; color: var(--ink-2); }
.connect-code { position: relative; margin: 8px 0 0; }
.connect-code code { display: block; padding: 10px 72px 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
.connect-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 0; }
.connect-tabs input { position: absolute; opacity: 0; pointer-events: none; }
.connect-tabs label { display: inline-block; padding: 5px 12px; border-radius: 8px; background: var(--surface-2); color: var(--ink-2); font-size: var(--text-sm); cursor: pointer; }
.connect-tabs input:checked + label { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
.connect-code button { position: absolute; top: 4px; right: 4px; min-height: 36px; padding: 0 10px; font-size: var(--text-sm); }
.connect-tabs input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
.connect-panel { display: none; flex: 1 0 100%; }
#connect-claude:checked ~ .connect-panel-claude, #connect-cursor:checked ~ .connect-panel-cursor, #connect-codex:checked ~ .connect-panel-codex, #connect-gemini:checked ~ .connect-panel-gemini, #connect-hosted:checked ~ .connect-panel-hosted { display: block; }
.connect-create { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0 0; }
.connect-create .connect-label { margin: 0; }
.connect-create input { flex: 1 1 140px; min-width: 0; }
.connect-prompts { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 0; }
.connect-prompts button { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink-2); font-size: var(--text-sm); font-weight: 400; text-align: left; }
.connect-state { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; }
.connect-state form { margin-left: auto; }
.connect-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.connect-actions .ghost { border: 1px solid var(--line); }
.connect-page { max-width: 640px; margin: 0 auto; }
.connect-steps { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 12px; }
.connect-step { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.connect-step.is-current { border-color: var(--accent); }
.connect-step h2 { margin: 3px 0 0; font-size: var(--text-md, 1rem); }
.connect-step.is-todo h2 { color: var(--muted); }
.connect-num { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 50%; font-size: var(--text-sm); font-weight: 600; color: var(--ink-2); }
.connect-num .icon { width: 16px; height: 16px; }
.is-current .connect-num { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.is-done .connect-num { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.connect-add { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); }
/* Phones: the number and title share a row; what the step holds spans the whole card. */
@media (max-width: 600px) {
  .connect-step { row-gap: 0; padding: 16px 14px; }
  .connect-step > div { display: contents; }
  .connect-step > div > * { grid-column: 1 / -1; }
  .connect-step > div > h2 { grid-column: 2; align-self: center; margin: 0; }
}
.connect-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
