html:has(#handbook[open]) { overflow: hidden; }
#handbook {
  --hb-ink: #30242c;
  --hb-paper: #fffaf1;
  --hb-rule: #e0d7cd;
  --hb-rose: #8b3450;
  position: fixed;
  inset: 0;
  width: min(796px, calc(100% - 32px));
  height: min(560px, calc(100vh - 28px));
  height: min(560px, calc(100dvh - 28px));
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  border: 1px solid #f9f1ea;
  border-radius: 23px;
  overflow: hidden;
  overscroll-behavior: contain;
  background: #fffaf6;
  box-shadow: 0 24px 100px #25112359;
  color: var(--hb-ink);
}
#handbook[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
#handbook::backdrop { background: #251b28ba; backdrop-filter: blur(5px); }
#handbook button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 0;
  border-radius: 24px;
  background: transparent;
  color: var(--hb-ink);
  font: 750 14px/1.25 Manrope, Arial, sans-serif;
  cursor: pointer;
}
#handbook button:focus-visible { outline: 3px solid var(--hb-rose); outline-offset: 2px; }
#handbook [hidden] { display: none !important; }
#handbook .hb-header { display: flex; align-items: center; gap: 10px; padding: 7px 16px 7px 24px; }
#handbook .hb-header img { flex: none; width: 23px; height: 25px; object-fit: contain; }
#handbook .hb-header h2 { margin: 0; font: 750 16px/1.25 Manrope, Arial, sans-serif; letter-spacing: -.025em; }
#handbook .hb-close { flex: none; width: 44px; margin-inline-start: auto; }
#handbook .hb-close span { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--hb-rule); border-radius: 50%; font: 22px/1 Arial, sans-serif; }
#handbook .hb-close:hover span { background: #f4eae7; }

#handbook .hb-cover {
  position: relative;
  margin: 0 12px;
  min-height: 0;
  padding: 11px 18px 16px 20px;
  border: 1px solid #78384a;
  border-radius: 5px 14px 14px 5px;
  background: linear-gradient(90deg, #7b344a, #ab526b 9px, #682e44 11px, #97455c 17px, #9d4e63 85%, #894055);
}
#handbook .hb-stack {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100%;
  border-radius: 2px 7px 7px 2px;
  background: var(--hb-paper);
  box-shadow: 1px 1px #c9bca9, 2px 2px #f6edde, 3px 3px #c2b6a4, 4px 4px #f6eddd, 5px 5px #ae9889, 3px 5px 10px #3d1a3080;
  perspective: 1800px;
}
#handbook .hb-leaf {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden auto;
  overscroll-behavior: contain;
  touch-action: pan-y pinch-zoom;
  scrollbar-width: thin;
  scrollbar-color: #c6aaa1 var(--hb-paper);
  border-radius: inherit;
  background: linear-gradient(90deg, #e8dece, #f6eddf 1.6%, var(--hb-paper) 5.5%);
  transform-origin: left center;
  backface-visibility: hidden;
}
#handbook .hb-turn-copy { z-index: 2; overflow: hidden; pointer-events: none; }
#handbook .hb-turn-copy.hb-under { z-index: 0; }
#handbook .hb-layout {
  display: grid;
  min-height: 100%;
  grid-template-columns: minmax(0, .84fr) minmax(0, 1.16fr);
  align-items: stretch;
  gap: clamp(20px, 2.5vw, 34px);
  padding: clamp(17px, 3vw, 32px);
}
#handbook .hb-media { grid-column: 1; grid-row: 1; display: flex; min-width: 0; flex-direction: column; justify-content: center; }
#handbook .hb-media .hb-photo { flex: 1; }
#handbook .hb-photo {
  position: relative;
  min-height: 155px;
  overflow: hidden;
  border-radius: 2px 2px 52px 2px;
  background: #eadcce;
}
#handbook .hb-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#handbook .hb-prose { grid-column: 2; grid-row: 1; min-width: 0; align-self: center; padding: 10px 0; overflow-wrap: break-word; }
#handbook .hb-prose::before { content: ''; display: block; width: 38px; height: 3px; margin-bottom: 19px; background: var(--hb-rose); }
#handbook .hb-prose h3 {
  margin: 0 0 13px;
  color: var(--hb-ink);
  font: 500 clamp(27px, 3.2vw, 40px)/1.075 Georgia, 'Times New Roman', serif;
  letter-spacing: -.04em;
  text-wrap: balance;
}
#handbook .hb-prose h3:focus { outline: none; }
#handbook .hb-prose p { margin: 0; color: #584b50; font-size: 15px; line-height: 1.55; }
#handbook .hb-prose ul { margin: 18px 0 0; padding: 0 0 0 17px; list-style: square; }
#handbook .hb-prose li { margin: 0; padding-inline-start: 3px; color: var(--hb-ink); font-size: 14px; line-height: 1.52; }
#handbook .hb-prose li + li { margin-top: 8px; }
#handbook .hb-prose li::marker { color: var(--hb-rose); }

