:root {
  --ink: #172033;
  --muted: #667085;
  --soft: #f1f7ff;
  --paper: #fbf7f1;
  --white: #ffffff;
  --navy: #10233f;
  --blue: #3b82f6;
  --blue-dark: #1d4ed8;
  --cyan: #5dd4e8;
  --gold: #f3b95f;
  --peach: #ffdfc8;
  --mint: #dff8ed;
  --green: #13a871;
  --line: #eadfd4;
  --danger: #c2412e;
  --shadow: 0 24px 70px rgba(83, 65, 45, 0.12);
  --soft-shadow: 0 12px 34px rgba(83, 65, 45, 0.08);
  --reader-scale: 1;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 223, 200, 0.75), transparent 21rem),
    radial-gradient(circle at 90% 0%, rgba(93, 212, 232, 0.2), transparent 28rem),
    linear-gradient(180deg, #fffaf4 0%, #f4f8fb 48%, #fbf7f1 100%);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  font-size: calc(16px * var(--reader-scale));
  line-height: 1.58;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.reader-dark {
  --ink: #f3f7fb;
  --muted: #d4dde7;
  --paper: #0c1622;
  --white: #172638;
  --navy: #07121f;
  --blue-dark: #8fc2ff;
  --cyan: #9be7f4;
  --green: #46d69b;
  --line: #3d5268;
  --danger: #ff9a8d;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
  --soft-shadow: 0 12px 34px rgba(0, 0, 0, 0.22);
  background:
    radial-gradient(circle at 15% 6%, rgba(15, 118, 110, 0.24), transparent 24rem),
    radial-gradient(circle at 92% 0%, rgba(59, 130, 246, 0.18), transparent 28rem),
    linear-gradient(180deg, #07121f 0%, #0d1821 100%);
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.reader-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 68px;
  padding: 0.85rem clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid rgba(234, 223, 212, 0.72);
  background: rgba(255, 250, 244, 0.86);
  backdrop-filter: blur(18px);
}

.reader-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.72rem;
  min-width: 0;
  font-weight: 700;
  text-decoration: none;
}

.reader-brand span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-mark {
  display: grid;
  width: 2.4rem;
  height: 2.4rem;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--blue), #67e8f9);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(59, 130, 246, 0.28);
}

.reader-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.7rem;
  min-width: 0;
  flex: 1;
}

.reader-link,
.reader-tool {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 0 0.82rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  box-shadow: var(--soft-shadow);
  cursor: pointer;
}

body.reader-dark .reader-link,
body.reader-dark .reader-tool,
body.reader-dark .search-box,
body.reader-dark .reader-topbar {
  background: rgba(21, 35, 49, 0.88);
}

body.reader-dark .reader-link,
body.reader-dark .reader-tool,
body.reader-dark .search-box,
body.reader-dark .icon-button {
  border-color: #486078;
  color: var(--ink);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: min(360px, 42vw);
  min-height: 44px;
  padding: 0 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--soft-shadow);
}

.search-box span {
  color: var(--blue-dark);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.icon-button {
  display: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
}

.ebook-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: clamp(1.2rem, 2.5vw, 2rem);
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem);
}

.ebook-sidebar {
  position: sticky;
  top: 88px;
  align-self: start;
  max-height: calc(100vh - 104px);
  overflow: auto;
}

.sidebar-card,
.chapter-nav,
.quick-start,
.chapter,
.search-results {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(18px);
}

.sidebar-card {
  padding: 1.15rem;
  margin-bottom: 0.8rem;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(241, 247, 255, 0.9)),
    var(--white);
}

