:root {
  --bg-1: #f3efe6;
  --bg-2: #e5dbcf;
  --paper: #fffaf2;
  --accent: #8a2f2f;
  --accent-2: #d07a2a;
  --accent-3: #2c6e6c;
  --accent-rgb: 138, 47, 47;
  --accent-2-rgb: 208, 122, 42;
  --accent-3-rgb: 44, 110, 108;
  --text: #1c1a18;
  --muted: #5a514a;
  --border: rgba(28, 26, 24, 0.12);
  --shadow: 0 20px 60px rgba(32, 25, 18, 0.18);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% 10%, rgba(var(--accent-rgb), 0.12), transparent 40%),
    radial-gradient(circle at 85% 20%, rgba(var(--accent-3-rgb), 0.1), transparent 35%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2));
  color: var(--text);
  overflow-x: hidden;
  position: relative;
}

h1, h2, h3 {
  margin: 0;
  font-family: "Fraunces", "Space Grotesk", serif;
  letter-spacing: -0.01em;
}

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

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

.doc-shell {
  position: relative;
}

.page-lines,
.paper-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}

.page-lines {
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(28, 26, 24, 0.05) 0,
      rgba(28, 26, 24, 0.05) 1px,
      transparent 24px,
      transparent 32px
    ),
    linear-gradient(to right, rgba(var(--accent-rgb), 0.08) 72px, transparent 72px);
  opacity: 0.55;
  transition: opacity 0.25s ease, transform 0.2s ease;
}

.paper-noise {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
  opacity: 0.28;
  transition: transform 0.2s ease;
}

body:not(.show-guides) .page-lines {
  opacity: 0.1;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 38px;
  padding: 78px clamp(18px, 4vw, 70px) 40px;
  align-items: center;
  max-width: 1180px;
  margin: 0 auto;
}

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

.lede {
  margin: 16px 0 22px;
  max-width: 60ch;
}

.hero__meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.7);
  color: var(--text);
  box-shadow: var(--shadow);
  font-weight: 600;
  font-size: 14px;
}

.btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  padding: 14px 18px;
  border-radius: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  cursor: pointer;
}

.btn.primary {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #fff4e6;
  box-shadow: 0 12px 32px rgba(var(--accent-rgb), 0.26);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.66);
}

.hero__actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.hero__note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.note__label {
  font-weight: 700;
  color: var(--accent);
}

.note__text {
  font-family: "IBM Plex Mono", monospace;
  color: var(--muted);
}

.hero__visual {
  position: relative;
}

.doc-window {
  border: 1px solid rgba(28, 26, 24, 0.2);
  border-radius: 20px;
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.doc-window__bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.12), rgba(var(--accent-2-rgb), 0.14));
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}