#handbook [data-handbook-hotspot] {
  position: absolute;
  inset-inline-start: 10px;
  bottom: 12px;
  max-width: calc(100% - 30px);
  padding: 6px 13px 6px 8px;
  background: #fffaf1;
  color: #492039;
  box-shadow: 0 2px 12px #37212b42;
  text-align: start;
}
#handbook [data-handbook-hotspot] > span:first-child {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--hb-rose);
  color: white;
  font: bold 17px/1 Georgia, serif;
}
#handbook [data-handbook-hotspot][aria-expanded="true"] { box-shadow: inset 0 0 0 2px var(--hb-rose); }
#handbook [data-handbook-note] { margin: 8px 0 0; padding: 10px 13px; background: #f3e8df; color: #513444; border-radius: 8px; font-size: 14px; line-height: 1.4; }

#handbook[data-page="2"] .hb-layout { grid-template-columns: minmax(0, 1.25fr) minmax(0, .85fr); gap: clamp(13px, 2.2vw, 24px); }
#handbook .hb-movie { width: 100%; margin: 0; }
#handbook .hb-movie figcaption { margin: 0 0 8px; color: var(--hb-rose); font-size: 14px; line-height: 1.4; font-weight: 750; }
#handbook .hb-video-slot video { display: block; width: 100%; aspect-ratio: 16 / 9; background: #2d252a; object-fit: contain; }
#handbook .hb-video-slot video::cue {
  color: #fff;
  background-color: rgb(35 25 31 / 92%);
  font: 600 clamp(13px, 1.35vw, 16px)/1.25 Arial, sans-serif;
}
#handbook [data-handbook-transcript] { margin-top: 7px; border-bottom: 1px solid var(--hb-rule); }
#handbook [data-handbook-transcript] summary { padding: 10px 0; color: var(--hb-rose); font-size: 13px; line-height: 1.5; font-weight: 750; cursor: pointer; }
#handbook [data-handbook-transcript] summary:focus-visible { outline: 2px solid var(--hb-rose); }
#handbook [data-handbook-transcript] p { margin: 0 0 11px; font-size: 13px; line-height: 1.5; }

#handbook .hb-quiz { margin: 14px 0 0; padding: 0; min-width: 0; border: 0; }
#handbook .hb-quiz legend { margin: 0 0 8px; padding: 0; color: #593449; font-size: 15px; line-height: 1.35; font-weight: 750; }
#handbook .hb-answers { display: grid; gap: 6px; }
#handbook .hb-answers button { justify-content: start; padding: 8px 12px; border: 1px solid #c7aeb7; border-radius: 9px; background: #fffdf9; font-size: 13px; line-height: 1.35; text-align: start; }
#handbook .hb-answers button:hover, #handbook .hb-answers button[aria-pressed="true"] { border-color: var(--hb-rose); box-shadow: inset 0 0 0 1px var(--hb-rose); }
#handbook .hb-quiz [data-handbook-feedback]:not(:empty) { margin-top: 9px; padding: 9px 11px; border-inline-start: 3px solid #a36532; background: #f5e9d9; color: #5c3a26; font-size: 13px; line-height: 1.45; }
#handbook .hb-quiz [data-handbook-feedback][data-correct="true"] { border-color: #3a7056; background: #e6f0e3; color: #28513c; }

