:root {
  --bg: #ffffff;
  --text: #0d0d0d;
  --text-2: #3d3d3d;
  --muted: #6e6e73;
  --line: #ececec;
  --soft: #f5f5f7;
  --accent: #0d0d0d;
  --accent-text: #ffffff;
  --accent-hover: #2b2b2b;
  --link: #1a5fd6;
  --bg-elev: #ffffff;
  --bg-alt: #fafafa;
  --topbar-bg: rgba(255, 255, 255, 0.86);
  --input-border: #d9d9d9;
  --chip-hover: #d4d4d4;
  --body-text: #242424;
  --danger: #b3261e;
  --danger-line: #f0c9c6;
  --danger-bg: #fdf0ef;
  --ok: #1f7a3a;
  --ok-bg: #e7f4ea;
  --warn: #8a5a00;
  --warn-bg: #fdf3dc;
  --skel-a: #f3f3f5;
  --skel-b: #fafafa;
  --grid: #f0f0f0;
  --axis: #dcdcdc;
  --crosshair: #bdbdbd;
  --shadow: rgba(0, 0, 0, .08);
  --thumb-a: #eef1f7;
  --thumb-b: #f6eef4;
  /* Chart series (validated palette, light surface) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --radius: 18px;
  --sans: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --display: "Inter Display", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  color-scheme: light;
}

/* Dark theme: follows the device unless the visitor picked light or dark
   (data-theme on <html>, set by the toggle in the top bar). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f10; --text: #f2f2f3; --text-2: #cfcfd4; --muted: #9a9aa2; --line: #2a2a2e; --soft: #1c1c1f;
    --accent: #f2f2f3; --accent-text: #111113; --accent-hover: #d9d9dd; --link: #7fb0ff;
    --bg-elev: #18181b; --bg-alt: #141416; --topbar-bg: rgba(15, 15, 16, 0.82); --input-border: #3a3a3f; --chip-hover: #4a4a50;
    --body-text: #e4e4e7; --danger: #ff8a80; --danger-line: #5c2b28; --danger-bg: #2a1614; --ok: #7ad48f; --ok-bg: #16301e;
    --warn: #f0c060; --warn-bg: #33280f; --skel-a: #1a1a1d; --skel-b: #232327; --grid: #232327; --axis: #3a3a3f; --crosshair: #5a5a60;
    --shadow: rgba(0, 0, 0, .5); --thumb-a: #1f2230; --thumb-b: #2a1f28; --series-1: #3987e5; --series-2: #d95926;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f0f10; --text: #f2f2f3; --text-2: #cfcfd4; --muted: #9a9aa2; --line: #2a2a2e; --soft: #1c1c1f;
  --accent: #f2f2f3; --accent-text: #111113; --accent-hover: #d9d9dd; --link: #7fb0ff;
  --bg-elev: #18181b; --bg-alt: #141416; --topbar-bg: rgba(15, 15, 16, 0.82); --input-border: #3a3a3f; --chip-hover: #4a4a50;
  --body-text: #e4e4e7; --danger: #ff8a80; --danger-line: #5c2b28; --danger-bg: #2a1614; --ok: #7ad48f; --ok-bg: #16301e;
  --warn: #f0c060; --warn-bg: #33280f; --skel-a: #1a1a1d; --skel-b: #232327; --grid: #232327; --axis: #3a3a3f; --crosshair: #5a5a60;
  --shadow: rgba(0, 0, 0, .5); --thumb-a: #1f2230; --thumb-b: #2a1f28; --series-1: #3987e5; --series-2: #d95926;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Components set their own display; the hidden attribute always wins. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; border-radius: 6px; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 0 24px; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--topbar-bg);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: 0 24px; height: 64px; display: flex; align-items: center; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 650; font-size: 1.02rem; letter-spacing: -0.01em; }
/* The logo has a black and a white version; the theme picks one. */
.logo { display: inline-flex; align-items: center; }
.logo img { display: block; height: 26px; width: auto; }
.logo .logo-dark { display: none; }
:root[data-theme="dark"] .logo .logo-light { display: none; }
:root[data-theme="dark"] .logo .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo .logo-light { display: none; }
  :root:not([data-theme="light"]) .logo .logo-dark { display: block; }
}
.brand { flex: none; }
.topbar-right { display: flex; align-items: center; gap: 6px; flex: none; margin-left: auto; }
/* Section links scroll sideways when they don't fit, fading at the edge. */
.topnav {
  display: flex; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none;
  mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
}
.topnav::-webkit-scrollbar { display: none; }
.topnav a { color: var(--muted); font-size: .93rem; font-weight: 500; white-space: nowrap; padding: 6px 10px; border-radius: 999px; }
.topnav a:hover { color: var(--text); }
.topnav a[aria-current="page"] { color: var(--text); background: var(--soft); }
.topnav a:last-child { margin-right: 24px; }
.admin-link { font-size: .9rem; font-weight: 550; padding: 6px 10px; border-radius: 999px; white-space: nowrap; color: var(--muted); }
.admin-link:hover, .admin-link.is-active { color: var(--text); background: var(--soft); }

