:root {
  color-scheme: light;
  --ink: #111;
  --muted: #6d6a63;
  --paper: #fbfaf6;
  --page: #fff;
  --line: #ded9cf;
  --marker: #fff2a8;
  --green: #2f6b4f;
  --green-dark: #1f4e39;
  --shadow: 0 24px 70px rgba(18, 18, 18, 0.14);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: ui-serif, "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
  letter-spacing: 0;
}
button, input { font: inherit; }
button { cursor: pointer; }
.book-navbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 64px;
  padding: 10px clamp(14px, 3vw, 34px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(16px);
}
.icon-button,
.primary-button,
.pager button,
.view-switch button {
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--page);
  color: var(--ink);
}
.icon-button {
  width: 40px;
  height: 40px;
  font-size: 22px;
}
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font: 700 14px/1.2 ui-sans-serif, system-ui, sans-serif;
}
.breadcrumbs strong {
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.load-status {
  color: var(--muted);
  font: 14px/1.2 ui-sans-serif, system-ui, sans-serif;
}
.nav-actions {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 10px;
}
.text-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--page);
  color: var(--ink);
  padding: 0 12px;
  font: 800 13px/1 ui-sans-serif, system-ui, sans-serif;
}
.text-button:hover {
  border-color: var(--ink);
}
.book-home {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(30px, 6vw, 74px) 0 70px;
}
.book-hero {
  display: grid;
  grid-template-columns: minmax(240px, 360px) minmax(280px, 1fr);
  gap: clamp(28px, 7vw, 96px);
  align-items: center;
}
.cover-card {
  position: relative;
  width: min(100%, 360px);
  justify-self: end;
}
.cover-card img {
  display: block;
  width: 100%;
  height: auto;
  box-shadow: var(--shadow);
}
.cover-card__text {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  pointer-events: none;
}
.cover-card__text span {
  display: block;
  font-size: clamp(42px, 6vw, 72px);
  font-weight: 900;
  letter-spacing: 0.12em;
  writing-mode: vertical-rl;
}
.cover-card__text small {
  display: block;
  margin: 34px auto 0;
  color: var(--muted);
  font-size: 18px;
  letter-spacing: 0.28em;
}
.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  font: 800 12px/1 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.book-intro h1 {
  margin: 0;
  font-size: clamp(54px, 11vw, 120px);
  line-height: 0.94;
  font-weight: 900;
}
.book-author {
  margin: 18px 0 0;
  font-size: clamp(22px, 3vw, 34px);
}
.book-subtitle {
  margin: 12px 0 28px;
  color: var(--muted);
  font-size: 18px;
}
.primary-button {
  min-height: 48px;
  padding: 0 22px;
  background: var(--green);
  border-color: var(--green-dark);
  color: white;
  font-weight: 800;
}
.toc-section {
  margin-top: clamp(46px, 8vw, 96px);
  border-top: 1px solid var(--line);
  padding-top: 28px;
}
.toc-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  margin-bottom: 22px;
}
.toc-toolbar h2 {
  margin: 0;
  font-size: clamp(30px, 5vw, 56px);
  line-height: 1;
}
.toc-controls {
  display: flex;
  gap: 10px;
  align-items: center;
}
.toc-controls input {
  width: min(42vw, 280px);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--page);
  padding: 11px 15px;
  outline: none;
}
.toc-controls input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08);
}
.view-switch {
  display: inline-flex;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  background: var(--page);
}
.view-switch button {
  min-height: 34px;
  border: 0;
  padding: 0 12px;
  color: var(--muted);
}
.view-switch button[aria-pressed="true"] {
  background: var(--ink);
  color: white;
}
.toc {
  list-style: none;
  margin: 0;
  padding: 0;
}
.toc--grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.toc--list {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}
.toc__item button {
  width: 100%;
  min-height: 148px;
  border: 1px solid var(--line);
  background: var(--page);
  color: var(--ink);
  padding: 16px;
  text-align: left;
  border-radius: 5px;
  box-shadow: 0 1px 0 rgba(17, 17, 17, 0.04);
}
.toc__item button:hover {
  border-color: var(--ink);
  box-shadow: 0 8px 24px rgba(17, 17, 17, 0.08);
}
.toc--list .toc__item button {
  min-height: 0;
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 14px;
  align-items: baseline;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.toc__number,
.toc__date {
  color: var(--muted);
  font: 700 13px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.toc__title {
  display: block;
  margin-top: 16px;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.25;
}
.toc--list .toc__title {
  margin-top: 0;
  font-size: 18px;
}
.article-view {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(30px, 6vw, 74px) 0 54px;
  display: grid;
  grid-template-columns: minmax(240px, 310px) minmax(0, 1fr);
  gap: clamp(24px, 4vw, 58px);
  align-items: start;
}
.article-view--toc-hidden {
  width: min(920px, calc(100% - 32px));
  grid-template-columns: minmax(0, 1fr);
}
.article-view--toc-hidden .article-sidebar {
  display: none;
}
.article-sidebar {
  position: sticky;
  top: 86px;
  max-height: calc(100vh - 104px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--page) 82%, var(--paper));
  padding: 16px;
}
.article-sidebar__top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.article-sidebar__top h2 {
  margin: 0;
  font-size: 26px;
  line-height: 1;
}
.article-sidebar input {
  width: 100%;
  margin: 14px 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--page);
  padding: 10px 13px;
  outline: none;
}
.article-sidebar input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08);
}
.article-toc {
  display: grid;
  gap: 4px;
}
.article-toc button {
  width: 100%;
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 10px;
  align-items: baseline;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  padding: 8px;
  text-align: left;
}
.article-toc button:hover,
.article-toc button[aria-current="true"] {
  background: var(--page);
  border-color: var(--line);
}
.article-toc button[aria-current="true"] {
  box-shadow: inset 4px 0 0 var(--marker);
}
.article-toc__number {
  color: var(--muted);
  font: 700 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.article-toc__title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  line-height: 1.35;
}
.article-main {
  min-width: 0;
}
.article {
  width: min(760px, 100%);
  margin: 0 auto;
}
.article-loader {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.8;
}
.article h1 {
  margin: 0 0 14px;
  font-size: clamp(36px, 6vw, 72px);
  line-height: 1;
  font-weight: 900;
}
.article__meta {
  color: var(--muted);
  margin: 0 0 38px;
  font: 15px/1.4 ui-sans-serif, system-ui, sans-serif;
}
.article__body {
  font-size: 20px;
  line-height: 2;
}
.article__body p,
.article__body section,
.article__body blockquote,
.article__body table {
  margin: 0 0 1.25em;
}
.article__body blockquote {
  border-left: 4px solid var(--line);
  color: var(--muted);
  padding-left: 1em;
  margin-left: 0;
}
.article__body table {
  width: 100%;
  border-collapse: collapse;
}
.article__body td,
.article__body th {
  border: 1px solid var(--line);
  padding: 0.4em 0.55em;
}
.pager {
  width: min(760px, 100%);
  margin: 42px auto 0;
  border-top: 1px solid var(--line);
  padding-top: 20px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
}
.pager button {
  min-height: 44px;
  padding: 0 18px;
  font-weight: 800;
}
.pager button:first-child { justify-self: start; }
.pager button:last-child { justify-self: end; }
.pager button:disabled {
  opacity: 0.32;
  cursor: default;
}
@media (max-width: 760px) {
  .book-navbar {
    grid-template-columns: 40px minmax(0, 1fr) auto;
  }
  .load-status,
  .breadcrumbs span:first-child,
  .breadcrumbs span:nth-child(2) {
    display: none;
  }
  .book-hero {
    grid-template-columns: 1fr;
  }
  .cover-card {
    width: min(58vw, 240px);
    justify-self: start;
  }
  .toc-toolbar,
  .toc-controls {
    display: grid;
    width: 100%;
  }
  .toc-controls input {
    width: 100%;
  }
  .toc--grid {
    grid-template-columns: 1fr;
  }
  .toc--list .toc__item button {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .toc__title {
    margin-top: 8px;
  }
  .article__body {
    font-size: 18px;
  }
}
@media (max-width: 900px) {
  .article-view,
  .article-view--toc-hidden {
    width: min(100% - 20px, 760px);
    display: block;
  }
  .article-sidebar {
    position: fixed;
    inset: 64px auto 0 0;
    z-index: 9;
    width: min(86vw, 340px);
    max-height: none;
    border-radius: 0 8px 0 0;
    box-shadow: var(--shadow);
    transform: translateX(0);
    transition: transform 180ms ease;
  }
  .article-view--toc-hidden .article-sidebar {
    display: block;
    transform: translateX(-105%);
  }
}
