:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --ink: #1b1a17;
  --ink-2: #4a4740;
  --ink-3: #7a766c;
  --rule: #e4dfd4;
  --rule-strong: #1b1a17;
  --media: #ece7dc;
  --link: #1b1a17;
  --ai: #5b3fd6;
  --tesla: #c8102e;
  --apple: #0a6ed1;
  --serif: "Iowan Old Style", "Palatino Linotype", Charter, "Bitstream Charter", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141311;
    --surface: #1c1b18;
    --ink: #eeeae1;
    --ink-2: #bfbab0;
    --ink-3: #8d887e;
    --rule: #2e2c28;
    --rule-strong: #eeeae1;
    --media: #26241f;
    --link: #eeeae1;
    --ai: #a996ff;
    --tesla: #ff5a6e;
    --apple: #5fb3ff;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible { outline: 2px solid var(--apple); outline-offset: 2px; border-radius: 2px; }
img { display: block; max-width: 100%; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 28px; } }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 12px; background: var(--surface); padding: 8px 12px; z-index: 10; }

/* Masthead */
.masthead { border-bottom: 3px double var(--rule-strong); background: var(--bg); }
.masthead-inner { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 24px; padding-top: 18px; padding-bottom: 12px; }
.brand { font: 700 clamp(28px, 5vw, 40px)/1 var(--serif); letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.nav { list-style: none; display: flex; gap: 4px 18px; margin: 0; padding: 0; flex-wrap: wrap; font-size: 14px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; }
.nav a { color: var(--ink-2); padding: 4px 0; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--ink); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: currentColor; }
.nav a.nav-ai[aria-current="page"] { color: var(--ai); }
.nav a.nav-tesla[aria-current="page"] { color: var(--tesla); }
.nav a.nav-apple[aria-current="page"] { color: var(--apple); }

main { padding-top: 28px; padding-bottom: 48px; min-height: 60vh; }

/* Topic accent */
.topic-ai { --accent: var(--ai); }
.topic-tesla { --accent: var(--tesla); }
.topic-apple { --accent: var(--apple); }

/* Story */
.story { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.story-media { position: relative; display: block; aspect-ratio: 16 / 9; background: var(--media); border-radius: var(--radius); overflow: hidden; }
.story-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.story-media-fallback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 12px; text-align: center; font: 600 15px/1.2 var(--serif); color: var(--accent, var(--ink-3)); border-top: 4px solid var(--accent, var(--rule)); }
.story-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 0; font-size: 12.5px; color: var(--ink-3); letter-spacing: 0.01em; }
.story-meta .source { font-weight: 600; color: var(--ink-2); }
.chip { font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; font-size: 11px; color: var(--accent); }
.story-title { margin: 4px 0 0; font: 700 19px/1.25 var(--serif); letter-spacing: -0.005em; text-wrap: balance; }
.story-title a:hover { color: var(--accent); text-decoration: none; }
.story-summary { margin: 6px 0 0; color: var(--ink-2); font-size: 15px; }
.story-why { margin: 8px 0 0; font-size: 14px; color: var(--ink-2); border-left: 3px solid var(--accent, var(--rule)); padding-left: 10px; }
.story-why strong { color: var(--ink); font-weight: 600; }

/* Hero */
.hero { padding-bottom: 32px; margin-bottom: 8px; border-bottom: 1px solid var(--rule); }
.story-hero .story-title { font-size: clamp(26px, 4vw, 38px); line-height: 1.12; letter-spacing: -0.015em; }
.story-hero .story-summary { font-size: 17px; }
@media (min-width: 860px) {
  .story-hero { display: grid; grid-template-columns: 3fr 2fr; gap: 32px; align-items: center; }
}

/* Sections & grid */
.section { padding-top: 28px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; border-top: 2px solid var(--accent, var(--rule-strong)); padding-top: 10px; margin-bottom: 20px; }
.section-head h2 { margin: 0; font: 700 22px/1.2 var(--serif); }
.section-head h2 a { color: var(--accent, var(--ink)); }
.section-head .more, .count { font-size: 13px; color: var(--ink-3); font-weight: 600; white-space: nowrap; }
.grid { display: grid; gap: 32px 28px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }

/* Rows (day page) */
.rows { display: flex; flex-direction: column; }
.story-row { padding: 16px 0; border-bottom: 1px solid var(--rule); }
.story-row:first-child { padding-top: 0; }
.story-row .story-title { font-size: 18px; }

/* Page heads */
.page-head { border-bottom: 1px solid var(--rule); padding-bottom: 18px; margin-bottom: 28px; }
.page-head h1 { margin: 0; font: 700 clamp(30px, 5vw, 44px)/1.1 var(--serif); letter-spacing: -0.015em; color: var(--accent, var(--ink)); }
.page-head p { margin: 8px 0 0; color: var(--ink-2); }
.kicker { text-transform: uppercase; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; color: var(--ink-3) !important; margin: 0 0 6px !important; }
.day-nav { display: flex; gap: 20px; margin-top: 12px; font-size: 14px; font-weight: 600; }

.pager { display: flex; justify-content: space-between; margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--rule); font-weight: 600; }

.archive { list-style: none; padding: 0; margin: 0; max-width: 640px; }
.archive li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.archive a { font: 600 17px/1.3 var(--serif); }

.empty { color: var(--ink-3); font-size: 17px; padding: 48px 0; text-align: center; }

.prose { max-width: 680px; }
.prose h1 { font: 700 clamp(30px, 5vw, 40px)/1.15 var(--serif); margin: 0 0 16px; }
.prose h2 { font: 700 22px/1.3 var(--serif); margin: 32px 0 8px; }
.prose h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; margin: 20px 0 6px; color: var(--ink-3); }
.prose p, .prose li { color: var(--ink-2); }
.prose a { text-decoration: underline; text-underline-offset: 3px; }
.prose code { font-size: 0.9em; background: var(--media); padding: 1px 5px; border-radius: 4px; }

/* Footer */
.footer { border-top: 1px solid var(--rule); color: var(--ink-3); font-size: 13.5px; }
.footer-inner { padding-top: 24px; padding-bottom: 40px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 32px; }
.footer p { margin: 0; max-width: 640px; }
.footer-links { display: flex; gap: 18px; font-weight: 600; }
.footer-links a { color: var(--ink-2); }

/* Keep grid cards even: clamp long summaries (hero and day rows stay full). */
.story-card .story-summary { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 5; line-clamp: 5; overflow: hidden; }
