:root {
  color-scheme: dark;
  --bg: #050505;
  --nav-bg: #080808;
  --surface: #101010;
  --surface-strong: #191919;
  --text: #f0f0f0;
  --text-soft: #bdbdbd;
  --text-faint: #7b7b7b;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.17);
  --accent: #00c878;
  --accent-strong: #00e08a;
  --accent-soft: rgba(0, 200, 120, 0.13);
  --accent-ink: #00180e;
  --accent-muted: #0d5d60;
  --accent-muted-ink: #f2ffff;
  --image-bg: #f4f5f0;
  --search-mark: #155b43;
  --highlight-mint: rgba(0, 200, 120, 0.34);
  --highlight-sun: rgba(221, 179, 82, 0.4);
  --highlight-blue: rgba(92, 154, 213, 0.38);
  --highlight-pink: rgba(222, 105, 142, 0.34);
  --highlight-violet: rgba(155, 126, 214, 0.35);
  --highlight-red: rgba(229, 92, 84, 0.34);
  --annotation-marker-mint: #00d884;
  --annotation-marker-sun: #e4bb58;
  --annotation-marker-blue: #6aa7df;
  --annotation-marker-pink: #e579a2;
  --annotation-marker-violet: #a68ae4;
  --annotation-marker-red: #f0716a;
  --syntax-comment: #8b949e;
  --syntax-keyword: #ff7ab2;
  --syntax-string: #a8d279;
  --syntax-number: #f4bf75;
  --syntax-title: #6cd9cf;
  --syntax-variable: #d2a8ff;
  --syntax-meta: #79c0ff;
  --syntax-addition: #56d364;
  --syntax-deletion: #ff7b72;
  --danger: #e28278;
  --shadow: rgba(0, 0, 0, 0.52);
  --radius: 2px;
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --topbar-content-height: 56px;
  --topbar-height: calc(var(--topbar-content-height) + var(--safe-area-top));
  --book-nav-width: 272px;
  --chapter-tools-width: 336px;
  --reader-scale: 1;
  --ui-latin: "SourceSans3VF", "Source Sans 3", "Aptos", "Segoe UI", Arial;
  --ui-cjk: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei";
  --sans: var(--ui-latin), var(--ui-cjk), sans-serif;
  --reading-latin: "Source Serif 4 Variable", "Source Serif 4", "Sitka Text", "Charter", "Bitstream Charter", Georgia;
  --classic-latin: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia;
  --sans-latin: "SourceSans3VF", "Source Sans 3", "Aptos", "Segoe UI", Arial;
  --reading-cjk: "Source Han Serif SC", "Noto Serif CJK SC", "Songti SC", STSong, SimSun;
  --hei-cjk: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", SimHei;
  --system-cjk: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC", SimSun;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --reader-font-latin: var(--reading-latin);
  --reader-font-cjk: var(--reading-cjk);
  --reader-font: var(--reader-font-latin), var(--reader-font-cjk), serif;
  --reading-measure: 100%;
  --reading-line-height-en: 1.72;
  --reading-line-height-zh: 1.86;
  --reading-letter-spacing-en: 0em;
  --reading-letter-spacing-zh: 0.012em;
  --reading-line-height: var(--reading-line-height-en);
  --reading-paragraph-gap: 0.9em;
  --reading-letter-spacing: var(--reading-letter-spacing-en);
}

/* Content library */
body[data-view="library"] .reader-layout {
  width: 100%;
  display: block;
}

body[data-view="library"] .book-nav,
body[data-view="library"] .chapter-tools,
body[data-view="library"] .sidebar-resizer,
body[data-view="library"] .topbar-actions,
body[data-view="library"] .mobile-only {
  display: none;
}

body[data-view="library"] .topbar {
  grid-template-columns: 272px minmax(0, 1fr);
}

body[data-view="library"] .reader-main {
  width: 100%;
  padding: clamp(48px, 7vw, 92px) clamp(24px, 6vw, 96px) 110px;
}

.library-view {
  width: min(100%, 1320px);
  margin: 0 auto;
}

.library-boot-state {
  display: none;
}

body[data-view="library"] .library-boot-state {
  display: block;
}

body[data-view="library"] .reader-boot-state {
  display: none;
}

.library-boot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: clamp(54px, 7vw, 88px);
}

.library-boot-card {
  min-height: 220px;
  border: 1px solid var(--border);
  background: var(--surface);
}

@media (max-width: 760px) {
  .library-boot-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .library-boot-card:nth-child(n + 3) {
    display: none;
  }
}

.library-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 48px;
  align-items: end;
  padding-top: 24px;
  padding-bottom: 44px;
  border-top: 3px solid var(--accent-muted);
  border-bottom: 1px solid var(--border-strong);
}

.library-kicker {
  margin: 0 0 14px;
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.library-header h1,
.library-state h1 {
  margin: 0;
  font-size: clamp(3.5rem, 6vw, 6rem);
  letter-spacing: -0.07em;
  line-height: 0.94;
}

.library-header > div > p:last-child,
.library-state > p:not(.library-kicker) {
  max-width: 62ch;
  margin: 24px 0 0;
  color: var(--text-soft);
  font-family: var(--reader-font);
  font-size: 1.05rem;
  line-height: 1.6;
}

.library-header dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(110px, 1fr));
  margin: 0;
  border: 1px solid var(--border-strong);
}

.library-header dl div {
  min-width: 130px;
  padding: 16px 18px;
}

.library-header dl div + div {
  border-left: 1px solid var(--border-strong);
}

.library-header dt {
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.61rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.library-header dd {
  margin: 5px 0 0;
  font-size: 1.35rem;
  font-weight: 750;
}

.library-shelves {
  padding: 34px 0 30px;
  border-bottom: 1px solid var(--border-strong);
}

.library-shelves-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 240px);
  gap: 32px;
  align-items: end;
  padding-bottom: 26px;
}

.library-shelves-intro h2,
.library-collection-header h2 {
  margin: 0;
  font-size: clamp(1.9rem, 3vw, 3rem);
  letter-spacing: -0.045em;
  line-height: 1;
}

.library-shelves-intro p {
  max-width: 55ch;
  margin: 9px 0 0;
  color: var(--text-soft);
  font-family: var(--reader-font);
  line-height: 1.55;
}

.library-shelf-row {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 24px;
  align-items: center;
  padding: 15px 0;
  border-top: 1px solid var(--border);
}

.library-shelf-row h3,
.library-custom-heading h3 {
  margin: 0;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.library-shelf-strip {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(172px, 100%), 1fr));
  gap: 8px;
  overflow: visible;
  padding: 1px;
}

.library-shelf-link {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-soft);
  text-decoration: none;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 90ms ease;
}

.library-shelf-link:hover {
  border-color: var(--accent);
  color: var(--text);
}

.library-shelf-link:active {
  transform: translateY(1px);
}

.library-shelf-link.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.library-shelf-link small {
  flex: 0 0 auto;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.63rem;
}

.library-shelves-intro > .library-shelf-link {
  width: 100%;
}

.library-custom-heading {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.library-new-shelf,
.package-organize-button {
  padding: 3px 0;
  border: 0;
  border-bottom: 1px solid var(--border-strong);
  border-radius: 0;
  background: transparent;
  color: var(--text-soft);
  font-size: 0.72rem;
  cursor: pointer;
}

.library-new-shelf:hover,
.package-organize-button:hover {
  border-bottom-color: var(--accent);
  color: var(--text);
}

.library-custom-empty {
  margin: 0;
  color: var(--text-faint);
  font-family: var(--reader-font);
  font-size: 0.88rem;
}

.library-collection {
  padding-top: 46px;
}

.library-collection-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 30px;
  align-items: end;
}

.library-collection-header > div:first-child > p:first-child {
  margin: 0 0 9px;
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 700;
}

.library-collection-description {
  max-width: 60ch;
  margin: 13px 0 0;
  color: var(--text-soft);
  font-family: var(--reader-font);
  line-height: 1.55;
}

.library-collection-meta {
  display: flex;
  align-items: center;
  gap: 13px;
}

.library-collection-meta > span {
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.65rem;
  text-transform: uppercase;
}

.library-collection-empty {
  margin-top: 28px;
  padding: 34px 0 6px;
  border-top: 1px solid var(--border-strong);
}

.library-collection-empty h3 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: -0.025em;
}

.library-collection-empty p {
  max-width: 54ch;
  margin: 10px 0 20px;
  color: var(--text-soft);
  font-family: var(--reader-font);
  line-height: 1.55;
}

.package-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  padding-top: 28px;
}

.package-card {
  content-visibility: auto;
  contain-intrinsic-size: auto 520px;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(150px, 0.55fr) minmax(0, 1.45fr);
  border: 1px solid var(--border-strong);
  background: var(--surface);
}

.package-grid-sentinel {
  min-height: 1px;
  grid-column: 1 / -1;
}

.library-cover {
  min-height: 330px;
  overflow: hidden;
  border-right: 1px solid var(--border-strong);
  background: var(--surface-strong);
}

.library-cover img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.library-cover-placeholder {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 19px;
}

.library-cover-placeholder span {
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.library-cover-placeholder strong {
  font-family: var(--reading-latin), var(--reading-cjk), serif;
  font-size: clamp(3rem, 6vw, 5.4rem);
  line-height: 0.85;
}

.package-card-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.package-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 22px;
}

.package-badges span {
  padding: 3px 6px;
  border: 1px solid var(--border-strong);
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.package-card h2 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 3rem);
  letter-spacing: -0.045em;
  line-height: 0.98;
  text-wrap: balance;
}

.package-author {
  margin: 11px 0 0;
  color: var(--text-soft);
  font-family: var(--reader-font);
  font-style: italic;
}

.package-taxonomy {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 13px;
  margin-top: 15px;
}

.package-taxonomy a {
  border-bottom: 1px solid var(--border-strong);
  color: var(--text-faint);
  font-size: 0.67rem;
  text-decoration: none;
}

.package-taxonomy a:hover {
  border-bottom-color: var(--accent);
  color: var(--text);
}

.package-description {
  display: -webkit-box;
  margin: 18px 0 24px;
  overflow: hidden;
  color: var(--text-soft);
  font-family: var(--reader-font);
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.package-progress {
  margin-top: auto;
}

.package-progress > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.61rem;
  text-transform: uppercase;
}

.package-progress progress {
  width: 100%;
  height: 4px;
  display: block;
  border: 0;
  background: var(--surface-strong);
  color: var(--accent);
  accent-color: var(--accent);
}

.package-progress progress::-webkit-progress-bar {
  background: var(--surface-strong);
}

.package-progress progress::-webkit-progress-value {
  background: var(--accent);
}

.package-progress progress::-moz-progress-bar {
  background: var(--accent);
}

.package-recent {
  min-height: 1.2em;
  margin: 10px 0 20px;
  overflow: hidden;
  color: var(--text-faint);
  font-size: 0.68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.package-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.package-actions .package-organize-button {
  align-self: center;
  margin-left: 4px;
}

.library-field-label {
  display: block;
  margin-bottom: 7px;
  color: var(--text-soft);
  font-size: 0.76rem;
  font-weight: 700;
}

.library-text-input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}

.library-field-help,
.organizer-description,
.shelf-management > p {
  margin: 9px 0 0;
  color: var(--text-faint);
  font-family: var(--reader-font);
  font-size: 0.82rem;
  line-height: 1.5;
}

.library-field-error {
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 0.76rem;
}

.library-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.shelf-management {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--border-strong);
}

.shelf-management h3 {
  margin: 0;
  font-size: 1rem;
}

.shelf-management > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.secondary-button:disabled {
  border-color: var(--border);
  color: var(--text-faint);
  cursor: not-allowed;
  opacity: 0.55;
}

.library-danger-button {
  margin-top: 24px;
  padding: 7px 0;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--danger) 55%, transparent);
  border-radius: 0;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
}

.organizer-description {
  margin: -10px 0 18px;
  color: var(--text-soft);
  font-size: 1rem;
}

.organizer-list {
  display: grid;
  gap: 8px;
}

.organizer-choice {
  min-height: 58px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  cursor: pointer;
}

.organizer-choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.organizer-choice input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.organizer-choice span {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.organizer-choice strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.organizer-choice small,
.organizer-empty {
  color: var(--text-faint);
  font-family: var(--reader-font);
  font-size: 0.75rem;
}

.organizer-empty {
  margin: 0;
  padding: 18px 0;
  line-height: 1.5;
}

.organizer-create {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-strong);
}

.organizer-create > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.library-state {
  width: min(100%, 850px);
  margin: 12vh auto 0;
  padding-top: 24px;
  border-top: 3px solid var(--accent-muted);
}

.library-state .secondary-button {
  margin-top: 25px;
}

