:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --ink: #1b1a17;
  --ink-2: #57534b;
  --ink-3: #8a857b;
  --line: #e5dfd4;
  --accent: #e8513a;
  --accent-ink: #ffffff;
  --chip: #efe9df;
  --shadow: 0 1px 2px rgb(30 25 15 / 5%), 0 6px 24px rgb(30 25 15 / 6%);
  --radius: 14px;
  --serif: "Iowan Old Style", "Charter", "Georgia", "Cambria", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #121212;
  --surface: #1c1c1b;
  --ink: #f1eee8;
  --ink-2: #b9b4aa;
  --ink-3: #85817a;
  --line: #2d2c2a;
  --accent: #ff6a50;
  --chip: #282725;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 6px 24px rgb(0 0 0 / 25%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* ---------- Masthead ---------- */
.masthead {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.masthead-inner {
  max-width: 1240px; margin: 0 auto; padding: 14px 24px 10px;
  display: flex; align-items: center; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; margin-right: auto; }
.brand-mark { width: 32px; height: 32px; flex: none; stroke: none; }
.brand-name { font: 700 24px/1 var(--serif); letter-spacing: -0.02em; }

.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 0 14px; height: 40px; width: min(320px, 40vw); color: var(--ink-3);
}
.search:focus-within { border-color: var(--ink-3); }
.search svg { width: 18px; height: 18px; flex: none; }
.search input { border: 0; outline: 0; background: transparent; color: var(--ink); font: inherit; width: 100%; }

.btn, .icon-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 40px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; font: 600 14px var(--sans); cursor: pointer;
}
.btn { padding: 0 16px; }
.icon-btn { width: 40px; justify-content: center; }
.btn:hover, .icon-btn:hover { border-color: var(--ink-3); }
.btn svg, .icon-btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.install-btn { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.install-btn:hover { border-color: var(--accent); filter: brightness(1.08); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* "Add to home screen" instructions for iPhone and iPad */
.install-help {
  width: min(380px, calc(100vw - 32px)); padding: 28px 24px 24px; border: 0; border-radius: 20px;
  background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px rgb(0 0 0 / 35%);
}
.install-help::backdrop { background: rgb(0 0 0 / 45%); }
.install-help form { display: grid; justify-items: center; gap: 14px; text-align: center; }
.install-help img { border-radius: 14px; }
.install-help h2 { font: 700 22px/1.2 var(--serif); margin: 0; }
.install-help ol { text-align: left; margin: 0; padding-left: 22px; display: grid; gap: 10px; color: var(--ink-2); font-size: 15px; }
.install-help ol svg { width: 18px; height: 18px; vertical-align: -3px; color: var(--accent); }
.install-help .btn { width: 100%; justify-content: center; }
.badge {
  background: var(--accent); color: var(--accent-ink); border-radius: 999px;
  font-size: 12px; min-width: 20px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center;
}

.tabs {
  max-width: 1240px; margin: 0 auto; padding: 0 24px 10px;
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; border: 0; background: transparent; color: var(--ink-2);
  font: 600 14px var(--sans); padding: 7px 14px; border-radius: 999px; cursor: pointer;
}
.tab:hover { background: var(--chip); color: var(--ink); }
.tab[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.tab .n { opacity: .55; font-weight: 500; margin-left: 4px; }
.tab.topic { display: inline-flex; align-items: center; gap: 5px; color: var(--accent); }
.tab.topic svg { width: 14px; height: 14px; fill: currentColor; stroke: none; }
.tab.topic[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.tab.add-topic { color: var(--ink-3); border: 1px dashed var(--line); }
.tab.add-topic:hover { color: var(--accent); border-color: var(--accent); background: transparent; }
.tab-divider { flex: none; width: 1px; margin: 6px 4px; background: var(--line); }

/* ---------- Feed ---------- */
main { max-width: 1240px; margin: 0 auto; padding: 18px 24px 40px; }
.meta-line { color: var(--ink-3); font-size: 13px; margin: 0 0 18px; }
.meta-line button { border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }

.section-label {
  display: flex; align-items: center; gap: 12px;
  font: 700 12px var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3);
  margin: 34px 0 16px;
}
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

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

/* Cards are text-first: a category-coloured rule on top instead of a picture. */
.card {
  --cat: var(--accent);
  position: relative; display: flex; flex-direction: column; gap: 10px;
  padding: 20px 20px 18px;
  background: var(--surface); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); transition: transform .18s ease, box-shadow .18s ease;
}
.card::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--cat); }
.card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgb(30 25 15 / 6%), 0 14px 36px rgb(30 25 15 / 12%); }
.card:hover h2 a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--cat); text-decoration-thickness: 2px; text-underline-offset: 4px; }