.label {
  margin: 0 0 0.6rem;
  color: var(--blue-dark);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar-card strong {
  display: block;
  margin-bottom: 0.7rem;
  font-size: 1.45rem;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f5;
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #60a5fa, #34d399);
  transition: width 220ms ease;
}

.chapter-nav {
  padding: 0.55rem;
}

.chapter-link {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 0.65rem;
  align-items: center;
  width: 100%;
  padding: 0.78rem;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.chapter-link:hover,
.chapter-link.active {
  background: linear-gradient(135deg, #edf6ff, #fff7ed);
  color: var(--ink);
}

.chapter-link.done {
  color: var(--green);
}

.chapter-link b {
  display: grid;
  height: 34px;
  place-items: center;
  border-radius: 12px;
  background: #eef6ff;
  font-size: 0.8rem;
}

.chapter-link span {
  overflow: hidden;
  font-size: 0.92rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ebook-reader {
  min-width: 0;
}

.ebook-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 420px);
  gap: clamp(1rem, 4vw, 2rem);
  align-items: center;
  min-height: auto;
  padding: clamp(2rem, 5vw, 3.4rem);
  border-radius: 32px;
  background:
    radial-gradient(circle at 88% 18%, rgba(255, 223, 200, 0.42), transparent 15rem),
    radial-gradient(circle at 70% 85%, rgba(93, 212, 232, 0.26), transparent 18rem),
    linear-gradient(135deg, #10233f 0%, #1d4ed8 55%, #3b82f6 100%),
    var(--navy);
  color: var(--white);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.ebook-hero::before {
  content: "";
  position: absolute;
  right: -7rem;
  top: -7rem;
  width: 22rem;
  height: 22rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
}

.ebook-hero::after {
  content: "";
  position: absolute;
  right: 22rem;
  bottom: -5rem;
  width: 13rem;
  height: 13rem;
  border-radius: 999px;
  background: rgba(255, 223, 200, 0.22);
}

.hero-copy {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.06;
  letter-spacing: 0;
}

h1 {
  max-width: 680px;
  font-size: clamp(2.25rem, 4.2vw, 3.85rem);
  font-weight: 750;
}

h2 {
  font-size: clamp(1.7rem, 2.7vw, 2.55rem);
  font-weight: 730;
}

h3 {
  font-size: 1.32rem;
  font-weight: 700;
}

.hero-copy p:not(.label) {
  max-width: 650px;
  margin: 1.2rem 0 0;
  color: #eef6ff;
  font-size: clamp(1.04rem, 1.55vw, 1.25rem);
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.6rem;
}

.hero-stats span {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  min-height: 48px;
  padding: 0.56rem 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #f2f7ff;
  font-weight: 650;
}

.hero-stats strong {
  color: var(--white);
  font-size: 1.55rem;
}

.hero-panel,
.hero-cover {
  position: relative;
  z-index: 1;
}

.hero-cover {
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.hero-cover img {
  width: 100%;
  height: 100%;
  min-height: 290px;
  object-fit: cover;
}

.hero-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.2rem;
  padding: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.mini-flow,
.agent-core {
  display: grid;
  gap: 0.7rem;
}

.mini-flow {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
}

.mini-flow span,
.agent-core span {
  min-height: 58px;
  padding: 0.35rem;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.16);
  color: #f8fbff;
  font-weight: 700;
  text-align: center;
}

.mini-flow i {
  display: none;
}

.agent-core {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.quick-start {
  display: grid;
  grid-template-columns: minmax(0, 0.78fr) minmax(0, 1.22fr);
  gap: clamp(1rem, 3vw, 2rem);
  margin: 1.1rem 0;
  padding: clamp(1.2rem, 3vw, 2rem);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(239, 248, 255, 0.88)),
    var(--white);
}

.quick-start h2 {
  font-size: clamp(1.55rem, 2.2vw, 2.25rem);
  line-height: 1.12;
}

.quick-start ol {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
  font-weight: 500;
}

.search-results {
  margin: 1rem 0;
  padding: 1rem;
}

.quiz-section {
  margin: 1.1rem 0;
  padding: clamp(1.4rem, 4vw, 2.4rem);
  border: 1px solid var(--line);
  border-radius: 28px;
  background:
    radial-gradient(circle at top right, rgba(255, 223, 200, 0.7), transparent 16rem),
    linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(240, 248, 255, 0.92));
  box-shadow: var(--soft-shadow);
}

.quiz-intro {
  max-width: 820px;
}

.quiz-intro p:not(.label) {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 1.08rem;
}

.quiz-score {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin: 1.2rem 0;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(59, 130, 246, 0.16);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
}

.quiz-score span {
  color: var(--blue-dark);
  font-size: 1.05rem;
  font-weight: 700;
}

.quiz-list {
  display: grid;
  gap: 1rem;
}

.quiz-card {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--white);
  box-shadow: 0 8px 24px rgba(83, 65, 45, 0.06);
}

.quiz-card.correct {
  border-color: rgba(19, 168, 113, 0.35);
  background: linear-gradient(135deg, #ffffff, #f0fbf6);
}

.quiz-card.wrong {
  border-color: rgba(194, 65, 46, 0.28);
  background: linear-gradient(135deg, #ffffff, #fff7f4);
}

.quiz-question span {
  display: inline-flex;
  margin-bottom: 0.5rem;
  color: #d0871d;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.quiz-question h3 {
  font-size: clamp(1.08rem, 2vw, 1.35rem);
}

.quiz-options {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}

.quiz-option {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fffdf9;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.quiz-option:hover {
  transform: translateY(-1px);
  border-color: #cfe4ff;
  background: #f7fbff;
}

.quiz-option b {
  display: grid;
  height: 38px;
  place-items: center;
  border-radius: 13px;
  background: #eef6ff;
  color: var(--blue-dark);
}

.quiz-option span {
  font-weight: 500;
}

.quiz-option.is-correct {
  border-color: rgba(19, 168, 113, 0.4);
  background: #ecfbf4;
}

.quiz-option.is-correct b {
  background: var(--green);
  color: var(--white);
}

.quiz-option.is-wrong {
  border-color: rgba(194, 65, 46, 0.36);
  background: #fff1ee;
}

.quiz-option.is-wrong b {
  background: var(--danger);
  color: var(--white);
}

.quiz-feedback {
  margin: 0.85rem 0 0;
  padding: 0.8rem 0.9rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
}

.quiz-feedback strong {
  color: var(--ink);
}

.result-item {
  display: block;
  padding: 0.85rem 0;
  border-top: 1px solid var(--line);
  text-decoration: none;
}

.result-item:first-of-type {
  border-top: 0;
}

.result-item strong {
  display: block;
  color: var(--ink);
}

.result-item span {
  color: var(--muted);
}

.chapter {
  margin: 1.1rem 0;
  overflow: hidden;
}

.chapter-header {
  padding: clamp(1.4rem, 4vw, 2.4rem);
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at top right, rgba(255, 223, 200, 0.55), transparent 18rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 251, 255, 0.96));
}

.chapter-kicker {
  color: #d0871d;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.chapter-header h2 {
  margin-top: 0.25rem;
}

.complete-btn,
.copy-btn {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.complete-btn {
  padding: 0.62rem 1rem;
  box-shadow: 0 8px 18px rgba(83, 65, 45, 0.06);
}

.complete-btn.done {
  border-color: rgba(21, 149, 106, 0.28);
  background: #e9f8f2;
  color: var(--green);
}

.chapter-body {
  padding: clamp(1.4rem, 4vw, 2.4rem);
}

.lead {
  max-width: 820px;
  margin: 1.25rem 0 1.4rem;
  color: #344054;
  font-size: 1.16rem;
}

body.reader-dark .lead,
body.reader-dark .info-card p,
body.reader-dark .step-card p,
body.reader-dark .warning-card p,
body.reader-dark .visual-card figcaption,
body.reader-dark .quick-start ol,
body.reader-dark .result-item span,
body.reader-dark .quiz-intro p:not(.label),
body.reader-dark .quiz-feedback {
  color: var(--muted);
}

body.reader-dark .chapter,
body.reader-dark .quick-start,
body.reader-dark .sidebar-card,
body.reader-dark .chapter-nav,
body.reader-dark .search-results,
body.reader-dark .quiz-section {
  border-color: var(--line);
  background: rgba(21, 35, 49, 0.9);
}

body.reader-dark .chapter-header {
  background:
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.2), transparent 18rem),
    linear-gradient(180deg, rgba(21, 35, 49, 0.98), rgba(15, 29, 43, 0.96));
}

body.reader-dark .info-card,
body.reader-dark .step-card,
body.reader-dark .warning-card,
body.reader-dark .prompt-card,
body.reader-dark .visual-card,
body.reader-dark .quiz-card,
body.reader-dark .check-item,
body.reader-dark .quiz-option {
  border-color: var(--line);
  background: #172638;
  color: var(--ink);
}

body.reader-dark .chapter-link:hover,
body.reader-dark .chapter-link.active {
  background: rgba(96, 165, 250, 0.17);
  color: var(--ink);
}

body.reader-dark .chapter-link b,
body.reader-dark .quiz-option b,
body.reader-dark .step-card b {
  background: #203955;
  color: #a9d1ff;
}

body.reader-dark .quick-start {
  background:
    linear-gradient(135deg, rgba(21, 35, 49, 0.96), rgba(15, 29, 43, 0.94)),
    var(--white);
}

body.reader-dark .quiz-score,
body.reader-dark .quiz-feedback {
  border-color: var(--line);
  background: rgba(12, 22, 34, 0.72);
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.2rem 0;
}

.info-card,
.step-card,
.warning-card,
.prompt-card,
.visual-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--white);
  box-shadow: 0 8px 24px rgba(83, 65, 45, 0.06);
}

