:root {
  --book-bg: #f6f7fb;
  --book-surface: #ffffff;
  --book-text: #1f2937;
  --book-muted: #6b7280;
  --book-border: rgba(17, 24, 39, 0.10);
  --book-shadow: 0 18px 45px rgba(15, 23, 42, 0.10);
  --book-radius: 18px;
  --book-font-size: 17px;
}

.book-body {
  background: var(--book-bg);
  color: var(--book-text);
}

.book-shell {
  min-height: 100vh;
  padding-top: 84px; /* navbar space */
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

.book-sidebar {
  position: sticky;
  top: 92px;
  height: calc(100vh - 110px);
  background: var(--book-surface);
  border: 1px solid var(--book-border);
  border-radius: var(--book-radius);
  box-shadow: var(--book-shadow);
  overflow: hidden;
}

.book-sidebar__inner {
  height: 100%;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.book-brand__title {
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.book-brand__subtitle {
  font-size: 0.9rem;
  color: var(--book-muted);
}

.book-search {
  position: relative;
}

.book-search i {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  color: var(--book-muted);
  pointer-events: none;
}

.book-search .form-control {
  padding-left: 38px;
  border-radius: 999px;
  border-color: var(--book-border);
}

.book-toc {
  overflow: auto;
  padding-right: 6px;
}

.book-toc__group {
  margin-bottom: 14px;
}

.book-toc__heading {
  font-weight: 700;
  color: var(--book-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 10px 0 8px;
}

.book-toc__item {
  display: block;
  padding: 10px 12px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--book-text);
  border: 1px solid transparent;
  transition: 0.15s ease;
}

.book-toc__item:hover {
  background: rgba(246, 144, 166, 0.10);
  border-color: rgba(246, 144, 166, 0.20);
}

.book-toc__item.is-active {
  background: rgba(246, 144, 166, 0.16);
  border-color: rgba(246, 144, 166, 0.35);
}

.book-toc__title {
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 3px;
}

.book-toc__desc {
  font-size: 0.88rem;
  color: var(--book-muted);
  margin: 0;
}

.book-reader {
  background: var(--book-surface);
  border: 1px solid var(--book-border);
  border-radius: var(--book-radius);
  box-shadow: var(--book-shadow);
  overflow: hidden;
  position: relative;
}

.book-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--book-border);
  background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(255,255,255,0.85));
  backdrop-filter: blur(10px);
}

.book-topbar__spacer {
  flex: 1;
}

.book-controls {
  display: flex;
  gap: 8px;
}

.book-icon-btn {
  border-radius: 999px;
}

.book-progress {
  height: 4px;
  background: rgba(17, 24, 39, 0.08);
}

.book-progress__bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--brand-pink), #ffb3c2);
  transition: width 0.12s linear;
}

.book-content {
  padding: 26px 24px 30px;
}

.book-content__meta {
  color: var(--book-muted);
  font-size: 0.95rem;
}

.book-content__title {
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 8px 0 6px;
}

.book-content__subtitle {
  color: var(--book-muted);
  margin: 0 0 18px;
}

.book-content__body {
  font-size: var(--book-font-size);
  line-height: 1.75;
}

.book-content__body h2 {
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 26px 0 10px;
}

.book-content__body ul {
  padding-left: 1.2rem;
}

.book-callout {
  border: 1px solid rgba(246, 144, 166, 0.35);
  background: rgba(246, 144, 166, 0.10);
  border-radius: 14px;
  padding: 14px 14px;
  margin: 18px 0;
}

.book-callout__title {
  font-weight: 800;
  margin-bottom: 6px;
}

.book-content__footer {
  border-top: 1px solid var(--book-border);
  margin-top: 24px;
  padding-top: 18px;
}

.book-pagehint {
  color: var(--book-muted);
  font-size: 0.95rem;
}

/* Mobile: slide-in TOC */
@media (max-width: 991.98px) {
  .book-shell {
    grid-template-columns: 1fr;
  }

  .book-sidebar {
    position: fixed;
    inset: 84px 12px 12px 12px;
    z-index: 1050;
    transform: translateX(-110%);
    transition: transform 0.2s ease;
  }

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

/* Dark theme */
.book-body.book-dark {
  --book-bg: #0b1220;
  --book-surface: rgba(17, 24, 39, 0.72);
  --book-text: #e5e7eb;
  --book-muted: #a3aab8;
  --book-border: rgba(226, 232, 240, 0.12);
  --book-shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
}

.book-body.book-dark .book-topbar {
  background: linear-gradient(180deg, rgba(17,24,39,0.85), rgba(17,24,39,0.65));
}

.book-body.book-dark .book-progress {
  background: rgba(226, 232, 240, 0.10);
}

.book-body.book-dark .book-search .form-control {
  background: rgba(15, 23, 42, 0.55);
  color: var(--book-text);
}

.book-body.book-dark .book-search .form-control::placeholder {
  color: rgba(229, 231, 235, 0.7);
}
