:root {
  --ink: #070f18;
  --gold: #f5b942;
  --gold-deep: #c8922a;
  --fog: #f4f7fb;
  --muted: rgba(244, 247, 251, 0.78);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  background: #02060c;
  color: var(--fog);
  font-family: "Figtree", system-ui, sans-serif;
  overflow: hidden;
}

.app, [data-stage] {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
}

.stage {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 100%;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--ink);
  overflow: hidden;
}

.boot {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  color: var(--muted);
}

/* Cover */
.cover {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: calc(2.2rem + var(--safe-top)) 1.25rem calc(1.6rem + var(--safe-bottom));
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(31, 107, 82, 0.28), transparent 58%),
    var(--ink);
}
.cover.is-off { display: none !important; }

.cover .eyebrow {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 0.7rem;
}

.cover h1 {
  font-family: "Bricolage Grotesque", Georgia, serif;
  font-weight: 800;
  font-size: clamp(2.2rem, 10vw, 2.8rem);
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.cover h1 span { color: var(--gold); }

.cover .lede {
  margin-top: 0.7rem;
  color: var(--fog);
  font-size: 1.12rem;
  line-height: 1.4;
  max-width: 22ch;
  font-weight: 600;
}

.cover-hint {
  margin-top: 0.55rem;
  color: var(--muted);
  font-size: 0.88rem;
  max-width: 32ch;
}

.cover-actions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 1.4rem;
  max-width: 22rem;
}

.btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(10, 22, 40, 0.9);
  color: var(--fog);
  font: inherit;
  font-weight: 700;
  min-height: 48px;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.btn.primary {
  border-color: transparent;
  background: linear-gradient(180deg, var(--gold), var(--gold-deep));
  color: #1a1200;
}
.cover-links {
  margin-top: 1.1rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.cover-links a { color: var(--gold); }

.chapter-list {
  margin-top: 1.6rem;
  display: grid;
  gap: 0.15rem;
}
.chapter-list button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--fog);
  font: inherit;
  text-align: left;
  padding: 0.45rem 0;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1.6rem 1fr;
  gap: 0.4rem;
}
.chapter-list .n { color: var(--gold); font-weight: 800; }
.chapter-list .t { font-weight: 600; }

/* Reader */
.reader { display: none; position: absolute; inset: 0; }
.reader.on { display: block; }

.progress {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 40;
  display: flex;
  gap: 0;
  height: 2px;
}
.progress span {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.progress span i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--gold);
}
.progress span.done i { width: 100%; }

.topbar {
  position: absolute;
  top: calc(0.85rem + var(--safe-top));
  left: 1.1rem;
  right: 1.1rem;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chip {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(244, 247, 251, 0.72);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  min-height: 36px;
  padding: 0.25rem 0;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.45);
}
.chip:hover { color: var(--fog); }

.beat {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: minmax(0, 48%) minmax(0, 52%);
  padding: calc(3.2rem + var(--safe-top)) 1.25rem calc(5.4rem + var(--safe-bottom));
  opacity: 0;
  pointer-events: none;
}
.beat.active { opacity: 1; pointer-events: auto; }

