:root {
  --navy: #0F1B2D;
  --navy-2: #1a2942;
  --gold: #E8A319;
  --gold-soft: #F5C75C;
  --gold-dark: #B87E0A;
  --surface: #ffffff;
  --bg: #FAFAFA;
  --alt: #F1F5F9;
  --text: #0F1B2D;
  --text-2: #475569;
  --muted: #64748B;
  --border: #E2E8F0;
  --radius: 8px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 1.5rem; }
.wrap.narrow { max-width: 760px; }
a { color: var(--gold-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header / footer */
.site-header {
  background: var(--navy);
  border-bottom: 1px solid #1E2A3C;
  position: sticky; top: 0; z-index: 10;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { color: #E5E7EB; font-weight: 700; letter-spacing: 0.02em; }
.brand:hover { text-decoration: none; color: #fff; }
.brand-sub { color: var(--gold); font-weight: 600; }
.site-nav { display: flex; gap: 1.5rem; align-items: center; }
.site-nav a { color: #94A3B8; font-size: 0.9rem; }
.site-nav a:hover { color: #fff; text-decoration: none; }
.site-nav .acct { color: var(--gold-soft); font-weight: 600; }

.site-footer { background: var(--navy); color: #94A3B8; margin-top: 4rem; padding: 2rem 0; font-size: 0.85rem; }
.site-footer p { margin: 0.25rem 0; }
.site-footer .fine { color: #64748B; font-style: italic; }

/* Hero */
.hero {
  background: linear-gradient(135deg, var(--navy-2) 0%, var(--navy) 100%);
  color: #E5E7EB;
  padding: 4rem 0 3.5rem;
}
.eyebrow { text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.75rem; font-weight: 700; color: var(--gold); display: block; margin-bottom: 0.75rem; }
.hero h1 { color: #fff; font-size: 2.4rem; line-height: 1.12; margin: 0 0 0.6rem; }
.hero .subtitle { color: var(--gold-soft); font-size: 1.05rem; margin: 0 0 1.25rem; }
.hero .lead { color: #94A3B8; font-size: 1.1rem; max-width: 46rem; }

/* Access CTA */
.access-cta { margin-top: 2rem; padding: 1.25rem 1.5rem; background: rgba(232,163,25,0.08); border-left: 4px solid var(--gold); border-radius: var(--radius); max-width: 40rem; }
.access-cta p { margin: 0 0 0.75rem; color: #cbd5e1; }
.access-cta .fine { color: #64748B; font-style: italic; font-size: 0.85rem; margin-top: 0.5rem; margin-bottom: 0; }
.access-badge.ok { margin-top: 2rem; color: #4ade80; font-weight: 700; }

.btn { display: inline-block; border: none; cursor: pointer; font: inherit; font-weight: 600; padding: 0.7rem 1.4rem; border-radius: var(--radius); }
.btn-primary { background: var(--gold); color: var(--navy); }
.btn-primary:hover { background: var(--gold-soft); text-decoration: none; }

/* Inline login form (email → magic link, no bounce) */
.login-inline { margin-top: 0.6rem; max-width: 34rem; }
.login-inline-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.login-inline input[type=email] {
  flex: 1 1 16rem; min-width: 12rem;
  padding: 0.7rem 0.9rem; border-radius: var(--radius);
  border: 1px solid var(--border); font: inherit; background: #fff; color: var(--text);
}
.login-inline input[type=email]:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
.login-inline .fine { margin: 0.55rem 0 0; }

/* TOC */
.toc { padding-top: 2.5rem; }
.part { margin-bottom: 3rem; }
.part-head h2 { font-size: 0.85rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold-dark); margin: 0 0 0.4rem; }
.part-head p { color: var(--text-2); max-width: 46rem; margin: 0 0 1.25rem; font-size: 0.95rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }

.chapter-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--gold); border-radius: var(--radius); padding: 1.25rem; color: inherit; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.chapter-card:hover { transform: translateY(-3px); box-shadow: 0 12px 24px -14px rgba(15,27,45,.28); border-color: var(--gold); text-decoration: none; }
.card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; }
.num { font-weight: 700; color: var(--gold-dark); font-variant-numeric: tabular-nums; }
.tag { font-size: 0.6rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; }
.tag.open { background: #16A34A; color: #fff; }
.tag.lock { background: var(--alt); }
.chapter-card h3 { font-size: 1.02rem; line-height: 1.3; margin: 0 0 0.5rem; color: var(--text); }
.chapter-card .teaser { color: var(--gold-dark); font-weight: 600; font-size: 0.9rem; margin: 0 0 0.6rem; }
.chapter-card .summary { color: var(--text-2); font-size: 0.88rem; margin: 0; }

/* Chapter page */
.chapter { padding: 2.5rem 0 1rem; }
.back { display: inline-block; margin-bottom: 1rem; color: var(--muted); font-size: 0.9rem; }
.chapter h1 { font-size: 2rem; line-height: 1.15; margin: 0.25rem 0 1.5rem; }
.chapter .teaser { color: var(--gold-dark); font-weight: 600; }
.chapter .lead { font-size: 1.1rem; color: var(--text-2); }

.gate { margin: 2rem 0; padding: 1.75rem; background: var(--navy); color: #cbd5e1; border-radius: 16px; }
.gate h2 { color: #fff; margin: 0 0 0.75rem; font-size: 1.2rem; }
.gate p { margin: 0 0 1rem; }
.gate .fine { color: #64748B; font-style: italic; font-size: 0.85rem; }

/* Prose (rendered manuscript) */
.prose { font-size: 1.02rem; color: #1f2937; }
.prose h1, .prose h2, .prose h3 { line-height: 1.25; margin: 2rem 0 0.75rem; color: var(--text); }
.prose h2 { font-size: 1.4rem; border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }
.prose h3 { font-size: 1.15rem; }
.prose p { margin: 0 0 1rem; }
.prose img, .prose svg { max-width: 100%; height: auto; display: block; margin: 1.5rem auto; }
.prose blockquote { margin: 1.5rem 0; padding: 0.75rem 1.25rem; background: rgba(232,163,25,0.06); border-left: 4px solid var(--gold); border-radius: 4px; color: var(--text); }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose table { border-collapse: collapse; width: 100%; margin: 1.5rem 0; font-size: 0.95rem; }
.prose th, .prose td { border: 1px solid var(--border); padding: 0.5rem 0.75rem; text-align: left; }
.prose th { background: var(--alt); }
.prose pre { background: var(--navy); color: #e5e7eb; padding: 1rem 1.25rem; border-radius: var(--radius); overflow-x: auto; font-size: 0.85rem; line-height: 1.45; }
.prose code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.prose :not(pre) > code { background: var(--alt); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }

.chapter-nav { display: flex; justify-content: space-between; gap: 1rem; margin: 3rem 0 1rem; padding-top: 1.5rem; border-top: 1px solid var(--border); font-size: 0.9rem; }

@media (max-width: 640px) {
  .hero h1 { font-size: 1.8rem; }
  .site-nav { gap: 1rem; }
}