@media (max-width: 980px) {
  .package-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 680px) {
  body[data-view="library"] .topbar {
    grid-template-columns: minmax(0, 1fr);
    padding-inline: 8px;
  }

  body[data-view="library"] .brand-link {
    justify-self: start;
  }

  body[data-view="library"] .location-label {
    display: none;
  }

  body[data-view="library"] .reader-main {
    padding: 38px 16px calc(70px + var(--safe-area-bottom));
  }

  .library-header {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .library-header h1,
  .library-state h1 {
    font-size: clamp(3.2rem, 17vw, 5rem);
  }

  .library-header dl {
    width: 100%;
  }

  .library-shelves-intro,
  .library-shelf-row,
  .library-collection-header {
    grid-template-columns: minmax(0, 1fr);
  }

  .library-shelves-intro {
    gap: 20px;
  }

  .library-shelves-intro > .library-shelf-link {
    width: min(100%, 250px);
  }

  .library-shelf-row {
    gap: 11px;
    align-items: start;
  }

  .library-custom-heading {
    justify-content: flex-start;
  }

  .library-collection {
    padding-top: 38px;
  }

  .library-collection-meta {
    justify-content: space-between;
  }

  .package-card {
    grid-template-columns: 105px minmax(0, 1fr);
  }

  .library-cover {
    min-height: 310px;
  }

  .library-cover-placeholder {
    padding: 13px;
  }

  .library-cover-placeholder strong {
    font-size: 2.5rem;
  }

  .package-card-body {
    padding: 19px 16px;
  }

  .package-card h2 {
    font-size: 1.65rem;
  }

  .package-description {
    -webkit-line-clamp: 4;
  }

  .package-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .package-actions .primary-button,
  .package-actions .secondary-button,
  .package-actions .package-organize-button {
    width: 100%;
  }

  .package-actions .package-organize-button {
    align-self: stretch;
    margin: 4px 0 0;
    padding: 8px 0;
  }

  .organizer-create > div {
    grid-template-columns: minmax(0, 1fr);
  }

  .organizer-create .secondary-button {
    width: 100%;
  }
}

:root:lang(zh) {
  --reading-measure: 100%;
  --reading-line-height: var(--reading-line-height-zh);
  --reading-paragraph-gap: 0.78em;
  --reading-letter-spacing: var(--reading-letter-spacing-zh);
}

:root[data-theme="porcelain"] {
  color-scheme: light;
  --bg: #e9edef;
  --nav-bg: #e1e6e8;
  --surface: #f7f9f9;
  --surface-strong: #d8e0e2;
  --text: #162026;
  --text-soft: #4e5c62;
  --text-faint: #718087;
  --border: rgba(31, 54, 61, 0.15);
  --border-strong: rgba(31, 54, 61, 0.29);
  --accent: #147e69;
  --accent-strong: #075847;
  --accent-soft: rgba(20, 126, 105, 0.11);
  --accent-ink: #f4fffc;
  --accent-muted: #176b65;
  --accent-muted-ink: #f4fffc;
  --search-mark: #f0dc8b;
  --highlight-mint: rgba(83, 190, 157, 0.34);
  --highlight-sun: rgba(227, 181, 63, 0.4);
  --highlight-blue: rgba(91, 153, 210, 0.34);
  --highlight-pink: rgba(193, 79, 121, 0.2);
  --highlight-violet: rgba(121, 91, 180, 0.2);
  --highlight-red: rgba(178, 64, 58, 0.22);
  --annotation-marker-mint: #147e69;
  --annotation-marker-sun: #8a6200;
  --annotation-marker-blue: #246b9e;
  --annotation-marker-pink: #a9456b;
  --annotation-marker-violet: #7150a5;
  --annotation-marker-red: #a23b35;
  --syntax-comment: #5b6970;
  --syntax-keyword: #8d2f68;
  --syntax-string: #376f42;
  --syntax-number: #8a4b15;
  --syntax-title: #006b75;
  --syntax-variable: #70428f;
  --syntax-meta: #245d8c;
  --syntax-addition: #2d6e3d;
  --syntax-deletion: #a03e36;
  --danger: #a23b35;
  --shadow: rgba(30, 50, 56, 0.2);
}

:root[data-theme="paper"] {
  color-scheme: light;
  --bg: #f2eee2;
  --nav-bg: #e8e1d1;
  --surface: #fbf8ef;
  --surface-strong: #e5ddca;
  --text: #202925;
  --text-soft: #58615b;
  --text-faint: #7d827a;
  --border: rgba(50, 59, 54, 0.16);
  --border-strong: rgba(50, 59, 54, 0.3);
  --accent: #a1543f;
  --accent-strong: #793c2c;
  --accent-soft: rgba(161, 84, 63, 0.1);
  --accent-ink: #fffaf2;
  --accent-muted: #7a493c;
  --accent-muted-ink: #fffaf2;
  --search-mark: #ead884;
  --highlight-mint: rgba(103, 167, 120, 0.3);
  --highlight-sun: rgba(226, 175, 52, 0.4);
  --highlight-blue: rgba(90, 145, 190, 0.3);
  --highlight-pink: rgba(181, 75, 110, 0.21);
  --highlight-violet: rgba(117, 91, 165, 0.2);
  --highlight-red: rgba(174, 69, 58, 0.22);
  --annotation-marker-mint: #477a52;
  --annotation-marker-sun: #856000;
  --annotation-marker-blue: #3f7094;
  --annotation-marker-pink: #a44265;
  --annotation-marker-violet: #6d5099;
  --annotation-marker-red: #9d4037;
  --syntax-comment: #6f7169;
  --syntax-keyword: #973f62;
  --syntax-string: #42723e;
  --syntax-number: #945020;
  --syntax-title: #126b70;
  --syntax-variable: #76518d;
  --syntax-meta: #3c6286;
  --syntax-addition: #3f7542;
  --syntax-deletion: #a03e36;
  --danger: #a03e36;
  --shadow: rgba(64, 52, 39, 0.18);
}

:root[data-theme="flexoki"] {
  color-scheme: dark;
  --bg: #100f0f;
  --nav-bg: #0b0a0a;
  --surface: #171614;
  --surface-strong: #282520;
  --text: #cecdc3;
  --text-soft: #9f9d93;
  --text-faint: #6f6e69;
  --border: rgba(206, 205, 195, 0.12);
  --border-strong: rgba(206, 205, 195, 0.24);
  --accent: #da702c;
  --accent-strong: #e8985f;
  --accent-soft: rgba(218, 112, 44, 0.13);
  --accent-ink: #160b04;
  --accent-muted: #6d3b20;
  --accent-muted-ink: #fff5e9;
  --search-mark: #7a5d26;
  --highlight-mint: rgba(102, 164, 123, 0.34);
  --highlight-sun: rgba(208, 162, 48, 0.4);
  --highlight-blue: rgba(77, 132, 177, 0.38);
  --highlight-pink: rgba(206, 93, 151, 0.3);
  --highlight-violet: rgba(139, 126, 200, 0.3);
  --highlight-red: rgba(209, 77, 65, 0.3);
  --annotation-marker-mint: #78a984;
  --annotation-marker-sun: #d0a230;
  --annotation-marker-blue: #6c9fca;
  --annotation-marker-pink: #ce5d97;
  --annotation-marker-violet: #8b7ec8;
  --annotation-marker-red: #d14d41;
  --syntax-comment: #878580;
  --syntax-keyword: #ce5d97;
  --syntax-string: #879a39;
  --syntax-number: #d0a215;
  --syntax-title: #3aa99f;
  --syntax-variable: #a699d0;
  --syntax-meta: #4385be;
  --syntax-addition: #66800b;
  --syntax-deletion: #d14d41;
  --danger: #d45a50;
  --shadow: rgba(0, 0, 0, 0.56);
}

:root[data-reader-font-en="classic"] {
  --reader-font-latin: var(--classic-latin);
}

:root[data-reader-font-en="sans"] {
  --reader-font-latin: var(--sans-latin);
}

:root[data-reader-font-zh="hei"] {
  --reader-font-cjk: var(--hei-cjk);
}

:root[data-reader-font-zh="system"] {
  --reader-font-cjk: var(--system-cjk);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  scroll-behavior: auto;
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  overflow-wrap: break-word;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body.dialog-scroll-locked {
  position: fixed;
  top: var(--dialog-scroll-top, 0);
  right: 0;
  left: var(--dialog-scroll-left, 0);
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

button:active,
.primary-button:active,
.secondary-button:active {
  transform: translateY(1px);
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 50;
  padding: 9px 12px;
  border: 1px solid var(--accent);
  background: var(--surface);
  color: var(--text);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.reading-progress {
  position: fixed;
  inset: 0 auto auto 0;
  z-index: 40;
  width: 100%;
  height: 3px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  backface-visibility: hidden;
  contain: paint;
  will-change: transform;
}

.annotation-position-rail {
  position: fixed;
  top: calc(var(--topbar-height) + 12px);
  bottom: 18px;
  z-index: 22;
  width: 44px;
  pointer-events: none;
}

.annotation-position-rail[hidden],
body.focus-mode .annotation-position-rail,
body:not([data-view="document"]) .annotation-position-rail {
  display: none;
}

.annotation-position-track {
  position: absolute;
  inset: 12px 0;
  pointer-events: none;
}

.annotation-position-track::before {
  content: "";
  position: absolute;
  inset: 0 8px 0 auto;
  width: 1px;
  background: var(--border-strong);
}

.annotation-position-marker {
  position: absolute;
  top: var(--annotation-position);
  right: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--annotation-stroke, var(--annotation-marker-mint));
  transform: translateY(-50%);
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
}

.annotation-position-marker::before {
  content: "";
  position: absolute;
  top: 50%;
  right: 5px;
  width: 9px;
  height: 3px;
  border-radius: 2px 0 0 2px;
  background: currentColor;
  transform: translateY(-50%);
  transition: width 150ms ease-out;
}

.annotation-position-marker.has-note::after {
  content: "";
  position: absolute;
  top: calc(50% - 6px);
  right: 5px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}

.annotation-position-marker.annotation-mint,
.annotation-position-marker.annotation-sun,
.annotation-position-marker.annotation-blue,
.annotation-position-marker.annotation-pink,
.annotation-position-marker.annotation-violet,
.annotation-position-marker.annotation-red {
  background: transparent;
}

.annotation-position-marker.annotation-sun {
  color: var(--annotation-marker-sun);
}

.annotation-position-marker.annotation-blue {
  color: var(--annotation-marker-blue);
}

.annotation-position-marker:hover::before,
.annotation-position-marker:focus-visible::before {
  width: 19px;
}

.annotation-position-marker:active {
  transform: translateY(-50%);
}

.annotation-position-marker:active::before {
  opacity: 0.72;
}

body[data-view="document"] .reading-progress {
  transform: scaleX(0);
}

.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 30;
  height: var(--topbar-height);
  display: grid;
  grid-template-columns: var(--book-nav-width) minmax(0, 1fr) auto;
  align-items: stretch;
  padding-top: var(--safe-area-top);
  border-bottom: 1px solid var(--border-strong);
  background: var(--nav-bg);
}

.brand-link {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 18px;
  border-right: 1px solid var(--border-strong);
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 26px;
  padding: 0 7px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.brand-title {
  overflow: hidden;
  font-size: 0.84rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.location-label {
  align-self: center;
  min-width: 0;
  margin: 0;
  padding: 0 20px;
  overflow: hidden;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-breadcrumbs ol {
  min-width: 0;
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
  overflow: hidden;
  list-style: none;
}

.topbar-breadcrumbs li {
  min-width: 0;
  display: flex;
  align-items: center;
  flex: 0 1 auto;
}

.topbar-breadcrumbs li + li::before {
  content: "/";
  flex: none;
  margin: 0 9px;
  color: var(--border-strong);
}

.topbar-breadcrumbs a {
  min-width: 0;
  overflow: hidden;
  color: var(--text-faint);
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-breadcrumbs a:hover {
  color: var(--accent-strong);
}

.topbar-breadcrumbs a[aria-current="page"] {
  color: var(--text);
}

.topbar-actions {
  display: flex;
  align-items: stretch;
}

.language-picker {
  min-height: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border-left: 1px solid var(--border);
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.62rem;
}

.language-picker[hidden] {
  display: none;
}

.language-picker span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.language-picker select {
  max-width: 112px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.text-button,
.secondary-button,
.primary-button,
.segmented-control button,
.theme-control button,
.toolbar-text-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease, transform 90ms ease;
}

.topbar .text-button {
  min-height: 100%;
  padding: 0 14px;
  border-left-color: var(--border);
  border-radius: 0;
}

.reader-sync-status {
  min-height: 100%;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border: 0;
  border-left: 1px solid var(--border);
  background: transparent;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.62rem;
  cursor: pointer;
}

.reader-sync-status[hidden] {
  display: none;
}

.reader-sync-status:hover,
.reader-sync-status:focus-visible {
  background: var(--surface-strong);
  color: var(--text);
}

.reader-sync-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
}

.reader-sync-status[data-sync-state="syncing"] .reader-sync-dot {
  animation: reader-sync-pulse 900ms ease-in-out infinite alternate;
}

.reader-sync-status[data-sync-state="offline"] .reader-sync-dot,
.reader-sync-status[data-sync-state="error"] .reader-sync-dot,
.reader-sync-status[data-sync-state="auth-required"] .reader-sync-dot {
  background: var(--text-faint);
}

.reader-sync-status[data-sync-state="conflict"] .reader-sync-dot {
  background: var(--danger);
}

@keyframes reader-sync-pulse {
  from { opacity: 0.35; }
  to { opacity: 1; }
}

.text-button,
.toolbar-text-button {
  padding: 7px 11px;
  background: transparent;
  color: var(--text-soft);
}

.text-button:hover,
.toolbar-text-button:hover {
  background: var(--surface-strong);
  color: var(--text);
}

.primary-button,
.secondary-button {
  width: max-content;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  white-space: nowrap;
  text-decoration: none;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.primary-button:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.secondary-button {
  border-color: var(--border-strong);
  background: transparent;
  color: var(--text);
}

.secondary-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.reader-layout {
  width: 100%;
  min-height: 100dvh;
  margin: 0;
  padding-top: var(--topbar-height);
  display: grid;
  grid-template-columns: var(--book-nav-width) minmax(0, 1fr) var(--chapter-tools-width);
}

.sidebar-resizer {
  display: none;
}

.sidebar-resizer[hidden] {
  display: none;
}

@media (min-width: 1281px) {
  .sidebar-resizer {
    position: fixed;
    top: var(--topbar-height);
    bottom: 0;
    z-index: 29;
    width: 9px;
    display: block;
    cursor: col-resize;
    touch-action: none;
  }

  .sidebar-resizer::before {
    content: "";
    position: absolute;
    inset: 0 4px;
    background: transparent;
    transition: background-color 120ms ease;
  }

  .sidebar-resizer:hover::before,
  .sidebar-resizer:focus-visible::before,
  .sidebar-resizer.is-active::before {
    background: var(--accent);
  }

  .sidebar-resizer:focus-visible {
    outline: 2px solid var(--accent-strong);
    outline-offset: -2px;
  }

  .sidebar-resizer-left {
    left: var(--book-nav-width);
    transform: translateX(-50%);
  }

  .sidebar-resizer-right {
    right: var(--chapter-tools-width);
    transform: translateX(50%);
  }

  body.sidebar-resizing,
  body.sidebar-resizing * {
    cursor: col-resize !important;
    user-select: none !important;
  }

  body.focus-mode .sidebar-resizer {
    display: none;
  }
}

.book-nav,
.chapter-tools {
  position: sticky;
  top: var(--topbar-height);
  align-self: start;
  height: calc(100dvh - var(--topbar-height));
  overflow: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.book-nav:hover,
.book-nav:focus-within,
.book-nav.is-scrolling,
.chapter-tools:hover,
.chapter-tools:focus-within,
.chapter-tools.is-scrolling {
  scrollbar-color: color-mix(in srgb, var(--text-faint) 76%, transparent) transparent;
}

.book-nav::-webkit-scrollbar,
.chapter-tools::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.book-nav::-webkit-scrollbar-track,
.chapter-tools::-webkit-scrollbar-track,
.book-nav::-webkit-scrollbar-corner,
.chapter-tools::-webkit-scrollbar-corner {
  background: transparent;
}

.book-nav::-webkit-scrollbar-thumb,
.chapter-tools::-webkit-scrollbar-thumb {
  min-height: 32px;
  border-radius: 999px;
  background: transparent;
  transition: background-color 120ms ease;
}

.book-nav:hover::-webkit-scrollbar-thumb,
.book-nav:focus-within::-webkit-scrollbar-thumb,
.book-nav.is-scrolling::-webkit-scrollbar-thumb,
.chapter-tools:hover::-webkit-scrollbar-thumb,
.chapter-tools:focus-within::-webkit-scrollbar-thumb,
.chapter-tools.is-scrolling::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text-faint) 76%, transparent);
}

.book-nav::-webkit-scrollbar-thumb:hover,
.chapter-tools::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--text-soft) 88%, transparent);
}

.book-nav::-webkit-scrollbar-button,
.chapter-tools::-webkit-scrollbar-button {
  width: 0;
  height: 0;
  display: none;
}

.book-nav {
  padding: 24px 16px 36px;
  border-right: 1px solid var(--border-strong);
  background: var(--nav-bg);
}

body[data-view="document"] .book-nav::after {
  content: "";
  display: block;
  height: 62dvh;
  pointer-events: none;
}

.nav-home,
.nav-chapter {
  display: grid;
  gap: 5px;
  align-items: baseline;
  padding: 7px 9px;
  border-left: 2px solid transparent;
  color: var(--text-soft);
  text-decoration: none;
}

.nav-home {
  grid-template-columns: 28px minmax(0, 1fr);
  margin-bottom: 25px;
  color: var(--text);
  font-weight: 650;
}

.nav-view-switcher {
  margin: -7px 9px 22px;
  padding: 13px 0 15px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.nav-view-switcher > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.nav-view-switcher label,
.nav-view-switcher > div span {
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.59rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.nav-view-switcher > div span {
  letter-spacing: 0;
  text-transform: none;
}

.nav-view-switcher > div .nav-view-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: max-content;
}

.nav-unread-filter {
  min-height: 20px;
  padding: 1px 0;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: var(--accent-strong);
  font: 700 0.62rem/1.2 var(--mono);
  cursor: pointer;
}

.nav-unread-filter:hover,
.nav-unread-filter:focus-visible,
.nav-unread-filter[aria-pressed="true"] {
  border-bottom-color: var(--accent);
  outline: 0;
  color: var(--text);
}

.nav-unread-filter:disabled {
  border-bottom-color: transparent;
  color: var(--text-faint);
  cursor: default;
}

.nav-view-switcher select {
  width: 100%;
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: 0.75rem/1.25 var(--sans);
  cursor: pointer;
}

.nav-view-switcher select:hover,
.nav-view-switcher select:focus-visible {
  border-color: var(--accent);
  outline: 1px solid transparent;
}

.nav-view-switcher p {
  margin: 8px 0 0;
  color: var(--text-faint);
  font-family: var(--reader-font);
  font-size: 0.7rem;
  line-height: 1.45;
}

.nav-index {
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.64rem;
}

.nav-group {
  margin: 0 0 22px;
}

.nav-filter {
  width: calc(100% - 18px);
  margin: 2px 9px 20px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  font: 0.72rem/1.2 var(--sans);
}

.nav-filter:focus {
  border-color: var(--accent);
  outline: 1px solid var(--accent);
}

details.nav-group > summary {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 0 9px 6px;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  list-style: none;
  text-transform: uppercase;
}

details.nav-group > summary span:first-child {
  margin-right: auto;
}

details.nav-group > summary::-webkit-details-marker {
  display: none;
}

details.nav-group > summary::before {
  content: "+";
  margin-right: 8px;
  color: var(--accent-strong);
}

details.nav-group[open] > summary::before {
  content: "−";
}

.nav-group h2 {
  margin: 0 0 6px 9px;
  color: var(--text-faint);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nav-chapter {
  grid-template-columns: 28px minmax(0, 1fr);
  font-size: 0.79rem;
  line-height: 1.35;
}

.nav-chapter[aria-controls="outline-panel"] {
  grid-template-columns: 28px minmax(0, 1fr) 12px;
  cursor: pointer;
}

.nav-chapter[aria-controls="outline-panel"]::after {
  content: "";
  width: 6px;
  height: 6px;
  justify-self: center;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
  transition: transform 140ms ease;
}

.nav-chapter[aria-controls="outline-panel"][aria-expanded="false"]::after {
  transform: rotate(-45deg);
}

.nav-group-items {
  display: contents;
}

.nav-range-button {
  width: calc(100% - 18px);
  min-height: 36px;
  margin: 3px 9px 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  font: 0.66rem/1.2 var(--mono);
  letter-spacing: 0.05em;
}

.nav-range-button:hover,
.nav-range-button:focus-visible {
  border-color: var(--accent);
  color: var(--text);
}

.nav-chapter[data-reading-status="read"]:not([aria-current="page"]) .nav-title,
.nav-chapter[data-reading-status="read"]:not([aria-current="page"]) .nav-index {
  color: color-mix(in srgb, var(--text-soft) 82%, var(--text-faint));
}

.nav-chapter[data-reading-status="unread"]:not([aria-current="page"]) .nav-title {
  color: var(--text);
}

.nav-chapter[data-reading-status="unread"]:not([aria-current="page"]) .nav-index {
  color: var(--accent-strong);
  font-weight: 700;
}

.nav-home:hover,
.nav-chapter:hover {
  background: var(--surface);
  color: var(--text);
}

.nav-home[aria-current="page"],
.nav-chapter[aria-current="page"] {
  border-left-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.nav-home[aria-current="page"] .nav-index,
.nav-chapter[aria-current="page"] .nav-index {
  color: var(--accent-strong);
}

.nav-footer {
  margin-top: 30px;
  padding: 18px 9px 0;
  border-top: 1px solid var(--border);
}

.nav-footer p {
  margin: 0 0 11px;
  color: var(--text-faint);
  font-size: 0.69rem;
  line-height: 1.52;
}

.nav-footer .text-button {
  width: 100%;
  min-height: 31px;
  padding: 4px 0;
  text-align: left;
}

.reader-main {
  --reader-main-inline-padding: clamp(30px, 5vw, 80px);
  min-width: 0;
  padding: 54px var(--reader-main-inline-padding) 92px;
}

.chapter-tools {
  padding: 0 20px 44px;
  border-left: 1px solid var(--border-strong);
  background: color-mix(in srgb, var(--bg) 82%, var(--nav-bg));
}

.notes-rail-header {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 24px 0 15px;
  border-bottom: 1px solid var(--border-strong);
  background: color-mix(in srgb, var(--bg) 82%, var(--nav-bg));
}

.notes-rail-header .rail-kicker {
  margin-bottom: 5px;
}

.notes-rail-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.notes-rail-title-row h2 {
  margin: 0;
  color: var(--text);
  font-size: 1.15rem;
  line-height: 1.2;
}

.notes-rail-count {
  min-width: 26px;
  padding: 3px 7px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  font: 700 0.62rem/1 var(--mono);
  text-align: center;
}

.rail-panel:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 4px;
}

.notes-rail-header + .rail-panel {
  padding-top: 18px;
}

.rail-kicker {
  margin: 0 0 12px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.book-map-outline {
  margin: -2px 7px 14px 38px;
  padding: 8px 0 9px 10px;
  border-left: 1px solid var(--border-strong);
}

.book-map-outline[hidden] {
  display: none;
}

.book-map-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 8px 7px 10px;
  color: var(--text-faint);
  font: 700 0.57rem/1.25 var(--mono);
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

.book-map-header span:last-child {
  letter-spacing: 0;
  text-transform: none;
}

.outline-map-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.outline-map-item {
  position: relative;
  transition: background-color 140ms ease;
}

.outline-map-item.is-in-view {
  background: color-mix(in srgb, var(--accent) 11%, transparent);
}

.outline-map-item.is-range-start {
  border-radius: var(--radius) var(--radius) 0 0;
}

.outline-map-item.is-range-end {
  border-radius: 0 0 var(--radius) var(--radius);
}

.outline-map-item.is-range-start.is-range-end {
  border-radius: var(--radius);
}

.outline-map-item.level-3::before {
  content: "";
  position: absolute;
  top: 16px;
  left: 11px;
  width: 7px;
  border-top: 1px solid var(--border-strong);
}

.outline-link {
  min-height: 32px;
  display: grid;
  align-content: center;
  padding: 5px 8px 5px 10px;
  border-left: 2px solid transparent;
  color: var(--text-faint);
  font-size: 0.72rem;
  line-height: 1.4;
  text-decoration: none;
}

.outline-link small {
  display: block;
  margin-top: 1px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.56rem;
}

.outline-map-item.level-3 .outline-link {
  padding-left: 22px;
}

.outline-link:hover,
.outline-link:focus-visible,
.outline-link.is-active {
  border-left-color: var(--accent);
  outline: 0;
  color: var(--text);
}

.outline-link:hover,
.outline-link:focus-visible {
  background: var(--surface);
}

.outline-map-item.is-in-view > .outline-link:not(.is-active):hover,
.outline-map-item.is-in-view > .outline-link:not(.is-active):focus-visible {
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}

.outline-link.is-active {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  font-weight: 700;
}

.home-view {
  max-width: 1120px;
  margin: 0 auto;
}

.home-hero {
  min-height: calc(100dvh - var(--topbar-height) - 108px);
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, 0.65fr);
  align-items: center;
  gap: clamp(48px, 7vw, 96px);
}

.home-hero.has-editorial-overview {
  min-height: auto;
  padding: clamp(36px, 6vw, 72px) 0 clamp(72px, 9vw, 112px);
}

.hero-copy {
  max-width: 710px;
  padding-top: 22px;
  border-top: 3px solid var(--accent-muted);
}

.hero-kicker,
.dialog-kicker,
.chapter-group,
.section-heading > p {
  margin: 0 0 14px;
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hero-copy h1 {
  max-width: 680px;
  margin: 0;
  font-size: clamp(3.15rem, 5.5vw, 5.4rem);
  font-weight: 720;
  letter-spacing: -0.065em;
  line-height: 0.92;
  text-wrap: balance;
}

.hero-author {
  margin: 22px 0 0;
  color: var(--text-soft);
  font-family: var(--reader-font);
  font-size: 1.05rem;
  font-style: italic;
}

.hero-summary {
  max-width: 48ch;
  margin: 20px 0 0;
  color: var(--text-soft);
  font-family: var(--reader-font);
  font-size: 1.08rem;
  line-height: 1.62;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 27px;
}

.resume-note {
  margin: 10px 0 0;
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 0.61rem;
}

.book-facts {
  max-width: 590px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 38px 0 0;
  border-top: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-strong);
}

.book-facts div {
  padding: 15px 0;
}

.book-facts div + div {
  padding-left: 18px;
  border-left: 1px solid var(--border);
}

.book-facts dt {
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.59rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.book-facts dd {
  margin: 5px 0 0;
  font-size: 1.02rem;
  font-weight: 700;
}

.cover-panel {
  position: relative;
  width: min(100%, 330px);
  margin: 0;
  justify-self: end;
  padding: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.cover-placeholder {
  min-height: 31rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.8rem;
  padding: 2rem;
  border: 1px solid var(--border);
  background: var(--surface-strong);
}

.cover-placeholder strong {
  max-width: 12ch;
  font-family: var(--reading-latin), var(--reading-cjk), serif;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 0.95;
}

.cover-placeholder small {
  color: var(--text-soft);
}

.cover-label {
  display: block;
  padding: 2px 0 12px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.book-cover {
  display: block;
  width: 100%;
  height: auto;
  background: var(--surface-strong);
}

.cover-panel figcaption {
  padding: 10px 1px 1px;
  color: var(--text-faint);
  font-size: 0.66rem;
}

.editorial-overview {
  padding: clamp(58px, 8vw, 92px) 0 clamp(66px, 9vw, 104px);
  border-top: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-strong);
}

.overview-lead {
  max-width: 980px;
}

.overview-lead h2 {
  margin: 0 0 24px;
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.overview-thesis {
  max-width: 23em;
  margin: 0;
  font-family: var(--reader-font);
  font-size: clamp(1.9rem, 3.4vw, 3.3rem);
  font-weight: 620;
  letter-spacing: -0.045em;
  line-height: 1.17;
  text-wrap: balance;
}

.overview-body {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(240px, 0.55fr);
  gap: clamp(46px, 8vw, 104px);
  align-items: start;
  margin-top: clamp(44px, 6vw, 70px);
}

.overview-introduction {
  max-width: 70ch;
  color: var(--text-soft);
  font-family: var(--reader-font);
  font-size: 1.02rem;
  line-height: 1.84;
}

.overview-introduction p {
  margin: 0;
}

.overview-introduction p + p {
  margin-top: 1.25em;
}

.overview-aside {
  display: grid;
  gap: 34px;
}

.overview-aside-group {
  padding-top: 15px;
  border-top: 2px solid var(--accent-muted);
}

.overview-aside-group h3,
.overview-landmarks > h3 {
  margin: 0 0 14px;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.overview-aside-group ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text-soft);
  font-family: var(--reader-font);
}

.overview-aside-group li {
  padding-left: 0.2rem;
  line-height: 1.55;
}

.overview-aside-group li + li {
  margin-top: 0.72rem;
}

.overview-aside-group p {
  margin: 0;
  color: var(--text-faint);
  font-family: var(--reader-font);
  font-size: 0.86rem;
  line-height: 1.68;
}

.overview-landmarks {
  margin-top: clamp(58px, 8vw, 92px);
}

.overview-landmarks > h3 {
  margin-bottom: 22px;
  font-size: 0.82rem;
}

.overview-landmarks ol {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: clamp(32px, 6vw, 76px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.overview-landmarks li {
  min-width: 0;
}

.overview-landmarks a {
  min-height: 100%;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  padding: 18px 4px 21px;
  border-top: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  transition: background-color 150ms ease, color 150ms ease, transform 90ms ease;
}

.overview-landmarks a:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
  transform: translateX(3px);
}

.overview-landmark-number {
  padding-top: 2px;
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 0.63rem;
}

.overview-landmarks strong,
.overview-landmarks small {
  display: block;
}

.overview-landmarks strong {
  font-size: 0.92rem;
}

.overview-landmarks small {
  margin-top: 7px;
  color: var(--text-faint);
  font-family: var(--reader-font);
  font-size: 0.82rem;
  line-height: 1.58;
}

.visual-index,
.reading-map {
  margin-top: 104px;
}

.section-heading {
  display: grid;
  grid-template-columns: 150px minmax(0, 680px);
  gap: 30px;
  align-items: start;
  margin-bottom: 34px;
}

.section-heading > p {
  margin-top: 7px;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.8rem);
  letter-spacing: -0.055em;
  line-height: 1;
  text-wrap: balance;
}

.plate-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  padding: 1px;
  background: var(--border-strong);
}

.plate {
  min-width: 0;
  display: block;
  padding: 12px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.plate img {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: block;
  object-fit: contain;
  background: var(--image-bg);
  filter: saturate(0.82) contrast(0.96);
}

.plate > span {
  display: block;
  padding: 13px 2px 3px;
}

.plate strong,
.plate small {
  display: block;
}

.plate strong {
  font-size: 0.86rem;
}

.plate small {
  margin-top: 4px;
  color: var(--text-faint);
  font-family: var(--reader-font);
  font-size: 0.76rem;
}

.plate:hover {
  background: var(--accent-soft);
}

.map-group {
  scroll-margin-top: calc(var(--topbar-height) + 24px);
  display: grid;
  grid-template-columns: minmax(190px, 0.66fr) minmax(360px, 1.34fr);
  gap: 38px;
  padding: 27px 0;
  border-top: 1px solid var(--border);
}

#contents {
  scroll-margin-top: calc(var(--topbar-height) + 24px);
}

.map-group:last-child {
  border-bottom: 1px solid var(--border);
}

.map-group h3 {
  margin: 0;
  font-size: 1rem;
}

.map-group p {
  max-width: 45ch;
  margin: 7px 0 0;
  color: var(--text-soft);
  font-family: var(--reader-font);
  font-size: 0.9rem;
  line-height: 1.55;
}

.map-links {
  display: grid;
}

.map-links a {
  min-width: 0;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: baseline;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 0.82rem;
  text-decoration: none;
}

.map-links a:first-child {
  border-top: 1px solid var(--border);
}

.map-links a:hover {
  padding-left: 9px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.map-number,
.map-time {
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.62rem;
}

.edition-note {
  max-width: var(--reading-measure);
  margin: 82px 0 0 auto;
  padding: 19px 0 19px 24px;
  border-left: 3px solid var(--accent);
  color: var(--text-soft);
  font-family: var(--reader-font);
  font-size: 1rem;
  line-height: 1.62;
}

.chapter-view {
  max-width: 800px;
  margin: 0 auto;
  font-size: calc(1rem * var(--reader-scale));
}

.chapter-header {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 24px;
  padding: 0 0 32px;
  border-bottom: 1px solid var(--border-strong);
}

.chapter-number {
  padding-top: 5px;
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 1.15rem;
}

.chapter-labels {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  margin: -5px 0 -5px auto;
}

.chapter-label-button {
  min-width: 32px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.chapter-editorial-label,
.chapter-label-control {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  box-sizing: border-box;
}

.chapter-editorial-label {
  display: block;
  max-width: min(100%, 30ch);
  padding: 5px 9px 5px 11px;
  overflow: hidden;
  border-block: 1px solid var(--border-strong);
  border-inline-start: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 72%, transparent);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.59rem;
  font-weight: 750;
  letter-spacing: 0.085em;
  line-height: 1.25;
  text-overflow: ellipsis;
  text-align: end;
  text-transform: uppercase;
  white-space: nowrap;
}

.chapter-label-control {
  min-width: 24px;
  justify-content: center;
  padding: 4px 6px;
  border: 1px solid var(--border-strong);
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 750;
  line-height: 1;
}

.chapter-label-button:hover .chapter-editorial-label,
.chapter-label-button:hover .chapter-label-control {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.chapter-label-button:active {
  transform: translateY(1px);
}

.chapter-header h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2.8rem, 5.5vw, 5rem);
  font-weight: 720;
  letter-spacing: -0.06em;
  line-height: 0.96;
  text-wrap: balance;
}

.chapter-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px 18px;
  margin-top: 21px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.65rem;
}

.chapter-reading-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-soft);
  font: inherit;
}

.reading-status-marker {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border: 1px solid transparent;
  background: transparent;
}

.chapter-reading-status[data-reading-status="unread"] .reading-status-marker {
  border-color: var(--accent);
  background: var(--accent);
}

.chapter-reading-status[data-reading-status="read"] {
  color: var(--text-soft);
}

.book-body {
  position: relative;
  color: var(--text);
  font-family: var(--reader-font);
  font-size: 1.125em;
  font-kerning: normal;
  font-optical-sizing: auto;
  letter-spacing: var(--reading-letter-spacing);
  line-height: var(--reading-line-height);
  hanging-punctuation: first last;
}

.book-body > *,
.book-body > :is(div, article, section) > :is(p, h2, h3, h4, h5, h6, ul, ol, aside, figure, table, pre, blockquote) {
  content-visibility: auto;
  contain-intrinsic-block-size: auto 180px;
}

body.is-restoring-document-position .book-body > *,
body.is-restoring-document-position .book-body > :is(div, article, section) > :is(p, h2, h3, h4, h5, h6, ul, ol, aside, figure, table, pre, blockquote) {
  content-visibility: visible;
}

.book-body > p,
.book-body > :is(div, article, section) > p {
  contain-intrinsic-block-size: auto 96px;
}

.book-body > h2,
.book-body > :is(div, article, section) > h2 {
  contain-intrinsic-block-size: auto 64px;
}

.book-body > h3,
.book-body > :is(div, article, section) > h3 {
  contain-intrinsic-block-size: auto 32px;
}

.book-body > h4,
.book-body > :is(div, article, section) > h4 {
  contain-intrinsic-block-size: auto 26px;
}

.book-body > :is(ul, ol),
.book-body > :is(div, article, section) > :is(ul, ol) {
  contain-intrinsic-block-size: auto 280px;
}

.book-body > :is(div, aside, figure, table, pre, blockquote),
.book-body > :is(div, article, section) > :is(aside, figure, table, pre, blockquote) {
  contain-intrinsic-block-size: auto 220px;
}

.book-body p {
  max-width: var(--reading-measure);
  margin: 0 0 var(--reading-paragraph-gap);
}

:root:lang(en) .book-body > p:first-of-type::first-letter,
:root:lang(en) .book-body > div:first-child > p:first-of-type::first-letter {
  float: left;
  margin: 0.08em 0.1em 0 0;
  color: var(--accent-strong);
  font-family: var(--sans);
  font-size: 3.5em;
  font-weight: 700;
  line-height: 0.76;
}

.book-body h2,
.book-body h3,
.book-body h4 {
  color: var(--text);
  font-family: var(--sans);
  scroll-margin-top: calc(var(--topbar-height) + 28px);
  text-wrap: balance;
}

.book-body h2 {
  margin: 2.7em 0 0.75em;
  padding-top: 0.7em;
  border-top: 2px solid var(--accent);
  font-size: 1.72em;
  letter-spacing: -0.035em;
  line-height: 1.13;
}

:root[data-theme="willemstad"] .book-body h2 {
  padding: 0.34em 0.46em;
  border-top: 0;
  background: var(--accent);
  color: var(--accent-ink);
}

:root[data-theme="willemstad"] .book-body h2 a {
  color: inherit;
  text-decoration-color: color-mix(in srgb, currentColor 52%, transparent);
}

.book-body h3 {
  margin: 2.1em 0 0.58em;
  font-size: 1.25em;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.book-body h4 {
  margin: 1.75em 0 0.46em;
  color: var(--text-soft);
  font-size: 1em;
  line-height: 1.25;
}

:root:lang(en) .book-body {
  hyphens: auto;
}

:root:lang(zh) .chapter-view {
  max-width: 720px;
}

:root:lang(zh) .chapter-header h1 {
  letter-spacing: -0.015em;
  line-height: 1.05;
}

:root:lang(zh) .book-body {
  line-break: strict;
  overflow-wrap: anywhere;
  text-autospace: normal;
  text-spacing-trim: trim-start;
  word-break: normal;
}

:root:lang(zh) .book-body h2,
:root:lang(zh) .book-body h3,
:root:lang(zh) .book-body h4 {
  letter-spacing: 0;
  line-height: 1.35;
}

:root:lang(zh) .book-body p:not(.is-centered),
:root:lang(zh) .book-body li {
  text-align: justify;
  text-justify: inter-ideograph;
}

.book-body strong {
  font-weight: 700;
}

.book-body strong.is-italic {
  font-style: italic;
}

.book-body a {
  color: var(--accent-strong);
  text-decoration-color: color-mix(in srgb, var(--accent) 60%, transparent);
  text-underline-offset: 0.18em;
}

.book-body a[data-link-preview] {
  text-decoration-style: dotted;
  text-decoration-thickness: 0.08em;
}

.book-body a:hover {
  text-decoration-color: currentColor;
}

.book-body a[data-link-preview]:focus-visible {
  border-radius: 2px;
}

.book-body .book-list,
.book-body ol {
  max-width: var(--reading-measure);
  margin: 1.15em 0 1.4em;
  padding-left: 1.45em;
}

.book-body li {
  margin: 0.5em 0;
  padding-left: 0.28em;
}

.book-body .book-list li > p {
  max-width: none;
  margin: 0;
}

.book-body .book-list li > p + p {
  margin-top: 0.55em;
}

.book-body div.highlighter-rouge {
  width: min(100%, var(--reading-measure));
  max-width: 100%;
  min-width: 0;
  margin: 1.35em 0 1.6em;
}

.book-body div.highlighter-rouge .highlight {
  max-width: 100%;
  min-width: 0;
}

.book-body .code-block {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 1.35em 0 1.6em;
  letter-spacing: normal;
}

.book-body div.highlighter-rouge .code-block {
  margin: 0;
}

.code-block-toolbar {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border-strong);
  background: var(--surface-strong);
  color: var(--text-soft);
  font-family: var(--mono);
}

.code-block-language {
  overflow: hidden;
  padding: 0 12px;
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.code-copy-button {
  min-width: 72px;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-left: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 650;
}

.code-copy-button:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.book-body pre {
  box-sizing: border-box;
  max-width: 100%;
  margin: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  padding: 0.9em 1.05em;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.78em;
  line-height: 1.65;
  tab-size: 2;
  white-space: pre;
  scrollbar-width: thin;
}

.book-body .code-block > pre {
  border-top: 0;
  background: var(--surface) !important;
}

.book-body pre code {
  color: inherit;
  font: inherit;
}

.book-body pre code.hljs {
  display: block;
  overflow: visible;
  padding: 0;
  background: transparent;
}

.hljs-comment,
.hljs-quote {
  color: var(--syntax-comment);
  font-style: italic;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-section,
.hljs-link {
  color: var(--syntax-keyword);
}

.hljs-string,
.hljs-regexp,
.hljs-symbol,
.hljs-bullet,
.hljs-attribute {
  color: var(--syntax-string);
}

.hljs-number,
.hljs-built_in,
.hljs-type,
.hljs-params {
  color: var(--syntax-number);
}

.hljs-title,
.hljs-title.class_,
.hljs-title.function_,
.hljs-selector-id,
.hljs-selector-class {
  color: var(--syntax-title);
}

.hljs-variable,
.hljs-template-variable,
.hljs-property {
  color: var(--syntax-variable);
}

.hljs-meta,
.hljs-meta .hljs-keyword,
.hljs-doctag,
.hljs-name,
.hljs-tag {
  color: var(--syntax-meta);
}

.hljs-addition {
  color: var(--syntax-addition);
}

.hljs-deletion {
  color: var(--syntax-deletion);
}

.hljs-emphasis {
  font-style: italic;
}

.hljs-strong {
  font-weight: 700;
}

.book-body blockquote {
  margin: 1.8em 0;
  padding: 0.2em 0 0.2em 1.2em;
  border-left: 3px solid var(--accent);
  color: var(--text-soft);
}

.book-formula {
  color: inherit;
  font-family: math, "Cambria Math", "STIX Two Math", serif;
}

.book-body .formula-line {
  max-width: var(--reading-measure);
  margin: 1.15em 0 1.35em;
  overflow-x: auto;
  padding: 0.18em 0 0.32em;
  text-align: center;
  scrollbar-width: thin;
}

.formula-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  max-width: var(--reading-measure);
  margin: 1.15em 0 1.45em;
  gap: 0.45em 1.35em;
  align-items: center;
}

.book-body .formula-group .formula-line {
  margin: 0;
  padding: 0.32em 0;
}

.book-formula[data-layout="display"] {
  font-size: 1.16em;
}

.book-formula:not([data-layout="display"]) {
  margin-inline: 0.12em;
  vertical-align: -0.08em;
  font-size: 1.04em;
}

.book-formula mtext {
  font-family: var(--sans);
  font-style: normal;
}

.book-callout {
  max-width: var(--reading-measure);
  margin: 2em 0;
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  background: var(--surface);
}

.callout-title {
  padding: 11px 15px;
  border-bottom: 1px solid var(--border);
  background: var(--accent-muted);
  color: var(--accent-muted-ink);
  font-family: var(--sans);
  font-size: 0.76em;
  font-weight: 750;
  letter-spacing: 0.04em;
}

.callout-body {
  padding: 15px 17px 6px;
  color: var(--text-soft);
  font-size: 0.92em;
}

.book-body sup,
.book-body sub {
  font-size: 0.72em;
  line-height: 0;
}

.book-body .is-centered {
  text-align: center;
}

.book-body .epub-wonderbook {
  width: 100%;
}

.book-body .epub-wonderbook .epub-page-break,
.book-body .epub-wonderbook .pagebreak {
  height: 1px;
  margin: 3.5rem 0;
  border-top: 1px solid var(--border-strong);
}

.book-body .epub-wonderbook .epub-image,
.book-body .epub-wonderbook p[class*="image"] {
  max-width: 100%;
  margin: 1.8em auto 0.55em;
  text-align: center;
}

.book-body .epub-wonderbook .epub-image img,
.book-body .epub-wonderbook p[class*="image"] img {
  max-height: 78vh;
  object-fit: contain;
}

.book-body .epub-wonderbook .epub-caption,
.book-body .epub-wonderbook p[class*="caption"] {
  max-width: min(100%, 48rem);
  margin: -0.05em auto 1.8em;
  color: var(--text-faint);
  font-family: var(--sans);
  font-size: 0.78em;
  line-height: 1.4;
  text-align: center;
}

.book-body .epub-wonderbook p[class*="bq"],
.book-body .epub-wonderbook p[class*="note"] {
  max-width: min(100%, 48rem);
  margin: 1.7em 0;
  padding: 0.85em 1.1em;
  border-left: 3px solid var(--accent);
  background: var(--surface-strong);
  color: var(--text-soft);
}

.book-body .epub-wonderbook p.contents {
  margin-top: 0;
}

.book-body .epub-wonderbook p.toc-chap {
  margin: 1.65em 0 0.45em;
  font-family: var(--sans);
  font-weight: 700;
}

.book-body .epub-wonderbook p.toc1,
.book-body .epub-wonderbook p.toc1a,
.book-body .epub-wonderbook p.toct,
.book-body .epub-wonderbook p.toct1 {
  margin: 0.3em 0;
  padding-left: 1.2rem;
  font-family: var(--sans);
  font-size: 0.94em;
  line-height: 1.45;
}

.book-body .epub-wonderbook p.toc2 {
  margin: 0.25em 0;
  padding-left: 2.5rem;
  font-family: var(--sans);
  font-size: 0.9em;
  line-height: 1.4;
}

.book-body .epub-wonderbook > div[class*="group"],
.book-body .epub-wonderbook > div[class*="sidebar"],
.book-body .epub-wonderbook > div[class*="box"] {
  max-width: 100%;
  margin: 1.8em 0;
}

.book-body .image-row {
  max-width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: 12px;
  margin: 1.9em auto;
  text-align: center;
}

.book-body img {
  max-width: 100%;
  height: auto;
  display: inline-block;
  border: 1px solid var(--border);
  background: var(--image-bg);
  cursor: zoom-in;
}

.book-body img[data-pixel-art="true"] {
  image-rendering: pixelated;
}

.table-scroll {
  width: min(100%, calc(100vw - 32px));
  margin: 1.8em 0;
  overflow-x: auto;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  scrollbar-width: thin;
}

/* Wide reference grids scroll on their own paint layer with stable column geometry. */
.table-scroll.reader-wide-table-shell {
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  contain: layout paint;
  isolation: isolate;
  will-change: scroll-position;
  -webkit-overflow-scrolling: touch;
}

.book-body table.reader-wide-table {
  width: max(100%, calc(var(--reader-wide-columns, 6) * 7em));
  min-width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

.book-body table.reader-wide-table th,
.book-body table.reader-wide-table td {
  min-width: 0;
}

.book-body table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.75em;
  line-height: 1.4;
}

.book-body th,
.book-body td {
  min-width: 7em;
  padding: 9px 11px;
  border: 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
}

.book-body th {
  background: var(--surface-strong);
}

.book-body tr:last-child td {
  border-bottom: 0;
}

.book-body td p {
  margin: 0 0 0.42em;
}

.book-body td p:last-child {
  margin-bottom: 0;
}

/* MediaWiki facts are preserved as tables, but presented as ReaderToy field-guide material. */
.reader-infobox-shell {
  max-width: 44rem;
  margin: 2em 0 2.4em;
  overflow: visible;
  border-color: var(--border-strong);
  border-top: 3px solid var(--accent);
  background: var(--surface);
}

.book-body table.reader-infobox {
  min-width: 0;
  background: transparent;
  font-size: 0.84em;
  line-height: 1.48;
}

.book-body .reader-infobox-title {
  padding: 13px 15px;
  border-bottom: 1px solid var(--border-strong);
  background: color-mix(in srgb, var(--accent) 11%, var(--surface));
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.035em;
  text-align: left;
}

.book-body .reader-infobox > tbody > tr > th,
.book-body .reader-infobox > tbody > tr > td {
  min-width: 0;
  padding: 10px 14px;
  border-bottom-color: var(--border);
}

.book-body .reader-infobox > tbody > tr > .reader-infobox-label {
  width: 40%;
  background: color-mix(in srgb, var(--surface-strong) 58%, var(--surface));
  color: var(--text-soft);
  font-weight: 650;
}

.book-body .reader-infobox > tbody > .reader-infobox-media-row > td {
  padding: 16px;
  background: var(--surface);
  text-align: center;
  vertical-align: middle;
}

.book-body .reader-infobox-media-row img {
  border-color: var(--border);
}

.book-body .reader-infobox > tbody > .reader-infobox-section-row > th {
  padding: 18px 14px 8px;
  border-top: 1px solid var(--border-strong);
  border-bottom: 0;
  background: transparent;
  color: var(--accent-strong);
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.book-body .reader-infobox ul {
  margin: 0;
  padding-left: 1.25em;
}

.reader-infobox-matrix-shell {
  width: 100%;
  margin: 2px 0 4px;
  overflow: visible;
  border: 0;
  background: transparent;
}

.book-body table.reader-infobox-matrix {
  min-width: 0;
  table-layout: fixed;
  background: transparent !important;
  font-size: 0.8rem;
  line-height: 1.35;
}

.book-body .reader-infobox-matrix th,
.book-body .reader-infobox-matrix td {
  min-width: 0;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  background: transparent;
}

.book-body .reader-infobox-matrix thead th {
  background: var(--surface-strong);
  color: var(--text);
  font-weight: 700;
  text-align: center;
}

.book-body .reader-infobox-matrix tbody th {
  width: 42%;
  background: color-mix(in srgb, var(--surface-strong) 58%, var(--surface));
  color: var(--text-soft);
  font-weight: 650;
}

.book-body .reader-infobox-matrix tbody td {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.book-body .wiki-flavor-text {
  margin: 1.8em 0 2.15em;
  padding: 0.9em 1.05em 0.95em 1.2em;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  color: var(--text-soft);
  font-family: var(--reader-font);
  font-size: 0.98em;
  line-height: 1.62;
}

.book-body .wiki-flavor-text p {
  margin: 0;
}

.book-body .wiki-flavor-text i,
.book-body .wiki-flavor-text em {
  font-style: italic;
}

.chapter-view[data-document="index"] .book-body {
  columns: 2 280px;
  column-gap: 42px;
  font-size: 0.94em;
}

.chapter-view[data-document="index"] .book-body p {
  break-inside: avoid;
  margin-bottom: 0.38em;
  line-height: 1.45;
}

mark {
  padding: 0 0.05em;
  border-radius: 1px;
  color: inherit;
}

.search-hit {
  background: var(--search-mark);
}

.user-highlight {
  --annotation-fill: var(--annotation-marker-mint);
  --annotation-stroke: var(--annotation-marker-mint);
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  vertical-align: baseline;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.annotation-mint {
  --annotation-fill: var(--annotation-marker-mint);
  --annotation-stroke: var(--annotation-marker-mint);
}

.annotation-sun {
  --annotation-fill: var(--annotation-marker-sun);
  --annotation-stroke: var(--annotation-marker-sun);
}

.annotation-blue {
  --annotation-fill: var(--annotation-marker-blue);
  --annotation-stroke: var(--annotation-marker-blue);
}

.annotation-pink {
  --annotation-fill: var(--annotation-marker-pink);
  --annotation-stroke: var(--annotation-marker-pink);
}

.annotation-violet {
  --annotation-fill: var(--annotation-marker-violet);
  --annotation-stroke: var(--annotation-marker-violet);
}

.annotation-red {
  --annotation-fill: var(--annotation-marker-red);
  --annotation-stroke: var(--annotation-marker-red);
}

.user-highlight.annotation-style-highlight,
.note-quote.annotation-style-highlight {
  background: var(--annotation-fill);
  color: var(--bg);
  text-decoration: none;
}

.user-highlight.annotation-style-highlight {
  box-shadow: 0 -0.1em 0 var(--annotation-fill), 0 0.035em 0 var(--annotation-fill);
}

.user-highlight.annotation-style-underline,
.note-quote.annotation-style-underline {
  background: transparent;
  text-decoration-line: underline;
  text-decoration-color: var(--annotation-stroke);
  text-decoration-thickness: 0.13em;
  text-underline-offset: 0.14em;
  text-decoration-skip-ink: none;
}

.user-highlight.annotation-style-wavy,
.note-quote.annotation-style-wavy {
  background: transparent;
  text-decoration-line: underline;
  text-decoration-style: wavy;
  text-decoration-color: var(--annotation-stroke);
  text-decoration-thickness: 0.09em;
  text-underline-offset: 0.14em;
  text-decoration-skip-ink: none;
}

.user-highlight.annotation-style-strike,
.note-quote.annotation-style-strike {
  background: transparent;
  text-decoration-line: line-through;
  text-decoration-color: var(--annotation-stroke);
  text-decoration-thickness: 0.11em;
}

.user-highlight.is-pulsing {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.chapter-completion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 88px;
  padding: 22px 0;
  border-top: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border);
}

.chapter-completion-label {
  margin: 0;
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.3;
}

.chapter-completion-action {
  min-width: 132px;
}

.chapter-completion[data-reading-status="read"] .chapter-completion-label {
  color: var(--accent-strong);
}

.chapter-completion[data-reading-status="read"] .chapter-completion-action {
  border-color: var(--border-strong);
  background: transparent;
  color: var(--text-soft);
  font-weight: 600;
}

.chapter-completion[data-reading-status="read"] .chapter-completion-action:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.chapter-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin-top: 24px;
  padding: 1px;
  background: var(--border-strong);
}

.pager-link {
  min-height: 90px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 15px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.pager-link.next {
  align-items: flex-end;
  text-align: right;
}

.pager-label {
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.pager-title {
  margin-top: 6px;
  font-weight: 700;
}

.pager-link:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.notes-intro {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.notes-intro p:last-child {
  margin: 0;
  color: var(--text-faint);
  font-family: var(--reader-font);
  font-size: 0.75rem;
  line-height: 1.5;
}

.sync-conflicts {
  margin: 14px 0 4px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--danger) 52%, var(--border));
  background: color-mix(in srgb, var(--danger) 7%, var(--surface));
}

.sync-conflicts-heading h3 {
  margin: 3px 0 10px;
  font: 700 0.86rem/1.2 var(--sans);
}

.sync-conflict-card + .sync-conflict-card {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.sync-conflict-card > p,
.sync-conflict-version p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.7rem;
  line-height: 1.45;
}

.sync-conflict-versions {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.sync-conflict-version {
  padding: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.sync-conflict-version strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text-faint);
  font: 700 0.56rem/1.2 var(--mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sync-conflict-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.sync-conflict-actions button {
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface-strong);
  color: var(--text);
  font: 0.62rem/1.2 var(--mono);
  cursor: pointer;
}

.sync-conflict-actions button:hover,
.sync-conflict-actions button:focus-visible {
  border-color: var(--danger);
}

.annotation-data-setting > p {
  max-width: 64ch;
  margin: 0 0 12px;
  color: var(--text-faint);
  font-size: 0.76rem;
  line-height: 1.5;
}

.annotation-data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.note-card {
  margin-inline: -8px;
  padding: 14px 0;
  padding-inline: 8px;
  border-bottom: 1px solid var(--border);
}

.note-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 7px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.55rem;
  text-transform: uppercase;
}

.annotation-semantic-badge {
  padding: 3px 6px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text-soft);
  letter-spacing: 0.025em;
}

.note-meta-button {
  min-width: 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  white-space: nowrap;
  cursor: pointer;
}

.note-meta-button::after {
  flex: 0 0 auto;
  color: var(--text-faint);
  font-size: 0.82rem;
  content: "›";
}

.note-meta-button[aria-expanded="true"]::after {
  transform: rotate(90deg);
}

.note-meta-button:hover,
.note-meta-button[aria-expanded="true"] {
  color: var(--text);
}

.note-meta-button:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 1px;
}

.note-appearance-button {
  justify-content: flex-end;
  overflow: hidden;
  text-align: right;
}

.note-appearance-button span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-quote {
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-left: 3px solid var(--annotation-stroke);
  color: var(--text);
  font-family: var(--reader-font);
  font-size: 0.76rem;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
}

.note-area-preview {
  --annotation-fill: var(--annotation-marker-mint);
  --annotation-stroke: var(--annotation-marker-mint);
  width: 100%;
  display: grid;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-left: 3px solid var(--annotation-stroke);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.note-area-preview:hover {
  border-color: var(--annotation-stroke);
  background: var(--surface-strong);
}

.note-area-preview:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.note-area-preview img {
  width: 100%;
  height: auto;
  max-height: 220px;
  display: block;
  object-fit: contain;
  background: color-mix(in srgb, var(--surface-strong) 78%, var(--bg));
}

.note-area-placeholder {
  min-height: 106px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--annotation-fill) 14%, var(--surface));
  color: var(--annotation-stroke);
}

.note-area-placeholder svg {
  width: 36px;
  height: 36px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.note-area-caption {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  font-family: var(--sans);
  font-size: 0.68rem;
}

.note-area-caption strong {
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 650;
  text-transform: uppercase;
}

.note-area-caption span {
  color: var(--text-faint);
}

.note-area-preview:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.annotation-properties {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.annotation-quick-editor {
  grid-template-columns: 1fr;
  margin: 0 0 10px;
  padding: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.annotation-quick-editor label {
  margin-top: 0;
}

.annotation-properties label,
.note-color-options {
  min-width: 0;
  margin: 0;
}

.annotation-properties label > span,
.note-color-options legend {
  display: block;
  margin-bottom: 5px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.56rem;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

.annotation-properties select {
  width: 100%;
  min-height: 40px;
  padding: 6px 26px 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.68rem;
  cursor: pointer;
}

.note-color-options {
  grid-column: 1 / -1;
  padding: 0;
  border: 0;
}

.note-color-options .color-button {
  width: 44px;
  height: 44px;
}

.note-color-swatches {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  gap: 6px;
}

.note-card label {
  display: block;
  margin-top: 10px;
  color: var(--text-faint);
  font-size: 0.62rem;
}

.note-field-label {
  margin: 10px 0 5px;
  color: var(--text-faint);
  font-size: 0.62rem;
}

.note-markdown-shell {
  width: 100%;
  min-width: 0;
}

.note-markdown-preview,
.note-markdown-shell .cm-editor {
  width: 100%;
  min-height: 68px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.72rem;
  line-height: 1.42;
  overflow-wrap: anywhere;
}

.note-markdown-preview {
  padding: 8px;
  cursor: text;
}

.note-markdown-preview:focus-visible,
.note-markdown-shell .cm-editor.cm-focused {
  outline: 2px solid var(--accent-strong);
  outline-offset: 1px;
}

.note-markdown-preview.is-empty {
  color: var(--text-faint);
}

.note-markdown-block + .note-markdown-block {
  margin-top: 0.72em;
}

.note-markdown-preview p,
.note-markdown-preview h1,
.note-markdown-preview h2,
.note-markdown-preview h3,
.note-markdown-preview h4,
.note-markdown-preview h5,
.note-markdown-preview h6,
.note-markdown-preview blockquote,
.note-markdown-preview pre,
.note-markdown-preview ul,
.note-markdown-preview ol {
  margin: 0;
}

.note-markdown-preview h1,
.note-markdown-preview h2,
.note-markdown-preview h3,
.note-markdown-preview h4,
.note-markdown-preview h5,
.note-markdown-preview h6 {
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.2;
}

.note-markdown-preview h1 { font-size: 1.45em; }
.note-markdown-preview h2 { font-size: 1.3em; }
.note-markdown-preview h3 { font-size: 1.17em; }
.note-markdown-preview h4,
.note-markdown-preview h5,
.note-markdown-preview h6 { font-size: 1.05em; }

.note-markdown-preview ul,
.note-markdown-preview ol {
  padding-left: 1.55em;
}

.note-markdown-preview li + li {
  margin-top: 0.24em;
}

.note-markdown-preview blockquote {
  padding-left: 0.75em;
  border-left: 2px solid var(--annotation-stroke, var(--accent));
  color: var(--text-soft);
}

.note-markdown-preview code,
.note-markdown-shell .cm-note-inline-code,
.note-markdown-shell .cm-note-code-block {
  background: var(--surface-strong);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.92em;
}

.note-markdown-preview code {
  padding: 0.08em 0.28em;
}

.note-markdown-preview pre {
  padding: 7px 8px;
  background: var(--surface-strong);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.note-markdown-preview pre code {
  padding: 0;
  background: transparent;
}

.note-markdown-preview a,
.note-markdown-shell .cm-note-link {
  color: var(--accent-strong);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

.note-markdown-preview input[type="checkbox"],
.note-markdown-shell .cm-note-task-toggle {
  width: 1em;
  height: 1em;
  margin: 0 0.35em 0 0;
  accent-color: var(--accent);
  vertical-align: -0.12em;
}

.note-markdown-preview input[type="checkbox"] {
  pointer-events: none;
}

.note-markdown-image-omitted {
  color: var(--text-faint);
  font-style: italic;
}

.note-markdown-shell .cm-editor {
  font-family: var(--sans);
}

.note-markdown-shell .cm-scroller {
  overflow: visible;
  font-family: inherit;
  line-height: inherit;
}

.note-markdown-shell .cm-content {
  min-height: 66px;
  padding: 8px;
  caret-color: var(--text);
}

.note-markdown-shell .cm-line {
  padding: 0;
}

.note-markdown-shell .cm-cursor {
  border-left-color: var(--text);
}

.note-markdown-shell .cm-selectionBackground,
.note-markdown-shell .cm-content ::selection {
  background: color-mix(in srgb, var(--accent) 32%, transparent) !important;
}

.note-markdown-shell .cm-note-heading {
  color: var(--text);
  font-weight: 700;
  line-height: 1.2;
}

.note-markdown-shell .cm-note-heading-1 { font-size: 1.45em; }
.note-markdown-shell .cm-note-heading-2 { font-size: 1.3em; }
.note-markdown-shell .cm-note-heading-3 { font-size: 1.17em; }
.note-markdown-shell .cm-note-heading-4,
.note-markdown-shell .cm-note-heading-5,
.note-markdown-shell .cm-note-heading-6 { font-size: 1.05em; }

.note-markdown-shell .cm-note-strong {
  font-weight: 700;
}

.note-markdown-shell .cm-note-emphasis {
  font-style: italic;
}

.note-markdown-shell .cm-note-blockquote {
  padding-left: 0.75em;
  border-left: 2px solid var(--annotation-stroke, var(--accent));
  color: var(--text-soft);
}

.note-markdown-shell .cm-note-code-block {
  padding-inline: 8px;
}

.note-markdown-shell .cm-note-task-toggle {
  cursor: pointer;
}

.note-card textarea {
  width: 100%;
  min-height: 68px;
  display: block;
  margin-top: 5px;
  padding: 8px;
  overflow-y: hidden;
  resize: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  field-sizing: content;
  font-size: 0.72rem;
  line-height: 1.42;
}

.note-card footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 10px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.56rem;
  text-transform: uppercase;
}

.note-card footer > [data-note-delete] {
  min-height: 44px;
  padding: 3px 0;
  border: 0;
  background: transparent;
  color: var(--danger);
  font-size: 0.62rem;
  cursor: pointer;
}

.note-card.is-unresolved {
  opacity: 0.78;
}

.note-card.is-unresolved .note-quote {
  cursor: not-allowed;
}

.note-location-warning {
  margin: 7px 0 0;
  color: var(--danger);
  font: 0.66rem/1.4 var(--sans);
}

.notes-empty {
  margin: 18px 0;
  color: var(--text-faint);
  font-family: var(--reader-font);
  font-size: 0.8rem;
  line-height: 1.55;
}

.reader-dialog {
  width: min(650px, calc(100vw - 28px));
  max-height: min(780px, calc(100dvh - 32px));
  margin: auto;
  padding: 26px;
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 18px 22px 70px var(--shadow);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.reader-dialog::backdrop,
.image-dialog::backdrop {
  background: color-mix(in srgb, var(--bg) 65%, transparent);
  backdrop-filter: blur(5px);
}

.dialog-header {
  position: sticky;
  top: -26px;
  z-index: 4;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  margin: -26px -26px 24px;
  padding: 26px 26px 18px;
  border-bottom: 1px solid var(--border-strong);
  background: var(--surface);
}

.dialog-header h2 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: -0.04em;
}

.dialog-kicker {
  margin-bottom: 7px;
}

.dialog-close {
  min-height: 44px;
  flex: 0 0 auto;
  margin: 0;
}

.search-label {
  display: block;
  margin-bottom: 7px;
  color: var(--text-soft);
  font-size: 0.76rem;
  font-weight: 700;
}

#search-input {
  width: 100%;
  min-height: 49px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}

#search-input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
  opacity: 1;
}

.keyboard-hint {
  margin: 9px 0 0;
  color: var(--text-faint);
  font-size: 0.65rem;
}

kbd {
  padding: 2px 5px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-family: var(--mono);
  font-size: 0.61rem;
}

.search-results {
  margin-top: 19px;
}

.search-result {
  display: block;
  padding: 15px 3px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}

.search-result:first-child {
  border-top: 1px solid var(--border);
}

.search-result-title {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  font-weight: 700;
}

.search-result-title span:last-child {
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 500;
}

.search-result p {
  margin: 7px 0 0;
  color: var(--text-soft);
  font-family: var(--reader-font);
  font-size: 0.88rem;
  line-height: 1.5;
}

.empty-state,
.error-state {
  margin: 0;
  padding: 23px 0;
  color: var(--text-soft);
  font-family: var(--reader-font);
  line-height: 1.55;
}

.setting-group {
  margin: 0;
  padding: 19px 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.setting-group:first-of-type {
  border-top: 0;
}

.setting-group legend {
  width: 100%;
  padding: 0 0 9px;
  color: var(--text-soft);
  font-size: 0.73rem;
  font-weight: 700;
}

.shortcut-list {
  display: grid;
  gap: 9px;
  margin: 0;
}

.shortcut-list > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
}

.shortcut-list dt {
  color: var(--text-soft);
  font-size: 0.72rem;
}

.shortcut-list dd {
  margin: 0;
  color: var(--text-faint);
  font-size: 0.65rem;
  text-align: right;
}

.shortcut-keys {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.shortcut-help {
  margin: 11px 0 0;
  color: var(--text-faint);
  font-size: 0.65rem;
  line-height: 1.45;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  padding: 1px;
  background: var(--border-strong);
}

.segmented-control button {
  border-radius: 0;
  background: var(--surface);
  color: var(--text-soft);
}

.segmented-control button:hover,
.segmented-control button[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

[data-reader-font-language="zh"][data-reader-font-value="song"] {
  font-family: var(--reading-cjk), serif;
}

[data-reader-font-language="zh"][data-reader-font-value="hei"] {
  font-family: var(--hei-cjk), sans-serif;
}

[data-reader-font-language="zh"][data-reader-font-value="system"] {
  font-family: var(--system-cjk), sans-serif;
}

[data-reader-font-language="en"][data-reader-font-value="reading"] {
  font-family: var(--reading-latin), serif;
}

[data-reader-font-language="en"][data-reader-font-value="classic"] {
  font-family: var(--classic-latin), serif;
}

[data-reader-font-language="en"][data-reader-font-value="sans"] {
  font-family: var(--sans-latin), sans-serif;
}

.text-size-control button:nth-child(1) {
  font-size: 0.8rem;
}

.text-size-control button:nth-child(2) {
  font-size: 1rem;
}

.text-size-control button:nth-child(3) {
  font-size: 1.18rem;
}

.typography-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.typography-language {
  min-width: 0;
  padding-right: 20px;
}

.typography-language + .typography-language {
  padding-right: 0;
  padding-left: 20px;
  border-left: 1px solid var(--border);
}

.typography-language h3 {
  margin: 0 0 13px;
  color: var(--text);
  font-size: 0.82rem;
}

.range-setting + .range-setting {
  margin-top: 13px;
}

.range-setting-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.range-setting label {
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 650;
}

.range-setting output {
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 0.66rem;
  font-variant-numeric: tabular-nums;
}

.range-setting input[type="range"] {
  width: 100%;
  height: 28px;
  margin: 3px 0 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.range-setting input[type="range"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.typography-reset {
  min-height: 32px;
  margin-top: 11px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font-size: 0.67rem;
  text-align: left;
}

.typography-reset:hover,
.typography-reset:focus-visible {
  color: var(--accent-strong);
}

.theme-control {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}

.theme-control button {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 7px;
  border-color: var(--border);
  background: transparent;
  color: var(--text-soft);
  text-align: left;
}

.theme-control button:hover,
.theme-control button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.theme-swatch {
  width: 32px;
  height: 22px;
  display: block;
  border: 1px solid rgba(127, 127, 127, 0.35);
  box-shadow: inset 7px 0 0 var(--swatch-accent);
  background: var(--swatch-bg);
}

.swatch-willemstad {
  --swatch-bg: #050505;
  --swatch-accent: #00c878;
}

.swatch-porcelain {
  --swatch-bg: #e9edef;
  --swatch-accent: #147e69;
}

.swatch-paper {
  --swatch-bg: #f2eee2;
  --swatch-accent: #a1543f;
}

.swatch-flexoki {
  --swatch-bg: #100f0f;
  --swatch-accent: #da702c;
}

.swatch-system {
  --swatch-bg: #11181d;
  --swatch-accent: #e7ecee;
}

.display-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.info-dialog #book-information {
  font-family: var(--reader-font);
  line-height: 1.62;
}

.info-dialog #book-information p {
  margin: 0 0 1em;
}

.edition-build-note,
.edition-legal-note {
  margin-top: 22px !important;
  padding-top: 17px;
  border-top: 1px solid var(--border);
  color: var(--text-soft);
  font-family: var(--sans);
  font-size: 0.75rem;
}

.notes-dialog .note-card {
  max-width: 560px;
}

.notes-dialog .note-quote {
  font-size: 0.88rem;
}

.notes-dialog .note-card textarea {
  font-size: 0.84rem;
}

.notes-dialog .note-markdown-preview,
.notes-dialog .note-markdown-shell .cm-editor {
  font-size: 0.84rem;
}

.page-label-dialog {
  width: min(590px, calc(100vw - 28px));
}

.page-label-description {
  margin: -4px 0 19px;
  color: var(--text-soft);
  font-family: var(--reader-font);
  font-size: 0.9rem;
  line-height: 1.55;
}

.page-label-editor-list {
  display: grid;
  gap: 9px;
}

.page-label-editor-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
}

.page-label-editor-field {
  min-width: 0;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.page-label-editor-name,
#page-label-count {
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.page-label-editor-row .library-text-input,
.page-label-remove {
  min-height: 44px;
}

.page-label-remove {
  color: var(--text-faint);
}

.page-label-editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.page-label-editor-toolbar .secondary-button {
  padding-block: 8px;
}

.page-label-actions {
  align-items: center;
}

.page-label-defaults {
  margin-inline-start: auto;
}

.page-label-defaults:disabled {
  color: var(--text-faint);
  cursor: default;
  opacity: 0.5;
}

.image-dialog {
  width: min(1120px, calc(100vw - 26px));
  max-height: calc(100dvh - 26px);
  margin: auto;
  padding: 48px 16px 16px;
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.image-dialog img {
  max-width: 100%;
  max-height: calc(100dvh - 126px);
  width: auto;
  height: auto;
  display: block;
  margin: auto;
  background: var(--image-bg);
}

.image-dialog p {
  margin: 11px auto 0;
  color: var(--text-soft);
  font-size: 0.75rem;
  text-align: center;
}

.image-close {
  position: absolute;
  top: 9px;
  right: 9px;
  min-height: 32px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--text);
  cursor: pointer;
}

.link-preview {
  position: fixed;
  z-index: 55;
  width: min(430px, calc(100vw - 24px));
  max-height: min(460px, calc(100dvh - 24px));
  padding: 19px 20px 17px;
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 96%, var(--bg));
  color: var(--text);
  box-shadow: 0 18px 48px var(--shadow);
  opacity: 0;
  overscroll-behavior: contain;
  pointer-events: auto;
  transform: translateY(4px);
  transition: opacity 130ms ease-out, transform 130ms ease-out;
}

.link-preview:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: -2px;
}

.link-preview-book-body {
  margin-top: 14px;
  font-size: 0.86rem;
  line-height: 1.62;
}

.link-preview-book-body > :first-child {
  margin-top: 0;
}

.link-preview-book-body > p:first-of-type::first-letter,
.link-preview-book-body > div:first-child > p:first-of-type::first-letter {
  float: none;
  margin: 0;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
}

.link-preview-book-body p,
.link-preview-book-body li,
.link-preview-book-body blockquote {
  max-width: none;
}

.link-preview-book-body h2,
.link-preview-book-body h3,
.link-preview-book-body h4 {
  scroll-margin-top: 12px;
}

.link-preview-book-body img {
  height: auto;
  max-width: 100%;
}

.link-preview-book-body pre,
.link-preview-book-body .table-scroll {
  max-width: 100%;
  overflow: auto;
}

.link-preview[data-placement="above"] {
  border-top-width: 1px;
  border-bottom: 3px solid var(--accent);
  transform: translateY(-4px);
}

.link-preview.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.link-preview[hidden] {
  display: none;
}

.link-preview-eyebrow,
.link-preview-document,
.link-preview-footer {
  font-family: var(--mono);
}

.link-preview-eyebrow {
  margin: 0 0 9px;
  color: var(--accent-strong);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.35;
  text-transform: uppercase;
}

.link-preview-title {
  margin: 0;
  color: var(--text);
  font-family: var(--reader-font);
  font-size: clamp(1.06rem, 2vw, 1.28rem);
  line-height: 1.24;
}

.link-preview-document {
  margin: 7px 0 0;
  color: var(--text-faint);
  font-size: 0.64rem;
  line-height: 1.45;
}

.link-preview-excerpt,
.link-preview-loading {
  margin: 14px 0 0;
  color: var(--text-soft);
  font-family: var(--reader-font);
  font-size: 0.86rem;
  line-height: 1.62;
}

.link-preview-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-top: 16px;
  padding-top: 11px;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 0.57rem;
  line-height: 1.4;
}

.link-preview-footer span:last-child {
  color: var(--accent-strong);
  text-align: right;
}

@media (prefers-reduced-motion: reduce) {
  .link-preview {
    transition: none;
  }
}

@media (hover: none), (pointer: coarse) {
  .book-body a[data-link-preview] {
    text-decoration-style: solid;
  }
}

.annotation-toolbar {
  position: fixed;
  z-index: 60;
  width: min(172px, calc(100vw - 20px));
  max-width: calc(100vw - 20px);
  max-height: calc(100dvh - 20px);
  padding: 4px;
  overflow: visible;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 16px 42px var(--shadow);
}

.annotation-toolbar[data-mode="area"] {
  width: min(232px, calc(100vw - 20px));
}

.annotation-main {
  display: block;
}

.area-note-main {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 4px;
}

.area-note-main[hidden] {
  display: none;
}

.area-note-confirm,
.area-note-cancel {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 120ms ease, color 120ms ease, transform 100ms ease;
}

.area-note-confirm {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  text-align: left;
}

.area-note-confirm > span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.area-note-confirm strong,
.area-note-confirm small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.area-note-confirm strong {
  color: var(--text);
  font-size: 0.73rem;
  font-weight: 700;
}

.area-note-confirm small {
  color: var(--text-faint);
  font: 0.56rem/1.25 var(--mono);
  text-transform: uppercase;
}

.area-note-confirm svg,
.area-note-cancel svg {
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.area-note-confirm svg {
  width: 22px;
  height: 22px;
  color: var(--accent-strong);
}

.area-note-cancel {
  display: grid;
  place-items: center;
  padding: 0;
}

.area-note-cancel svg {
  width: 18px;
  height: 18px;
}

.area-note-confirm:hover,
.area-note-confirm:focus-visible,
.area-note-cancel:hover,
.area-note-cancel:focus-visible {
  background: var(--accent-soft);
  color: var(--text);
}

.area-note-confirm:focus-visible,
.area-note-cancel:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: -2px;
}

.area-note-confirm:active,
.area-note-cancel:active {
  transform: translateY(1px);
}

.annotation-style-presets {
  min-width: 0;
  display: grid;
  margin: 0;
  padding: 0;
  border: 0;
}

.annotation-style-action {
  position: static;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: stretch;
}

.annotation-style-action + .annotation-style-action,
.annotation-more-button {
  border-top: 1px solid var(--border);
}

.annotation-preset-button,
.annotation-more-button,
.annotation-color-toggle {
  min-width: 0;
  min-height: 48px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  touch-action: manipulation;
  transition: color 100ms ease, transform 100ms ease;
}

.annotation-preset-button,
.annotation-more-button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  padding: 6px 8px;
  font-family: var(--sans);
  font-size: 0.75rem;
  text-align: left;
}

.annotation-style-action:hover > .annotation-preset-button,
.annotation-style-action:hover > .annotation-color-toggle,
.annotation-toolbar:not([data-palette-open="true"]) .annotation-style-action:focus-within > .annotation-preset-button,
.annotation-toolbar:not([data-palette-open="true"]) .annotation-style-action:focus-within > .annotation-color-toggle,
.annotation-style-action[data-palette-active="true"] > .annotation-preset-button,
.annotation-style-action[data-palette-active="true"] > .annotation-color-toggle,
.annotation-preset-button:focus-visible,
.annotation-color-toggle:focus-visible,
.annotation-more-button:focus-visible {
  background: var(--accent-soft);
  color: var(--text);
}

.annotation-preset-button:focus-visible,
.annotation-color-toggle:focus-visible,
.annotation-more-button:focus-visible,
.annotation-palette-button:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: -2px;
}

.annotation-preset-button:active,
.annotation-color-toggle:active,
.annotation-palette-button:active {
  transform: translateY(1px);
}

.annotation-color-toggle {
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 1.12rem;
}

.annotation-color-toggle[aria-expanded="true"] {
  color: var(--text);
}

.annotation-style-sample {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: inline-grid;
  place-items: center;
  padding: 1px 3px;
  border-radius: 4px;
  color: var(--text);
  font-family: var(--reader-font);
  font-size: 0.75rem;
  line-height: 1.2;
}

.style-sample-highlight {
  background: var(--annotation-stroke, var(--annotation-marker-sun));
  color: var(--bg);
}

.style-sample-underline {
  text-decoration: underline 2px var(--annotation-stroke, var(--annotation-marker-mint));
  text-underline-offset: 3px;
  text-decoration-skip-ink: none;
}

.style-sample-wavy {
  text-decoration: underline wavy 1px var(--annotation-stroke, var(--annotation-marker-red));
  text-underline-offset: 3px;
  text-decoration-skip-ink: none;
}

.style-sample-more {
  color: currentColor;
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 1px;
}

.annotation-more-button {
  width: 100%;
  border-radius: 7px;
  box-shadow: inset 0 1px 0 var(--border);
}

.annotation-more-button:disabled {
  color: var(--text-faint);
  cursor: default;
  opacity: 0.72;
}

.annotation-color-panel {
  position: absolute;
  top: 50%;
  left: calc(100% + 8px);
  width: 112px;
  display: grid;
  grid-template-columns: repeat(2, 44px);
  gap: 4px;
  padding: 8px;
  visibility: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 14px 36px var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(4px, -50%);
  transition: opacity 120ms ease, transform 120ms ease, visibility 0s linear 120ms;
}

.annotation-color-panel::after {
  position: absolute;
  top: 0;
  left: -9px;
  width: 9px;
  height: 100%;
  content: "";
}

.annotation-toolbar[data-flyout-side="left"] .annotation-color-panel {
  right: calc(100% + 8px);
  left: auto;
  transform: translate(-4px, -50%);
}

.annotation-toolbar[data-flyout-side="left"] .annotation-color-panel::after {
  right: -9px;
  left: auto;
}

.annotation-toolbar[data-palette-open="true"] .annotation-color-panel {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: translate(0, -50%);
  transition-delay: 0s;
}

.annotation-palette-button {
  position: relative;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent !important;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 120ms ease, transform 120ms ease;
}

.annotation-palette-button::before {
  width: 20px;
  height: 20px;
  border: 1px solid color-mix(in srgb, var(--annotation-swatch-stroke) 76%, var(--text));
  border-radius: 50%;
  background: var(--annotation-swatch-stroke);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--surface) 35%, transparent);
  content: "";
}