.visual {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.copy {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding-top: 1rem;
}

.kicker {
  color: var(--gold);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 0.7rem;
}

.headline {
  font-family: "Bricolage Grotesque", Georgia, serif;
  font-weight: 700;
  font-size: clamp(1.7rem, 7.2vw, 2.15rem);
  line-height: 1.06;
  letter-spacing: -0.035em;
  max-width: 13ch;
}

.headline span { color: var(--gold); }

.copy p {
  margin-top: 0.7rem;
  color: rgba(244, 247, 251, 0.72);
  font-size: 1.02rem;
  font-weight: 500;
  line-height: 1.45;
  max-width: 28ch;
}

.points {
  list-style: none;
  margin-top: 1.35rem;
  display: grid;
  max-width: 28rem;
}
.points li {
  display: grid;
  grid-template-columns: 1.7rem 1fr;
  gap: 0.7rem;
  align-items: baseline;
  padding: 0.72rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--fog);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.4;
}
.points li:last-child { border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.points li span {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.cta-row { display: flex; gap: 0.5rem; margin-top: 1.2rem; flex-wrap: wrap; }

.device {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.phone {
  height: 100%;
  aspect-ratio: 9 / 16;
  max-width: min(58vw, 240px);
  padding: 7px;
  border-radius: 1.35rem;
  background: #11161c;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12),
    0 22px 50px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.poster {
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 0.9rem;
}

.phone img, .poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
  border-radius: 1.05rem;
}
.poster img { border-radius: 0.9rem; }

.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.15rem calc(0.95rem + var(--safe-bottom));
  background: linear-gradient(180deg, transparent, rgba(7, 15, 24, 0.94) 42%);
}

.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.controls button {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(244, 247, 251, 0.78);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  min-height: 40px;
  padding: 0.35rem 0.15rem;
  cursor: pointer;
}
.controls button.primary {
  background: var(--gold);
  color: #1a1200;
  min-width: 5.6rem;
  padding: 0.45rem 1.15rem;
  border-radius: 999px;
}
.controls button:hover { color: var(--fog); }
.controls button.primary:hover { color: #1a1200; filter: brightness(1.05); }

.counter {
  font-size: 0.78rem;
  font-weight: 500;
  color: rgba(244, 247, 251, 0.48);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.counter i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(244, 247, 251, 0.35);
}

.toc {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: none;
  flex-direction: column;
  padding: calc(1.2rem + var(--safe-top)) 1.3rem calc(1.2rem + var(--safe-bottom));
  background: rgba(7, 15, 24, 0.98);
}
.toc.on { display: flex; }
.toc-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.toc-head h2 {
  font-family: "Bricolage Grotesque", Georgia, serif;
  font-size: 1.35rem;
  font-weight: 700;
}
.toc-list { overflow: auto; display: grid; }
.toc-item {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  padding: 0.85rem 0;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1.8rem 1fr;
  gap: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.toc-item.active { color: var(--gold); }
.toc-item .n { font-weight: 700; color: var(--gold); font-size: 0.85rem; }

@media (min-width: 900px) {
  .app {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #05080d;
  }
  .stage {
    width: min(1180px, 94vw);
    max-width: none;
    height: min(740px, 88dvh);
    min-height: 0;
    margin: 1rem;
    border-radius: 1.1rem;
    flex: 0 0 min(1180px, 94vw);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
  }
  .cover { padding: 2.6rem 2.8rem; }
  .cover-actions { flex-direction: row; max-width: none; }
  .chapter-list {
    grid-template-columns: 1fr 1fr;
    column-gap: 1.5rem;
  }
  .topbar {
    left: 2.2rem;
    right: 2.2rem;
    top: 1.15rem;
  }
  .beat {
    grid-template-columns: minmax(340px, 42%) minmax(0, 1fr);
    grid-template-rows: 1fr;
    align-items: stretch;
    gap: 0;
    padding: 0;
  }
  .visual {
    order: 2;
    min-height: 0;
    background: #04070c;
  }
  .copy {
    order: 1;
    overflow: auto;
    height: 100%;
    padding: 5rem 2.8rem 5.6rem 2.8rem;
    justify-content: flex-start;
  }
  .headline { font-size: 2.7rem; max-width: 14ch; }
  .copy p { font-size: 1.08rem; margin-top: 0.85rem; }
  .points { margin-top: 1.6rem; }
  .device {
    width: 100%;
    height: 100%;
    padding: 3.2rem 2rem 4.2rem;
    background:
      radial-gradient(ellipse 70% 50% at 50% 42%, rgba(31, 80, 70, 0.22), transparent 62%),
      #04070c;
  }
  .phone {
    height: 100%;
    max-width: 300px;
  }
  .poster {
    border-radius: 0;
    height: 100%;
  }
  .poster img { border-radius: 0; object-position: center; }
  .controls {
    padding: 0.9rem 2.2rem 1.1rem;
  }
}

@media (max-width: 520px) {
  .counter { display: none; }
}