#handbook .hb-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
}
#handbook [data-handbook-page-label] { color: #66555b; font: 650 12px/1.3 Manrope, Arial, sans-serif; text-align: center; }
#handbook [data-handbook-prev] { justify-self: start; padding: 6px 10px; }
#handbook [data-handbook-prev]:hover:enabled { color: var(--hb-rose); }
#handbook [data-handbook-prev]:disabled { opacity: .48; cursor: default; }
#handbook [data-handbook-next] { justify-self: end; padding: 8px 17px; background: var(--hb-ink); color: #fff; }
#handbook [data-handbook-next]:hover { background: #543341; }
#handbook .hb-nav button [aria-hidden] { flex: none; font: 20px/1 Arial, sans-serif; }

@media (max-width: 620px) {
  #handbook {
    width: min(470px, calc(100% - 16px));
    height: min(626px, calc(100vh - 18px));
    height: min(626px, calc(100dvh - 18px));
    border-radius: 18px;
  }
  #handbook .hb-header { padding: 5px 8px 5px 16px; }
  #handbook .hb-cover { margin-inline: 8px; padding: 7px 11px 12px 13px; }
  #handbook .hb-layout, #handbook[data-page="2"] .hb-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; gap: 14px; padding: 15px 17px 19px; }
  #handbook .hb-media .hb-photo { flex: none; }
  #handbook[data-page="3"] .hb-photo { height: clamp(80px, 12dvh, 100px); }
  #handbook .hb-photo { height: clamp(112px, 21dvh, 175px); min-height: 0; border-bottom-right-radius: 33px; }
  #handbook .hb-prose { grid-column: 1; grid-row: 2; align-self: start; padding: 0; }
  #handbook .hb-prose::before { margin-bottom: 11px; }
  #handbook .hb-prose h3 { font-size: 29px; margin-bottom: 9px; }
  #handbook .hb-prose ul { margin-top: 14px; }
  #handbook .hb-nav { grid-template-columns: auto minmax(0, 1fr) auto; gap: 5px; padding: 8px 11px; }
  #handbook .hb-nav button { font-size: 13px; gap: 4px; }
  #handbook [data-handbook-prev] { padding-inline: 3px; }
  #handbook [data-handbook-next] { max-width: 39vw; padding-inline: 11px; }
  #handbook [data-handbook-page-label] { font-size: 11px; }
}
@media (max-height: 520px) {
  #handbook { height: calc(100vh - 10px); height: calc(100dvh - 10px); border-radius: 14px; }
  #handbook .hb-header, #handbook .hb-nav { padding-block: 2px; }
  #handbook .hb-layout { padding: 12px 16px; gap: 15px; }
  #handbook .hb-prose { padding: 0; }
  #handbook .hb-prose::before { margin-bottom: 8px; }
  #handbook .hb-prose h3 { font-size: 24px; margin-bottom: 6px; }
  #handbook .hb-prose ul { margin-top: 9px; }
}
@media (min-width: 520px) and (max-height: 520px) {
  #handbook { width: min(796px, calc(100% - 20px)); }
  #handbook .hb-layout { grid-template-columns: minmax(0, .58fr) minmax(0, 1.42fr); grid-template-rows: auto; }
  #handbook[data-page="2"] .hb-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto; }
  #handbook .hb-prose { grid-column: 2; grid-row: 1; }
  #handbook .hb-media .hb-photo { flex: 1; }
  #handbook .hb-photo { min-height: 95px; height: auto; }
}
@media (forced-colors: active) {
  #handbook .hb-nav button, #handbook .hb-leaf { border: 1px solid ButtonText; }
}