/* Light/dark switch: shows the moon in light mode and the sun in dark mode. */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme]) .theme-toggle .icon-moon { display: none; }
}

/* Search box in the top bar: collapsed to the magnifier until opened. */
.nav-search { position: relative; display: flex; align-items: center; }
.nav-search input {
  width: 0; padding: 7px 0; border: 1px solid transparent; opacity: 0;
  font: inherit; font-size: .92rem; color: var(--text); background: var(--soft); border-radius: 999px;
  transition: width .25s ease, padding .25s ease, opacity .2s ease;
}
.nav-search.is-open input { width: 230px; padding: 7px 38px 7px 14px; opacity: 1; border-color: var(--line); }
.nav-search.is-open .icon-btn { position: absolute; right: 0; }
.nav-search input:focus { outline: 2px solid var(--link); outline-offset: 1px; }
.nav-search input::-webkit-search-cancel-button { display: none; }

.announcement { background: var(--soft); color: var(--text-2); text-align: center; font-size: .9rem; padding: 9px 16px; border-bottom: 1px solid var(--line); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 999px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--soft); color: var(--text); }
.icon-btn:disabled { opacity: .45; cursor: default; }
.icon-btn svg { display: block; transform-origin: 50% 50%; }
.icon-btn.spinning svg { animation: spin .9s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .icon-btn.spinning svg { animation-duration: 2.4s; } }

.btn {
  border: 1px solid var(--line); background: var(--bg); border-radius: 999px;
  padding: 10px 22px; font-weight: 550; cursor: pointer; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--soft); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-sm { padding: 7px 16px; font-size: .9rem; display: inline-flex; align-items: center; }
.btn-lg { padding: 14px 28px; font-size: 1.05rem; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger-line); }
.btn-danger:hover { background: var(--danger-bg); }
a.btn { display: inline-flex; align-items: center; gap: 8px; }

