:root {
  --paper: #f6f0e3;
  --paper-soft: rgba(255, 251, 243, 0.82);
  --ink: #1d1b17;
  --muted: #695d49;
  --accent: #8a5a24;
  --accent-deep: #5c3512;
  --line: #d7ccb7;
  --card-line: rgba(117, 93, 58, 0.16);
  --card-shadow: 0 20px 52px rgba(56, 39, 14, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(212, 173, 117, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(123, 76, 22, 0.1), transparent 24%),
    linear-gradient(180deg, #f8f4ea 0%, #f2ebdd 52%, #efe6d7 100%);
}

.shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 28px 22px;
  background: rgba(239, 232, 218, 0.72);
  border-right: 1px solid rgba(128, 105, 72, 0.14);
  backdrop-filter: blur(18px);
}

.sidebar-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

.sidebar-link:hover,
.sidebar-link.is-active {
  color: var(--accent-deep);
  background: rgba(255, 250, 241, 0.8);
  border-color: rgba(138, 90, 36, 0.2);
}

.content {
  padding: 40px clamp(24px, 4vw, 52px);
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 24px;
  align-items: end;
  margin-bottom: 28px;
}

.home-kicker,
.failed-kicker {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.home-title {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-size: clamp(46px, 7vw, 84px);
  line-height: 0.95;
  letter-spacing: -0.03em;
}

.home-dek {
  max-width: 34rem;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.65;
}

.home-search {
  padding: 20px;
  border: 1px solid var(--card-line);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 252, 246, 0.92), rgba(250, 243, 230, 0.88));
  box-shadow: var(--card-shadow);
}

.home-search-label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.home-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.home-search input,
.panel input {
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid rgba(138, 90, 36, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font: inherit;
}

.home-search button,
.panel button,
.failed-item button {
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, #8a5a24 0%, #6c4016 100%);
  color: #fbf6ee;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.home-search button:hover,
.panel button:hover,
.failed-item button:hover {
  background: linear-gradient(135deg, #9a6730 0%, #7a491b 100%);
}

.story-card {
  overflow: hidden;
  border: 1px solid var(--card-line);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(247, 238, 222, 0.96));
  box-shadow: var(--card-shadow);
}

.home-feature {
  margin-bottom: 24px;
}

.home-feature-link {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  min-height: 420px;
  color: inherit;
  text-decoration: none;
}

.home-feature-body,
.story-card-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px;
}

.story-card-link {
  display: flex;
  flex-direction: column;
  height: 100%;
  color: inherit;
  text-decoration: none;
}

.story-card-media {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(160deg, rgba(206, 173, 115, 0.32), rgba(111, 65, 24, 0.12)),
    linear-gradient(180deg, rgba(255, 252, 246, 0.92), rgba(246, 235, 214, 0.92));
}

.story-card-media img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 220px;
  object-fit: cover;
}

.story-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.story-card-source {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.story-card-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(138, 90, 36, 0.16);
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.84);
  color: var(--accent-deep);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.home-feature-title,
.story-card-title {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  line-height: 1.04;
  letter-spacing: -0.02em;
}

.home-feature-title {
  font-size: clamp(32px, 4vw, 54px);
}

.story-card-title {
  font-size: 28px;
}

.story-card-summary {
  margin: 0;
  color: #4b4030;
  font-family: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-size: 18px;
  line-height: 1.75;
}

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

.home-empty {
  padding: 28px;
  border: 1px dashed rgba(138, 90, 36, 0.26);
  border-radius: 22px;
  background: rgba(255, 252, 246, 0.7);
  color: var(--muted);
}

.failed-page {
  max-width: 920px;
}

.failed-header {
  margin-bottom: 20px;
}

.failed-header h1 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-size: clamp(30px, 5vw, 48px);
}

.panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
  padding: 18px;
  border: 1px solid var(--card-line);
  border-radius: 20px;
  background: rgba(255, 252, 246, 0.82);
}

