:root {
  --bg: #f6f3ec;
  --surface: #fffdf8;
  --ink: #201d18;
  --muted: #726b5e;
  --faint: #a49b8a;
  --rule: #ddd6c7;
  --rule-strong: #201d18;
  --accent: #a8431f;
  --accent-ink: #fff8f4;
  --shadow: 0 10px 30px -18px rgba(32, 29, 24, 0.35);
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --max-width: 1180px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17140f;
    --surface: #1e1a14;
    --ink: #f1ece1;
    --muted: #b0a794;
    --faint: #746b5b;
    --rule: #382f22;
    --rule-strong: #f1ece1;
    --accent: #e0895f;
    --accent-ink: #211208;
    --shadow: 0 10px 30px -16px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #17140f;
  --surface: #1e1a14;
  --ink: #f1ece1;
  --muted: #b0a794;
  --faint: #746b5b;
  --rule: #382f22;
  --rule-strong: #f1ece1;
  --accent: #e0895f;
  --accent-ink: #211208;
  --shadow: 0 10px 30px -16px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
}

body {
  padding-bottom: 56px;
}

a {
  color: inherit;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  z-index: 100;
  font-family: var(--sans);
  font-size: 0.85rem;
}
.skip-link:focus {
  left: 16px;
  top: 16px;
}

/* ---------- Masthead ---------- */

.masthead {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 22px 20px 0;
}

.masthead-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.kicker {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
}

.icon-button {
  border: 1px solid var(--rule);
  background: none;
  color: var(--muted);
  border-radius: 6px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 150ms ease, color 150ms ease, transform 150ms ease;
}
.icon-button:hover {
  background: var(--rule);
  color: var(--ink);
}
.icon-button:active {
  transform: scale(0.94);
}

.wordmark {
  margin: 2px 0 6px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  letter-spacing: -0.02em;
  line-height: 1;
}

.dateline {
  margin: 0 0 16px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--muted);
}

/* ---------- Toolbar: tabs + search ---------- */

.toolbar {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  border-top: 3px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule);
}

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1 1 0%;
  min-width: 0;
}
.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex-shrink: 0;
  border: none;
  background: none;
  cursor: pointer;
  padding: 12px 12px 10px;
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: color 150ms ease, border-color 150ms ease;
}
.tab:hover {
  color: var(--ink);
}
.tab .dot {
  width: 6px;
  height: 6px;
  border-radius: 1px;
  flex-shrink: 0;
}
.tab[aria-pressed="true"] {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--accent);
}
.tab .count {
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  font-size: 0.76rem;
}

.search-wrap {
  position: relative;
  flex: 0 0 200px;
}
.search-icon {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  pointer-events: none;
}
#search-input {
  width: 100%;
  padding: 10px 4px 10px 22px;
  border: none;
  border-bottom: 1px solid transparent;
  background: none;
  color: var(--ink);
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.95rem;
}
#search-input::placeholder {
  color: var(--faint);
  opacity: 1;
}
#search-input:focus {
  outline: none;
  border-bottom-color: var(--accent);
}

/* ---------- Content ---------- */

.content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 28px 20px 0;
}

.rule {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 28px 0;
}

/* ---------- Lead story ---------- */

.lead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 28px;
  align-items: start;
}

.lead-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}
.lead-kicker .dot {
  width: 7px;
  height: 7px;
  border-radius: 1px;
  background: currentColor;
}

.lead-title {
  display: block;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.7rem, 3.4vw, 2.5rem);
  line-height: 1.12;
  letter-spacing: -0.01em;
  text-decoration: none;
  text-wrap: balance;
}
.lead-title:hover {
  text-decoration: underline;
  text-decoration-color: var(--faint);
  text-underline-offset: 4px;
}

.lead-excerpt {
  font-family: var(--serif);
  font-size: 1.08rem;
  line-height: 1.55;
  color: var(--muted);
  margin: 14px 0 0;
  max-width: 62ch;
}

.lead-meta {
  margin-top: 16px;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--faint);
  display: flex;
  align-items: center;
  gap: 8px;
}

.lead-aside {
  border-left: 1px solid var(--rule);
  padding-left: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.lead-aside-title {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 4px;
}
.lead-aside-item {
  display: block;
  font-family: var(--serif);
  font-size: 0.98rem;
  font-weight: 500;
  line-height: 1.35;
  text-decoration: none;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}
.lead-aside-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.lead-aside-item:hover {
  color: var(--accent);
}
.lead-aside-source {
  display: block;
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
  margin-top: 4px;
}

/* ---------- River ---------- */

.river {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 40px;
}

.river-item {
  padding: 20px 0;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.river-item:nth-child(1),
.river-item:nth-child(2) {
  border-top: none;
}

.river-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--sans);
  font-size: 0.72rem;
  color: var(--faint);
}
.river-source {
  font-weight: 600;
  color: var(--muted);
}

.river-title {
  font-family: var(--serif);
  font-size: 1.08rem;
  font-weight: 600;
  line-height: 1.32;
  text-decoration: none;
  display: flex;
  gap: 6px;
  text-wrap: pretty;
}
.river-title:hover {
  color: var(--accent);
}
.river-title svg {
  flex-shrink: 0;
  margin-top: 6px;
  opacity: 0;
  transition: opacity 150ms ease;
}
.river-title:hover svg {
  opacity: 0.6;
}

.river-excerpt {
  font-family: var(--serif);
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--muted);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.river-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 2px;
}
.tag {
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--tag-color, var(--accent));
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tag::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 1px;
  background: currentColor;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  font-family: var(--serif);
  font-style: italic;
  padding: 64px 20px;
}

.sentinel {
  height: 1px;
}

.load-more {
  display: block;
  margin: 24px auto 0;
  padding: 11px 22px;
  border: 1px solid var(--rule-strong);
  background: none;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, transform 150ms ease;
}
.load-more:hover {
  background: var(--ink);
  color: var(--bg);
}
.load-more:active {
  transform: scale(0.98);
}

.site-footer {
  max-width: var(--max-width);
  margin: 48px auto 0;
  padding: 20px;
  border-top: 1px solid var(--rule);
  color: var(--faint);
  font-family: var(--sans);
  font-size: 0.76rem;
  text-align: center;
}

/* ---------- Responsive ---------- */

@media (max-width: 820px) {
  .lead {
    grid-template-columns: 1fr;
  }
  .lead-aside {
    border-left: none;
    border-top: 1px solid var(--rule);
    padding-left: 0;
    padding-top: 20px;
  }
  .river {
    grid-template-columns: 1fr;
  }
  .river-item:nth-child(2) {
    border-top: 1px solid var(--rule);
  }
}

@media (max-width: 560px) {
  .toolbar {
    flex-wrap: wrap;
    padding-bottom: 8px;
  }
  .search-wrap {
    flex: 1 1 100%;
    order: 3;
    border-top: 1px solid var(--rule);
    padding-top: 4px;
  }
}