.annotation-palette-button:hover {
  background: var(--accent-soft) !important;
}

.annotation-palette-button[aria-pressed="true"]::before {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text-soft);
}

.color-button {
  position: relative;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  touch-action: manipulation;
}

.color-button:hover,
.color-button[aria-pressed="true"] {
  border-color: var(--accent-strong);
  box-shadow: inset 0 0 0 2px var(--surface), inset 0 0 0 4px var(--accent-strong);
}

.color-mint {
  --annotation-swatch-color: var(--annotation-marker-mint);
  --annotation-swatch-stroke: var(--annotation-marker-mint);
  background: var(--annotation-marker-mint);
}

.color-sun {
  --annotation-swatch-color: var(--annotation-marker-sun);
  --annotation-swatch-stroke: var(--annotation-marker-sun);
  background: var(--annotation-marker-sun);
}

.color-blue {
  --annotation-swatch-color: var(--annotation-marker-blue);
  --annotation-swatch-stroke: var(--annotation-marker-blue);
  background: var(--annotation-marker-blue);
}

.color-pink {
  --annotation-swatch-color: var(--annotation-marker-pink);
  --annotation-swatch-stroke: var(--annotation-marker-pink);
  background: var(--annotation-marker-pink);
}

.color-violet {
  --annotation-swatch-color: var(--annotation-marker-violet);
  --annotation-swatch-stroke: var(--annotation-marker-violet);
  background: var(--annotation-marker-violet);
}