.panel label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.failed-list {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.failed-item {
  display: grid;
  gap: 12px;
  padding: 18px 20px;
  border: 1px solid var(--card-line);
  border-radius: 18px;
  background: rgba(255, 251, 243, 0.88);
}

.failed-item-main {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.failed-item-main a {
  color: var(--accent-deep);
  font-weight: 700;
  text-decoration-thickness: 1px;
}

.failed-item-error {
  margin: 0;
  color: #7f3027;
}

.admin-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 20px;
}

.admin-scope-nav {
  display: flex;
  gap: 12px;
}

.admin-scope-nav a {
  color: var(--accent-deep);
  font-weight: 700;
}

.admin-scope-nav .is-active {
  text-decoration: underline;
}

.admin-table {
  width: 100%;
  margin-top: 20px;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.snapshot-frame {
  width: 100%;
  min-height: 560px;
  border: 1px solid #d5d1c7;
  background: #fff;
  margin-top: 12px;
}

.reader-body-shell {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(217, 185, 138, 0.18), transparent 22%),
    radial-gradient(circle at 85% 8%, rgba(116, 69, 26, 0.12), transparent 20%),
    linear-gradient(180deg, #f7f1e5 0%, #efe5d3 52%, #ece0cb 100%);
}

.reader-shell {
  width: min(1360px, calc(100vw - 48px));
  margin: 0 auto;
  padding: clamp(28px, 4vw, 54px) 0 64px;
}

.reader-page {
  display: grid;
  gap: 28px;
}

.reader-hero {
  display: grid;
  gap: 16px;
  max-width: 920px;
  padding: clamp(28px, 4vw, 40px);
  border: 1px solid rgba(112, 81, 44, 0.12);
  border-radius: 32px;
  background:
    linear-gradient(180deg, rgba(255, 252, 247, 0.96), rgba(248, 240, 226, 0.88));
  box-shadow: 0 26px 64px rgba(67, 48, 21, 0.08);
}

.reader-eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.reader-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.reader-source-host,
.reader-status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.reader-source-host {
  border: 1px solid rgba(138, 90, 36, 0.16);
  background: rgba(255, 249, 239, 0.9);
  color: var(--accent-deep);
}

.reader-status-badge {
  border: 1px solid rgba(92, 53, 18, 0.12);
  background: rgba(239, 230, 211, 0.92);
  color: #65421d;
}

.reader-title {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-size: clamp(40px, 5vw, 72px);
  line-height: 0.96;
  letter-spacing: -0.03em;
}

.reader-source,
.reader-notice {
  margin: 0;
}

.reader-source {
  color: var(--muted);
  font-size: 15px;
}

.reader-source a {
  color: var(--accent-deep);
  font-weight: 700;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

.reader-notice {
  max-width: 46rem;
  padding: 14px 16px;
  border: 1px solid rgba(138, 90, 36, 0.18);
  border-radius: 18px;
  background: rgba(255, 247, 232, 0.9);
  color: #604826;
  font-size: 14px;
  line-height: 1.65;
}

.reader-content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 24px;
  align-items: start;
}

.reader-main,
.reader-artifacts {
  display: grid;
  gap: 18px;
}

.reader-card {
  overflow: hidden;
  border: 1px solid rgba(112, 81, 44, 0.12);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 253, 249, 0.98), rgba(250, 244, 233, 0.94));
  box-shadow: 0 20px 52px rgba(56, 39, 14, 0.08);
}

.reader-body {
  padding: clamp(24px, 4vw, 44px);
}

.reader-prose {
  max-width: 74ch;
  margin: 0 auto;
  color: #2f281f;
  font-family: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-size: clamp(19px, 1.25vw, 22px);
  line-height: 1.9;
}

.reader-prose > :first-child,
.reader-prose article > :first-child {
  margin-top: 0;
}

.reader-prose > :last-child,
.reader-prose article > :last-child {
  margin-bottom: 0;
}

.reader-prose :where(h1, h2, h3, h4) {
  margin: 1.5em 0 0.45em;
  color: #17130e;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  line-height: 1.18;
}

.reader-prose :where(h1) {
  font-size: clamp(34px, 3vw, 46px);
}

.reader-prose :where(h2) {
  font-size: clamp(26px, 2vw, 32px);
}

.reader-prose :where(h3) {
  font-size: clamp(21px, 1.6vw, 25px);
}

.reader-prose :where(p, ul, ol, blockquote, pre, figure, table) {
  margin: 1em 0;
}

.reader-prose :where(ul, ol) {
  padding-left: 1.4em;
}

.reader-prose :where(li + li) {
  margin-top: 0.45em;
}

.reader-prose a {
  color: var(--accent-deep);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.12em;
}

.reader-prose img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.6em auto;
  border-radius: 20px;
  box-shadow: 0 18px 36px rgba(53, 36, 14, 0.08);
}

.reader-prose blockquote {
  margin-left: 0;
  margin-right: 0;
  padding: 18px 22px;
  border-left: 4px solid #c9ab79;
  border-radius: 0 18px 18px 0;
  background: rgba(244, 234, 215, 0.82);
  color: #5d4a31;
}

.reader-prose pre,
.artifact-pre {
  overflow-x: auto;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  line-height: 1.65;
}

.reader-artifacts {
  position: sticky;
  top: 24px;
}

.artifact-block {
  overflow: hidden;
  border: 1px solid rgba(112, 81, 44, 0.14);
  border-radius: 20px;
  background: rgba(255, 251, 243, 0.88);
  box-shadow: 0 16px 36px rgba(56, 39, 14, 0.06);
}

.artifact-block[open] {
  background: rgba(255, 253, 248, 0.95);
  overflow: hidden;
}

.artifact-block summary {
  cursor: pointer;
  list-style: none;
  padding: 16px 18px;
  color: var(--accent-deep);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.artifact-block summary::-webkit-details-marker {
  display: none;
}

.artifact-pre {
  margin: 0;
  padding: 0 18px 18px;
  color: #403427;
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    flex-direction: row;
    align-items: center;
    padding: 16px 20px;
    border-right: 0;
    border-bottom: 1px solid rgba(128, 105, 72, 0.14);
  }

  .content {
    padding: 16px;
  }

  .home-hero {
    grid-template-columns: 1fr;
  }

  .home-search-row,
  .panel {
    grid-template-columns: 1fr;
  }

  .home-feature-link {
    grid-template-columns: 1fr;
    min-height: 0;
  }

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

  .reader-shell {
    width: min(100vw - 24px, 100%);
    padding-top: 18px;
  }

  .reader-hero {
    padding: 24px 20px;
    border-radius: 24px;
  }

  .reader-content-grid {
    grid-template-columns: 1fr;
  }

  .reader-artifacts {
    position: static;
  }

  .reader-card {
    border-radius: 16px;
  }

  .reader-body {
    padding: 22px 18px;
  }

  .reader-prose {
    font-size: 18px;
  }

  .snapshot-frame {
    min-height: 420px;
  }
}