.sr-only, .hp { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.form-msg { min-height: 1.5em; margin: 10px 0 0; font-size: .92rem; color: var(--muted); }
.form-msg.is-error { color: var(--danger); }
.form-msg.is-ok { color: var(--ok); }
.form-msg a { color: var(--link); text-decoration: underline; }

/* ---------- Account menu ---------- */

.account { position: relative; }
.account summary { list-style: none; cursor: pointer; border-radius: 999px; display: block; }
.account summary::-webkit-details-marker { display: none; }
.avatar-img { display: block; width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.avatar-sm { width: 32px; height: 32px; font-size: .78rem; }
.account-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; z-index: 20;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 14px; padding: 8px;
  box-shadow: 0 12px 32px var(--shadow);
}
.account-name { padding: 8px 10px 0; font-weight: 600; }
.account-email { padding: 0 10px 8px; color: var(--muted); font-size: .88rem; border-bottom: 1px solid var(--line); margin-bottom: 6px; overflow-wrap: anywhere; }
.account-link { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: .93rem; }
.account-link:hover { background: var(--soft); }

/* ---------- Landing ---------- */

/* Home: the headline's band, with a grid of shapes behind it that swell
   near a moving pointer (public/cursor-wave.js). */
.hero-band { position: relative; overflow: hidden; }
.cursor-wave { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; display: block; }
.hero-band .stage { z-index: 1; }

/* Home: the band stays under the top bar while the news slides up over it
   (public/home.js sets --leave, 0 to 1, as the page scrolls). */
.home-page .hero-band { --leave: 0; position: sticky; top: var(--topbar-h, 64px); z-index: 0; }
.home-page .stage { min-height: calc(100svh - var(--topbar-h, 64px)); }
.home-page .stage-hero { opacity: calc(1 - var(--leave) * 1.25); transform: translateY(calc(var(--leave) * -56px)) scale(calc(1 - var(--leave) * 0.05)); }
.home-page .cursor-wave { opacity: calc(1 - var(--leave) * 0.85); }
.scroll-cue {
  position: absolute; left: 50%; bottom: 28px; z-index: 1; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .9rem; font-weight: 550;
  opacity: calc(1 - var(--leave) * 4);
}
.scroll-cue:hover { color: var(--text); }
.scroll-cue svg { animation: cue 1.8s ease-in-out infinite; }
@keyframes cue { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(4px); } }
.home-news {
  position: relative; z-index: 2; background: var(--bg);
  border-radius: 28px 28px 0 0; box-shadow: 0 -18px 40px -24px var(--shadow); border-top: 1px solid var(--line);
  scroll-margin-top: var(--topbar-h, 64px);
}
.home-news .hero h2 { margin: 0; font: 650 clamp(2.4rem, 5vw, 3.6rem)/1.05 var(--display); letter-spacing: -0.035em; }
.hero-subscribe { margin: 28px auto 0; }
.hero-subscribe-note { margin: 10px auto 0; max-width: 460px; color: var(--muted); font-size: .9rem; }
.stage-hero .form-msg { min-height: 1.2em; }
@media (prefers-reduced-motion: reduce) { .scroll-cue svg { animation: none; } }