.color-red {
  --annotation-swatch-color: var(--annotation-marker-red);
  --annotation-swatch-stroke: var(--annotation-marker-red);
  background: var(--annotation-marker-red);
}

.reader-toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 70;
  max-width: calc(100vw - 30px);
  padding: 9px 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.77rem;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.reader-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.loading-state {
  max-width: 720px;
  margin: 12vh auto 0;
}

.skeleton {
  background: var(--surface-strong);
}

.skeleton-kicker {
  width: 120px;
  height: 11px;
  margin-bottom: 22px;
}

.skeleton-title {
  width: min(560px, 86%);
  height: 62px;
  margin-bottom: 44px;
}

.skeleton-line {
  width: 100%;
  height: 14px;
  margin-bottom: 14px;
}

.skeleton-line.short {
  width: 74%;
}

.nav-scrim,
.mobile-only {
  display: none;
}

@media (min-width: 1281px) {
  body[data-view="home"] .reader-main {
    grid-column: 2 / 4;
  }
}

@media (min-width: 1181px) {
  body.focus-mode .reader-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  body.focus-mode .book-nav,
  body.focus-mode .chapter-tools,
  body.focus-mode .location-label {
    display: none;
  }

  body.focus-mode .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  body.focus-mode .reader-main {
    --reader-main-inline-padding: clamp(30px, 10vw, 160px);
    grid-column: 1;
    padding-inline: var(--reader-main-inline-padding);
  }

  body.focus-mode .chapter-view {
    max-width: 840px;
  }
}