.info-card,
.step-card,
.warning-card,
.visual-card {
  padding: 1rem;
}

.info-card,
.step-card,
.check-item,
.visual-card,
.prompt-card {
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.info-card:hover,
.step-card:hover,
.check-item:hover,
.visual-card:hover,
.prompt-card:hover {
  transform: translateY(-2px);
  border-color: #cfe4ff;
  box-shadow: 0 14px 32px rgba(83, 65, 45, 0.1);
}

.info-card strong,
.step-card strong,
.warning-card strong {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
}

.info-card p,
.step-card p,
.warning-card p {
  margin: 0;
  color: var(--muted);
}

.step-list {
  display: grid;
  gap: 0.8rem;
  margin: 1.2rem 0;
}

.step-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 0.9rem;
  align-items: start;
}

.step-card b {
  display: grid;
  height: 42px;
  place-items: center;
  border-radius: 15px;
  background: linear-gradient(135deg, #dbeafe, #e0f7ff);
  color: var(--blue-dark);
}

.warning-card {
  border-color: rgba(194, 65, 46, 0.24);
  background: #fff7f4;
}

.warning-card strong {
  color: var(--danger);
}

.prompt-card {
  margin: 1rem 0;
  overflow: hidden;
}

.prompt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(135deg, #10233f, #1d4ed8);
  color: var(--white);
}

.prompt-head strong {
  font-size: 0.92rem;
}

.copy-btn {
  padding: 0.5rem 0.7rem;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
}

pre {
  margin: 0;
  padding: 1rem;
  overflow: auto;
  background: #0c1b30;
  color: #f3f8ff;
  font-size: 0.94rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.visual-card img {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: 18px;
  background: #f8fbff;
}

.visual-card figcaption {
  margin-top: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}

.checklist {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 1rem 0;
}

.check-item {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  min-height: 48px;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--white);
  color: #2d3948;
  font-weight: 500;
}

.check-item input {
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 0.2rem;
  accent-color: var(--green);
}

.check-item:has(input:checked) {
  border-color: rgba(19, 168, 113, 0.3);
  background: #f0fbf6;
  color: #126b4c;
}

body.reader-dark .check-item:has(input:checked),
body.reader-dark .quiz-card.correct,
body.reader-dark .quiz-option.is-correct {
  border-color: rgba(70, 214, 155, 0.48);
  background: #12382d;
  color: #dffcf1;
}

body.reader-dark .quiz-card.wrong,
body.reader-dark .quiz-option.is-wrong,
body.reader-dark .warning-card {
  border-color: rgba(255, 154, 141, 0.42);
  background: #3a1f21;
  color: #ffe5e1;
}

.callout-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  margin: 1rem 0;
}

