/* A local reading aid, sharing the original white/navy/teal palette. */
html:has(.reading-links) {
  --reading-menu-limit: min(420px, 45dvh);
  scroll-padding-top: calc(var(--reading-shell-height, 196px) + 16px);
}
/* With scripts disabled the chosen link leaves native details open. Reserve the
   panel's maximum extent too, so the fragment still lands beneath its links. */
html:has(.reading-menu[open]) {
  scroll-padding-top: calc(var(--reading-shell-height, 196px) + var(--reading-menu-limit) + 16px);
}
.reading-shell {
  --reading-paper: var(--paper, var(--bg, #fff));
  --reading-ink: #214e57;
  --reading-line: var(--line, #dce3e6);
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--reading-paper);
}
.reading-shell.reading-links > :is(.site-header, .nav) { position: relative; top: auto; }
.reading-navigation { position: relative; border-bottom: 1px solid var(--reading-line); }
.reading-menu { width: min(1120px, calc(100% - 80px)); margin-inline: auto; }
.reading-menu > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  padding: 10px 0;
  color: var(--reading-ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  cursor: pointer;
  list-style: none;
}
.reading-menu > summary::-webkit-details-marker { display: none; }
.reading-menu > summary::after {
  content: '';
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
}
.reading-menu[open] > summary::after { transform: rotate(225deg) translate(-2px, -2px); }
.reading-menu > summary:hover { color: #087f8c; }
.reading-menu > .reading-links {
  position: absolute;
  inset-inline: 0;
  top: 100%;
  max-height: var(--reading-menu-limit);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #497568 #f0f6f6;
  margin: 0;
  padding: 12px max(40px, calc((100% - 1120px) / 2));
  list-style: none;
  background: var(--reading-paper);
  border-bottom: 1px solid var(--reading-line);
}
.reading-menu:not([open]) > .reading-links { display: none; }
.reading-shell .reading-links a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--reading-ink);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.5;
  text-decoration: none;
  overflow-wrap: break-word;
}
.reading-shell .reading-links a:hover { background: #f0f6f6; text-decoration: underline; text-underline-offset: 4px; }
.reading-menu :is(summary,a):focus-visible { outline: 3px solid #087f8c; outline-offset: -3px; }
.review-chapters[data-reading-chapters] > summary { min-height: 44px; padding-block: 10px; line-height: 24px; }
.review-chapters[data-reading-chapters] a { display: flex; align-items: center; min-height: 44px; }
@media (max-width: 734px) {
  .reading-menu { width: calc(100% - 32px); }
  .reading-menu > .reading-links { padding: 8px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  html:has(.reading-links) { scroll-behavior: auto; }
}