@media (max-width: 1280px) {
  .reader-layout {
    grid-template-columns: 248px minmax(0, 1fr);
  }

  .chapter-tools {
    display: none;
  }

  .topbar {
    grid-template-columns: 248px minmax(0, 1fr) auto;
  }
}

@media (min-width: 821px) and (max-width: 940px) {
  .home-hero {
    min-height: auto;
    grid-template-columns: minmax(0, 1fr);
    padding-top: 26px;
  }

  .cover-panel {
    width: min(70%, 310px);
    justify-self: center;
  }

  .map-group {
    grid-template-columns: 1fr;
    gap: 18px;
  }
}

@media (max-width: 820px) {
  :root {
    --topbar-content-height: 58px;
  }

  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    padding-inline: 8px;
  }

  .mobile-only {
    display: inline-flex;
    align-items: center;
  }

  .topbar > .text-button {
    min-height: 100%;
    padding-inline: 8px;
    border-left: 0;
  }

  .brand-link {
    min-width: 0;
    justify-self: center;
    padding: 0 8px;
    border-right: 0;
  }

  .brand-title,
  .location-label,
  #notes-button,
  #focus-button {
    display: none;
  }

  .topbar-actions .text-button {
    padding-inline: 8px;
    border-left: 0;
  }

  .reader-layout {
    display: block;
  }

  .book-nav {
    position: fixed;
    inset: var(--topbar-height) auto 0 0;
    z-index: 25;
    width: min(86vw, 340px);
    height: calc(100dvh - var(--topbar-height));
    background: var(--nav-bg);
    transform: translateX(-100%);
    transition: transform var(--nav-settle-duration, 240ms) cubic-bezier(0.3, 0.2, 0.35, 1);
    will-change: transform;
  }

  .outline-link {
    min-height: 44px;
  }

  body.nav-open {
    overflow: hidden;
  }

  body.nav-open .book-nav {
    transform: translateX(0);
  }

  body.nav-gesture-active .book-nav {
    transition: none;
  }

  body.nav-gesture-open .book-nav {
    transform: translateX(calc(-100% + var(--nav-drag-distance, 0px)));
  }

  body.nav-gesture-close .book-nav {
    transform: translateX(var(--nav-drag-distance, 0px));
  }

  .nav-scrim {
    position: fixed;
    inset: var(--topbar-height) 0 0;
    z-index: 20;
    width: 100%;
    border: 0;
    background: color-mix(in srgb, var(--bg) 62%, transparent);
    backdrop-filter: blur(3px);
    opacity: 1;
    transition: opacity var(--nav-settle-duration, 240ms) cubic-bezier(0.3, 0.2, 0.35, 1);
    will-change: opacity;
  }

  body.nav-open .nav-scrim,
  body.nav-gesture-active .nav-scrim {
    display: block;
  }

  body.nav-gesture-active .nav-scrim {
    opacity: var(--nav-scrim-opacity, 0);
    pointer-events: none;
    transition: none;
  }

  .topbar,
  .reader-main,
  .book-nav,
  .nav-scrim {
    touch-action: pan-y pinch-zoom;
  }

  .book-body pre,
  .book-body .formula-line,
  .table-scroll,
  .pdf-pages {
    touch-action: pan-x pan-y pinch-zoom;
  }

  .nav-home,
  .nav-chapter {
    min-height: 48px;
    align-items: center;
    padding: 10px 12px;
    touch-action: manipulation;
    transition: background-color 100ms ease-out, border-color 100ms ease-out, color 100ms ease-out;
  }

  .nav-home:active,
  .nav-chapter:active {
    border-left-color: var(--accent);
    background: var(--accent-soft);
    color: var(--text);
  }

  details.nav-group > summary,
  .nav-view-switcher select,
  .nav-unread-filter {
    min-height: 44px;
    touch-action: manipulation;
  }

  .reader-main {
    --reader-main-inline-padding: 18px;
    width: 100%;
    padding: 34px var(--reader-main-inline-padding) calc(66px + var(--safe-area-bottom));
  }

  .home-hero {
    min-height: auto;
    grid-template-columns: minmax(0, 1fr);
    gap: 46px;
    padding: 8px 0 54px;
  }

  .hero-copy h1 {
    font-size: clamp(3rem, 14vw, 4.6rem);
  }

  .cover-panel {
    width: min(72vw, 300px);
    justify-self: center;
  }

  .visual-index,
  .reading-map {
    margin-top: 72px;
  }

  .editorial-overview {
    padding: 54px 0 64px;
  }

  .overview-body,
  .overview-landmarks ol {
    grid-template-columns: 1fr;
  }

  .overview-body {
    gap: 40px;
  }

  .overview-thesis {
    max-width: none;
    font-size: clamp(1.82rem, 7.5vw, 2.8rem);
    line-height: 1.21;
  }

  .section-heading {
    grid-template-columns: 1fr;
    gap: 5px;
    margin-bottom: 27px;
  }

  .plate-grid {
    grid-template-columns: 1fr;
  }

  .plate {
    display: grid;
    grid-template-columns: minmax(110px, 0.8fr) minmax(0, 1fr);
    align-items: center;
    gap: 13px;
  }

  .map-group {
    grid-template-columns: 1fr;
    gap: 17px;
  }

  .chapter-header {
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 10px;
    margin-bottom: 18px;
  }

  .chapter-number {
    font-size: 0.8rem;
  }

  .chapter-labels {
    flex-basis: 100%;
    justify-content: flex-start;
    margin: 1px 0 -4px;
  }

  .chapter-label-button {
    min-width: 44px;
    min-height: 44px;
  }

  .chapter-header h1 {
    font-size: clamp(2.65rem, 13vw, 4.5rem);
  }

  .book-body {
    font-size: 1.0625em;
    line-height: var(--reading-line-height);
  }

  .chapter-view[data-document="index"] .book-body {
    columns: 1;
  }

  .chapter-completion {
    align-items: stretch;
    flex-direction: column;
    gap: 16px;
    padding: 20px 0;
  }

  .chapter-completion-action {
    min-height: 44px;
    width: 100%;
  }

  .book-body .separator > a {
    margin-inline: 0 !important;
  }

  .chapter-pager {
    grid-template-columns: 1fr;
  }

  .pager-link.next {
    align-items: flex-start;
    text-align: left;
  }

}

