:root {
  color-scheme: light;
  --canvas: #f3f6f7;
  --surface: #ffffff;
  --text: #182733;
  --muted: #5d746a;
  --link: #2f6675;
  --accent: #d56f4a;
  --line: #d8e2e4;
  --shadow: 0 18px 48px rgb(24 39 51 / 10%);
  font-family: "Atkinson Hyperlegible", ui-sans-serif, system-ui, sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0c151c;
  --surface: #13232c;
  --text: #edf4f4;
  --muted: #a8c0b8;
  --link: #8dc5ce;
  --accent: #ed9672;
  --line: #29404a;
  --shadow: 0 18px 48px rgb(0 0 0 / 25%);
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body { min-width: 320px; margin: 0; background: var(--canvas); color: var(--text); }
a { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.site-header, .shell, .site-footer { width: min(100% - 32px, 960px); margin: 0 auto; }
.site-header { display: flex; align-items: center; justify-content: space-between; min-height: 68px; }
.brand { color: var(--text); font-weight: 800; letter-spacing: -.02em; text-decoration: none; }
.brand-mark { color: var(--accent); margin-right: 6px; }
.theme-toggle { min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.topic-nav { display: flex; gap: 20px; overflow-x: auto; padding: 8px 0 22px; }
.topic-link { color: var(--muted); font-size: .95rem; text-decoration: none; white-space: nowrap; }
.topic-nav a { min-height: 44px; padding: 12px 0; color: var(--muted); font-size: .95rem; text-decoration: none; white-space: nowrap; }
.topic-nav a.is-active { color: var(--link); font-weight: 800; }
.intro { max-width: 670px; padding: 20px 0 30px; }
.kicker { margin: 0 0 10px; color: var(--accent); font-family: ui-monospace, SFMono-Regular, monospace; font-size: .74rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
h1, h2, h3 { margin: 0; }
h1 { max-width: 13ch; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.45rem, 10vw, 4.6rem); font-weight: 500; letter-spacing: -.055em; line-height: .98; }
.intro-copy { max-width: 46ch; margin: 18px 0 0; color: var(--muted); font-size: 1.05rem; line-height: 1.45; }
.feed { padding-bottom: 34px; }
.context-rail { margin: 0 0 30px; padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: color-mix(in srgb, var(--surface) 82%, var(--accent)); }
.context-rail h2 { margin-bottom: 8px; }
.rail-intro, .thread-meta { margin: 0 0 12px; color: var(--muted); font-size: .9rem; }
.thread { border-top: 1px solid var(--line); padding: 12px 0 2px; }
.thread summary { cursor: pointer; font-family: Georgia, serif; font-size: 1.15rem; }
.thread-sources { margin: 0 0 8px; padding-left: 20px; color: var(--muted); }
.thread-sources a { color: var(--link); }
.feed-heading-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding-bottom: 12px; }
h2 { font-family: ui-monospace, SFMono-Regular, monospace; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }
.feed-status { color: var(--muted); font-family: ui-monospace, SFMono-Regular, monospace; font-size: .72rem; }
.story-card { position: relative; overflow: hidden; padding: 24px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.story-card::before { position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--accent); content: ""; }
.story-meta { display: flex; flex-wrap: wrap; gap: 9px 16px; margin-bottom: 18px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, monospace; font-size: .7rem; letter-spacing: .04em; text-transform: uppercase; }
.story-card h3 { max-width: 26ch; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.75rem, 7vw, 3.15rem); font-weight: 500; letter-spacing: -.04em; line-height: 1.03; }
.story-summary { max-width: 62ch; margin: 18px 0 24px; color: var(--muted); font-size: 1.06rem; line-height: 1.5; }
.story-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.source { color: var(--link); font-size: .9rem; font-weight: 800; }
.open-link { min-height: 44px; padding: 11px 15px; border-radius: 99px; background: var(--link); color: #fff; font-weight: 800; text-decoration: none; }
[data-theme="dark"] .open-link { color: var(--canvas); }
.save-button { min-height: 44px; padding: 8px 13px; border: 1px solid var(--line); border-radius: 99px; background: transparent; color: var(--text); font: inherit; cursor: pointer; }
.loading, .error { padding: 20px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); }
.empty { padding: 28px 0; color: var(--muted); }
.site-footer { padding: 8px 0 32px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, monospace; font-size: .7rem; }
.secondary-panel { margin: 18px 0; padding: 18px 0; border-top: 1px solid var(--line); color: var(--muted); }
.secondary-panel h2 { color: var(--text); margin-bottom: 10px; }
fieldset { display: grid; gap: 10px; margin: 0 0 18px; padding: 0; border: 0; }
legend { margin-bottom: 6px; color: var(--text); font-weight: 800; }
label { display: flex; align-items: center; gap: 9px; min-height: 44px; }
input, select { accent-color: var(--link); min-width: 20px; min-height: 20px; font: inherit; }
select, input[type="time"], #pair-code { max-width: 14rem; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); }
.pair-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.pair-row button { min-height: 44px; padding: 8px 15px; border: 0; border-radius: 99px; background: var(--link); color: #fff; font: inherit; font-weight: 800; cursor: pointer; }

@media (min-width: 700px) {
  .site-header, .shell, .site-footer { width: min(100% - 64px, 1080px); }
  .site-header { min-height: 84px; }
  .topic-nav { gap: 28px; padding-top: 14px; }
  .intro { padding: 54px 0 56px; }
  .story-card { padding: 38px 42px; }
}

@media (min-width: 1000px) { .shell { display: grid; grid-template-columns: 1fr 320px; column-gap: 34px; } .topic-nav, .intro { grid-column: 1 / -1; } .context-rail { grid-column: 2; grid-row: 3 / span 2; margin-top: 0; } .feed { grid-column: 1; grid-row: 3 / span 2; } .secondary-panel { grid-column: 1 / -1; } }

@media (prefers-reduced-motion: no-preference) {
  .story-card { animation: enter .35s ease-out both; }
  @keyframes enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
