:root {
  color-scheme: light;
  --navy: #102a45;
  --bronze: #865526;
  --muted: #455b70;
  --rule: #cbd6e1;
  --white: #fbfdff;
  --surface: #eff4f9;
  --default-page-ratio: .563003;
  font-family: 'Noto Sans', 'Helvetica Neue', Arial, sans-serif;
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { block-size: 100%; }
body {
  margin: 0;
  block-size: 100%;
  block-size: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  color: var(--navy);
  background: radial-gradient(ellipse at 50% 0%, #fafcfe 0%, #e9eff5 75%);
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid #936334; outline-offset: 3px; }
.sr-only, .skip-link:not(:focus) {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip-link:focus { position: fixed; z-index: 10; inset: 5px auto auto 5px; padding: 12px; background: white; }

.toolbar {
  background: #fbfcfe;
  border-bottom: 1px solid var(--rule);
  padding-top: env(safe-area-inset-top, 0px);
}
.toolbar-inner {
  display: grid;
  gap: 4px;
  width: min(100%, 1160px);
  margin-inline: auto;
  padding: 5px 17px 6px;
}
.toolbar-top {
  display: grid;
  grid-template-columns: minmax(100px, 160px) auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}
.brand { width: min(100%, 160px); display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; }
.brand img { width: 100%; height: auto; display: block; }
.site-routes, .cover-routes {
  display: flex;
  justify-content: center;
  gap: 4px;
}
.site-routes a, .cover-routes a {
  display: grid;
  align-items: center;
  min-height: 44px;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: .88rem;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}
.site-routes a:hover, .cover-routes a:hover, .cover-routes a[aria-current="location"] { background: #e7edf4; }
.language-control { min-width: 0; justify-self: end; }
#language-switch {
  appearance: none;
  max-width: 100%;
  border: 1px solid #cad6e1;
  border-radius: 5px;
  background: #f5f8fb url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='m1 1.5 5 5 5-5' fill='none' stroke='%23455b70' stroke-width='1.3'/%3E%3C/svg%3E") no-repeat right 9px center;
  padding: 3px 26px 3px 10px;
  min-height: 40px;
  font-size: .88rem;
}
.toolbar-controls, .reading-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 8px;
}
.edition-button {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  min-height: 44px;
  padding: 6px 12px;
  background: var(--navy);
  border: 1px solid var(--navy);
  border-radius: 5px;
  color: white;
  font-size: .875rem;
  font-weight: 650;
  line-height: 1.2;
  text-align: start;
}
.edition-button:hover { background: #203c5b; }
#current-edition {
  color: #dbe6f1;
  font-size: .82rem;
  font-weight: 500;
  white-space: nowrap;
}
.modes {
  border: 1px solid #cad6e1;
  background: #edf2f8;
  border-radius: 6px;
  padding: 3px;
  display: flex;
  align-items: center;
  gap: 3px;
}
.modes button {
  border: 0;
  background: transparent;
  border-radius: 4px;
  min-height: 39px;
  padding: 0 13px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 650;
  white-space: nowrap;
}
.modes button[aria-pressed='true'] { background: var(--navy); color: white; }
.tools { display: flex; justify-content: flex-end; align-items: center; gap: 5px; }
.tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding-inline: 10px;
  border: 0;
  background: transparent;
  border-radius: 4px;
  text-decoration: none;
  font-size: .83rem;
  font-weight: 650;
  white-space: nowrap;
}
.tool:hover, .page-step:hover:not(:disabled), .counter:hover { background: #e7edf4; }
.pdf { color: var(--bronze); }
.pdf > svg { flex-shrink: 0; }

#reader { min-width: 0; min-height: 0; overflow: hidden; }
.scroll-view {
  height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
  padding: 17px 15px 28px;
  scroll-padding-block: 14px;
  scroll-snap-type: y proximity;
}
.scroll-view .leaf {
  width: min(100%, var(--scroll-leaf-max, 550px));
  margin: 0 auto 18px;
  scroll-snap-align: start;
}
.scroll-view .leaf:last-child { margin-bottom: 0; }
.leaf {
  position: relative;
  width: 100%;
  aspect-ratio: var(--page-ratio, var(--default-page-ratio));
  background: #f9fcff;
  box-shadow: 0 1px 3px #102a451e, 0 9px 24px #102a4516;
  isolation: isolate;
}
.leaf-image {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}
.hotspot {
  position: absolute;
  display: block;
  -webkit-tap-highlight-color: #142e4925;
  border-radius: 3px;
}
.hotspot:focus-visible { outline-offset: -2px; background: #e2cf9b38; }
@media (hover: hover) { .hotspot:hover { box-shadow: inset 0 0 0 1.3px #bb8a5075; background: #ffffff15; } }
.flip-view {
  display: grid;
  height: 100%;
  min-height: 0;
  place-items: center;
  padding: 10px 11px;
  touch-action: pan-y pinch-zoom;
  perspective: 1600px;
}
.book-frame {
  position: relative;
  width: var(--leaf-width, min(100%, var(--flip-leaf-max, 530px),
    calc((100dvh - 176px) * var(--page-ratio, var(--default-page-ratio)))));
  aspect-ratio: var(--page-ratio, var(--default-page-ratio));
  isolation: isolate;
  transform-style: preserve-3d;
}
body[data-edition="desktop"] {
  --default-page-ratio: 1.777778;
  --scroll-leaf-max: 1140px;
  --flip-leaf-max: 1140px;
}
.flip-view .leaf, .turning-leaf { position: absolute; inset: 0; }
.turning-leaf {
  overflow: hidden;
  z-index: 2;
  pointer-events: none;
  backface-visibility: hidden;
  transform-origin: left center;
  box-shadow: 11px 0 22px #13284040;
  animation: turn-forward .48s cubic-bezier(.42, .04, .25, 1) both;
  will-change: transform;
}
.turning-leaf.backwards { transform-origin: right center; animation-name: turn-back; }
.turning-leaf::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, #11243d0a 0%, #e0ecfa62 76%, #132a4b45 100%);
  animation: shading .48s ease both;
}
.turning-leaf.backwards::after { transform: scaleX(-1); }
.turning-leaf img { width: 100%; height: 100%; display: block; }
@keyframes turn-forward { 0% { transform: rotateY(0); } 92%, 100% { transform: rotateY(-102deg); } }
@keyframes turn-back { 0% { transform: rotateY(0); } 92%, 100% { transform: rotateY(102deg); } }
@keyframes shading { 0% { opacity: 0; } 62% { opacity: 1; } 100% { opacity: .3; } }

.pagination {
  background: #fafcfe;
  border-top: 1px solid var(--rule);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.pagination-inner {
  width: min(100%, 570px);
  margin-inline: auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
}
.page-step, .counter {
  display: inline-flex;
  min-height: 44px;
  padding-inline: 12px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  font-size: .88rem;
  font-weight: 650;
}
.page-step:first-child { justify-self: start; }
.page-step:last-child { justify-self: end; }
.page-step:disabled { opacity: .32; }
.counter { border-color: var(--rule); min-width: 79px; background: #f3f7fb; font-variant-numeric: tabular-nums; }
.count-divider { color: var(--bronze); font-weight: 400; }
.page-tools { display: flex; gap: 5px; align-items: center; justify-content: center; }
.view-images { color: var(--bronze); }
#art-dialog {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  color: var(--navy);
  background: #f7f6f3;
  border: 0;
}
#art-dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
#art-dialog::backdrop { background: #f7f6f3; }
.art-bar, .art-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 3px clamp(8px, 3vw, 40px);
}
.art-bar { border-bottom: 1px solid #dedbd5; }
.art-bar h2 { margin: 0; padding-left: 3px; font: normal clamp(18px, 3.5vw, 28px)/1.2 Georgia, serif; }
.art-view { margin: 0; min-height: 0; min-width: 0; }
.art-view img { display: block; width: 100%; height: 100%; object-fit: contain; object-position: center; }
.art-controls { min-height: 46px; justify-content: center; border-top: 1px solid #dedbd5; }
.art-controls button { width: 48px; font-size: 1.25rem; }
.art-controls button:disabled { opacity: .32; }
.art-description { display: flex; align-items: baseline; justify-content: center; gap: 8px; text-align: center; }
#art-caption { font-size: .85rem; }
#art-count { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .77rem; white-space: nowrap; }
@media (max-width: 355px) { .view-images span { display: none; } }

#contents-dialog, #editions-dialog, #downloads-dialog {
  width: min(498px, calc(100vw - 21px));
  max-height: calc(100dvh - 30px);
  color: var(--navy);
  border: 1px solid #cbd6e1;
  border-radius: 8px;
  background: #fbfdff;
  padding: 0;
  box-shadow: 0 10px 48px #102a4530;
}
#contents-dialog::backdrop, #editions-dialog::backdrop, #downloads-dialog::backdrop { background: #162d4882; }
.dialog-inner { padding: 13px clamp(13px, 4vw, 23px) 16px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h1 { margin: 6px 0; font: 400 2.15rem Georgia, serif; }
#dialog-close { font-size: 1.65rem; line-height: 1; }
#editions-dialog, #downloads-dialog { width: min(430px, calc(100vw - 24px)); }
#editions-title, #downloads-title { margin: 0; font-size: 1.25rem; }
.dialog-close { font-size: 1.65rem; line-height: 1; }
.edition-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: clamp(8px, 3vw, 14px);
  margin-top: 8px;
}
.edition-options section { display: grid; gap: 6px; min-width: 0; }
.edition-options h3 { margin: 0 0 2px; font-size: .9rem; }
.edition-options a {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 2px 7px;
  min-height: 48px;
  padding: 7px 10px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: #edf4fa;
  font-size: .9rem;
  font-weight: 650;
  text-decoration: none;
}
.edition-options a span + span { color: var(--muted); font-size: .83rem; }
.edition-options a:hover { background: #e1ebf4; }
.edition-options a[aria-current] { border-color: var(--navy); background: var(--navy); color: white; }
.edition-options a[aria-current] span + span { color: #dbe6f1; }
.project-search { display: grid; gap: 6px; margin: 13px 0 18px; }
.project-search label { font-size: .9rem; font-weight: 650; }
.project-search input {
  width: 100%;
  min-height: 46px;
  padding: 8px 12px;
  background: white;
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-size: 1rem;
}
.project-search input::placeholder { color: var(--muted); opacity: 1; }
.contents-featured {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  padding-block-end: 10px;
}
.contents-featured a {
  display: flex;
  align-items: center;
  min-height: 46px;
  padding: 9px 10px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: #edf4fa;
  font-size: .92rem;
  font-weight: 650;
  line-height: 1.25;
  text-decoration: none;
}
.contents-featured a:hover { background: #e1ebf4; }
.project-search-status { margin: 7px 0 11px; color: var(--muted); font-size: .9rem; }
.goto { display: grid; grid-template-columns: 1fr 80px 55px; gap: 8px; align-items: center; padding: 10px 0 13px; }
.goto label { font-weight: 650; }
.goto input, .goto button { border: 1px solid var(--rule); border-radius: 4px; min-height: 46px; min-width: 0; }
.goto input { padding: 0 8px; font-size: 16px; background: white; }
.goto button { background: var(--navy); color: white; }
#chapter-title { margin: 13px 0 6px; font-size: 1rem; font-weight: 650; }
.contents-list { list-style: none; margin: 0; padding: 0; }
.contents-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  border-top: 1px solid #e0e7ee;
  font-size: .9rem;
  font-weight: 650;
  text-decoration: none;
}
.contents-list a:hover { color: var(--bronze); }
.page-marker { color: var(--bronze); font-size: .84rem; font-variant-numeric: tabular-nums; }
.project-match { padding-block: 8px; }
.project-match-detail { display: block; margin-top: 3px; color: var(--muted); font-size: .875rem; font-weight: 450; }
.no-script { display: grid; gap: 12px; place-items: center; height: 100%; overflow: auto; }
.no-script img { width: min(96%, 430px); height: auto; }

@media (max-width: 960px) {
  .toolbar-top { grid-template-columns: minmax(60px, 1fr) auto auto; gap: 3px 9px; }
  .site-routes { grid-column: 2; }
  .language-control { grid-column: 3; grid-row: 1; }
  .cover-routes { grid-column: 1 / -1; grid-row: 2; }
  .cover-routes a { background: #eff4f9; }
}

@media (max-width: 540px) {
  .toolbar-inner { padding-inline: 8px; gap: 5px; }
  .toolbar-top { grid-template-columns: minmax(55px, 1fr) minmax(0, max-content) auto; gap: 3px 5px; }
  .site-routes a { padding-inline: 5px; font-size: .83rem; overflow-wrap: anywhere; }
  .cover-routes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cover-routes a { min-height: 40px; padding-inline: 5px; font-size: .82rem; overflow-wrap: anywhere; }
  .brand { width: min(100%, 104px); }
  #language-switch { min-height: 38px; max-width: 94px; padding-inline-start: 6px; font-size: .82rem; }
  .edition-button { display: inline-grid; gap: 2px; padding-inline: 8px; }
  .modes { gap: 1px; padding: 2px; }
  .modes button { min-height: 39px; padding-inline: 7px; font-size: .78rem; }
  .reading-controls { gap: 3px; }
  .tools { gap: 1px; }
  .tool { padding-inline: 6px; min-width: 32px; }
  .contents span { display: none; }
  .pdf { padding-inline: 4px; font-size: .78rem; gap: 3px; }
  .pdf > svg { width: 14px; height: 14px; }
  .scroll-view { padding: 7px 5px 13px; scroll-padding-block: 5px; scrollbar-width: none; }
  .scroll-view .leaf { margin-bottom: 10px; }
  .pagination-inner { padding-inline: 10px; }
}
@media (max-width: 360px) {
  .toolbar-controls { justify-content: center; }
  .pdf > svg { display: none; }
  .page-step { padding-inline: 7px; gap: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  .turning-leaf, .turning-leaf::after { animation-duration: .001s !important; }
}

.leaf-hd {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.download-page {
  display: grid;
  grid-template-rows: minmax(min-content, 1fr);
  place-items: center;
  overflow: auto;
  padding: clamp(12px, 4vw, 24px);
}
.download-panel {
  width: min(100%, 420px);
  padding: clamp(16px, 5.5vw, 32px);
  background: var(--white);
  box-shadow: 0 8px 32px #102a4512;
}
.download-panel img { display: block; width: 142px; height: auto; }
.download-panel h1 { margin: 28px 0 10px; font: 400 2.15rem/1.12 Georgia, serif; }
.download-edition { margin: 0 0 14px; color: var(--muted); font-size: .9rem; }
.pdf-options { display: grid; gap: 8px; }
.download-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 52px;
  padding: 8px 12px;
  border: 1px solid var(--navy);
  border-radius: 5px;
  color: white;
  background: var(--navy);
  font-size: .95rem;
  font-weight: 650;
  text-decoration: none;
}
.download-action:hover { background: #203c5b; }
.download-action.lightweight {
  border-color: var(--rule);
  color: var(--navy);
  background: var(--surface);
}
.download-action.lightweight:hover { background: #e1ebf4; }
.file-size { color: #dbe6f1; font-size: .9rem; font-weight: 550; white-space: nowrap; }
.lightweight .file-size { color: var(--muted); }
.download-status { margin: 10px 0 0; color: var(--muted); font-size: .88rem; }
.download-status:empty { margin: 0; }
.download-panel .back { display: inline-block; margin-top: 16px; color: var(--muted); font-size: .88rem; }