/* Home: the headline in the middle. */
.stage {
  position: relative; max-width: 1400px; margin: 0 auto; padding: 0 24px;
  min-height: clamp(700px, calc(100vh - 64px), 880px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.stage-hero { position: relative; z-index: 1; max-width: 640px; text-align: center; padding: 24px 8px; }
.stage-hero h1 { margin: 0; font: 700 clamp(2.4rem, 5.5vw, 4rem)/1.05 var(--display); letter-spacing: -0.04em; }
.stage-hero .lede { margin: 20px auto 0; max-width: 520px; color: var(--muted); font-size: 1.15rem; }

.newsletter { max-width: 720px; margin: 0 auto; border-top: 1px solid var(--line); padding: 48px 24px 24px; text-align: center; }
@media (max-width: 640px) { .newsletter { margin: 0 16px; padding: 40px 0 16px; } }
.newsletter h2 { margin: 0; font: 650 1.35rem/1.3 var(--display); letter-spacing: -0.015em; }
.newsletter > p { margin: 8px 0 22px; color: var(--muted); }
.subscribe { display: flex; gap: 10px; max-width: 460px; margin: 0 auto; }
.subscribe input[type="email"] {
  flex: 1; min-width: 0; font: inherit; padding: 11px 18px; border: 1px solid var(--input-border); border-radius: 999px; background: var(--bg);
}
.subscribe input[type="email"]:focus { outline: 2px solid var(--link); outline-offset: 1px; border-color: transparent; }
.subscribe input[aria-invalid="true"] { border-color: var(--danger); }

/* Build your newsletter (/newsletter) */
.nl-layout { max-width: 720px; padding-bottom: 64px; }
.nl-form { display: flex; flex-direction: column; gap: 22px; }
.nl-group { border: 0; margin: 0; padding: 0; }
.nl-group legend { font: 650 1.05rem/1.3 var(--display); padding: 0; }
.nl-group > .muted { margin: 4px 0 10px; font-size: .9rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span { display: inline-block; padding: 7px 14px; border: 1px solid var(--input-border); border-radius: 999px; font-size: .93rem; background: var(--bg); transition: background .15s, border-color .15s, color .15s; }
.chip:hover span { border-color: var(--chip-hover); background: var(--soft); }
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip input:focus-visible + span { outline: 2px solid var(--link); outline-offset: 2px; }
.nl-email { display: flex; gap: 10px; flex-wrap: wrap; }
.nl-email input[type="email"] { flex: 1 1 240px; min-width: 0; font: inherit; padding: 11px 18px; border: 1px solid var(--input-border); border-radius: 999px; background: var(--bg); color: var(--text); }
.nl-email input[type="email"]:focus { outline: 2px solid var(--link); outline-offset: 1px; border-color: transparent; }
.nl-email input[aria-invalid="true"] { border-color: var(--danger); }
.nl-email input[readonly] { background: var(--soft); color: var(--muted); }
.nl-link { padding: 14px 16px; border-radius: 12px; background: var(--soft); font-size: .93rem; }
.nl-link p { margin: 0 0 10px; color: var(--text-2); }
.nl-link-row { display: flex; gap: 8px; }
.nl-link-row input { flex: 1; min-width: 0; font: inherit; font-size: .88rem; padding: 7px 12px; border: 1px solid var(--input-border); border-radius: 8px; background: var(--bg); color: var(--text); }
.nl-unsub { align-self: flex-start; }

/* ---------- Sign in ---------- */

.signin { display: grid; place-items: center; padding: 12vh 24px 40px; }
.signin-card { width: 100%; max-width: 420px; text-align: center; border: 1px solid var(--line); border-radius: 24px; padding: 44px 32px 32px; }
.signin-card h1 { margin: 18px 0 8px; font: 650 1.5rem/1.25 var(--display); letter-spacing: -0.02em; }
.signin-card > p { margin: 0 0 24px; color: var(--muted); }
.logo-lg img { height: 40px; }
.gsi { display: flex; justify-content: center; min-height: 44px; }
.dev-signin { margin-top: 24px; padding-top: 20px; border-top: 1px dashed var(--line); display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.dev-signin input { flex: 1; min-width: 180px; font: inherit; padding: 8px 14px; border: 1px solid var(--input-border); border-radius: 999px; }
.dev-note { width: 100%; margin: 0; color: var(--muted); font-size: .85rem; }

/* ---------- Home ---------- */

.hero { padding: 56px 0 28px; }
.hero h1 { margin: 0; font: 650 clamp(2.4rem, 5vw, 3.6rem)/1.05 var(--display); letter-spacing: -0.035em; }
.hero p { margin: 14px 0 0; color: var(--muted); font-size: 1.1rem; max-width: 560px; }


/* Bento grid: large and wide tiles break up the rhythm, like an editorial front page. */
.bento {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-flow: dense;
  gap: 40px 24px;
}
.bento:empty { display: none; }

.tile { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.tile .cover { aspect-ratio: 4 / 3; border-radius: var(--radius); }
.tile-text { display: flex; flex-direction: column; gap: 8px; }
.tile h2 { margin: 0; font: 600 1.08rem/1.3 var(--display); letter-spacing: -0.012em; }
.tile-summary { margin: 0; color: var(--text-2); font-size: .98rem; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tile-meta { color: var(--muted); font-size: .84rem; }
.tile-kicker { font-size: .76rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.tile:hover h2 { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.tile:hover .cover { transform: scale(1.012); }
.cover { transition: transform .35s cubic-bezier(.2,.7,.2,1); }

.tile--lg { grid-column: span 2; grid-row: span 2; }
.tile--lg .cover { aspect-ratio: auto; flex: 1; min-height: 340px; }
.tile--lg h2 { font-size: clamp(1.5rem, 2.3vw, 2rem); line-height: 1.15; letter-spacing: -0.025em; }
.tile--lg .tile-summary { font-size: 1.05rem; }

.tile--wide { grid-column: span 2; flex-direction: row; align-items: stretch; gap: 22px; }
.tile--wide .cover { flex: 0 0 52%; aspect-ratio: 4 / 3; }
.tile--wide .tile-text { justify-content: center; }
.tile--wide h2 { font-size: 1.35rem; line-height: 1.2; letter-spacing: -0.02em; }

/* Text-only tile */
.tile--note { background: var(--soft); border-radius: var(--radius); padding: 22px; justify-content: space-between; }
.tile--note .tile-text { gap: 10px; }
.tile--note h2 { font-size: 1.15rem; }
.tile--note .note-source { font-size: .8rem; font-weight: 600; letter-spacing: .02em; color: var(--muted); text-transform: uppercase; }

/* Generated cover art: layered gradients seeded per article. */
.cover {
  position: relative;
  overflow: hidden;
  margin: 0;
  background:
    radial-gradient(60% 70% at var(--x1) var(--y1), hsl(var(--h1) 88% 64% / .95), transparent 70%),
    radial-gradient(55% 65% at var(--x2) var(--y2), hsl(var(--h2) 92% 62% / .9), transparent 70%),
    radial-gradient(50% 50% at 85% 10%, hsl(var(--h3) 85% 80% / .8), transparent 70%),
    linear-gradient(140deg, hsl(var(--h3) 60% 90%), hsl(var(--h2) 55% 80%));
}
.cover::after {
  /* fine grain so the gradients read as art rather than a flat fill */
  content: ""; position: absolute; inset: 0; opacity: .18; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.cover-label {
  position: absolute; left: 16px; bottom: 14px; z-index: 1;
  color: #fff; font-weight: 600; font-size: .85rem; letter-spacing: .01em;
  text-shadow: 0 1px 12px rgba(0,0,0,.25);
}
.tile--lg .cover-label { font-size: 1rem; left: 22px; bottom: 20px; }
.cover.has-image { background: var(--soft); }
:root[data-theme="dark"] .cover:not(.has-image) { filter: brightness(.82) saturate(.9); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cover:not(.has-image) { filter: brightness(.82) saturate(.9); } }
.cover.has-image::after { display: none; }
.cover.has-image img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover.has-image .cover-label { text-shadow: 0 1px 14px rgba(0,0,0,.55); }

/* Loading placeholders */
.skel { border-radius: var(--radius); background: linear-gradient(90deg, var(--skel-a) 0%, var(--skel-b) 50%, var(--skel-a) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite; aspect-ratio: 4 / 3; }
.skel.lg { grid-column: span 2; grid-row: span 2; aspect-ratio: auto; }
@keyframes shimmer { to { background-position: -200% 0; } }

.empty { color: var(--muted); text-align: center; padding: 60px 0; }
.load-more-row { display: flex; justify-content: center; margin: 48px 0 24px; }

/* ---------- Footer ---------- */

.site-footer { border-top: 1px solid var(--line); margin-top: 72px; padding: 28px 0 40px; color: var(--muted); font-size: .85rem; }
.site-footer .wrap { display: flex; flex-direction: column; gap: 14px; }

/* ---------- Article (Medium-style) ---------- */

.story { max-width: 728px; margin: 0 auto; padding: 48px 24px 0; }
.story-category { display: inline-block; margin-bottom: 14px; font-size: .8rem; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.story-category:hover { color: var(--text); }
.tag-list { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tag { font-size: .85rem; color: var(--text-2); background: var(--soft); border-radius: 999px; padding: 4px 12px; }
.tag:hover { color: var(--text); background: var(--line); }
.story-tags { margin: 8px 0 24px; }
.search-hero { max-width: 760px; }
.search-hero #result-count { margin: 12px 0 0; }
.story-title { margin: 0; font: 700 clamp(2rem, 4.4vw, 2.625rem)/1.2 var(--display); letter-spacing: -0.022em; }
.story-subtitle { margin: 14px 0 0; font: 400 1.3rem/1.45 var(--display); color: var(--muted); letter-spacing: -0.01em; }

.byline { display: flex; align-items: center; gap: 12px; margin-top: 32px; }
.avatar {
  flex: none; display: inline-grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, hsl(var(--ah) 70% 62%), hsl(calc(var(--ah) + 50) 75% 58%));
  color: #fff; font-weight: 650; font-size: .95rem; letter-spacing: .02em;
}
.byline-name { font-weight: 550; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.byline-meta { color: var(--muted); font-size: .9rem; }
.byline-meta a { color: var(--text); }
.byline-meta a:hover { text-decoration: underline; }

.story-cover { aspect-ratio: 16 / 8; border-radius: 12px; margin-top: 36px; }

.story-body { margin-top: 36px; font: 400 1.25rem/1.6 var(--serif); color: var(--body-text); letter-spacing: -0.003em; }
.story-body p { margin: 0 0 1.5em; }
.story-body.drop-cap p:first-child::first-letter { float: left; font: 700 3.6em/.82 var(--serif); margin: .08em .1em 0 0; }

.source-note { margin: 8px 0 0; padding: 18px 20px; background: var(--soft); border-radius: 12px; color: var(--text-2); font-size: .95rem; }
.source-note a { color: var(--link); }
.source-note a:hover { text-decoration: underline; }
.source-list { margin: 8px 0 0; padding-left: 20px; }
.source-list li { margin: 2px 0; overflow-wrap: anywhere; }


.more-stories { background: var(--bg-alt); margin-top: 40px; padding: 48px 0 16px; }
.more-stories h2 { margin: 0 0 28px; font: 650 1.4rem/1.3 var(--display); letter-spacing: -0.015em; }
.mini-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; }
.mini .cover { aspect-ratio: 16 / 10; border-radius: 12px; }
.mini-source { margin-top: 14px; font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.mini h3 { margin: 6px 0 8px; font: 600 1.1rem/1.3 var(--display); letter-spacing: -0.012em; }
.mini:hover h3 { text-decoration: underline; text-underline-offset: 3px; }
.mini-meta { color: var(--muted); font-size: .85rem; }

.not-found { padding-bottom: 80px; }
.not-found a { color: var(--link); }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--accent); color: var(--accent-text); padding: 10px 18px; border-radius: 999px; font-size: .9rem;
  transition: all .25s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--danger); color: var(--bg); }
.toast-ok { background: var(--ok); color: var(--bg); }

/* ---------- Admin console ---------- */

.admin { padding-top: 36px; }
.admin-head { display: flex; flex-direction: column; gap: 18px; margin-bottom: 24px; }
.admin-head h1 { margin: 0; font: 650 2rem/1.1 var(--display); letter-spacing: -0.03em; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); }
.panel.is-loading .card, .panel.is-loading .stats { opacity: .55; transition: opacity .2s; }

.filterbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 20px; }
.filterbar select, .filterbar input[type="search"] { font: inherit; font-size: .92rem; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); }
.filterbar input[type="search"] { min-width: 220px; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.segmented button { border: 0; background: none; padding: 5px 14px; border-radius: 999px; cursor: pointer; font-size: .9rem; color: var(--text-2); }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.muted { color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; }
.stat-label { color: var(--muted); font-size: .88rem; }
.stat-value { font: 650 2rem/1.15 var(--sans); letter-spacing: -0.02em; margin-top: 6px; }
.stat-note { color: var(--muted); font-size: .82rem; margin-top: 4px; }

.card { position: relative; border: 1px solid var(--line); border-radius: 18px; padding: 20px; background: var(--bg); min-width: 0; }
.card-head { margin-bottom: 12px; }
.card-head.row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.card-head h2 { margin: 0; font: 600 1.02rem/1.3 var(--display); }
.card-head p { margin: 3px 0 0; color: var(--muted); font-size: .86rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }

.chart { width: 100%; }
.chart svg { display: block; max-width: 100%; height: auto; overflow: visible; }
.chart .axis text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .crosshair { stroke: var(--crosshair); stroke-width: 1; }
.chart .dot { stroke: var(--bg); stroke-width: 2; }
.chart .hit { outline: none; cursor: crosshair; }
.chart .hit:focus-visible { stroke: var(--link); stroke-width: 1; }
.chart .bar { transition: opacity .15s; }
.legend { display: flex; gap: 16px; font-size: .85rem; color: var(--text-2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 14px; height: 2px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.chart-tip { position: absolute; z-index: 5; pointer-events: none; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; box-shadow: 0 6px 20px var(--shadow); font-size: .84rem; white-space: nowrap; }
.tip-title { color: var(--muted); margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 8px; }
.tip-key { width: 12px; height: 2px; border-radius: 2px; }
.tip-name { color: var(--muted); }

.barlist { display: flex; flex-direction: column; gap: 10px; }
.barlist-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: .9rem; }
a.barlist-row:hover .barlist-label { text-decoration: underline; }
.barlist-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barlist-track { height: 8px; }
.barlist-fill { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--series-1); }
.barlist-value { font-variant-numeric: tabular-nums; color: var(--text-2); min-width: 2.5em; text-align: right; }

.table-view summary { cursor: pointer; font-weight: 550; }
.table-wrap { overflow-x: auto; margin-top: 12px; max-height: 520px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 550; font-size: .82rem; position: sticky; top: 0; background: var(--bg); }
td { font-variant-numeric: tabular-nums; }
td.person { display: flex; align-items: center; gap: 10px; }
td.person img { width: 28px; height: 28px; border-radius: 50%; }
.link-btn { border: 0; background: none; color: var(--danger); cursor: pointer; font-size: .86rem; padding: 0; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 16px; align-items: start; }
.article-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 18px; overflow: auto; max-height: 78vh; }
.article-list li + li { border-top: 1px solid var(--line); }
.article-list .a-row { display: flex; align-items: stretch; }
.article-list .a-select { flex: none; margin: 0 0 0 14px; align-self: center; width: 16px; height: 16px; accent-color: var(--link); }
.article-list .a-row > button { flex: 1; min-width: 0; padding-left: 10px; }
.article-list button { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 4px 12px; width: 100%; text-align: left; border: 0; background: none; padding: 12px 14px; cursor: pointer; }
.article-list button:hover { background: var(--bg-alt); }
.article-list button.is-active { background: var(--soft); }
.article-list .thumb { grid-row: span 2; width: 48px; height: 48px; border-radius: 10px; object-fit: cover; }
.thumb-empty { display: block; background: linear-gradient(135deg, var(--thumb-a), var(--thumb-b)); }
.a-main { display: flex; flex-direction: column; min-width: 0; }
.a-title { font-weight: 550; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.a-meta { color: var(--muted); font-size: .82rem; margin-top: 2px; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.badge { font-size: .72rem; font-weight: 600; color: var(--text-2); background: var(--soft); border-radius: 999px; padding: 2px 8px; }
.badge-on { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.empty-row { padding: 20px; }

.editor-card { position: sticky; top: 80px; }
.editor-card.narrow { position: static; max-width: 760px; }
.nl-subs { margin-top: 24px; }
.nl-actions { white-space: nowrap; }
.nl-actions .link-btn { margin-left: 8px; }
.nl-issue { margin: 6px 0 4px; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.nl-issue-row td { background: var(--soft); }
.research-card { max-width: 760px; margin-bottom: 18px; }
.paste-card { max-width: 760px; margin-bottom: 18px; }
.paste-form { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.paste-form .field, .paste-form .field-row { width: 100%; }
.research-form { display: flex; gap: 10px; flex-wrap: wrap; }
.research-form input { flex: 1 1 240px; min-width: 0; font: inherit; font-size: .95rem; padding: 9px 12px; border: 1px solid var(--input-border); border-radius: 10px; background: var(--bg); color: var(--text); }
.source-links { margin: -4px 0 4px; padding-left: 20px; font-size: .9rem; color: var(--text-2); }
.source-links li { margin: 2px 0; overflow-wrap: anywhere; }
.source-links a { color: var(--link); }
.editor { display: flex; flex-direction: column; gap: 14px; }
.editor > p.muted { margin: 0; font-size: .86rem; }
.editor > p.muted a { color: var(--link); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; font-weight: 550; }
.field em { font-style: normal; font-weight: 400; color: var(--muted); }
.field input, .field textarea, .field select { font: inherit; font-weight: 400; font-size: .95rem; padding: 9px 12px; border: 1px solid var(--input-border); border-radius: 10px; background: var(--bg); width: 100%; }
.field textarea { resize: vertical; line-height: 1.55; font-family: var(--serif); font-size: 1.02rem; }
.field-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.field-row .field { flex: 0 1 280px; }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; padding-bottom: 10px; }
.image-field { display: flex; flex-direction: column; gap: 10px; }
.image-preview img { display: block; max-width: 100%; max-height: 220px; border-radius: 12px; object-fit: cover; }
.image-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 400; }
.file-btn { cursor: pointer; }
.editor-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.feed-list { list-style: none; padding: 0; margin: 14px 0 0; columns: 2 280px; font-size: .92rem; }
.feed-list li { padding: 4px 0; break-inside: avoid; }
.feed-list .ok { color: var(--ok); }
.feed-list .bad { color: var(--danger); }

/* Admin: settings, personas, categories */
.panel-intro p { margin: 0 0 16px; color: var(--text-2); max-width: 760px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.settings-grid .card { display: flex; flex-direction: column; gap: 14px; }
.span-2 { grid-column: 1 / -1; }
.field-grow { flex: 1 1 320px !important; }
.sources-card { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.sources-card h3 { margin: 8px 0 0; font-size: 1rem; }
.sources-card h3 + p { margin: 0; }
.sources-card .save-bar { position: static; border-top: 0; padding-bottom: 0; }
.feed-url { font-size: .8rem; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
input.num { width: 90px; font: inherit; padding: 6px 10px; border: 1px solid var(--input-border); border-radius: 8px; background: var(--bg); color: var(--text); }
.save-bar {
  position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-top: 16px; padding: 14px 0; background: var(--bg); border-top: 1px solid var(--line);
}
.persona-list { display: flex; flex-direction: column; gap: 16px; margin: 16px 0; }
.persona { display: flex; flex-direction: column; gap: 12px; }
.row-actions { display: flex; align-items: center; gap: 16px; }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; white-space: nowrap; }
.cat-list { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; }
.cat-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.cat-row .field { flex: 0 1 180px; }
.cat-row .field-full { flex: 1 1 100%; }
.cat-row textarea { font-family: inherit; font-size: .95rem; }
.cat-order { display: flex; flex-direction: column; }
.cat-order .icon-btn { width: 28px; height: 24px; font-size: .9rem; }
.cat-row .check, .cat-row .link-btn { padding-bottom: 12px; }
.review-note { margin: 0 0 14px; }
.notice-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border-radius: 12px; background: var(--warn-bg); color: var(--warn); font-size: .92rem; }
.rewrite-box { border-top: 1px solid var(--line); padding-top: 14px; }
.rewrite-box summary { cursor: pointer; font-weight: 550; }
.rewrite-box .field-row { margin-top: 10px; }
.field select, .field input, .field textarea { color: var(--text); }
.settings-grid textarea, .persona textarea, #rules { font-family: var(--sans); font-size: .93rem; line-height: 1.5; }
.settings-grid .field-row .field { flex: 1 1 200px; }
.settings-grid .table-wrap { max-height: none; }

/* ---------- Responsive ---------- */

/* Narrow screens: the section links get their own row under the brand. */
@media (max-width: 900px) {
  .topbar-inner { flex-wrap: wrap; height: auto; padding-top: 10px; row-gap: 4px; }
  .topnav { order: 3; flex-basis: 100%; margin: 0 -10px; padding-bottom: 6px; }
  .admin-link { display: none; }
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1080px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
  .editor-card { position: static; }
  .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile--lg { grid-row: span 1; }
  .tile--lg .cover { aspect-ratio: 16 / 9; min-height: 0; flex: none; }
  .skel.lg { grid-row: span 1; aspect-ratio: 16 / 9; }
}

@media (max-width: 640px) {
  .wrap, .topbar-inner { padding: 0 16px; }
  .hero { padding: 36px 0 20px; }
  .bento { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .tile--lg, .tile--wide, .skel.lg { grid-column: auto; }
  .tile--wide { flex-direction: column; gap: 14px; }
  .tile--wide .cover { flex: none; }
  .tile .cover, .tile--lg .cover, .tile--wide .cover { aspect-ratio: 16 / 9; }
  .tile--wide h2, .tile--lg h2 { font-size: 1.35rem; }
  .logo img { height: 22px; }
  .logo-lg img { height: 36px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-value { font-size: 1.6rem; }
  .subscribe { flex-direction: column; }
  .stage { padding: 0 16px; min-height: 0; }
  .stage-hero { padding: 48px 0 28px; }
  .nav-search.is-open input { width: min(56vw, 200px); }
  .story { padding-top: 32px; }
  .story-subtitle { font-size: 1.12rem; }
  .story-body { font-size: 1.125rem; }
  .mini-grid { grid-template-columns: minmax(0, 1fr); }
}

.is-error { color: var(--danger); }
code { font: .88em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--soft); border-radius: 5px; padding: 1px 5px; }
