:root {
  color-scheme: dark;
  --bg: #050708;
  --panel: rgba(255, 255, 255, 0.055);
  --panel-strong: rgba(255, 255, 255, 0.085);
  --ink: #f4f0e8;
  --muted: #a9b4bd;
  --line: rgba(244, 240, 232, 0.13);
  --cyan: #20e0d2;
  --blue: #2ca8ff;
  --purple: #8b5cf6;
  --amber: #f2b84b;
  --radius: 8px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% -10%, rgba(32, 224, 210, 0.1), transparent 32rem),
    var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body.modal-open {
  overflow: hidden;
}

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

img {
  display: block;
  max-width: 100%;
  height: auto;
}

.progress {
  position: fixed;
  z-index: 80;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.07);
}

.progress span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--blue), var(--purple));
}

.hero {
  padding: 24px 18px 28px;
  border-bottom: 1px solid var(--line);
}

.ebook-cover {
  display: grid;
  gap: 18px;
}

.cover-frame {
  border: 1px solid rgba(32, 224, 210, 0.24);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.cover-frame img {
  width: 100%;
}

.cover-meta {
  display: grid;
  gap: 8px;
}

.eyebrow,
.toc-title {
  margin: 0 0 14px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  text-transform: uppercase;
}

.chapter-label {
  margin: 0 0 14px;
  color: #b8cce0;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

h1,
h2,
h3,
p,
blockquote,
ul {
  margin-top: 0;
}

h1 {
  margin: 0;
  color: var(--ink);
  font-size: 30px;
  line-height: 1.08;
  font-weight: 800;
  text-wrap: balance;
}

.cover-meta p {
  margin: 0;
  color: #ffffff;
  font-size: 15px;
  line-height: 1.45;
  font-weight: 800;
}

.note {
  color: #b8c2c9;
  font-size: 14px;
  font-weight: 500 !important;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  width: 100%;
  margin-top: 26px;
  padding: 0 20px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  color: #041010;
  font-size: 15px;
  font-weight: 800;
  box-shadow: 0 18px 48px rgba(32, 224, 210, 0.22);
}

.reader-shell {
  display: block;
  padding: 0 18px 58px;
}

.desktop-toc {
  display: none;
}

.toc a {
  display: block;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.ebook {
  width: min(760px, 100%);
  margin: 0 auto;
}

.chapter,
.continue-section {
  scroll-margin-top: 122px;
  margin-bottom: 22px;
  padding: 24px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.032)),
    rgba(5, 7, 8, 0.78);
  box-shadow: var(--shadow);
}

.chapter.accent-purple {
  border-color: rgba(139, 92, 246, 0.34);
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(139, 92, 246, 0.08);
}

.chapter.accent-amber {
  border-color: rgba(242, 184, 75, 0.34);
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(242, 184, 75, 0.08);
}

.chapter h2,
.continue-section h2 {
  margin-bottom: 18px;
  color: #ffffff;
  font-size: 28px;
  line-height: 1.16;
  font-weight: 800;
  text-wrap: balance;
}

.chapter h3 {
  margin: 26px 0 12px;
  color: #ffffff;
  font-size: 18px;
  line-height: 1.34;
  text-wrap: balance;
}

.chapter .subsection-title {
  margin-top: 34px;
  padding-top: 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 23px;
  line-height: 1.24;
}

.chapter p,
.continue-section p,
.chapter li,
.continue-section li {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.82;
}

.chapter p + p,
.continue-section p + p {
  margin-top: 14px;
}

.chapter ul,
.continue-section ul {
  padding-left: 20px;
  margin-bottom: 18px;
}

.chapter li + li,
.continue-section li + li {
  margin-top: 8px;
}

blockquote {
  margin: 22px 0;
  padding-left: 18px;
  border-left: 3px solid var(--cyan);
  color: #ffffff;
  font-size: 19px;
  line-height: 1.5;
  font-weight: 800;
  text-wrap: balance;
}

.accent-purple blockquote {
  border-left-color: var(--purple);
}

.accent-amber blockquote {
  border-left-color: var(--amber);
}

.rule {
  color: #ffffff !important;
  font-size: 15px !important;
  line-height: 1.65 !important;
  font-weight: 800;
}

.term-line {
  display: inline-flex;
  align-items: center;
  margin: 16px 0 4px;
  padding: 8px 12px;
  border: 1px solid rgba(139, 92, 246, 0.34);
  border-radius: var(--radius);
  background: rgba(139, 92, 246, 0.08);
  color: #ffffff !important;
  font-family: inherit;
  font-size: 16px !important;
  line-height: 1.35 !important;
  font-weight: 800;
  cursor: pointer;
  appearance: none;
}

.term-line:hover,
.term-line:focus-visible {
  border-color: rgba(32, 224, 210, 0.58);
  background: rgba(139, 92, 246, 0.16);
  outline: none;
}

.risk-reading {
  margin-top: 4px;
}

.risk-reading p {
  line-height: 1.68;
}

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

.risk-reading blockquote {
  margin: 18px 0;
  font-size: 18px;
  line-height: 1.46;
}

.risk-reading .term-line {
  margin: 10px 0 2px;
  padding: 7px 11px;
  font-size: 15px !important;
}

figure {
  margin: 28px 0 0;
}

.image-button {
  width: 100%;
  padding: 0;
  border: 1px solid rgba(32, 224, 210, 0.22);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.28);
  cursor: zoom-in;
  overflow: hidden;
}

