:root {
  --ink: #102c34;
  --muted: #62777d;
  --teal: #00546f;
  --teal-deep: #003948;
  --paper: #f4f7f6;
  --line: #dce5e4;
  --white: #fff;
  --shadow: 0 18px 50px rgba(5, 57, 70, .1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 105px; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
}
button, input, select { font: inherit; }
a { color: inherit; }

.reader-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 78px;
  padding: 12px max(22px, calc((100% - 1220px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(14px);
}
.reader-brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 12px;
  color: white;
  background: var(--teal);
  font: 800 24px/1 "Noto Sans SC", sans-serif;
}
.reader-brand strong, .reader-brand small { display: block; line-height: 1.2; }
.reader-brand strong { font-size: 16px; }
.reader-brand small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.reader-controls { display: flex; align-items: center; gap: 12px; }
.level-picker { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; font-weight: 800; }
.level-picker select {
  min-height: 42px;
  padding: 7px 34px 7px 12px;
  border: 1px solid #cbd9da;
  border-radius: 10px;
  color: var(--ink);
  background: white;
  font-weight: 800;
}
.download-button {
  min-height: 42px;
  padding: 9px 15px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  color: white;
  background: var(--ink);
  font-size: 13px;
  font-weight: 850;
  text-decoration: none;
}

main { width: min(1220px, calc(100% - 40px)); margin: 0 auto; }
.reader-intro { padding: 58px 0 34px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 9px; color: var(--teal); font-size: 12px; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(34px, 5vw, 58px); line-height: 1.05; letter-spacing: -.045em; }
.reader-intro > p:last-child { margin: 14px 0 0; color: var(--muted); font-size: 17px; }
.loading-state { padding: 80px 0; color: var(--muted); text-align: center; }

.reader-layout { padding: 38px 0 90px; display: grid; grid-template-columns: 268px minmax(0, 1fr); gap: 38px; align-items: start; }
.reader-sidebar {
  position: sticky;
  top: 104px;
  max-height: calc(100vh - 126px);
  padding: 20px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
}
.back-link { display: inline-block; margin-bottom: 22px; color: var(--teal); font-size: 13px; font-weight: 850; text-decoration: none; }
.search-box > span:first-child { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 850; }
.search-input-wrap { position: relative; display: block; }
.search-input-wrap svg { position: absolute; left: 11px; top: 50%; width: 18px; transform: translateY(-50%); fill: none; stroke: #6c7e82; stroke-width: 2; }
.search-input-wrap input { width: 100%; height: 43px; padding: 8px 10px 8px 37px; border: 1px solid #cad7d8; border-radius: 11px; outline: none; }
.search-input-wrap input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0, 84, 111, .1); }
.search-status { min-height: 20px; margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.book-toc { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.book-toc > p { margin: 0 0 10px; font-size: 12px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.book-toc ol { margin: 0; padding: 0; list-style: none; }
.book-toc li + li { margin-top: 3px; }
.book-toc a { display: block; padding: 7px 9px; border-radius: 8px; color: #4c6268; font-size: 12px; line-height: 1.4; text-decoration: none; }
.book-toc a:hover, .book-toc a:focus-visible { color: var(--teal); background: #edf6f6; }

.book-page { min-width: 0; padding: clamp(24px, 5vw, 62px); border: 1px solid var(--line); border-radius: 22px; background: white; box-shadow: var(--shadow); }
.book-cover { margin: calc(clamp(24px, 5vw, 62px) * -1) calc(clamp(24px, 5vw, 62px) * -1) 54px; padding: clamp(36px, 6vw, 72px) clamp(24px, 5vw, 62px); color: white; border-radius: 22px 22px 0 0; background: var(--teal); }
.book-cover small { display: block; color: #9ee8f7; font-size: 12px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.book-cover h2 { max-width: 700px; margin: 18px 0 0; font-size: clamp(38px, 6vw, 68px); line-height: 1; letter-spacing: -.05em; }
.book-cover p { max-width: 720px; margin: 19px 0 0; color: rgba(255,255,255,.78); }

.content-block { scroll-margin-top: 105px; }
.book-page h2.content-block { margin: 62px 0 22px; padding-top: 30px; border-top: 2px solid var(--ink); font-size: clamp(26px, 3.6vw, 38px); line-height: 1.2; letter-spacing: -.03em; }
.book-page h2.content-block:first-child { margin-top: 0; }
.book-page h3.content-block { margin: 34px 0 14px; color: var(--teal); font-size: 21px; line-height: 1.3; }
.book-page p.content-block { margin: 0 0 15px; white-space: pre-wrap; }
.table-wrap { max-width: 100%; margin: 24px 0 32px; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { min-width: 120px; padding: 11px 13px; text-align: left; vertical-align: top; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); white-space: pre-wrap; }
th:last-child, td:last-child { border-right: 0; }
tr:last-child td { border-bottom: 0; }
th { color: var(--teal-deep); background: #eaf3f3; font-weight: 850; }
tbody tr:nth-child(even) { background: #fafcfc; }
.answer-vault { margin-top: 56px; border: 1px solid #bed1d3; border-radius: 16px; background: #f5f9f9; }
.answer-vault summary { padding: 20px 22px; color: var(--teal); cursor: pointer; font-weight: 900; }
.answer-vault-body { padding: 0 24px 28px; }
.answer-vault-body h2.content-block { margin-top: 30px; }
.content-block[hidden] { display: none !important; }
.no-results { margin: 50px 0; padding: 22px; border-radius: 12px; color: var(--muted); background: var(--paper); text-align: center; }
mark { padding: 0 .08em; background: #ffe3a3; }

footer { padding: 24px; color: var(--muted); background: white; text-align: center; font-size: 13px; }

@media (max-width: 850px) {
  .reader-header { position: static; align-items: flex-start; }
  .reader-controls { align-items: stretch; }
  .level-picker { display: grid; gap: 2px; }
  .reader-layout { grid-template-columns: 1fr; }
  .reader-sidebar { position: static; max-height: none; }
  .book-toc ol { columns: 2; column-gap: 12px; }
  html { scroll-padding-top: 20px; }
  .content-block { scroll-margin-top: 20px; }
}

@media (max-width: 560px) {
  .reader-header { padding: 12px 16px; flex-direction: column; }
  .reader-brand strong { font-size:15px; }
  .reader-controls { width: 100%; justify-content: space-between; gap:7px; }
  .reader-controls>* { min-width:0; }
  .level-picker span { display: none; }
  .level-picker select { max-width:110px; }
  .download-button { padding-inline:10px; font-size:12px; }
  main { width: min(100% - 24px, 1220px); }
  .reader-intro { padding-top:24px; }
  .reader-intro h1 { font-size:32px; }
  .reader-layout { padding-top:18px; gap:16px; }
  .reader-sidebar { padding:16px; }
  .book-toc ol { max-height:180px; overflow-y:auto; }
  .book-page { padding: 22px 16px 38px; border-radius: 16px; }
  .book-cover { margin: -22px -16px 38px; padding: 38px 22px; border-radius: 16px 16px 0 0; }
  .book-toc ol { columns: 1; }
  .book-page h2.content-block { margin-top: 44px; }
  th, td { min-width: 110px; padding: 9px 10px; font-size: 13px; }
}
