:root {
  color-scheme: dark;
  --ink: #f0eadb;
  --muted: #aaa394;
  --ground: #121110;
  --stage: #000;
  --accent: #9c3c2e;
  --paper: #dfd5bb;
  --bar: #211d19;
  --bar-rule: #51483f;
  --button: #24211e;
  --button-border: #5b544c;
  --button-hover: #2c2824;
  --status-well: #0e0d0c;
  --strip: #0d0c0b;
  --strip-border: #302c28;
  --thumbnail: #28231f;
  --scroll-thumb: #4b443d;
  --scroll-track: #171513;
  --restore: rgba(18,17,16,.72);
  --restore-hover: rgba(36,33,30,.96);
  --restore-border: rgba(170,163,148,.42);
  --focus: #d26d5d;
  --sans: Arial, Helvetica, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}

html[data-theme="light"] {
  color-scheme: light;
  --ink: #211e19;
  --muted: #665f53;
  --ground: #d8cfb9;
  --stage: #b9af99;
  --accent: #7a2b21;
  --bar: #eee6d3;
  --bar-rule: #8f846f;
  --button: #e1d7c1;
  --button-border: #817661;
  --button-hover: #d3c7ae;
  --status-well: #c9bea7;
  --strip: #d4cab4;
  --strip-border: #8c816c;
  --thumbnail: #c4b99f;
  --scroll-thumb: #807561;
  --scroll-track: #d6ccb6;
  --restore: rgba(239,231,211,.78);
  --restore-hover: rgba(246,239,222,.98);
  --restore-border: rgba(74,67,56,.4);
  --focus: #8d3025;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--ground); font-family: var(--sans); transition: color 180ms ease, background-color 180ms ease; }
button, a { font: inherit; }
a { color: inherit; }
a:focus-visible, button:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.reader-bar {
  position: relative;
  top: 0;
  right: 0;
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 50px;
  height: 50px;
  padding: .32rem .65rem;
  background: var(--bar);
  border-bottom: 1px solid var(--bar-rule);
  backdrop-filter: blur(10px);
  transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease, transform 180ms ease, opacity 180ms ease, visibility 180ms;
}
.back-link { justify-self: start; font-size: .65rem; font-weight: 700; letter-spacing: .07em; text-decoration: none; text-transform: uppercase; }
.issue-heading { text-align: center; }
.issue-heading p { margin: 0; color: var(--muted); font-size: .58rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.issue-heading h1 { margin: .08rem 0 0; font-family: var(--serif); font-size: 1rem; line-height: 1; text-transform: uppercase; }
.header-actions { display: flex; justify-self: end; gap: .4rem; }
.icon-button { padding: .35rem .5rem; color: var(--ink); background: transparent; border: 1px solid var(--button-border); font-size: .62rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; cursor: pointer; }
.icon-button:hover { background: var(--button-hover); }

.reader-ui-restore {
  position: fixed;
  right: .8rem;
  bottom: .8rem;
  z-index: 50;
  padding: .45rem .62rem;
  color: var(--ink);
  background: var(--restore);
  border: 1px solid var(--restore-border);
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
  opacity: .38;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: opacity 140ms ease, background 140ms ease;
}
.reader-ui-restore:hover, .reader-ui-restore:focus-visible { background: var(--restore-hover); opacity: 1; }

.reader-main {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  height: calc(100dvh - 50px);
  padding: 0;
}
.book-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: .4rem;
  overflow: auto;
  background: var(--stage);
  overscroll-behavior: contain;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
  transition: background-color 180ms ease;
}
.book-zoom {
  display: inline-block;
  transform: scale(var(--reader-zoom, 1));
  transform-origin: top center;
  transition: transform 180ms ease, opacity 180ms ease;
}
.book-zoom.looping-forward { opacity: .2; transform: scale(var(--reader-zoom, 1)) rotateY(-8deg) scale(.96); }
.book-zoom.looping-back { opacity: .2; transform: scale(var(--reader-zoom, 1)) rotateY(8deg) scale(.96); }
.book {
  margin: 0 auto;
  width: min(calc((100dvh - 96px) * 4 / 3), calc(100vw - .8rem)) !important;
  height: min(calc(100dvh - 96px), calc((100vw - .8rem) * 3 / 4)) !important;
  filter: drop-shadow(0 18px 24px rgba(0,0,0,.6));
}
.book.stf__parent, .book .stf__parent { margin: 0 auto; }
.book canvas { image-rendering: auto; }

.fallback-book { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: min(100%, calc((100dvh - 240px) * 4 / 3)); aspect-ratio: 4 / 3; background: var(--ground); }
.fallback-page { position: relative; min-width: 0; min-height: 0; margin: 0; overflow: hidden; }
.fallback-page img { display: block; width: 100%; height: 100%; object-fit: contain; }
.fallback-page figcaption { position: absolute; right: .3rem; bottom: .3rem; padding: .12rem .25rem; background: rgba(0,0,0,.72); font-size: .65rem; }

.reader-controls {
  display: grid;
  grid-template-columns: auto auto auto auto;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  width: 100%;
  margin: 0;
  padding: .3rem .55rem;
  background: var(--bar);
  border-top: 1px solid var(--bar-rule);
  transition: background-color 180ms ease, border-color 180ms ease;
}
.reader-controls button, .zoom-controls button {
  padding: .55rem .75rem;
  color: var(--ink);
  background: var(--button);
  border: 1px solid var(--button-border);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  cursor: pointer;
}
.reader-controls > button {
  justify-self: auto;
  width: 2.25rem;
  min-width: 0;
  padding: .3rem;
  font-size: 0;
}
.reader-controls > .reader-ui-toggle {
  width: auto;
  padding: .3rem .5rem;
  font-size: .58rem;
}
.reader-controls #previous::before, .reader-controls #next::before { font-size: .95rem; }
.reader-controls #previous::before { content: "←"; }
.reader-controls #next::before { content: "→"; }
.reader-controls button:hover:not(:disabled), .zoom-controls button:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); }
.reader-controls button:disabled, .zoom-controls button:disabled { opacity: .32; cursor: default; }
.reader-status { display: flex; align-items: center; gap: .55rem; min-width: 0; text-align: center; }
.reader-status > p { margin: 0; color: var(--muted); font-size: .65rem; white-space: nowrap; }
.zoom-controls { display: inline-grid; grid-template-columns: auto minmax(3.4rem, auto) auto auto; align-items: center; }
.zoom-controls button { padding: .25rem .45rem; }
.zoom-controls #zoom-reset { display: none; }
.zoom-controls output { align-self: stretch; display: grid; place-items: center; padding: 0 .45rem; color: var(--muted); background: var(--status-well); border-top: 1px solid var(--button-border); border-bottom: 1px solid var(--button-border); font-size: .7rem; }

