:root {
  color-scheme: light;
  --ink: #211719;
  --soft-ink: #46383b;
  --muted: #74686a;
  --line: #ded7d0;
  --paper: #fbfaf8;
  --surface: #ffffff;
  --red: #9e2032;
  --red-dark: #641320;
  --blue: #20394f;
  --green: #1f6b4b;
  --rose: #f7e7e8;
  --shadow: 0 18px 50px rgba(39, 25, 28, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Georgia, "Times New Roman", serif;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  min-height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand,
nav a,
button,
summary,
label,
.label,
.eyebrow {
  font-family: Arial, Helvetica, sans-serif;
}

.brand {
  align-items: baseline;
  color: var(--red);
  display: inline-flex;
  gap: 5px;
  text-decoration: none;
  white-space: nowrap;
}

.brand-script {
  font-family: "Brush Script MT", "Segoe Script", cursive;
  font-size: 31px;
  font-weight: 400;
  line-height: 1;
}

.brand-text {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  line-height: 1;
}

.site-nav {
  display: flex;
  flex: 1;
  gap: 18px;
  justify-content: center;
}

.site-nav a,
.footer-column a {
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.site-nav a:hover,
.footer-column a:hover {
  color: var(--red);
}

.header-cta {
  background: var(--red);
  border: 1px solid var(--red);
  border-radius: 999px;
  color: white;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  font-weight: 700;
  padding: 11px 17px;
  text-decoration: none;
  white-space: nowrap;
}

main {
  width: min(1060px, calc(100% - 32px));
  margin: 0 auto;
  padding: 38px 0 72px;
}

.reader-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(210px, 300px);
  gap: 34px;
  align-items: center;
  padding: 18px 0 28px;
}

.hero-copy {
  min-width: 0;
}

.eyebrow,
.label {
  display: block;
  margin: 0 0 8px;
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  max-width: 740px;
  margin: 0;
  font-size: clamp(38px, 6vw, 70px);
  line-height: 1;
  letter-spacing: 0;
}

.lede {
  max-width: 680px;
  margin: 18px 0 0;
  color: var(--soft-ink);
  font-size: 20px;
  line-height: 1.55;
}

.hero-card-stack {
  display: grid;
  gap: 14px;
}

.story-card {
  border: 1px solid rgba(164, 25, 36, 0.18);
  border-radius: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 275px;
  min-width: 0;
  overflow: hidden;
  padding: 20px;
  position: relative;
}

.card-label {
  color: var(--red);
  font: 800 10px Arial, Helvetica, sans-serif;
  letter-spacing: 0.18em;
  margin: 0;
  text-transform: uppercase;
}

.story-card h2 {
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 400;
  line-height: 1.02;
  margin: 12px 0;
  position: relative;
}

.story-card p,
.story-card dd {
  color: var(--soft-ink);
  font-size: 14px;
  line-height: 1.35;
  margin: 0;
  position: relative;
}

.chemistry-card {
  background: linear-gradient(155deg, #fffdf9, #f7e9e4 58%, #eadfda);
}

.world-card {
  background: linear-gradient(155deg, #fffaf4, #dfeee7 58%, #f7e4dd);
}

.locked-card {
  background: linear-gradient(155deg, #2b1b1d, #8e1723 62%, #f1dad5);
  color: #fff8ef;
}

.locked-card .card-label,
.locked-card p,
.locked-card h2 {
  color: #fff8ef;
}

.lock-mark {
  border: 1px solid rgba(255, 248, 239, 0.38);
  border-radius: 999px;
  padding: 10px 12px;
  text-align: center;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  position: relative;
}

.card-tags span {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(164, 25, 36, 0.14);
  border-radius: 999px;
  color: var(--red-dark);
  font: 700 11px Arial, Helvetica, sans-serif;
  padding: 6px 8px;
}

.story-card dl {
  display: grid;
  gap: 8px;
  margin: 0;
  position: relative;
}

.story-card dt {
  color: var(--red);
  font: 800 9px Arial, Helvetica, sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 8px 0 28px;
}

.status-grid > div,
.chapter,
.gate,
.tools-panel,
.reader-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.status-grid > div {
  min-height: 82px;
  padding: 18px;
}

.status-grid strong {
  display: block;
  color: var(--blue);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.chapters {
  display: grid;
  gap: 18px;
}

.chapter {
  padding: clamp(22px, 4vw, 42px);
  box-shadow: 0 8px 24px rgba(39, 25, 28, 0.04);
}

.chapter-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  margin: 0 0 20px;
}

.chapter h2 {
  margin: 0;
  font-size: clamp(25px, 4vw, 36px);
  line-height: 1.1;
}

.chapter-number {
  flex: 0 0 auto;
  min-width: 54px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
  color: var(--red);
  font: 800 13px Arial, Helvetica, sans-serif;
  text-align: center;
}

.chapter p {
  max-width: 760px;
  margin: 0 0 16px;
  color: var(--soft-ink);
  font-size: 19px;
  line-height: 1.75;
}

.chapter-text.cursor::after {
  animation: blink 850ms step-end infinite;
  color: var(--red);
  content: "|";
  margin-left: 2px;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.reader-note {
  padding: 24px;
}

.reader-note p {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

.gate {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  margin-top: 22px;
  padding: 24px;
  background: var(--rose);
}

.gate h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

.gate p {
  margin: 0;
  color: var(--muted);
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  background: var(--red);
  color: white;
  font-weight: 800;
  white-space: nowrap;
}

button:disabled {
  background: #9b8f93;
}

.tools-panel {
  margin-top: 30px;
  padding: 0;
  overflow: hidden;
}

.reader-progress-card {
  background: rgba(255, 252, 247, 0.94);
  border: 1px solid rgba(164, 25, 36, 0.16);
  border-radius: 18px;
  bottom: 28px;
  box-shadow: var(--shadow);
  max-width: 260px;
  padding: 16px;
  position: fixed;
  right: 24px;
  z-index: 25;
}

.reader-progress-kicker,
.reader-progress-detail {
  color: var(--muted);
  font: 12px/1.45 Arial, Helvetica, sans-serif;
  margin: 0;
}

.reader-progress-line {
  color: var(--ink);
  font-size: 17px;
  line-height: 1.25;
  margin: 5px 0 7px;
}

.site-footer {
  background: var(--ink);
  color: #fff8ef;
  display: grid;
  gap: 28px;
  grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(130px, 0.7fr));
  padding: clamp(34px, 6vw, 62px) clamp(22px, 5vw, 64px);
}

.footer-brand p {
  color: #e8d8cf;
  font-size: 16px;
  line-height: 1.55;
  margin: 16px 0 0;
  max-width: 360px;
}

.footer-wordmark .brand-text {
  color: #fff8ef;
}

.footer-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-column h2 {
  color: #f3ddd7;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11px;
  letter-spacing: 0.18em;
  margin: 0 0 3px;
  text-transform: uppercase;
}

.footer-column a {
  color: #f8eee8;
}

summary {
  min-height: 54px;
  padding: 17px 20px;
  color: var(--blue);
  cursor: pointer;
  font-weight: 800;
}

.tool-section {
  display: grid;
  gap: 18px;
  border-top: 1px solid var(--line);
  padding: 22px;
}

.tool-section h2 {
  margin: 0;
  font-size: 24px;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #fff;
  font: 16px Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

textarea,
.tool-result {
  grid-column: 1 / -1;
}

.tool-section button {
  justify-self: start;
}

.tool-result {
  min-height: 78px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  color: var(--muted);
  font: 13px/1.5 Consolas, "Courier New", monospace;
  white-space: pre-wrap;
}

@media (max-width: 840px) {
  .reader-hero {
    grid-template-columns: 1fr;
  }

  .hero-card-stack {
    grid-template-columns: repeat(3, minmax(250px, 1fr));
    overflow-x: auto;
    padding-bottom: 10px;
    scroll-snap-type: x mandatory;
  }

  .story-card {
    scroll-snap-align: center;
  }
}

@media (max-width: 680px) {
  .topbar,
  .gate,
  .chapter-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    padding: 14px 18px;
  }

  .site-nav {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  main {
    width: min(100% - 24px, 1060px);
    padding-top: 24px;
  }

  .status-grid,
  form {
    grid-template-columns: 1fr;
  }

  .chapter-number {
    min-width: 0;
  }

  button {
    width: 100%;
  }

  .reader-progress-card {
    margin: 0 0 18px;
    max-width: none;
    position: static;
  }

  .site-footer {
    grid-template-columns: 1fr;
  }
}