.accent-purple .image-button {
  border-color: rgba(139, 92, 246, 0.4);
}

.accent-amber .image-button {
  border-color: rgba(242, 184, 75, 0.36);
}

figcaption {
  margin-top: 12px;
  color: #c7cfd4;
  font-size: 13px;
  line-height: 1.55;
}

.continue-section {
  border-color: rgba(242, 184, 75, 0.32);
  background:
    radial-gradient(circle at 90% 0%, rgba(242, 184, 75, 0.14), transparent 16rem),
    radial-gradient(circle at 10% 100%, rgba(32, 224, 210, 0.11), transparent 18rem),
    rgba(5, 7, 8, 0.86);
}

.continue-section .button {
  margin-top: 18px;
}

.footer {
  padding: 28px 18px 38px;
  border-top: 1px solid var(--line);
  background: #040505;
}

.footer p {
  width: min(760px, 100%);
  margin: 0 auto;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.calculator-modal {
  position: fixed;
  z-index: 120;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(10px);
}

.calculator-modal.is-open {
  display: flex;
}

.calculator-panel {
  position: relative;
  width: min(100%, 470px);
  padding: 26px 20px 22px;
  border: 1px solid rgba(32, 224, 210, 0.34);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 100% 0%, rgba(44, 168, 255, 0.12), transparent 14rem),
    radial-gradient(circle at 0% 100%, rgba(139, 92, 246, 0.13), transparent 14rem),
    #050708;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.72), inset 0 0 0 1px rgba(139, 92, 246, 0.12);
}

.calculator-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(32, 224, 210, 0.3);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.045);
  color: #ffffff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.calculator-close:hover,
.calculator-close:focus-visible {
  border-color: var(--cyan);
  outline: none;
}

.calculator-kicker {
  margin: 0 0 10px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  text-transform: uppercase;
}

.calculator-panel h1,
.calculator-panel h2 {
  width: calc(100% - 46px);
  margin: 0;
  color: #ffffff;
  font-size: 30px;
  line-height: 1.12;
  font-weight: 800;
  text-wrap: balance;
}

.calculator-subtitle {
  margin: 12px 0 22px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.calculator-fields {
  display: grid;
  gap: 14px;
}

.calculator-field {
  display: grid;
  gap: 8px;
}

.calculator-field span {
  color: #d9e8f5;
  font-size: 13px;
  font-weight: 800;
}

.calculator-field input {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid rgba(32, 224, 210, 0.28);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.055);
  color: #ffffff;
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  outline: none;
}

.calculator-field input::placeholder {
  color: rgba(169, 180, 189, 0.58);
}

.calculator-field input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(32, 224, 210, 0.12);
}

.calculator-result {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(242, 184, 75, 0.38);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(242, 184, 75, 0.16), rgba(139, 92, 246, 0.08)),
    rgba(255, 255, 255, 0.04);
}

.calculator-result span {
  color: #d8e4ee;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.calculator-result strong {
  color: var(--amber);
  font-size: 38px;
  line-height: 1;
  font-weight: 800;
}

.calculator-footer {
  margin: 18px 0 0;
  padding-left: 14px;
  border-left: 3px solid var(--purple);
  color: #ffffff;
  font-size: 15px;
  line-height: 1.5;
  font-weight: 800;
}

.calculator-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% 0%, rgba(32, 224, 210, 0.12), transparent 30rem),
    radial-gradient(circle at 18% 100%, rgba(139, 92, 246, 0.12), transparent 24rem),
    var(--bg);
}

.standalone-calculator {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 26px 18px;
}

.calculator-panel-static {
  width: min(100%, 520px);
}

.calculator-panel-static h1 {
  width: 100%;
}

.calculator-back {
  display: inline-flex;
  align-items: center;
  margin-top: 20px;
  color: var(--cyan);
  font-size: 14px;
  font-weight: 800;
}

.lightbox {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.88);
}

.lightbox.is-open {
  display: flex;
}

.lightbox img {
  max-height: 88vh;
  width: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.lightbox-close {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 28px;
  line-height: 1;
}

@media (min-width: 980px) {
  .hero {
    width: min(940px, calc(100% - 112px));
    margin: 0 auto;
    padding: 44px 0 40px;
  }

  h1 {
    font-size: 46px;
  }

  .ebook-cover {
    grid-template-columns: minmax(360px, 0.9fr) minmax(280px, 0.6fr);
    align-items: center;
    gap: 34px;
  }

  .cover-meta p {
    font-size: 17px;
  }

  .chapter h2,
  .continue-section h2 {
    font-size: 46px;
    line-height: 1.08;
  }

  .chapter h3 {
    font-size: 23px;
    line-height: 1.28;
  }

  .chapter .subsection-title {
    font-size: 30px;
    line-height: 1.18;
  }

  blockquote {
    font-size: 22px;
    line-height: 1.46;
  }

  .button {
    width: auto;
    min-width: 286px;
  }

  .reader-shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 34px;
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 84px 28px 80px;
  }

  .desktop-toc {
    position: sticky;
    top: 24px;
    display: block;
    align-self: start;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.04);
  }

  .toc a {
    padding: 9px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }

  .toc a:last-child {
    border-bottom: 0;
  }

  .toc a:hover {
    color: #ffffff;
  }

  .ebook {
    margin: 0;
  }

  .chapter,
  .continue-section {
    padding: 42px;
    margin-bottom: 30px;
  }
}