.page-strip {
  position: fixed;
  bottom: 39px;
  left: 50%;
  z-index: 30;
  display: flex;
  gap: .45rem;
  width: min(100%, 1040px);
  margin: 0;
  padding: .55rem;
  overflow-x: auto;
  background: var(--strip);
  border: 1px solid var(--strip-border);
  transform: translateX(-50%);
  transition: opacity 140ms ease, max-height 140ms ease, padding 140ms ease;
}
.page-strip.is-collapsed { max-height: 0; margin-top: 0; padding-block: 0; overflow: hidden; border-color: transparent; opacity: 0; }
.thumbnail { flex: 0 0 54px; padding: 0; background: var(--thumbnail); border: 2px solid transparent; cursor: pointer; }
.thumbnail[aria-current="page"] { border-color: var(--focus); }
.thumbnail img { display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: cover; }
.thumbnail span { display: block; padding: .18rem 0; color: var(--muted); font-size: .65rem; }
.reader-hint { display: none; }

.unavailable { width: min(620px, 100%); margin: 10vh auto; padding: clamp(1.5rem, 5vw, 3.5rem); background: var(--paper); color: #201e1a; border: 8px double #201e1a; text-align: center; }
.unavailable .status { margin: 0; font-size: .75rem; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.unavailable h2 { margin: .35rem 0 .7rem; font-family: var(--serif); font-size: clamp(2rem, 7vw, 4rem); line-height: .9; text-transform: uppercase; }
.unavailable p { line-height: 1.5; }
.unavailable a { font-weight: 800; text-transform: uppercase; }

.shortcuts-dialog {
  width: min(520px, calc(100% - 2rem));
  padding: 0;
  color: #201e1a;
  background: var(--paper);
  border: 5px double #201e1a;
  box-shadow: 0 18px 60px rgba(0,0,0,.65);
}
.shortcuts-dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(3px); }
.shortcuts-dialog form { padding: 1rem; }
.shortcuts-dialog header { display: flex; align-items: center; justify-content: space-between; padding-bottom: .55rem; border-bottom: 1px solid #201e1a; }
.shortcuts-dialog h2 { margin: 0; font-family: var(--serif); text-transform: uppercase; }
.shortcuts-dialog header button { padding: .2rem .55rem; color: #201e1a; background: transparent; border: 1px solid #201e1a; font-size: 1.2rem; cursor: pointer; }
.shortcuts-dialog dl { margin: .75rem 0; }
.shortcuts-dialog dl > div { display: grid; grid-template-columns: 9.5rem 1fr; gap: .75rem; padding: .3rem 0; border-bottom: 1px dotted #6f685c; }
.shortcuts-dialog dt { font-weight: 800; }
.shortcuts-dialog dd { margin: 0; }
.shortcuts-dialog p { margin-bottom: 0; font-size: .8rem; line-height: 1.4; }

.controls-hidden .reader-bar {
  position: fixed;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-110%);
}
.controls-hidden .reader-main { height: 100dvh; padding: 0; }
.controls-hidden .book-stage {
  place-items: center;
  width: 100%;
  height: 100dvh;
  min-height: 0;
  padding: 0;
  overflow: auto;
}
.controls-hidden .book {
  width: min(calc((100dvh - 1rem) * 4 / 3), calc(100vw - 1rem)) !important;
  height: min(calc(100dvh - 1rem), calc((100vw - 1rem) * 3 / 4)) !important;
}
.controls-hidden .reader-controls,
.controls-hidden .page-strip,
.controls-hidden .reader-hint { display: none; }

@media (max-width: 760px) {
  .reader-bar { grid-template-columns: 4.25rem minmax(0, 1fr) 6.8rem; min-height: 50px; height: 50px; padding: .32rem .45rem; }
  .back-link { font-size: 0; }
  .back-link::before { font-size: 1rem; content: "←"; }
  .issue-heading h1 { font-size: 1rem; }
  .issue-heading p { font-size: .58rem; }
  .header-actions { gap: .2rem; }
  body:not(.fullscreen-reader) .header-actions .icon-button {
    display: grid;
    place-items: center;
    width: 2.1rem;
    height: 2.1rem;
    padding: 0;
    font-size: 0;
  }
  body:not(.fullscreen-reader) #shortcuts-button::before { font-size: .8rem; content: "?"; }
  body:not(.fullscreen-reader) #fullscreen::before { font-size: 1rem; content: "⛶"; }
  body:not(.fullscreen-reader) .reader-bar .theme-toggle::before { font-size: .9rem; content: "◐"; }
  .reader-main { height: calc(100dvh - 50px); padding: 0; }
  .book-stage { height: 100%; min-height: 0; padding: .25rem; }
  .book {
    width: min(calc((100dvh - 96px) * 2 / 3), calc(100vw - .5rem)) !important;
    height: min(calc(100dvh - 96px), calc((100vw - .5rem) * 3 / 2)) !important;
  }
  .fallback-book { grid-template-columns: 1fr; width: min(100%, calc((100dvh - 230px) * 2 / 3)); aspect-ratio: 2 / 3; }
  .reader-controls { grid-template-columns: auto auto auto auto; gap: .25rem; padding-inline: .3rem; }
  .reader-controls > button { padding: .3rem; font-size: 0; }
  .reader-status { min-width: 0; }
  .reader-status > p { font-size: .58rem; }
  .zoom-controls button { padding: .22rem .38rem; }
  .zoom-controls button:last-child { display: none; }
  .zoom-controls { grid-template-columns: auto minmax(3rem, auto) auto; }
  .page-strip { bottom: 39px; }
  .reader-hint { display: none; }
  .shortcuts-dialog dl > div { grid-template-columns: 7.5rem 1fr; }
  .controls-hidden .book {
    width: min(calc(100dvh * 2 / 3), calc(100vw - .5rem)) !important;
    height: min(100dvh, calc((100vw - .5rem) * 3 / 2)) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .book-zoom, .page-strip { transition: none; }
}

html:fullscreen body.fullscreen-reader {
  height: 100dvh;
  overflow: hidden;
}
html:fullscreen body.fullscreen-reader .back-link,
html:fullscreen body.fullscreen-reader #shortcuts-button,
html:fullscreen body.fullscreen-reader .theme-toggle,
html:fullscreen body.fullscreen-reader .page-strip,
html:fullscreen body.fullscreen-reader .reader-hint { display: none; }
html:fullscreen body.fullscreen-reader:not(.controls-hidden) .reader-bar {
  position: relative;
  grid-template-columns: 2.1rem minmax(0, 1fr) 2.1rem;
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: none;
}
html:fullscreen body.fullscreen-reader:not(.controls-hidden) .issue-heading { grid-column: 2; }
html:fullscreen body.fullscreen-reader:not(.controls-hidden) .header-actions { grid-column: 3; }
html:fullscreen body.fullscreen-reader:not(.controls-hidden) #fullscreen {
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0 0 .12rem;
  border-radius: 999px;
  font-size: 1.35rem;
  line-height: 1;
  letter-spacing: 0;
}
html:fullscreen body.fullscreen-reader:not(.controls-hidden) .reader-main {
  height: calc(100dvh - 50px);
}
html:fullscreen body.fullscreen-reader:not(.controls-hidden) .book-stage {
  height: 100%;
  padding: .4rem;
}
html:fullscreen body.fullscreen-reader:not(.controls-hidden) .book {
  width: min(calc((100dvh - 96px) * 4 / 3), calc(100vw - .8rem)) !important;
  height: min(calc(100dvh - 96px), calc((100vw - .8rem) * 3 / 4)) !important;
}
html:fullscreen body.fullscreen-reader:not(.controls-hidden) .reader-controls { display: grid; }

@media (max-width: 760px) {
  html:fullscreen body.fullscreen-reader:not(.controls-hidden) .book {
    width: min(calc((100dvh - 96px) * 2 / 3), calc(100vw - .5rem)) !important;
    height: min(calc(100dvh - 96px), calc((100vw - .5rem) * 3 / 2)) !important;
  }
}
