:root {
  --bg: #07080c;
  --ink: #f2efe8;
  --dim: #9a958c;
  --gold: #e8c547;
  --green: #05f2a0;
  --sky: #6ec8ff;
  --panel: #12151c;
  --border: rgba(255, 255, 255, 0.08);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --measure: 44rem;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 45% at 50% -8%, rgba(232, 197, 71, 0.14), transparent 55%),
    radial-gradient(ellipse 50% 35% at 90% 15%, rgba(110, 200, 255, 0.08), transparent 50%),
    radial-gradient(ellipse 40% 30% at 10% 70%, rgba(5, 242, 160, 0.06), transparent 45%),
    var(--bg);
  line-height: 1.65;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

.book-top {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 52rem;
  margin: 0 auto;
  padding: 28px 20px 12px;
}
.book-top .seal {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(232, 197, 71, 0.55);
  box-shadow: 0 0 18px rgba(5, 242, 160, 0.2);
}
.book-top h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 700;
  letter-spacing: 0.02em;
}
.book-top .tag {
  margin: 4px 0 0;
  font-size: 0.85rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 800;
  background: linear-gradient(90deg, var(--gold), var(--green), var(--sky));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.toc {
  max-width: 52rem;
  margin: 0 auto 8px;
  padding: 8px 20px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  border-bottom: 1px solid var(--border);
}
.toc a {
  color: var(--dim);
  font-size: 0.86rem;
  font-weight: 600;
}
.toc a:hover { color: var(--gold); text-decoration: none; }

.book {
  max-width: 52rem;
  margin: 0 auto;
  padding: 12px 20px 40px;
}

.chapter {
  padding: 28px 0 36px;
  border-bottom: 1px solid var(--border);
}
.chapter:last-child { border-bottom: 0; }

.chapter h1 {
  font-family: var(--serif);
  font-size: clamp(1.7rem, 4vw, 2.35rem);
  line-height: 1.2;
  margin: 0 0 1rem;
  color: #fff;
}
.chapter h2 {
  font-family: var(--serif);
  font-size: 1.35rem;
  margin: 1.6rem 0 0.65rem;
  color: var(--gold);
}
.chapter h3 {
  font-size: 1.05rem;
  margin: 1.2rem 0 0.5rem;
  color: var(--sky);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.chapter p {
  margin: 0 0 0.95rem;
  max-width: var(--measure);
  color: #ebe7df;
  font-size: 1.05rem;
}
.chapter ul, .chapter ol {
  margin: 0 0 1rem;
  padding-left: 1.35rem;
  max-width: var(--measure);
}
.chapter li { margin: 0.35rem 0; color: #e4e0d8; }
.chapter blockquote {
  margin: 1.2rem 0;
  padding: 1rem 1.25rem;
  border-left: 4px solid var(--gold);
  background: rgba(232, 197, 71, 0.06);
  border-radius: 0 12px 12px 0;
  font-family: var(--serif);
  font-size: 1.12rem;
  line-height: 1.75;
  color: #f4f0e8;
  max-width: var(--measure);
}
.chapter pre {
  margin: 1rem 0;
  padding: 14px 16px;
  overflow-x: auto;
  border-radius: 12px;
  background: #0a0c0f;
  border: 1px solid var(--border);
  max-width: 100%;
}
.chapter code {
  font-family: ui-monospace, "JetBrains Mono", Menlo, monospace;
  font-size: 0.92em;
  color: var(--green);
}
.chapter pre code { color: #d8fcec; font-size: 0.88rem; }
.chapter table {
  width: 100%;
  max-width: var(--measure);
  border-collapse: collapse;
  margin: 1rem 0 1.2rem;
  font-size: 0.95rem;
}
.chapter th, .chapter td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.chapter th {
  background: rgba(5, 242, 160, 0.08);
  color: var(--green);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.chapter hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}
.chapter strong { color: #fff; }
.chapter .fig {
  margin: 1.25rem 0 1.5rem;
  padding: 0;
  max-width: min(100%, 36rem);
}
.chapter .fig img {
  display: block;
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
}
.chapter .fig figcaption {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--dim);
  letter-spacing: 0.02em;
}

/* Footer only at end — everything else is the book */
.end-foot {
  max-width: 52rem;
  margin: 0 auto;
  padding: 36px 20px 64px;
  border-top: 1px solid rgba(232, 197, 71, 0.25);
  text-align: center;
}
.end-foot .yes {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  background: linear-gradient(90deg, #fff, var(--gold), var(--green), var(--sky), #ff8fab);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.end-foot .links {
  margin: 0 0 10px;
  color: var(--dim);
  font-size: 0.92rem;
  line-height: 1.7;
}
.end-foot .links a { color: var(--dim); margin: 0 2px; }
.end-foot .links a:hover { color: var(--green); }
.end-foot .copy {
  margin: 0;
  color: #5c5a55;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
}

@media (max-width: 640px) {
  .book-top { padding: 20px 16px 8px; }
  .toc, .book, .end-foot { padding-left: 16px; padding-right: 16px; }
  .chapter p, .chapter li { font-size: 1.02rem; }
}