@media (max-width: 820px), (pointer: coarse) {
  .annotation-toolbar {
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px !important;
    top: auto !important;
    width: auto;
    max-width: none;
    max-height: min(62dvh, 430px);
    padding: 6px;
    overflow-x: hidden;
    overflow-y: auto;
    border-radius: 14px;
    overscroll-behavior: contain;
  }

  .annotation-toolbar[data-mode="area"] {
    width: auto;
  }

  .annotation-style-action {
    grid-template-columns: minmax(0, 1fr) 78px;
  }

  .annotation-style-action:hover > .annotation-preset-button,
  .annotation-style-action:hover > .annotation-color-toggle {
    background: transparent;
    color: var(--text-soft);
  }

  .annotation-style-action[data-palette-active="true"] > .annotation-preset-button,
  .annotation-style-action[data-palette-active="true"] > .annotation-color-toggle {
    background: var(--accent-soft);
    color: var(--text);
  }

  .annotation-preset-button,
  .annotation-more-button,
  .annotation-color-toggle {
    min-height: 56px;
  }

  .annotation-preset-button,
  .annotation-more-button {
    gap: 12px;
    padding-inline: 12px;
    font-size: 0.82rem;
  }

  .annotation-style-sample {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
    font-size: 0.82rem;
  }

  .annotation-color-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font: 0.58rem/1 var(--mono);
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .annotation-color-toggle::before {
    content: "Color";
  }

  .annotation-color-toggle > span {
    font-size: 1rem;
    transform: rotate(90deg);
    transition: transform 120ms ease;
  }

  .annotation-color-toggle[aria-expanded="true"] > span {
    transform: rotate(-90deg);
  }

  .annotation-color-panel,
  .annotation-toolbar[data-flyout-side="left"] .annotation-color-panel {
    position: static;
    width: auto;
    display: none;
    grid-template-columns: repeat(3, minmax(56px, 1fr));
    gap: 4px;
    margin: 4px 0 0;
    padding: 6px;
    visibility: visible;
    border-color: var(--border);
    border-radius: 9px;
    box-shadow: none;
    opacity: 1;
    pointer-events: auto;
    transform: none;
    transition: none;
  }

  .annotation-color-panel::after {
    display: none;
  }

  .annotation-toolbar[data-palette-open="true"] .annotation-color-panel {
    display: grid;
    transform: none;
  }

  .annotation-palette-button {
    width: auto;
    height: 54px;
  }

  .annotation-palette-button::before {
    width: 28px;
    height: 28px;
  }
}