.kicker { display: flex; align-items: center; gap: 4px 10px; font-size: 12.5px; color: var(--ink-3); flex-wrap: wrap; }
.kicker .cat { color: var(--cat); font-weight: 800; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.kicker .src { font-weight: 700; color: var(--ink-2); }
.coverage {
  display: inline-flex; align-items: center; gap: 5px; margin-left: auto;
  padding: 3px 9px; border-radius: 999px; background: var(--chip); color: var(--ink-2);
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.coverage svg { width: 12px; height: 12px; stroke-width: 2.5; }
.top-label {
  padding: 3px 9px; border-radius: 999px; background: var(--cat); color: #fff;
  font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
}

.card h2 { font: 600 20px/1.28 var(--serif); margin: 0; letter-spacing: -0.005em; text-wrap: pretty; }
.card h2 a { text-decoration: none; }
.card h2 a::after { content: ""; position: absolute; inset: 0; } /* whole card clickable */
.card h2 a:focus-visible { outline: none; }
.card:has(h2 a:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.summary { margin: 0; color: var(--ink-2); font-size: 14.5px; line-height: 1.5; }
.also { margin-top: auto; padding-top: 4px; font-size: 12.5px; color: var(--ink-3); position: relative; z-index: 1; }
.also a { color: var(--ink-2); font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--line); }
.also a:hover { color: var(--accent); border-color: var(--accent); }

/* Lead story: a big headline on a soft wash of its category colour. */
.lead { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; }
.lead .card.hero {
  grid-row: span 2; justify-content: space-between; gap: 28px; min-height: 340px; padding: 30px 32px 28px;
  background:
    radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--cat) 26%, transparent), transparent 60%),
    linear-gradient(160deg, color-mix(in srgb, var(--cat) 10%, var(--surface)), var(--surface));
}
.lead .card.hero::before { height: 5px; }
.lead .card.hero .hero-text { display: grid; gap: 14px; }
.lead .card.hero h2 { font-size: clamp(30px, 3.6vw, 46px); line-height: 1.08; letter-spacing: -0.02em; font-weight: 700; }
.lead .card.hero .summary { font-size: 16.5px; max-width: 60ch; }
.lead .card.hero .also { margin-top: 0; font-size: 13.5px; }
.lead .card.side h2 { font-size: 22px; line-height: 1.2; }
.lead .card.side { justify-content: center; }

.empty { text-align: center; color: var(--ink-2); padding: 80px 20px; }
.empty h2 { font: 600 26px var(--serif); color: var(--ink); margin: 0 0 8px; }
.empty code { background: var(--chip); padding: 2px 8px; border-radius: 6px; }

/* ---------- Drawer ---------- */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 40; width: min(400px, 100vw);
  background: var(--surface); border-left: 1px solid var(--line); overflow-y: auto;
  padding: 20px 24px 40px; box-shadow: -20px 0 60px rgb(0 0 0 / 15%);
  animation: slide .22s ease;
}
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer h2 { font: 700 24px var(--serif); margin: 0; }
.drawer h3 { font: 700 12px var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin: 28px 0 8px; }
.hint { font-size: 13.5px; color: var(--ink-2); margin: 0 0 12px; }
.topic-form { display: grid; gap: 8px; }
.topic-form .btn { justify-content: center; }
.topic-list { display: grid; gap: 8px; margin-top: 12px; }
.topic-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 8px 10px 14px; background: var(--chip); border-radius: 12px;
}
.topic-row strong { display: block; font-size: 15px; }
.topic-row small { display: block; color: var(--ink-3); font-size: 13px; }
.topic-row .icon-btn { width: 32px; height: 32px; flex: none; background: transparent; border-color: transparent; color: var(--ink-3); }
.topic-row .icon-btn:hover { color: var(--accent); }
.mute-form { display: flex; gap: 8px; }
.mute-form input, .topic-form input {
  flex: 1; min-width: 0; height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit;
}
.mute-form input:focus, .topic-form input:focus { outline: none; border-color: var(--ink-3); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 8px 6px 12px;
  background: var(--chip); border-radius: 999px; font-size: 14px; font-weight: 600;
}
.chip button { border: 0; background: none; color: var(--ink-3); cursor: pointer; padding: 0; display: grid; }
.chip button:hover { color: var(--accent); }
.chip svg { width: 16px; height: 16px; }
.sources { display: grid; gap: 4px; }
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; font-size: 15px; cursor: pointer; }
.toggle small { color: var(--ink-3); margin-left: 6px; }
.cat-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 9px; vertical-align: 1px; }
.toggle input { appearance: none; width: 40px; height: 24px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; transition: background .15s; flex: none; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgb(0 0 0 / 20%); }
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(16px); }
.toggle input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.status { list-style: none; margin: 0; padding: 0; font-size: 13px; color: var(--ink-2); display: grid; gap: 4px; }
.status .bad { color: var(--accent); }
.scrim { position: fixed; inset: 0; z-index: 30; background: rgb(0 0 0 / 30%); }

.footer { max-width: 1240px; margin: 0 auto; padding: 24px 24px 48px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 13px; }
.footer p { margin: 4px 0; max-width: 760px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .lead { grid-template-columns: 1fr; }
  .lead .card.hero { grid-row: auto; min-height: 0; padding: 24px 22px 22px; }
}
@media (max-width: 640px) {
  .masthead-inner { flex-wrap: wrap; padding: 12px 16px 8px; }
  .search { order: 5; width: 100%; }
  .install-btn { width: 40px; padding: 0; justify-content: center; }
  .install-label { display: none; }
  .tabs { padding: 0 16px 10px; }
  main { padding: 14px 16px 32px; }
  .footer { padding: 20px 16px 40px; }
  .grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