.callout-row span {
  padding: 0.9rem;
  border-radius: 18px;
  background: linear-gradient(135deg, #eaf4ff, #fff5ec);
  color: #1f4c82;
  font-weight: 700;
}

body.reader-dark .callout-row span {
  background: #203955;
  color: #d7ebff;
}

.chapter-completion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  margin-top: 1.2rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(241, 247, 255, 0.72);
}

.chapter-completion span {
  color: var(--muted);
  font-weight: 650;
}

body.reader-dark .chapter-completion {
  border-color: var(--line);
  background: rgba(12, 22, 34, 0.72);
}

.reader-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.4rem clamp(1rem, 3vw, 2rem);
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.78);
}

mark {
  padding: 0 0.12rem;
  border-radius: 4px;
  background: #fff0bd;
  color: var(--ink);
}

@media (min-width: 1180px) {
  .ebook-shell {
    grid-template-columns: 260px minmax(0, 1fr);
    width: min(1360px, 100%);
  }

  .ebook-hero {
    grid-template-columns: minmax(0, 1fr) 360px;
    padding: 3rem;
  }

  h1 {
    max-width: 720px;
    font-size: 3.25rem;
    line-height: 1.08;
  }

  .hero-copy p:not(.label) {
    max-width: 700px;
  }

  .hero-panel {
    padding: 1rem;
  }

  .chapter-body,
  .chapter-header {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

@media (max-width: 1020px) {
  .reader-topbar {
    align-items: flex-start;
    flex-wrap: wrap;
    min-height: auto;
  }

  .reader-brand {
    max-width: calc(100% - 56px);
    min-height: 44px;
  }

  .reader-actions {
    flex: 0 0 100%;
    order: 2;
    justify-content: flex-start;
  }

  .search-box {
    flex: 1 1 260px;
    width: auto;
  }

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

  .ebook-sidebar {
    position: fixed;
    inset: 122px auto 0 0;
    z-index: 25;
    width: min(340px, 88vw);
    max-height: none;
    padding: 1rem;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    background: rgba(248, 250, 252, 0.98);
    box-shadow: var(--shadow);
  }

  body.reader-dark .ebook-sidebar {
    background: rgba(12, 22, 34, 0.98);
  }

  .ebook-sidebar.open {
    transform: translateX(0);
  }

  .icon-button {
    display: inline-grid;
    place-items: center;
  }

  .ebook-hero,
  .quick-start {
    grid-template-columns: 1fr;
  }

  .hero-cover img {
    max-height: 360px;
  }
}

@media (max-width: 760px) {
  .reader-topbar {
    padding: 0.7rem 0.75rem;
    gap: 0.55rem;
  }

  .reader-brand span:last-child {
    display: inline;
    max-width: 58vw;
    font-size: 0.95rem;
  }

  .search-box {
    order: -1;
    flex-basis: 100%;
    width: 100%;
  }

  .reader-actions {
    flex-wrap: wrap;
    gap: 0.45rem;
  }

  .reader-link,
  .reader-tool {
    min-height: 38px;
    padding: 0 0.58rem;
    font-size: 0.82rem;
  }

  .ebook-shell {
    padding: 0.75rem;
  }

  .ebook-hero {
    min-height: auto;
    padding: 1.4rem;
    border-radius: 24px;
  }

  .hero-panel,
  .hero-cover {
    display: none;
  }

  .chapter-header {
    grid-template-columns: 1fr;
  }

  .chapter-completion {
    align-items: stretch;
    flex-direction: column;
  }

  .chapter-completion .complete-btn {
    width: 100%;
  }

  .content-grid,
  .checklist,
  .callout-row {
    grid-template-columns: 1fr;
  }

  .step-card {
    grid-template-columns: 34px minmax(0, 1fr);
  }
}