@media (max-width: 480px) {
  .brand-mark {
    min-width: 34px;
  }

  .hero-actions,
  .hero-actions a,
  .hero-actions button {
    width: 100%;
  }

  .book-facts {
    grid-template-columns: 1fr;
  }

  .book-facts div + div {
    padding-left: 0;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .map-links a {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .map-time {
    display: none;
  }

  .reader-dialog {
    padding: 19px;
  }

  .dialog-header {
    top: -19px;
    margin: -19px -19px 20px;
    padding: 19px 19px 16px;
  }

  .theme-control {
    grid-template-columns: 1fr;
  }

  .typography-grid {
    grid-template-columns: 1fr;
  }

  .typography-language {
    padding-right: 0;
  }

  .typography-language + .typography-language {
    margin-top: 18px;
    padding-top: 18px;
    padding-left: 0;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .display-actions,
  .display-actions button {
    width: 100%;
  }

}

.chapter-view.pdf-chapter-view {
  max-width: none;
  font-size: 1rem;
}

.pdf-chapter-view .chapter-header {
  max-width: 980px;
  margin-inline: auto;
}

.pdf-chapter-view .chapter-header h1 {
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1.02;
}

.pdf-reader {
  width: min(100%, 1040px);
  margin: 0 auto;
}

.pdf-toolbar {
  position: sticky;
  top: var(--topbar-height);
  z-index: 18;
  min-height: 52px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin-inline: calc(0px - var(--reader-main-inline-padding));
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-inline: 0;
  border-radius: 0;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: 0 7px 20px color-mix(in srgb, var(--shadow) 58%, transparent);
  backdrop-filter: blur(12px);
}

.pdf-toolbar-group {
  display: flex;
  align-items: center;
  gap: 7px;
}

.pdf-toolbar button,
.pdf-toolbar input,
.pdf-toolbar select {
  min-height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.pdf-toolbar button {
  padding: 6px 10px;
  cursor: pointer;
}

.pdf-area-note-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 650;
}

.pdf-area-note-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.pdf-toolbar button:hover,
.pdf-toolbar button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.pdf-area-note-hint {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 3px 0;
  padding: 7px 8px 7px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 65%, var(--border));
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--text-soft);
  font-size: 0.7rem;
}

.pdf-area-note-hint[hidden] {
  display: none;
}

.pdf-area-note-hint strong {
  margin-right: 6px;
  color: var(--text);
}

.pdf-area-note-hint button {
  min-width: 48px;
  min-height: 36px;
  padding: 5px 9px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.pdf-area-note-hint button:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.pdf-page-control label,
.pdf-page-control span,
.pdf-tone-control,
.pdf-toolbar output {
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.62rem;
}

.pdf-page-control input {
  width: 58px;
  padding: 5px 7px;
  text-align: center;
}

.pdf-toolbar output {
  min-width: 43px;
  text-align: right;
}

.pdf-tone-control {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
}

.pdf-tone-control select {
  padding: 5px 24px 5px 8px;
  font-family: var(--sans);
  font-size: 0.7rem;
}

.pdf-layout-note {
  margin: 10px 3px 15px;
  color: var(--text-faint);
  font-size: 0.68rem;
  line-height: 1.45;
  text-align: center;
}

.pdf-loading {
  min-height: 45dvh;
  display: grid;
  place-items: center;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.72rem;
}

.pdf-pages {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: clamp(16px, 3vw, 32px);
  overflow: visible;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--nav-bg) 70%, var(--bg));
}

