:root {
  --bg: #fbf7f0;
  --panel: #ffffff;
  --ink: #23201c;
  --muted: #6d6459;
  --line: #e7ded0;
  --accent: #b4611a;
  --accent-soft: #fdeede;
  --shadow: 0 1px 2px rgba(35, 32, 28, .06), 0 8px 24px rgba(35, 32, 28, .05);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17151a;
    --panel: #201d24;
    --ink: #f0ebe4;
    --muted: #a49b92;
    --line: #322d38;
    --accent: #f0a55e;
    --accent-soft: #33261a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* --- masthead --- */
.masthead { padding: 40px 0 26px; }
.masthead h1 {
  margin: 0; font-size: clamp(30px, 5vw, 44px); letter-spacing: -.02em;
  display: flex; align-items: center; gap: 12px;
}
.sun {
  width: .78em; height: .78em; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 35%, #ffd27d, var(--accent));
  box-shadow: 0 0 0 5px var(--accent-soft);
}
.tagline { margin: 10px 0 0; color: var(--muted); font-size: 17px; }
.freshness { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }

/* --- controls --- */
.controls {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}
.controls .row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.controls .row + .row { margin-top: 10px; }

.sorter { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg {
  appearance: none; border: 0; background: none; color: var(--muted);
  font: inherit; font-weight: 600; font-size: 14px;
  padding: 7px 16px; border-radius: 999px; cursor: pointer;
}
.seg.is-on { background: var(--accent); color: #fff; }
.seg:focus-visible, .chip:focus-visible, .clear:focus-visible,
input:focus-visible, select:focus-visible, #more:focus-visible, .card a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.search { flex: 1 1 200px; min-width: 160px; }
.search input, .picker select {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 9px 15px;
}
.picker { flex: 0 1 240px; }

/* Needs to out-specify `.controls .row` above, or the chips wrap into a tall
   stack on narrow screens instead of scrolling sideways. */
.controls .row.scroller {
  overflow-x: auto; flex-wrap: nowrap; scrollbar-width: thin;
  padding-bottom: 2px; -webkit-overflow-scrolling: touch;
}
.chip {
  appearance: none; flex: none; cursor: pointer; font: inherit; font-size: 14px;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px;
}
.chip.is-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip .n { color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 5px; }
.chip.is-on .n { color: inherit; opacity: .75; }

.clear {
  appearance: none; cursor: pointer; font: inherit; font-size: 14px;
  background: none; border: 0; color: var(--accent); text-decoration: underline; padding: 6px 2px;
}
.tally { color: var(--muted); font-size: 13.5px; margin-left: auto; }

/* --- newsletter signup (below the stories) --- */
.signup { padding: 14px 0 34px; }
.signup-card {
  position: relative; overflow: hidden; text-align: center;
  padding: 38px 28px 34px;
  border: 1px solid var(--line); border-radius: 20px;
  background:
    radial-gradient(120% 140% at 50% -30%, var(--accent-soft) 0%, transparent 62%),
    var(--panel);
  box-shadow: var(--shadow);
}
.signup-sun {
  display: block; width: 40px; height: 40px; margin: 0 auto 14px; border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, #ffd99180, var(--accent));
  box-shadow: 0 0 0 9px var(--accent-soft);
}
.signup-card h2 {
  margin: 0 0 8px; font-size: clamp(21px, 3.4vw, 27px);
  letter-spacing: -.02em; line-height: 1.22;
}
.signup-sub {
  margin: 0 auto 20px; max-width: 46ch;
  color: var(--muted); font-size: 15.5px; line-height: 1.5;
}
.signup-form { max-width: 470px; margin: 0 auto; }
.signup-row { display: flex; gap: 9px; }
.signup-form input[type="email"] {
  flex: 1 1 auto; min-width: 0; font: inherit; font-size: 15.5px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 999px; padding: 13px 19px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.signup-form input[type="email"]:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.signup-form button {
  appearance: none; cursor: pointer; flex: none;
  font: inherit; font-size: 15.5px; font-weight: 650;
  background: var(--accent); color: #fff; border: 0;
  border-radius: 999px; padding: 13px 26px;
  transition: filter .15s ease, transform .15s ease;
}
.signup-form button:hover:not(:disabled) { filter: brightness(1.07); }
.signup-form button:active:not(:disabled) { transform: translateY(1px); }
.signup-form button:disabled { opacity: .55; cursor: default; }
.signup-msg { margin: 12px 0 0; font-size: 14px; min-height: 1.3em; color: var(--muted); }
.signup-msg.is-bad { color: #b3261e; }
.signup-msg.is-good { color: var(--accent); font-weight: 600; }
.signup-fine { margin: 9px 0 0; font-size: 12.5px; color: var(--muted); opacity: .85; }
/* Off-screen rather than display:none — some bots skip hidden fields. */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

@media (max-width: 520px) {
  .signup-row { flex-wrap: wrap; }
  .signup-form input[type="email"], .signup-form button { flex: 1 0 100%; }
}
@media (prefers-color-scheme: dark) { .signup-msg.is-bad { color: #ff9a8f; } }

/* --- cards --- */
.grid {
  display: grid; gap: 18px; padding: 26px 0;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  /* Most sources ship no image, so let each card size to its own text rather
     than stretching every card in the row to match the tallest one. */
  align-items: start;
}
.card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(35,32,28,.08), 0 14px 32px rgba(35,32,28,.10); }
.card .shot { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--accent-soft); }
.card .body { padding: 15px 17px 17px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.card h2 { margin: 0; font-size: 17.5px; line-height: 1.32; letter-spacing: -.01em; }
.card h2 a { color: inherit; text-decoration: none; }
.card h2 a:hover { text-decoration: underline; text-decoration-color: var(--accent); }
.card p { margin: 0; color: var(--muted); font-size: 14.5px; }
.card .meta { margin-top: auto; padding-top: 6px; font-size: 12.5px; color: var(--muted); }
.card .meta-top { display: flex; align-items: center; gap: 8px; }
.card .meta-bot {
  display: flex; align-items: center; gap: 6px; margin-top: 5px;
  white-space: nowrap; overflow: hidden;
}
.card .src { overflow: hidden; text-overflow: ellipsis; }
.card .meta-bot time { flex: none; }
.card .where {
  background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: 2px 9px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card .dot { opacity: .5; flex: none; }
.card .glow {
  margin-left: auto; flex: none; font-weight: 700; color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* --- footer bits --- */
.empty { text-align: center; color: var(--muted); padding: 40px 0 10px; }
.more { display: flex; justify-content: center; padding: 6px 0 40px; }
#more {
  appearance: none; cursor: pointer; font: inherit; font-weight: 600;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px; padding: 11px 28px;
}
#more:hover { border-color: var(--accent); color: var(--accent); }
.foot { color: var(--muted); font-size: 13px; padding-bottom: 40px; border-top: 1px solid var(--line); padding-top: 18px; }
.is-loading { opacity: .5; transition: opacity .2s; }

/* On a phone the control block is a big slice of the viewport; let it scroll
   away instead of sitting on top of the stories. */
@media (max-width: 700px) {
  .controls { position: static; }
  .masthead { padding: 28px 0 18px; }
  .tally { margin-left: auto; }
  .grid { gap: 14px; padding: 18px 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .card:hover { transform: none; }
}