:root {
  color-scheme: light;
  --navy-950: #101820;
  --navy-900: #17212b;
  --navy-800: #24323e;
  --ink: #242a30;
  --ink-soft: #5f6467;
  --paper: #fffdf8;
  --paper-deep: #f4ecdd;
  --paper-muted: #ece2d1;
  --line: rgba(43, 49, 53, .14);
  --accent: #8b473d;
  --accent-bright: #a9584b;
  --brass: #9f7b42;
  --success: #506c5d;
  --warning: #a76536;
  --shadow: 0 26px 70px rgba(28, 29, 27, .16), 0 2px 8px rgba(28, 29, 27, .08);
  --page-font-size: 18px;
  --page-line-height: 1.72;
  --reading-font: Georgia, "Times New Roman", serif;
  --ui-font: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  --topbar-height: 68px;
  --left-rail: 258px;
  --right-rail: 282px;
}

html[data-theme="sepia"] {
  --paper: #f7eedf;
  --paper-deep: #e8d8bd;
  --paper-muted: #ddcbae;
  --ink: #392f27;
  --ink-soft: #74675a;
  --line: rgba(72, 54, 39, .16);
  --accent: #8b4d39;
}

html[data-theme="night"] {
  color-scheme: dark;
  --navy-950: #090e12;
  --navy-900: #10171e;
  --navy-800: #1a252f;
  --ink: #e8e1d5;
  --ink-soft: #a8a39a;
  --paper: #171b1d;
  --paper-deep: #101416;
  --paper-muted: #22282b;
  --line: rgba(231, 224, 212, .13);
  --accent: #ca7868;
  --accent-bright: #dc8c7c;
  --brass: #c4a36c;
  --success: #87a894;
  --shadow: 0 28px 80px rgba(0, 0, 0, .42), 0 2px 9px rgba(0, 0, 0, .34);
}

html[data-font="sans"] { --reading-font: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--paper-deep);
  font-family: var(--ui-font);
  text-rendering: optimizeLegibility;
}