.pdf-page {
  --total-scale-factor: 1;
  position: relative;
  flex: none;
  overflow: visible;
  background: #f7f7f5;
  box-shadow: 0 10px 30px color-mix(in srgb, var(--shadow) 72%, transparent);
  isolation: isolate;
}

.pdf-page.is-search-target {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.pdf-page:not([data-rendered="true"])::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #efefed;
  content: "";
}

.pdf-page-canvas,
.pdf-text-layer,
.pdf-search-layer,
.pdf-annotation-layer,
.pdf-area-layer {
  position: absolute;
  inset: 0;
}

.pdf-page-canvas {
  z-index: 1;
  display: block;
  transform-origin: 0 0;
}

.pdf-reader[data-pdf-appearance="dim"] .pdf-page-canvas {
  filter: sepia(0.08) brightness(0.82) contrast(0.96);
}

.pdf-reader[data-pdf-appearance="night"] .pdf-page-canvas {
  filter: invert(0.88) hue-rotate(180deg) brightness(0.78) contrast(0.9) saturate(0.72);
}

.pdf-text-layer {
  z-index: 2;
  overflow: clip;
  color-scheme: only light;
  color: transparent;
  caret-color: transparent;
  font-family: sans-serif;
  font-kerning: none;
  line-height: 1;
  letter-spacing: normal;
  text-align: initial;
  text-size-adjust: none;
  transform-origin: 0 0;
  forced-color-adjust: none;
}

.pdf-text-layer span,
.pdf-text-layer br {
  position: absolute;
  color: transparent;
  cursor: text;
  transform-origin: 0 0;
  user-select: text;
  white-space: pre;
}

.pdf-text-layer {
  --min-font-size: 1;
  --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size));
  --min-font-size-inv: calc(1 / var(--min-font-size));
}

.pdf-text-layer > :not(.markedContent),
.pdf-text-layer .markedContent span:not(.markedContent) {
  z-index: 1;
  --font-height: 0;
  --scale-x: 1;
  --rotate: 0deg;
  font-size: calc(var(--text-scale-factor) * var(--font-height));
  transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));
}

.pdf-text-layer .markedContent {
  display: contents;
}

.pdf-text-layer span[role="img"] {
  cursor: default;
  user-select: none;
}

.pdf-text-layer::selection,
.pdf-text-layer span::selection {
  background: color-mix(in srgb, var(--accent) 42%, transparent);
  color: transparent;
}

.pdf-text-layer .endOfContent {
  position: absolute;
  inset: 100% 0 0;
  z-index: 0;
  display: block;
  cursor: default;
  user-select: none;
}

.pdf-search-layer,
.pdf-annotation-layer {
  z-index: 3;
  pointer-events: none;
}

.pdf-area-layer {
  z-index: 5;
  overflow: hidden;
  cursor: crosshair;
  pointer-events: none;
  touch-action: none;
  user-select: none;
}

.pdf-reader[data-pdf-area-mode="true"] .pdf-area-layer {
  pointer-events: auto;
}

.pdf-reader[data-pdf-area-mode="true"] .pdf-text-layer,
.pdf-reader[data-pdf-area-mode="true"] .pdf-text-layer span {
  cursor: crosshair;
  pointer-events: none;
  user-select: none;
}

.pdf-area-layer:focus-visible {
  outline: 3px solid var(--accent-strong);
  outline-offset: -3px;
}

.pdf-area-selection {
  position: absolute;
  border: 2px solid var(--accent-strong);
  border-radius: 3px;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--surface) 72%, transparent), inset 0 0 0 1px color-mix(in srgb, var(--surface) 42%, transparent);
  pointer-events: none;
}

.pdf-annotation-layer {
  z-index: 4;
  overflow: visible;
}

.pdf-search-hit,
.pdf-annotation-fragment {
  position: absolute;
  border-radius: 2px;
  pointer-events: none;
}

.pdf-search-hit {
  background: color-mix(in srgb, var(--search-mark) 78%, transparent);
  outline: 1px solid color-mix(in srgb, var(--accent-strong) 65%, transparent);
}

.pdf-annotation-fragment {
  --annotation-fill: var(--annotation-marker-mint);
  --annotation-stroke: var(--annotation-marker-mint);
  color: var(--annotation-stroke);
}

.pdf-annotation-fragment.annotation-style-highlight {
  background: color-mix(in srgb, var(--annotation-fill) 46%, transparent);
  mix-blend-mode: multiply;
}

.pdf-annotation-fragment.annotation-style-underline {
  border-bottom: max(2px, calc(1.5px * var(--total-scale-factor))) solid var(--annotation-stroke);
}

.pdf-annotation-fragment.annotation-style-wavy {
  background: radial-gradient(circle at 3px -1px, transparent 2px, var(--annotation-stroke) 2.3px, var(--annotation-stroke) 3px, transparent 3.3px) 0 100% / 6px 4px repeat-x;
}

.pdf-annotation-fragment.annotation-style-strike::after {
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: max(2px, calc(1.4px * var(--total-scale-factor)));
  background: var(--annotation-stroke);
  content: "";
}

.pdf-annotation-fragment.annotation-kind-area {
  border: max(2px, calc(1.5px * var(--total-scale-factor))) solid var(--annotation-stroke);
  border-radius: 3px;
  background: color-mix(in srgb, var(--annotation-fill) 20%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--surface) 30%, transparent);
  mix-blend-mode: normal;
}

.pdf-annotation-fragment.is-pulsing {
  outline: 3px solid var(--accent-strong);
  outline-offset: 2px;
}

.pdf-annotation-pin {
  position: absolute;
  left: calc(100% + 4px);
  width: 26px;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--annotation-stroke, var(--annotation-marker-mint));
  cursor: pointer;
  pointer-events: auto;
  transform: translateY(-25%);
}

.pdf-annotation-pin::before {
  position: absolute;
  top: 50%;
  left: 2px;
  width: 14px;
  height: 3px;
  border-radius: 0 2px 2px 0;
  background: currentColor;
  content: "";
  transform: translateY(-50%);
}

.pdf-page-label {
  position: absolute;
  right: 8px;
  bottom: -19px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.58rem;
}

.pdf-section-anchor {
  position: absolute;
  top: 0;
  left: 0;
}

@media (max-width: 820px) {
  .chapter-view.pdf-chapter-view .chapter-header {
    margin-bottom: 14px;
  }

  .pdf-chapter-view .chapter-header h1 {
    font-size: clamp(1.8rem, 9vw, 3rem);
  }

  .pdf-toolbar {
    top: var(--topbar-height);
    justify-content: flex-start;
    padding: 7px 10px;
  }

  .pdf-tone-control {
    width: auto;
    margin-left: auto;
  }

  .pdf-annotation-tools {
    margin-left: 0;
  }

  .pdf-area-note-hint {
    align-items: flex-start;
    margin-inline: 0;
  }

  .pdf-layout-note {
    text-align: left;
  }

  .pdf-pages {
    gap: 18px;
    margin-inline: -18px;
    padding: 14px 8px 28px;
    border-inline: 0;
    overflow: hidden;
  }

  .pdf-annotation-pin {
    right: 0;
    left: auto;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .pdf-toolbar {
    background: var(--surface);
    backdrop-filter: none;
  }
}

@media (forced-colors: active) {
  .book-nav,
  .chapter-tools {
    scrollbar-color: auto;
  }

  .book-nav::-webkit-scrollbar-thumb,
  .chapter-tools::-webkit-scrollbar-thumb {
    background: ButtonText;
  }
}

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

@media print {
  :root {
    color-scheme: light;
  }

  .topbar,
  .book-nav,
  .chapter-tools,
  .sidebar-resizer,
  .chapter-completion,
  .chapter-pager,
  .reading-progress,
  .reader-toast,
  .link-preview,
  .annotation-toolbar,
  .annotation-position-rail,
  .code-block-toolbar {
    display: none !important;
  }

  .pdf-toolbar,
  .pdf-layout-note {
    display: none !important;
  }

  .reader-layout {
    display: block;
    padding: 0;
  }

  .reader-main {
    padding: 0;
  }

  .chapter-view {
    max-width: none;
  }

  .book-body {
    color: #222;
  }
}