.dots {
  display: flex;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot--red { background: #d84b4b; }
.dot--amber { background: #f6b44d; }
.dot--green { background: #4dbd7c; }

.doc-window__title {
  color: var(--text);
}

.doc-window__status {
  font-size: 13px;
  color: var(--muted);
  text-align: right;
}

.doc-window__toolbar {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  flex-wrap: wrap;
}

.tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(var(--accent-rgb), 0.08);
  font-weight: 700;
  color: var(--text);
  font-size: 12px;
}

.doc-window__ruler {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  gap: 6px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(var(--accent-2-rgb), 0.08);
}

.ruler__tick {
  height: 10px;
  background: rgba(28, 26, 24, 0.12);
  border-radius: 4px;
}

.ruler__tick--mark {
  height: 16px;
  background: rgba(var(--accent-rgb), 0.26);
}

.doc-window__page {
  padding: 22px 18px 26px;
  display: grid;
  gap: 10px;
  background: linear-gradient(180deg, rgba(28, 26, 24, 0.02), transparent);
  position: relative;
  min-height: 280px;
}

.page__line {
  font-family: "IBM Plex Mono", monospace;
  font-size: 14px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.page__line--note {
  color: var(--accent);
  font-weight: 700;
}

.page__line--highlight {
  background: linear-gradient(120deg, rgba(var(--accent-rgb), 0.14), rgba(var(--accent-2-rgb), 0.14));
  padding: 6px 8px;
  border-radius: 10px;
}

.page__caret {
  width: 2px;
  height: 22px;
  background: var(--accent-2);
  position: absolute;
  bottom: 20px;
  left: 18px;
  animation: blink 1.2s steps(2) infinite;
}

.floating-card {
  position: absolute;
  bottom: -18px;
  right: -16px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
  max-width: 320px;
}

.floating-list {
  padding-left: 18px;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.subhero {
  padding: 72px clamp(18px, 4vw, 70px) 36px;
  background: linear-gradient(120deg, rgba(var(--accent-rgb), 0.08), rgba(var(--accent-3-rgb), 0.08));
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.subhero h1 {
  margin: 12px 0 8px;
  font-size: clamp(32px, 4.6vw, 50px);
}

.subhero .lede {
  max-width: 68ch;
}

.subhero__meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.article {
  padding: 14px clamp(18px, 4vw, 70px) 70px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  max-width: 1100px;
  margin: 0 auto;
}

.article--with-toc {
  max-width: 1240px;
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.article__content {
  display: grid;
  gap: 32px;
}

.section {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px 20px;
  box-shadow: var(--shadow);
}

.section__header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.section__header h2 {
  font-size: clamp(22px, 3vw, 30px);
}

.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  z-index: 10;
  box-shadow: 0 6px 20px rgba(var(--accent-rgb), 0.2);
}

.toc {
  position: sticky;
  top: 24px;
  align-self: start;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.toc__header h3 {
  margin: 8px 0 10px;
  font-size: 20px;
}

.toc__list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.toc__link {
  display: block;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: color 0.2s ease, background 0.2s ease, border 0.2s ease;
}

.toc__link:hover {
  color: var(--text);
  background: rgba(var(--accent-rgb), 0.08);
}

.toc__link.active {
  color: var(--accent);
  border-color: rgba(var(--accent-rgb), 0.22);
  background: rgba(var(--accent-rgb), 0.1);
}

.toc__footer {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.failure-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.split {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 16px;
  align-items: start;
}

.longform p + p {
  margin-top: 10px;
}

.timeline-vertical {
  display: grid;
  gap: 12px;
}

.timeline-vertical__item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  background: rgba(28, 26, 24, 0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.timeline {
  padding: 26px clamp(18px, 4vw, 70px) 50px;
}

.timeline__head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.timeline__note {
  max-width: 44ch;
}

.topics {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.topic {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  min-height: 190px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.3s ease;
  opacity: 0.86;
  cursor: pointer;
}

.topic::before {
  content: attr(data-era);
  position: absolute;
  top: 12px;
  right: 12px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: rgba(28, 26, 24, 0.22);
}

.topic::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.08), transparent 50%);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.topic:hover {
  transform: translateY(-6px);
  box-shadow: 0 18px 40px rgba(var(--accent-rgb), 0.18);
  opacity: 1;
}

.topic:hover::after {
  opacity: 1;
}

.topic.visible {
  opacity: 1;
  transform: translateY(0);
}

.topic__label {
  display: inline-block;
  padding: 6px 10px;
  background: rgba(var(--accent-rgb), 0.1);
  border-radius: 10px;
  margin-bottom: 4px;
  font-weight: 700;
  color: var(--accent);
}

.topic__meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(28, 26, 24, 0.06);
  border-radius: 999px;
  font-weight: 600;
  color: var(--text);
}

.chip--tone {
  background: rgba(var(--accent-2-rgb), 0.16);
  color: var(--accent-2);
}

.chip-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: var(--accent);
  font-weight: 700;
  position: relative;
  z-index: 1;
}

.chip-link::after {
  content: "\2192";
  font-size: 14px;
  transition: transform 0.2s ease;
}

.topic:hover .chip-link::after {
  transform: translateX(4px);
}

.lab {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 24px;
  padding: 60px clamp(18px, 4vw, 70px) 90px;
  align-items: start;
}

.lab__panel {
  background: rgba(255, 255, 255, 0.93);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.lab__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 18px 0 12px;
}

.fact-card {
  background: rgba(28, 26, 24, 0.04);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.fact-card .label {
  display: block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 6px;
}

.fact-card.highlight {
  background: linear-gradient(120deg, rgba(var(--accent-rgb), 0.08), rgba(var(--accent-3-rgb), 0.08));
  border-color: rgba(var(--accent-rgb), 0.24);
}

.toggle-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 16px 0 10px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.switch input {
  display: none;
}

.slider {
  position: relative;
  width: 44px;
  height: 24px;
  background: rgba(28, 26, 24, 0.16);
  border-radius: 20px;
  transition: background 0.2s ease;
  border: 1px solid var(--border);
}

.slider::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.3);
}

.switch input:checked + .slider {
  background: rgba(var(--accent-rgb), 0.2);
}

.switch input:checked + .slider::after {
  transform: translateX(18px);
}

.switch .label {
  color: var(--muted);
  font-weight: 700;
}

.lab__cta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.lab__scene {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.1), rgba(var(--accent-2-rgb), 0.08));
  box-shadow: var(--shadow);
}

.scene__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.86);
  font-weight: 700;
  color: var(--accent);
}

.timeline-list {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  display: grid;
  gap: 8px;
}

.timeline-list li {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
}

.badge--year {
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
}

.quote {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.94);
  font-weight: 600;
  line-height: 1.6;
  color: var(--text);
}

.quote__attr {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-weight: 500;
}

.play-card {
  background: linear-gradient(120deg, rgba(var(--accent-rgb), 0.08), rgba(var(--accent-3-rgb), 0.08));
}

.footer {
  padding: 24px clamp(18px, 4vw, 70px) 36px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.86);
}

.footer__brand {
  font-weight: 700;
  color: var(--accent);
}

.footer__meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.mono-mode .doc-window__page,
.mono-mode .page__line,
.mono-mode .note__text {
  font-family: "IBM Plex Mono", monospace;
}

@keyframes blink {
  0%, 60%, 100% { opacity: 1; }
  70% { opacity: 0; }
}

@media (max-width: 1000px) {
  .hero, .lab {
    grid-template-columns: 1fr;
  }

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

  .hero__visual {
    order: -1;
  }

  .article--with-toc {
    grid-template-columns: 1fr;
  }

  .toc {
    position: static;
  }
}

@media (max-width: 680px) {
  .hero, .timeline, .lab {
    padding-inline: 16px;
  }

  .doc-window__toolbar {
    flex-wrap: wrap;
  }

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

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