/**
 * Book page surface tokens (chapter reader content area).
 * Site chrome uses data-theme; chapter pages use data-book-surface.
 */
[data-book-surface="light"] {
  --book-bg: #ffffff;
  --book-text: #111111;
  --book-muted: #666666;
  --book-heading: #222222;
  --book-rule: #d0d7de;
  --book-link: #0099c7;
  --book-link-hover: #00b4e6;
  --book-code-bg: rgba(0, 153, 199, 0.08);
  --book-code-text: #006d8f;
  --book-feature-bg: #f5f5f5;
  --book-feature-border: #e0e0e0;
  --book-quote-border: #aaaaaa;
  --book-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

[data-book-surface="dark"] {
  --book-bg: #121820;
  --book-text: #e8f0fa;
  --book-muted: #9aabb8;
  --book-heading: #f0f6ff;
  --book-rule: rgba(255, 255, 255, 0.14);
  --book-link: #5cefff;
  --book-link-hover: #9ef5ff;
  --book-code-bg: rgba(0, 212, 255, 0.12);
  --book-code-text: #b8ecff;
  --book-feature-bg: rgba(255, 255, 255, 0.06);
  --book-feature-border: rgba(255, 255, 255, 0.12);
  --book-quote-border: rgba(255, 255, 255, 0.28);
  --book-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
}

/* Reader chrome controls (also used on cover page) */
.book-theme-select {
  height: var(--header-control-h, 34px);
  min-height: var(--header-control-h, 34px);
  border: 1px solid var(--nav-border, rgba(255, 255, 255, 0.18));
  background: transparent;
  color: var(--muted, #888);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0 8px;
  cursor: pointer;
  max-width: 7.5rem;
  font-family: inherit;
}

.book-theme-select:hover {
  color: var(--text, #e8e8e8);
  background: rgba(255, 255, 255, 0.04);
}

[data-theme="light"] .book-theme-select:hover {
  background: rgba(0, 0, 0, 0.04);
}

.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--header-control-h, 34px);
  height: var(--header-control-h, 34px);
  min-width: var(--header-control-h, 34px);
  min-height: var(--header-control-h, 34px);
  border: 1px solid var(--nav-border, rgba(255, 255, 255, 0.18));
  background: transparent;
  color: var(--text, #e8e8e8);
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  font-family: inherit;
}

.theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

[data-theme="light"] .theme-toggle-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

[data-theme-pref="dark"] .theme-icon-light,
[data-theme-pref="dark"] .theme-icon-auto,
[data-theme-pref="light"] .theme-icon-dark,
[data-theme-pref="light"] .theme-icon-auto,
[data-theme-pref="auto"] .theme-icon-dark,
[data-theme-pref="auto"] .theme-icon-light {
  display: none;
}

.cover-theme-bar {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 10;
  display: flex;
  gap: 8px;
  align-items: center;
}
