
:root {
  --bg: #fbfaf7;
  --paper: #ffffff;
  --ink: #171411;
  --ink-soft: #5b554d;
  --muted: #8a8177;
  --line: #e5ded5;
  --orange: #f2660a;
  --orange-deep: #c64e00;
  --teal: #0f766e;
  --teal-soft: #e4f5f2;
  --code-bg: #201b17;
  --shadow: 0 18px 60px rgba(30, 23, 16, 0.12);
  --topbar-height: 68px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-height) + 20px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Noto Sans CJK SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.progress {
  position: fixed;
  inset: 0 0 auto;
  z-index: 30;
  height: 3px;
  background: transparent;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 clamp(18px, 4vw, 56px);
  background: rgba(251, 250, 247, 0.88);
  border-bottom: 1px solid rgba(229, 222, 213, 0.85);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: max-content;
  color: var(--ink);
  font-size: 15px;
  font-weight: 750;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  background: var(--orange);
  color: #fff;
  border-radius: 8px;
  font-weight: 850;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topnav a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

.topnav a:hover {
  background: #f2ece5;
  color: var(--ink);
}

.topnav a[data-download-link] {
  background: var(--ink);
  color: #fff;
}

.hero {
  min-height: calc(88svh - var(--topbar-height));
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  align-items: center;
  gap: clamp(28px, 6vw, 72px);
  padding: clamp(34px, 6vw, 76px) clamp(18px, 7vw, 96px) clamp(32px, 5vw, 64px);
  border-bottom: 1px solid var(--line);
}

.hero-copy {
  max-width: 860px;
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--orange-deep);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.hero h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(48px, 10vw, 118px);
  line-height: 0.98;
  letter-spacing: 0;
}

.hero-lede {
  max-width: 740px;
  margin: 24px 0 0;
  color: var(--ink-soft);
  font-size: clamp(18px, 2.2vw, 24px);
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 34px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 750;
  text-decoration: none;
}

.button-primary {
  background: var(--orange);
  color: #fff;
}

.button-secondary {
  background: var(--teal-soft);
  border-color: #b9ded8;
  color: var(--teal);
}

.hero-side {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.hero-preview {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: left top;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-panel {
  display: grid;
  gap: 18px;
  padding: 24px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-panel div {
  display: grid;
  gap: 5px;
  padding-bottom: 17px;
  border-bottom: 1px solid var(--line);
}

.hero-panel div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.panel-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.hero-panel strong {
  color: var(--ink);
  font-size: 18px;
  line-height: 1.45;
}

.book-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 900px);
  align-items: start;
  gap: clamp(28px, 5vw, 58px);
  max-width: 1280px;
  margin: 0 auto;
  padding: 44px clamp(18px, 4vw, 40px) 96px;
}

.toc-panel {
  position: sticky;
  top: calc(var(--topbar-height) + 24px);
  max-height: calc(100svh - var(--topbar-height) - 48px);
  overflow: auto;
  padding: 18px 0;
  border-right: 1px solid var(--line);
}

.toc-heading {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.toc-list {
  display: grid;
  gap: 2px;
  padding-right: 18px;
}

.toc-link {
  display: block;
  padding: 7px 10px;
  border-radius: 7px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.45;
  text-decoration: none;
}

.toc-link--sub {
  padding-left: 20px;
  color: var(--muted);
  font-size: 12px;
}

.toc-link:hover,
.toc-link.is-active {
  background: #f1ebe3;
  color: var(--orange-deep);
}

.book-content {
  min-width: 0;
  padding: 34px clamp(18px, 4vw, 58px) 58px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.book-content > h1:first-child {
  margin-top: 0;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.22;
}

.book-content h1,
.book-content h2,
.book-content h3,
.book-content h4,
.book-content h5,
.book-content h6 {
  color: var(--ink);
  line-height: 1.35;
  letter-spacing: 0;
}

.book-content h2 {
  margin: 48px 0 16px;
  padding-left: 14px;
  border-left: 5px solid var(--orange);
  font-size: clamp(24px, 3vw, 34px);
}

.book-content h3 {
  margin: 34px 0 12px;
  color: var(--orange-deep);
  font-size: clamp(20px, 2.2vw, 26px);
}

.book-content h4 {
  margin: 26px 0 10px;
  font-size: 19px;
}

.book-content h5,
.book-content h6 {
  margin: 20px 0 8px;
  color: var(--ink-soft);
  font-size: 16px;
}

.book-content p,
.book-content li {
  color: #302b25;
  font-size: 16px;
}

.book-content p {
  margin: 0 0 14px;
}

.book-content ul,
.book-content ol {
  margin: 0 0 18px;
  padding-left: 24px;
}

.book-content li + li {
  margin-top: 5px;
}

.book-content blockquote {
  margin: 20px 0;
  padding: 16px 18px;
  background: #fff7ef;
  border-left: 4px solid var(--orange);
  border-radius: 0 8px 8px 0;
}

.book-content blockquote p {
  margin: 0;
  color: var(--ink-soft);
}

.book-content table {
  width: 100%;
  margin: 18px 0 24px;
  border-collapse: collapse;
  overflow: hidden;
  font-size: 14px;
}

.book-content th,
.book-content td {
  padding: 10px 12px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.book-content th {
  background: #f6efe7;
  color: var(--ink);
  font-weight: 800;
}

.book-content code {
  padding: 2px 6px;
  background: #f1ede8;
  border-radius: 5px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.book-content pre {
  overflow: auto;
  margin: 18px 0 22px;
  padding: 18px;
  background: var(--code-bg);
  border-radius: 8px;
}

.book-content pre code {
  padding: 0;
  background: transparent;
  color: #f7efe7;
  font-size: 14px;
  line-height: 1.65;
}

.book-content a {
  color: var(--orange-deep);
  font-weight: 650;
  text-decoration-color: rgba(198, 78, 0, 0.3);
  text-underline-offset: 3px;
}

.book-content img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.book-content p[align="center"] {
  margin: 22px 0;
  text-align: center;
}

.book-content hr {
  margin: 36px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.back-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 25;
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-size: 20px;
  box-shadow: 0 12px 30px rgba(30, 23, 16, 0.16);
  cursor: pointer;
}

.back-top.is-visible {
  display: block;
}

@media (max-width: 980px) {
  .hero {
    min-height: auto;
    grid-template-columns: 1fr;
  }

  .hero-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .hero-panel div {
    padding: 0;
    border-bottom: 0;
  }

  .book-shell {
    grid-template-columns: 1fr;
  }

  .toc-panel {
    position: static;
    max-height: none;
    padding: 16px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  .toc-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-right: 0;
  }
}

@media (max-width: 680px) {
  :root {
    --topbar-height: 62px;
  }

  .topbar {
    gap: 12px;
    padding-inline: 14px;
  }

  .brand {
    font-size: 14px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
  }

  .topnav a {
    min-height: 34px;
    padding: 0 10px;
    font-size: 13px;
  }

  .topnav a[href="#toc"] {
    display: none;
  }

  .hero {
    padding-top: 38px;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .button {
    width: 100%;
  }

  .hero-panel {
    grid-template-columns: 1fr;
  }

  .book-shell {
    padding-inline: 12px;
  }

  .toc-list {
    grid-template-columns: 1fr;
  }

  .book-content {
    padding: 24px 16px 40px;
  }

  .book-content table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}