button, input, textarea { font: inherit; }
button { color: inherit; }
button, [role="button"] { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 78%, white);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 10px;
  left: 10px;
  transform: translateY(-150%);
  padding: 11px 16px;
  color: white;
  background: var(--accent);
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus { transform: translateY(0); }

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.ambient {
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .22;
  pointer-events: none;
}
.ambient--one { width: 420px; height: 420px; top: 18%; left: 26%; background: #c99a69; }
.ambient--two { width: 520px; height: 520px; right: 5%; bottom: -14%; background: #6d8790; opacity: .13; }

.app-shell {
  display: grid;
  grid-template: var(--topbar-height) minmax(0, 1fr) / var(--left-rail) minmax(0, 1fr) var(--right-rail);
  min-height: 100vh;
}

.topbar {
  position: sticky;
  z-index: 50;
  top: 0;
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(0, 1.5fr) minmax(240px, 1fr);
  align-items: center;
  height: var(--topbar-height);
  padding: 0 18px 0 16px;
  color: #f7f3eb;
  background: color-mix(in srgb, var(--navy-900) 94%, transparent);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  backdrop-filter: blur(18px);
}
.topbar__start, .topbar__actions { display: flex; align-items: center; gap: 8px; }
.topbar__actions { justify-content: flex-end; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 0;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
}
.brand__mark {
  display: grid;
  width: 36px;
  height: 42px;
  place-items: center;
  color: #f7efe2;
  border: 1px solid rgba(255, 255, 255, .34);
  border-radius: 3px 7px 7px 3px;
  box-shadow: inset 3px 0 rgba(255, 255, 255, .08);
  font-family: Georgia, serif;
  font-size: 12px;
  letter-spacing: .08em;
}
.brand__type { display: grid; line-height: 1.05; }
.brand__type strong { font-family: Georgia, serif; font-size: 17px; font-weight: 600; letter-spacing: .01em; }
.brand__type small { margin-top: 5px; color: rgba(255, 255, 255, .58); font-size: 10px; letter-spacing: .11em; text-transform: uppercase; }

.location {
  min-width: 0;
  padding: 0 20px;
  color: rgba(255, 255, 255, .64);
  font-size: 12px;
  letter-spacing: .09em;
  text-align: center;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
}

.icon-button,
.action-button,
.quiet-button,
.tool-button,
.primary-button,
.secondary-button,
.danger-button {
  min-height: 42px;
  border: 0;
  cursor: pointer;
}
.icon-button {
  display: inline-grid;
  width: 42px;
  min-width: 42px;
  place-items: center;
  color: inherit;
  background: transparent;
  border-radius: 10px;
}
.icon-button:hover { background: rgba(255, 255, 255, .08); }
.action-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 12px;
  color: rgba(255, 255, 255, .82);
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 10px;
  font-size: 13px;
}
.action-button:hover { background: rgba(255, 255, 255, .12); }
kbd {
  display: inline-grid;
  min-width: 22px;
  min-height: 22px;
  padding: 0 5px;
  place-items: center;
  color: inherit;
  background: rgba(127, 127, 127, .1);
  border: 1px solid currentColor;
  border-color: color-mix(in srgb, currentColor 20%, transparent);
  border-radius: 5px;
  box-shadow: 0 1px 0 color-mix(in srgb, currentColor 16%, transparent);
  font-family: var(--ui-font);
  font-size: 10px;
  line-height: 1;
}
.action-button kbd { color: rgba(255, 255, 255, .48); }

.library-rail,
.study-rail {
  position: sticky;
  top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  overflow: auto;
  scrollbar-width: thin;
}

.library-rail {
  z-index: 20;
  grid-column: 1;
  display: flex;
  flex-direction: column;
  padding: 25px 18px 18px;
  color: #e9e6df;
  background: var(--navy-900);
  border-right: 1px solid rgba(255, 255, 255, .06);
}
.rail-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 0 8px 18px; }
.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .17em;
  line-height: 1.25;
  text-transform: uppercase;
}
.library-rail .eyebrow { color: #c6a875; }
.rail-head h2 { margin: 0; font-family: Georgia, serif; font-size: 23px; font-weight: 500; }

.chapter-nav { display: grid; gap: 5px; }
.chapter-item { display: grid; }
.chapter-link {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 8px 8px 8px 7px;
  color: rgba(255, 255, 255, .74);
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
}
.chapter-link:hover { color: white; background: rgba(255, 255, 255, .055); }
.chapter-link[aria-current="true"] { color: white; background: rgba(255, 255, 255, .09); }
.chapter-link[aria-current="true"]::before {
  content: "";
  position: absolute;
  top: 11px;
  bottom: 11px;
  left: -3px;
  width: 3px;
  background: var(--subject-accent, #c6a875);
  border-radius: 4px;
}
.chapter-number {
  display: grid;
  width: 30px;
  height: 37px;
  place-items: center;
  color: var(--subject-accent, #c6a875);
  background: color-mix(in srgb, var(--subject-accent, #c6a875) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--subject-accent, #c6a875) 28%, transparent);
  border-radius: 3px 6px 6px 3px;
  font-family: Georgia, serif;
  font-size: 12px;
}
.chapter-label { min-width: 0; }
.chapter-label strong { display: block; font-size: 12px; font-weight: 650; line-height: 1.3; }
.chapter-label small { display: block; margin-top: 4px; color: rgba(255, 255, 255, .38); font-size: 10px; }
.chapter-state { width: 7px; height: 7px; background: rgba(255, 255, 255, .18); border-radius: 50%; }
.chapter-state.is-started { background: var(--subject-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--subject-accent) 18%, transparent); }
.chapter-pages {
  display: none;
  position: relative;
  max-height: 280px;
  margin: 2px 0 8px 22px;
  padding: 3px 0 5px 24px;
  overflow: auto;
  border-left: 1px solid rgba(255, 255, 255, .1);
}
.chapter-item.is-open .chapter-pages { display: grid; }
.folio-link {
  display: block;
  padding: 7px 8px;
  color: rgba(255, 255, 255, .48);
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-size: 10.5px;
  line-height: 1.35;
  text-align: left;
}
.folio-link:hover { color: white; }
.folio-link[aria-current="page"] { color: white; background: rgba(255, 255, 255, .08); }

.rail-foot { margin-top: auto; padding: 18px 8px 0; }
.overall-progress { display: grid; gap: 8px; color: rgba(255, 255, 255, .52); font-size: 11px; }
.overall-progress strong { color: white; font-size: 16px; }
.progress-track { height: 3px; overflow: hidden; background: color-mix(in srgb, var(--ink) 12%, transparent); border-radius: 10px; }
.progress-track i { display: block; width: 0; height: 100%; background: var(--accent); border-radius: inherit; transition: width .35s ease; }
.library-rail .progress-track { background: rgba(255, 255, 255, .1); }
.library-rail .progress-track i { background: #c6a875; }
.quiet-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
}
.quiet-button:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 4%, transparent); }
.quiet-button svg { width: 16px; }
.rail-foot .quiet-button { width: 100%; margin-top: 16px; color: rgba(255, 255, 255, .52); border-color: rgba(255, 255, 255, .1); }
.rail-foot .quiet-button:hover { color: white; background: rgba(255, 255, 255, .06); }

.main-content { grid-column: 2; min-width: 0; min-height: calc(100vh - var(--topbar-height)); }

.study-rail {
  grid-column: 3;
  padding: 28px 22px;
  background: color-mix(in srgb, var(--paper-deep) 90%, transparent);
  border-left: 1px solid var(--line);
}
.study-card {
  margin-bottom: 15px;
  padding: 18px;
  background: color-mix(in srgb, var(--paper) 68%, transparent);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.study-card__head { display: flex; justify-content: space-between; align-items: center; }
.study-card__head .eyebrow { margin: 0; }
.study-card__head > span { color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.study-card h2 { margin: 14px 0 15px; font-family: Georgia, serif; font-size: 19px; line-height: 1.25; }
.study-card > p:last-child { margin: 11px 0 0; color: var(--ink-soft); font-size: 11px; line-height: 1.5; }
.folio-outline { display: grid; gap: 2px; }
.folio-outline a {
  display: block;
  padding: 7px 8px;
  color: var(--ink-soft);
  border-left: 2px solid transparent;
  font-family: var(--reading-font);
  font-size: 12px;
  line-height: 1.35;
  text-decoration: none;
}
.folio-outline a:hover { color: var(--ink); border-color: var(--accent); }
.folio-outline a[data-level="3"] { padding-left: 17px; font-size: 11px; }
.study-card--prompt { background: color-mix(in srgb, var(--accent) 6%, var(--paper)); }
.prompt-icon { display: grid; width: 34px; height: 34px; margin-bottom: 18px; place-items: center; color: var(--accent); background: color-mix(in srgb, var(--accent) 11%, transparent); border-radius: 50%; }
.prompt-icon svg { width: 17px; }
.study-card--prompt h2 { margin-bottom: 9px; }
.study-card--prompt .quiet-button { width: 100%; margin-top: 16px; color: var(--accent); border-color: color-mix(in srgb, var(--accent) 28%, transparent); }
.keyboard-card { padding: 13px 5px; color: var(--ink-soft); font-size: 10px; }
.keyboard-card p { display: flex; align-items: center; gap: 5px; margin: 7px 0; }

.home-view { padding: clamp(34px, 6vw, 82px) clamp(28px, 6vw, 88px) 70px; }
.home-hero { display: grid; grid-template-columns: minmax(270px, 390px) minmax(340px, 1fr); gap: clamp(42px, 7vw, 108px); align-items: center; max-width: 1080px; margin: 0 auto; }
.cover-wrap { position: relative; width: min(100%, 360px); aspect-ratio: .72; margin: 0 auto; perspective: 1300px; }
.cover-pages { position: absolute; inset: 10px 0 8px 14px; background: #e5d8c3; border-radius: 2px 12px 12px 2px; box-shadow: 0 14px 28px rgba(34, 29, 23, .12); }
.cover-pages::after { content: ""; position: absolute; inset: 6px 5px; border-top: 1px solid rgba(70, 58, 42, .12); border-bottom: 1px solid rgba(70, 58, 42, .1); }
.cover-pages--back { transform: translate(12px, 3px) rotate(1.8deg); opacity: .58; animation: cover-breathe 8s ease-in-out infinite; }
.cover-pages--middle { transform: translate(6px, 1px) rotate(.8deg); opacity: .85; animation: cover-breathe 8s 1.2s ease-in-out infinite reverse; }
.book-cover {
  position: absolute;
  inset: 0 14px 0 0;
  display: flex;
  flex-direction: column;
  padding: clamp(28px, 4vw, 46px);
  color: #f4eadc;
  background:
    radial-gradient(circle at 22% 10%, rgba(255,255,255,.10), transparent 26%),
    linear-gradient(145deg, #253743, #17252f 66%, #101d25);
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 3px 12px 12px 3px;
  box-shadow: -6px 2px 0 #6f3f36, -9px 3px 0 #422a27, 0 34px 70px rgba(37, 34, 29, .29);
  transform: rotateY(-4deg) rotateZ(-.7deg);
  transform-origin: left center;
}
.book-cover::before { content: ""; position: absolute; top: 0; bottom: 0; left: 13px; width: 1px; background: rgba(255,255,255,.14); box-shadow: 3px 0 rgba(0,0,0,.14); }
.cover-rule { width: 42px; height: 2px; margin-bottom: 24px; background: #bd9260; }
.book-cover > p { margin: 0; color: rgba(255,255,255,.64); font-size: clamp(9px, 1.1vw, 11px); letter-spacing: .16em; line-height: 1.55; text-transform: uppercase; }
.cover-title { display: grid; margin: clamp(35px, 7vw, 64px) 0 18px; font-family: Georgia, serif; font-size: clamp(49px, 6vw, 76px); line-height: .78; letter-spacing: -.05em; }
.cover-title span { font-size: .48em; font-style: italic; font-weight: 400; letter-spacing: -.01em; }
.cover-title strong { font-weight: 500; }
.book-cover .cover-subtitle { max-width: 230px; color: rgba(255,255,255,.67); font-family: Georgia, serif; font-size: clamp(11px, 1.4vw, 14px); font-style: italic; letter-spacing: .01em; line-height: 1.55; text-transform: none; }
.cover-seal { display: grid; width: 64px; height: 64px; margin-top: auto; place-content: center; color: #d7b47a; border: 1px solid rgba(215,180,122,.55); border-radius: 50%; text-align: center; }
.cover-seal span { font-family: Georgia, serif; font-size: 20px; }
.cover-seal small { font-size: 7px; letter-spacing: .18em; }
.cover-bottom { position: absolute; right: 35px; bottom: 34px; color: rgba(255,255,255,.43); font-size: 8px; letter-spacing: .17em; text-transform: uppercase; }
@keyframes cover-breathe { 0%,100% { opacity: .56; transform: translate(12px,3px) rotate(1.8deg); } 50% { opacity: .78; transform: translate(15px,1px) rotate(2.2deg); } }

.hero-copy { max-width: 610px; }
.hero-copy .eyebrow { margin-bottom: 18px; }
.hero-copy h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(48px, 6vw, 78px); font-weight: 500; letter-spacing: -.05em; line-height: .96; }
.hero-copy h1 em { color: var(--accent); font-weight: 400; }
.hero-lede { max-width: 650px; margin: 28px 0 30px; color: var(--ink-soft); font-family: var(--reading-font); font-size: 18px; line-height: 1.68; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 19px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 750;
}
.primary-button { color: #fff9f2; background: var(--accent); box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 22%, transparent); }
.primary-button:hover { background: var(--accent-bright); transform: translateY(-1px); }
.primary-button svg { width: 17px; }
.secondary-button { color: var(--ink); background: transparent; border: 1px solid var(--line); }
.secondary-button:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.danger-button { color: #a64c44; background: transparent; }
.danger-button:hover { background: rgba(166,76,68,.08); }
.book-facts { display: flex; gap: 0; margin: 40px 0 0; }
.book-facts div { min-width: 100px; padding: 0 24px; border-left: 1px solid var(--line); }
.book-facts div:first-child { padding-left: 0; border-left: 0; }
.book-facts dt { font-family: Georgia, serif; font-size: 22px; font-weight: 600; }
.book-facts dd { margin: 4px 0 0; color: var(--ink-soft); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; }

.subject-section { max-width: 1080px; margin: 100px auto 0; }
.section-heading { display: flex; gap: 40px; align-items: flex-end; justify-content: space-between; margin-bottom: 27px; }
.section-heading h2 { margin: 0; font-family: Georgia, serif; font-size: clamp(31px, 4vw, 43px); font-weight: 500; letter-spacing: -.03em; }
.section-heading > p { max-width: 370px; margin: 0; color: var(--ink-soft); font-family: var(--reading-font); font-size: 14px; line-height: 1.55; }
.subject-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.subject-card {
  --subject-accent: var(--accent);
  position: relative;
  display: grid;
  grid-template-columns: 54px minmax(0,1fr) auto;
  gap: 15px;
  align-items: center;
  min-height: 118px;
  padding: 18px 18px 18px 15px;
  color: var(--ink);
  background: color-mix(in srgb, var(--paper) 74%, transparent);
  border: 1px solid var(--line);
  border-radius: 13px;
  cursor: pointer;
  text-align: left;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.subject-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--subject-accent) 38%, var(--line)); box-shadow: 0 13px 34px rgba(40,35,29,.08); }
.subject-card__tab { display: grid; width: 48px; height: 62px; place-content: center; color: var(--subject-accent); background: color-mix(in srgb, var(--subject-accent) 11%, var(--paper)); border: 1px solid color-mix(in srgb, var(--subject-accent) 24%, transparent); border-radius: 3px 8px 8px 3px; font-family: Georgia, serif; font-size: 14px; }
.subject-card__copy small { display: block; margin-bottom: 5px; color: var(--subject-accent); font-size: 9px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.subject-card__copy strong { display: block; font-family: Georgia, serif; font-size: 18px; font-weight: 550; line-height: 1.23; }
.subject-card__copy span { display: block; margin-top: 7px; color: var(--ink-soft); font-size: 10px; }
.subject-card__progress { display: grid; justify-items: end; gap: 8px; color: var(--ink-soft); font-size: 10px; }
.subject-card__progress i { display: block; width: 46px; height: 2px; background: var(--line); }
.subject-card__progress i::after { content: ""; display: block; width: var(--progress, 0%); height: 100%; background: var(--subject-accent); }
.method-strip { display: grid; grid-template-columns: repeat(3,1fr); max-width: 1080px; margin: 70px auto 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.method-strip article { display: grid; grid-template-columns: 35px 1fr; gap: 13px; padding: 30px 24px; border-left: 1px solid var(--line); }
.method-strip article:first-child { border-left: 0; padding-left: 0; }
.method-strip article:last-child { padding-right: 0; }
.method-strip article > span { color: var(--accent); font-family: Georgia, serif; font-size: 12px; }
.method-strip h3 { margin: 0 0 8px; font-family: Georgia, serif; font-size: 16px; font-weight: 600; }
.method-strip p { margin: 0; color: var(--ink-soft); font-family: var(--reading-font); font-size: 12px; line-height: 1.55; }

.reader-view { --accent: var(--chapter-accent, #8f3944); min-height: calc(100vh - var(--topbar-height)); }
.reader-toolbar {
  position: sticky;
  z-index: 12;
  top: var(--topbar-height);
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 28px;
  background: color-mix(in srgb, var(--paper-deep) 91%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.reader-breadcrumb { min-width: 0; color: var(--ink-soft); font-size: 11px; letter-spacing: .04em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-breadcrumb strong { color: var(--ink); }
.reader-toolbar__actions { display: flex; gap: 4px; }
.tool-button { display: inline-flex; align-items: center; gap: 6px; padding: 0 9px; color: var(--ink-soft); background: transparent; border-radius: 9px; font-size: 11px; font-weight: 700; }
.tool-button svg { width: 16px; height: 16px; }
.tool-button:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 5%, transparent); }
.tool-button.is-active { color: var(--accent); }
.tool-button--accent { color: var(--accent); }

.page-stage {
  display: grid;
  grid-template-columns: minmax(54px, 1fr) minmax(420px, 760px) minmax(54px, 1fr);
  gap: clamp(12px, 2.2vw, 32px);
  align-items: start;
  min-height: calc(100vh - var(--topbar-height) - 58px);
  padding: clamp(26px, 4vw, 52px) 18px 70px;
}
.page-frame { position: relative; grid-column: 2; min-width: 0; }
.page-frame::before, .page-frame::after { content: ""; position: absolute; z-index: -1; inset: 6px -5px -6px 5px; background: var(--paper); border: 1px solid var(--line); border-radius: 2px 10px 10px 2px; opacity: .58; }
.page-frame::after { inset: 12px -9px -11px 10px; opacity: .28; }
.book-page {
  position: relative;
  min-height: 74vh;
  padding: clamp(38px, 7vw, 78px) clamp(30px, 8vw, 86px) 45px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--ink) 2.5%, transparent), transparent 8%),
    var(--paper);
  border: 1px solid var(--line);
  border-radius: 2px 9px 9px 2px;
  box-shadow: var(--shadow);
  transform-origin: center;
  transition: opacity .18s ease, transform .26s cubic-bezier(.2,.7,.2,1), filter .18s ease;
  will-change: opacity, transform;
}
.page-frame.is-leaving .book-page { opacity: 0; filter: blur(2px); }
.page-frame.is-leaving[data-direction="next"] .book-page { transform: translateX(-9px) scale(.995); }
.page-frame.is-leaving[data-direction="prev"] .book-page { transform: translateX(9px) scale(.995); }
.page-frame.is-entering[data-direction="next"] .book-page { animation: page-in-next .29s cubic-bezier(.2,.72,.2,1); }
.page-frame.is-entering[data-direction="prev"] .book-page { animation: page-in-prev .29s cubic-bezier(.2,.72,.2,1); }
@keyframes page-in-next { from { opacity: 0; transform: translateX(9px) scale(.995); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes page-in-prev { from { opacity: 0; transform: translateX(-9px) scale(.995); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }
.folio-meta, .folio-footer { display: flex; align-items: center; justify-content: space-between; color: var(--ink-soft); font-family: var(--ui-font); font-size: 9px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; }
.folio-meta { margin-bottom: 33px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.folio-footer { margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--line); }
.folio-glyph { color: var(--accent); font-family: Georgia, serif; font-size: 10px; letter-spacing: .05em; }
.page-content { font-family: var(--reading-font); font-size: var(--page-font-size); line-height: var(--page-line-height); }
.page-content > :first-child { margin-top: 0; }
.page-content h1, .page-content h2, .page-content h3, .page-content h4, .page-content h5, .page-content h6 { color: var(--ink); text-wrap: balance; scroll-margin-top: 140px; }
.page-content h1 { margin: 0 0 16px; font-size: clamp(33px, 5vw, 48px); font-weight: 500; letter-spacing: -.035em; line-height: 1.08; }
.page-content h2 { margin: 2em 0 .75em; font-size: 1.63em; font-weight: 550; letter-spacing: -.025em; line-height: 1.18; }
.page-content h3 { margin: 1.75em 0 .55em; color: var(--accent); font-size: 1.14em; font-weight: 700; line-height: 1.3; }
.page-content h4 { margin: 1.5em 0 .5em; font-size: 1em; }
.page-content h5, .page-content h6 { margin: 1.4em 0 .45em; font-size: .9em; letter-spacing: .05em; text-transform: uppercase; }
.page-content p { margin: 0 0 1.18em; hanging-punctuation: first last; }
.page-content strong { font-weight: 700; }
.page-content em { color: color-mix(in srgb, var(--ink) 86%, var(--accent)); }
.page-content code { padding: .08em .28em; background: var(--paper-muted); border-radius: 4px; font-family: ui-monospace, monospace; font-size: .86em; }
.page-content hr { width: 54px; height: 2px; margin: 2.4em auto; background: var(--accent); border: 0; opacity: .5; }
.callout { position: relative; margin: 1.65em 0; padding: 18px 20px 18px 22px; background: color-mix(in srgb, var(--accent) 5%, var(--paper)); border: 1px solid color-mix(in srgb, var(--accent) 17%, var(--line)); border-left: 3px solid var(--accent); border-radius: 3px 9px 9px 3px; }
.callout p { margin: 0; }
.callout--hypo { background: color-mix(in srgb, var(--brass) 7%, var(--paper)); border-color: color-mix(in srgb, var(--brass) 19%, var(--line)); border-left-color: var(--brass); }
.callout--warning { background: color-mix(in srgb, var(--warning) 7%, var(--paper)); border-color: color-mix(in srgb, var(--warning) 21%, var(--line)); border-left-color: var(--warning); }
.callout--rule { background: color-mix(in srgb, var(--success) 7%, var(--paper)); border-color: color-mix(in srgb, var(--success) 20%, var(--line)); border-left-color: var(--success); }
.attack-path { margin: 1.8em 0; padding: 17px 20px; background: var(--navy-900); border-radius: 9px; color: #f4eee4; box-shadow: 0 10px 28px rgba(20,27,33,.14); }
.attack-path > span { display: block; margin-bottom: 9px; color: #d1ad75; font-family: var(--ui-font); font-size: 9px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.attack-path p { margin: 0; line-height: 1.6; }
.table-wrap { max-width: 100%; margin: 1.6em 0; overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.table-wrap:focus { outline-offset: 2px; }
.page-content table { width: 100%; min-width: 430px; border-collapse: collapse; font-family: var(--ui-font); font-size: .78em; line-height: 1.45; }
.page-content th, .page-content td { padding: 11px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.page-content th { background: var(--paper-muted); color: var(--ink); font-size: .86em; letter-spacing: .04em; text-transform: uppercase; }
.page-content .align-right { text-align: right; font-variant-numeric: tabular-nums; }
.page-content .align-center { text-align: center; }
.page-content tr:last-child td { border-bottom: 0; }

.page-turn {
  position: sticky;
  top: calc(var(--topbar-height) + 58px + 38vh);
  display: inline-flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  min-height: 48px;
  padding: 0 10px;
  color: var(--ink-soft);
  background: color-mix(in srgb, var(--paper) 55%, transparent);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  font-size: 10px;
  backdrop-filter: blur(8px);
}
.page-turn:hover:not(:disabled) { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 28%, var(--line)); }
.page-turn:disabled { opacity: .25; cursor: default; }
.page-turn--prev { grid-column: 1; justify-self: end; }
.page-turn--next { grid-column: 3; justify-self: start; }
.page-turn svg { width: 15px; }
.mobile-page-nav { display: none; }

.mobile-only { display: none; }
.scrim { position: fixed; z-index: 70; inset: var(--topbar-height) 0 0; background: rgba(5,10,14,.48); backdrop-filter: blur(2px); }

.modal {
  width: min(760px, calc(100vw - 30px));
  max-height: min(82vh, 760px);
  padding: 0;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 30px 100px rgba(0,0,0,.35);
}
.modal::backdrop { background: rgba(9,14,18,.62); backdrop-filter: blur(6px); }
.modal-shell { display: flex; flex-direction: column; max-height: inherit; padding: 25px; }
.modal-shell--compact { max-width: 540px; margin: 0 auto; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.modal-head h2 { margin: 0; font-family: Georgia, serif; font-size: 28px; font-weight: 550; }
.modal-head .icon-button { color: var(--ink-soft); }
.modal-head .icon-button:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.search-field { display: flex; align-items: center; gap: 10px; padding: 0 13px; border: 1px solid var(--line); border-radius: 11px; }
.search-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent); }
.search-field svg { flex: 0 0 auto; color: var(--ink-soft); }
.search-field input { width: 100%; min-height: 52px; color: var(--ink); background: transparent; border: 0; outline: 0; }
.search-field kbd { color: var(--ink-soft); }
.search-status { padding: 14px 2px 10px; color: var(--ink-soft); font-size: 11px; }
.search-results { display: grid; gap: 7px; overflow: auto; }
.search-result { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; padding: 15px; color: var(--ink); background: transparent; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; text-align: left; }
.search-result:hover, .search-result:focus-visible { background: color-mix(in srgb, var(--accent) 5%, var(--paper)); border-color: color-mix(in srgb, var(--accent) 28%, var(--line)); }
.search-result small { display: block; margin-bottom: 5px; color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.search-result strong { display: block; margin-bottom: 7px; font-family: Georgia, serif; font-size: 16px; }
.search-result p { margin: 0; color: var(--ink-soft); font-family: var(--reading-font); font-size: 12px; line-height: 1.45; }
.search-result > span { color: var(--ink-soft); font-size: 10px; }
.search-result mark { color: inherit; background: color-mix(in srgb, var(--brass) 38%, transparent); border-radius: 2px; }

.settings-modal { width: min(590px, calc(100vw - 30px)); }
fieldset { margin: 0 0 22px; padding: 0; border: 0; }
legend { margin-bottom: 10px; color: var(--ink-soft); font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.segmented { display: grid; grid-template-columns: repeat(3,1fr); padding: 4px; background: var(--paper-deep); border-radius: 10px; }
.segmented button { min-height: 40px; color: var(--ink-soft); background: transparent; border: 0; border-radius: 7px; cursor: pointer; font-size: 12px; }
.segmented button[aria-pressed="true"] { color: var(--ink); background: var(--paper); box-shadow: 0 2px 9px rgba(0,0,0,.08); font-weight: 700; }
#font-options { grid-template-columns: repeat(2,1fr); }
.size-control { display: grid; grid-template-columns: 55px 1fr 55px; gap: 7px; }
.size-control button { min-height: 42px; color: var(--ink); background: var(--paper-deep); border: 0; border-radius: 8px; cursor: pointer; }
.size-control output { display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.privacy-note { margin: 2px 0 0; padding-top: 18px; color: var(--ink-soft); border-top: 1px solid var(--line); font-size: 11px; line-height: 1.5; }

.recall-modal { width: min(680px, calc(100vw - 30px)); }
.recall-prompt { display: grid; min-height: 170px; padding: 30px; place-content: center; color: var(--ink); background: color-mix(in srgb, var(--accent) 6%, var(--paper-deep)); border: 1px solid color-mix(in srgb, var(--accent) 14%, var(--line)); border-radius: 12px; font-family: Georgia, serif; font-size: clamp(23px,4vw,32px); line-height: 1.25; text-align: center; text-wrap: balance; }
.recall-prompt::before { content: "RETRIEVE BEFORE READING"; margin-bottom: 14px; color: var(--accent); font-family: var(--ui-font); font-size: 9px; font-weight: 800; letter-spacing: .16em; }
.recall-answer { max-height: 300px; margin-top: 14px; padding: 22px; overflow: auto; background: var(--paper-deep); border-radius: 10px; font-family: var(--reading-font); font-size: 15px; line-height: 1.65; }
.primary-button--wide { width: 100%; margin-top: 14px; }
.recall-rating { margin-top: 18px; text-align: center; }
.recall-rating p { color: var(--ink-soft); font-size: 11px; }
.recall-rating > div { display: grid; grid-template-columns: repeat(3,1fr); gap: 7px; }
.recall-rating button { min-height: 43px; color: var(--ink); background: transparent; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 11px; }
.recall-rating button:hover { color: var(--accent); border-color: var(--accent); }

.note-field { display: grid; gap: 9px; color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.note-field textarea { width: 100%; resize: vertical; padding: 14px; color: var(--ink); background: var(--paper-deep); border: 1px solid var(--line); border-radius: 10px; font-family: var(--reading-font); font-size: 15px; line-height: 1.55; }
.note-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 15px; }

.toast { position: fixed; z-index: 200; right: 24px; bottom: 24px; max-width: 320px; padding: 12px 16px; color: white; background: var(--navy-900); border: 1px solid rgba(255,255,255,.12); border-radius: 10px; box-shadow: 0 14px 40px rgba(0,0,0,.25); font-size: 12px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.toast.is-visible { opacity: 1; transform: none; }
.noscript-message { position: fixed; z-index: 300; inset: auto 20px 20px; padding: 15px; color: white; background: #7f3f37; border-radius: 8px; }

@media (max-width: 1240px) {
  :root { --right-rail: 0px; }
  .app-shell { grid-template-columns: var(--left-rail) minmax(0,1fr); }
  .study-rail { display: none; }
  .main-content { grid-column: 2; }
  .topbar { grid-template-columns: 1fr 1fr; }
  .location { display: none; }
}

@media (max-width: 920px) {
  :root { --left-rail: 0px; }
  .app-shell { display: block; padding-top: var(--topbar-height); }
  .topbar { position: fixed; width: 100%; grid-template-columns: minmax(0,1fr) auto; }
  .mobile-only { display: inline-grid; }
  .library-rail {
    position: fixed;
    z-index: 80;
    top: var(--topbar-height);
    left: 0;
    width: min(330px, 88vw);
    height: calc(100vh - var(--topbar-height));
    transform: translateX(-105%);
    transition: transform .25s cubic-bezier(.2,.7,.2,1);
    box-shadow: 20px 0 60px rgba(0,0,0,.26);
  }
  body.nav-open .library-rail { transform: none; }
  .main-content { min-height: calc(100vh - var(--topbar-height)); }
  .home-view { padding-inline: clamp(20px,5vw,50px); }
  .home-hero { grid-template-columns: minmax(220px, 330px) minmax(310px,1fr); gap: 45px; }
  .page-stage { grid-template-columns: minmax(0,1fr); padding-inline: clamp(16px,4vw,38px); }
  .page-frame { grid-column: 1; }
  .page-turn { display: none; }
  .mobile-page-nav {
    position: fixed;
    z-index: 30;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    min-height: 62px;
    padding-bottom: env(safe-area-inset-bottom);
    color: #f4f1ea;
    background: color-mix(in srgb, var(--navy-900) 95%, transparent);
    border-top: 1px solid rgba(255,255,255,.1);
    backdrop-filter: blur(15px);
  }
  .mobile-page-nav button { display: flex; align-items: center; justify-content: center; gap: 7px; min-width: 90px; color: inherit; background: transparent; border: 0; cursor: pointer; font-size: 11px; }
  .mobile-page-nav button:disabled { opacity: .3; }
  .mobile-page-nav button:nth-child(2) { display: grid; padding: 8px 18px; line-height: 1.05; }
  .mobile-page-nav small { color: rgba(255,255,255,.5); font-size: 8px; letter-spacing: .1em; text-transform: uppercase; }
  .reader-view { padding-bottom: 64px; }
}

@media (max-width: 720px) {
  .brand__type small, .action-button span, .action-button kbd { display: none; }
  .action-button { width: 42px; padding: 0; justify-content: center; }
  .home-view { padding-top: 35px; }
  .home-hero { grid-template-columns: 1fr; gap: 48px; }
  .cover-wrap { width: min(78vw, 315px); }
  .hero-copy { text-align: center; }
  .hero-copy .eyebrow { text-align: center; }
  .hero-copy h1 { font-size: clamp(46px,13vw,68px); }
  .hero-lede { margin-inline: auto; }
  .hero-actions { justify-content: center; }
  .book-facts { justify-content: center; }
  .subject-section { margin-top: 76px; }
  .section-heading { display: block; }
  .section-heading > p { margin-top: 14px; }
  .subject-grid { grid-template-columns: 1fr; }
  .method-strip { grid-template-columns: 1fr; }
  .method-strip article, .method-strip article:first-child, .method-strip article:last-child { padding: 22px 0; border-left: 0; border-top: 1px solid var(--line); }
  .method-strip article:first-child { border-top: 0; }
  .reader-toolbar { padding-inline: 14px; }
  .tool-button span { display: none; }
  .book-page { min-height: 70vh; padding: 35px clamp(22px,7vw,42px) 32px; border-radius: 2px 7px 7px 2px; }
  .page-stage { padding-top: 20px; padding-bottom: 34px; }
  .page-content { font-size: var(--page-font-size); }
  .folio-meta { margin-bottom: 26px; }
  .modal-shell { padding: 20px; }
  .recall-rating > div { grid-template-columns: 1fr; }
}

@media (max-width: 440px) {
  :root { --topbar-height: 62px; }
  .topbar { padding-inline: 8px; }
  .brand { gap: 7px; }
  .brand__mark { width: 31px; height: 37px; }
  .brand__type strong { font-size: 15px; }
  .home-view { padding-inline: 16px; }
  .book-facts div { min-width: 0; padding-inline: 14px; }
  .subject-card { grid-template-columns: 47px minmax(0,1fr); }
  .subject-card__tab { width: 43px; height: 56px; }
  .subject-card__progress { display: none; }
  .reader-breadcrumb { max-width: 170px; }
  .book-page { padding-inline: 21px; }
  .page-content h1 { font-size: 31px; }
  .page-content h2 { font-size: 1.42em; }
  .folio-footer { gap: 12px; }
  .folio-footer > :first-child { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .cover-pages { animation: none; }
}

@media print {
  :root { --paper: white; --ink: black; --ink-soft: #444; }
  body { background: white; }
  .topbar, .library-rail, .study-rail, .reader-toolbar, .page-turn, .mobile-page-nav, .ambient, .toast { display: none !important; }
  .app-shell, .main-content, .reader-view, .page-stage, .page-frame { display: block; min-height: 0; padding: 0; }
  .book-page { min-height: 0; padding: 0; border: 0; box-shadow: none; }
  .page-content { font-size: 11pt; line-height: 1.5; }
  .folio-meta { margin-top: 0; }
  .callout { break-inside: avoid; }
  .table-wrap { overflow: visible; break-inside: avoid; }
}
