:root {
  --bg: #f5f1e8;
  --surface: #fbf8f1;
  --ink: #171411;
  --muted: #6a6256;
  --accent: #7d1717;
  --line: #d7d0c4;
  --serif: "Baskerville", "Times New Roman", Georgia, serif;
  --sans: "Franklin Gothic Medium", "Arial Narrow", "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
}

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

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

.wrap {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
}

.masthead {
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  background: var(--surface);
}

.masthead__ticker {
  border-bottom: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--muted);
}

.masthead__ticker-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 2.1rem;
}

.masthead__ticker-items {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.masthead__ticker-items strong {
  color: var(--ink);
  font-weight: 700;
}

.masthead__ticker-sep {
  color: #9c9387;
}

.masthead__inner {
  padding: 1.2rem 0 0.85rem;
  text-align: center;
}

.brand {
  display: inline-block;
  font-family: var(--serif);
  font-size: clamp(2.7rem, 6vw, 4.8rem);
  line-height: 0.92;
  font-weight: 700;
  letter-spacing: -0.05em;
  text-transform: uppercase;
}

.tagline {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.admin-slot {
  display: flex;
  justify-content: flex-end;
}

.admin-link,
.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.2rem;
  padding: 0.5rem 0.8rem;
  border-radius: 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.admin-link,
.btn-secondary {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.btn-primary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.btn-primary[disabled] {
  opacity: 0.6;
  cursor: wait;
}

.nav {
  display: flex;
  gap: 1.1rem;
  justify-content: center;
  padding: 0.7rem 0;
  overflow-x: auto;
  border-top: 1px solid var(--line);
  font-size: 0.84rem;
}

.nav a {
  white-space: nowrap;
  color: var(--ink);
}

.nav a:hover {
  color: var(--accent);
}

.homepage,
.section-page,
.article-page,
.error-page {
  padding: 1.5rem 0 3rem;
}

.eyebrow,
.meta {
  margin: 0;
  font-size: 0.74rem;
  color: var(--muted);
}

.feed-stream {
  display: grid;
  gap: 1.75rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem;
}

.frontpage-lead {
  border-bottom: 1px solid var(--line);
  padding-bottom: 1.5rem;
}

.lead-story {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.lead-story__image-link,
.card__image-link,
.stack__image-link {
  display: block;
}

.lead-story__image,
.card__image,
.stack__image,
.story__hero-image {
  width: 100%;
  object-fit: cover;
  background: #e7e0d4;
}

.lead-story__image,
.story__hero-image {
  aspect-ratio: 16 / 9;
}

.lead-story__body {
  display: grid;
  gap: 0.7rem;
}

.lead-story__body h1,
.card h2,
.stack__body h2,
.story h1,
.related-block__header h2,
.page-title,
.error-card h1 {
  margin: 0;
  font-family: var(--serif);
  line-height: 0.98;
  letter-spacing: -0.03em;
}

.lead-story__body h1 {
  font-size: clamp(2.2rem, 4.5vw, 4rem);
}

.lead-story__body p:last-child,
.card p:last-child,
.stack__body p:last-child {
  color: var(--muted);
}

.frontpage-grid {
  align-items: start;
}

.card,
.stack__item,
.story,
.empty,
.error-card {
  border-top: 1px solid var(--line);
}

.card {
  padding-top: 0.85rem;
}

.card__image,
.stack__image {
  aspect-ratio: 16 / 10;
  margin-bottom: 0.85rem;
}

.card h2 {
  font-size: 1.65rem;
  margin: 0.2rem 0 0.45rem;
}

.page-title {
  font-size: clamp(2rem, 4vw, 3.4rem);
  margin-bottom: 1rem;
}

.stack {
  display: grid;
  gap: 1rem;
}

.stack__item {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 1rem;
  padding-top: 1rem;
}

.stack__body {
  display: grid;
  gap: 0.45rem;
}

.story {
  max-width: 860px;
  margin: 0 auto;
  padding-top: 1rem;
}

.story h1 {
  font-size: clamp(2.7rem, 5vw, 4.8rem);
  margin-top: 0.15rem;
}

.dek {
  margin: 0.8rem 0 0;
  font-size: 1.16rem;
  color: var(--muted);
}

.meta {
  color: var(--muted);
}

.meta--listing {
  margin-top: 0.55rem;
}

.meta__sep {
  margin: 0 0.4rem;
}

.story__hero {
  margin: 1.2rem 0 1.6rem;
}

.story__body {
  font-family: var(--serif);
  font-size: 1.16rem;
  line-height: 1.82;
}

.related-block {
  margin-top: 2rem;
  display: grid;
  gap: 1rem;
}

.related-block__header {
  padding-top: 0.6rem;
  border-top: 1px solid var(--line);
}

.related-block__header h2 {
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  margin-top: 0.25rem;
}

.related-grid .card {
  min-height: 100%;
}

.error-card {
  padding-top: 1.5rem;
}

.error-code {
  margin: 0.25rem 0 0.75rem;
  font-family: var(--serif);
  font-size: clamp(3.2rem, 8vw, 6rem);
  line-height: 0.9;
  letter-spacing: -0.05em;
}

.error-message {
  max-width: 42rem;
  color: var(--muted);
  font-size: 1.02rem;
}

.error-actions {
  margin-top: 1.2rem;
}

.empty {
  padding-top: 1rem;
}

.feed-pager {
  display: grid;
  justify-items: center;
  gap: 0.85rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--line);
}

.feed-pager__status {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.feed-pager__actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.feed-pager.is-loading .feed-pager__status,
.feed-pager.has-error .feed-pager__status {
  color: var(--accent);
}

.tools-page {
  padding: 2rem 0 4rem;
}

.tools-hero,
.tools-panel,
.tools-card {
  background: var(--surface);
  border: 1px solid var(--line);
}

.tools-hero {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem;
  align-items: center;
}

.tools-hero h1,
.tools-card h2 {
  margin: 0;
  font-family: var(--serif);
  letter-spacing: -0.03em;
}

.tools-copy {
  color: var(--muted);
  max-width: 56ch;
}

.tools-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.tools-panel {
  margin-top: 1rem;
  padding: 1rem 1.2rem;
}

.tools-field {
  display: grid;
  gap: 0.45rem;
}

.tools-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 700;
}

.tools-input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0.85rem 1rem;
  border-radius: 0.45rem;
  font: inherit;
}

.tools-textarea {
  resize: vertical;
  min-height: 6rem;
}

.tools-form {
  display: grid;
  gap: 1rem;
}

.tools-two-up {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.tools-help {
  margin: 0;
  color: var(--muted);
  max-width: 60ch;
}

.tools-note {
  color: var(--muted);
}

.tools-note + .tools-note {
  margin-top: 0.5rem;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.tools-card {
  padding: 1.2rem;
}

.tools-list {
  display: grid;
  gap: 0.75rem;
}

.tools-row {
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}

.tools-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.tools-row strong {
  display: block;
}

.status-pill {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #efe3d1;
  color: #6e3d17;
}

.status-pill.ok,
.status-pill.completed {
  background: #ddeedc;
  color: #1e6631;
}

.status-pill.failed {
  background: #f7d7d6;
  color: #8e221e;
}

@media (max-width: 960px) {
  .grid,
  .tools-grid {
    grid-template-columns: 1fr;
  }

  .lead-story,
  .stack__item {
    grid-template-columns: 1fr;
  }

  .tools-hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .tools-two-up {
    grid-template-columns: 1fr;
  }

  .masthead__ticker-inner {
    flex-direction: column;
    align-items: flex-start;
    padding: 0.45rem 0;
  }

  .admin-slot {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .wrap {
    width: min(100% - 1.25rem, 100%);
  }

  .brand {
    font-size: 2.5rem;
  }

  .lead-story__body h1,
  .story h1 {
    font-size: 2.15rem;
  }
}
