.sampler {
  --study-gap: 22px;
  --study-summary-height: 54px;
  --sampler-padding: 8px;
  padding-bottom: var(--sampler-padding);
}
.sampler-intro {
  --intro-controls: calc(var(--mast-height, 77px) + var(--study-gap) + var(--study-summary-height) + var(--sampler-padding) + 1px);
  display: grid;
  grid-template-rows: auto minmax(min(240px, 35vh), 1fr);
  grid-template-rows: auto minmax(min(240px, 35svh), 1fr);
  min-height: calc(100vh - var(--intro-controls));
  min-height: calc(100dvh - var(--intro-controls));
}
.sampler-poster {
  position: relative;
  display: block;
  background: #171916;
}
.sampler-poster img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.opening-original { display: none; }
@media (min-width: 720px) {
  .opening-original { display: flex; }
  .cover-original { display: none; }
  .sampler-poster img { object-fit: cover; object-position: center 56%; }
}
.reading-section { min-height: 100vh; min-height: 100dvh; }
.launch, .trial-steps button, .dialog-bar button, .chapter-step, .swap-order {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
}
.launch {
  position: absolute;
  bottom: clamp(16px, 3vw, 32px);
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 24px;
  color: var(--ink);
  background: var(--acid);
  box-shadow: 0 2px 12px #17191666;
  white-space: nowrap;
}
.sampler-poster:is(:hover, :focus-visible) .launch { background: #efffba; }

#trial-reader[open] {
  display: flex;
  flex-direction: column;
  width: min(calc(100% - 48px), 1680px);
  height: calc(100vh - 40px);
  height: calc(100dvh - 40px);
  max-width: none;
  max-height: none;
  overflow: hidden;
  border: 1px solid var(--night-line);
  border-radius: 12px;
  box-shadow: 0 12px 70px #0006;
}
#trial-reader :focus-visible { outline-color: var(--acid); }
.trial-bar, .trial-tools { flex: none; }
.book-heading { display: grid; min-width: 0; line-height: 1.32; overflow-wrap: anywhere; hyphens: auto; }
.book-heading strong { font-size: 16px; font-weight: 620; }
.chapter-name, #mode-hint { font-size: 12px; color: var(--night-muted); }
.trial-window {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  background: #10110f;
  scrollbar-color: #63665c #191b17;
  outline-offset: -3px;
}
.trial-strip { width: min(100%, 1200px); margin-inline: auto; }
.trial-page, .trial-sheet img { width: 100%; }
.trial-page img { user-select: none; -webkit-user-drag: none; }
.trial-tail { display: none; }
.chapter-boundary { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 24px 10px; }
.chapter-boundary::before, .chapter-boundary::after { content: ""; width: 36px; height: 1px; background: var(--night-line); }
.chapter-boundary span { color: var(--night-text); font-size: 14px; }
.chapter-edge { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 66px; padding: 6px 12px; }
.chapter-step { padding: 0 18px; border: 1px solid var(--night-line); color: var(--night-text); background: var(--ink); }
.chapter-step:hover { color: var(--acid); }
.chapter-step .icon { height: 16px; width: 16px; }
[data-direction="previous"] .chapter-step .icon { transform: rotate(180deg); }
.pull-cue {
  display: none;
  position: relative;
  line-height: 1.35;
  padding-bottom: 5px;
  color: var(--night-muted);
  font-size: 13px;
}
.pull-cue::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  background: var(--acid);
  transform: scaleX(var(--pull, 0));
  transform-origin: left;
}
.chapter-edge[data-armed] .pull-cue { color: var(--acid); }
@media (any-pointer: coarse) { .pull-cue { display: block; } }
.chapter-edge[data-pulling] .pull-cue { display: block; }

[data-mode="gallery"] .trial-window { overflow: hidden; touch-action: pan-y pinch-zoom; }
[data-mode="gallery"] .trial-strip, [data-mode="gallery"] .trial-page,
[data-mode="gallery"] .trial-sheet, [data-mode="gallery"] .trial-sheet img { width: 100%; height: 100%; }
[data-mode="gallery"] .trial-sheet img { object-fit: contain; }
.trial-tools {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 5px clamp(10px, 2vw, 32px);
  padding: 10px clamp(14px, 2.5vw, 40px) 9px;
  border-top: 1px solid var(--night-line);
}
.mode-picker {
  display: flex;
  padding: 2px;
  border: 1px solid var(--night-line);
  border-radius: 28px;
  background: #242622;
}
.mode-picker label { position: relative; flex: 1 0 auto; }
.mode-picker input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.mode-picker span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 4px 15px;
  border-radius: 24px;
  color: #dcdfd3;
  font-size: 14px;
  font-weight: 550;
}
.mode-picker input:checked + span { color: var(--ink); background: var(--acid); }
.mode-picker input:focus-visible + span { outline: 2px solid var(--night-text); outline-offset: 1px; }
.mode-picker label:hover input:not(:checked) + span { background: var(--ink-low); }
.mode-picker .icon { width: 17px; height: 17px; }
#mode-hint { grid-column: 1 / -1; text-align: center; line-height: 1.4; }
.trial-progress { min-width: 0; }
.position { display: block; font-size: 14px; line-height: 1.4; font-variant-numeric: tabular-nums; }
.page-ticks { display: flex; gap: 4px; width: min(145px, 100%); margin-top: 6px; }
.page-ticks i { height: 3px; flex: 1; border-radius: 2px; background: var(--night-line); }
.page-ticks i:nth-child(2) { margin-inline-end: 5px; }
.page-ticks i.current { background: var(--acid); }
.trial-steps { display: flex; justify-content: flex-end; gap: 6px; }
.trial-steps button, .dialog-bar button {
  color: var(--night-text);
  border: 1px solid var(--night-line);
  background: var(--ink);
  padding: 0 12px;
  min-width: 44px;
}
.trial-steps button:hover:enabled, .dialog-bar button:hover { background: var(--ink-low); color: var(--acid); }
.trial-steps button:disabled { opacity: .38; cursor: default; }
.dialog-bar .compare-mode { max-width: 52%; font-size: 13px; line-height: 1.25; color: var(--acid); overflow-wrap: anywhere; }
.compare-mode .icon { width: 16px; height: 16px; }
[data-mode="gallery"] .page-ticks { direction: rtl; }
[data-mode="gallery"] .trial-next { order: -1; }
.gallery-label { white-space: nowrap; }
#trial-reader:not([data-mode="gallery"]) .gallery-label { display: none; }
#trial-reader:not([data-mode="gallery"]) .trial-prev .icon { transform: rotate(180deg); }
#trial-reader.tools-hidden :is(.trial-bar, .trial-tools) { display: none; }
.panel-study { border-top: 1px solid var(--night-line); margin-top: var(--study-gap); }
.panel-study > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--study-summary-height);
  color: var(--night-muted);
  font-size: 14px;
}
.panel-study summary strong { color: var(--night-text); font-weight: 550; }
.panel-study summary::after { content: "+"; font-size: 21px; margin-left: auto; }
.panel-study[open] summary::after { content: "−"; }
.panel-study .reader { margin-bottom: 10px; }
.panel-study .reader-title h2 { font-size: clamp(17px, 1.7vw, 25px); }

.strip-half { display: none; width: 100%; aspect-ratio: 3/4; overflow: hidden; }
.strip-half img { width: 200%; max-width: none; height: auto; }
.workbench:has([value="split"]:checked) .strip-half { display: block; }
.workbench:has([value="split"]:checked) .spread-original { display: none; }
.strip-half.first img, .workbench:has([data-reversed="true"]) .strip-half.second img { transform: translateX(-50%); }
.workbench:has([data-reversed="true"]) .strip-half.first img { transform: none; }
.swap-order { background: transparent; border: 1px solid var(--rule); padding: 5px 13px; margin-top: 9px; }
.order-value { color: var(--muted); font-size: 12px; }

html.dialog-open { overflow: hidden; }
dialog:not([open]) { display: none; }
dialog { padding: 0; border: 0; color: var(--night-text); background: var(--ink); }
dialog::backdrop { background: rgb(11 12 10 / 82%); }
dialog:focus-visible { outline-offset: -3px; }
.dialog-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 6px 10px 6px 18px;
  background: var(--ink);
  border-bottom: 1px solid var(--night-line);
}
.dialog-bar > :first-child { margin-right: auto; }
.dialog-bar #image-caption { font-size: 14px; }
.dialog-bar .dialog-close { flex: 0 0 44px; }
#image-viewer[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(94vw, 1440px);
  height: 90vh;
  height: 90dvh;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  border: 1px solid var(--night-line);
  border-radius: 9px;
}
.image-canvas { overflow: auto; overscroll-behavior: contain; }
.image-sheet { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.image-sheet img { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; cursor: zoom-in; }
.enlarged .image-sheet { display: grid; place-items: center; width: max-content; min-width: 100%; height: auto; min-height: 100%; }
.enlarged .image-sheet img { max-width: none; max-height: none; cursor: zoom-out; }
@media (max-width: 840px) {
  .trial-tools { grid-template-columns: 1fr auto; gap: 6px 12px; padding-inline: 14px; }
  .mode-picker { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
  .mode-picker span { padding-inline: 15px; }
}
@media (max-width: 700px), (pointer: coarse) and (max-height: 520px) {
  #trial-reader[open] {
    width: 100%; height: 100vh; height: 100dvh; margin: 0;
    border: 0; border-radius: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
}
@media (max-width: 700px) {
  .sampler { --study-gap: 14px; --study-summary-height: 48px; }
  .panel-study > summary { font-size: 13px; }
  .panel-study summary span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  #image-viewer[open] { width: 100%; height: 94dvh; border-radius: 4px; }
  .dialog-bar { gap: 6px; padding-left: 12px; }
}
@media (max-width: 700px), (max-aspect-ratio: 4/5) {
  #trial-reader:not([data-mode="gallery"]) :is(.trial-sheet,.trial-tail) { display: block; overflow: hidden; aspect-ratio: 3/4; }
  #trial-reader:not([data-mode="gallery"]) :is(.trial-sheet,.trial-tail) img { width: 200%; max-width: none; }
  #trial-reader:not([data-mode="gallery"]) .trial-sheet img { transform: translateX(-50%); }
}
@media (max-width: 520px) {
  .trial-tools { padding: 6px 12px 8px; }
  .mode-picker { justify-self: stretch; }
  .mode-picker span { gap: 4px; padding-inline: 4px; font-size: 13px; }
  .trial-steps button { gap: 4px; padding-inline: 8px; font-size: 12px; }
  .trial-steps .icon { width: 16px; }
  .position { font-size: 12px; }
  .dialog-bar .compare-mode { gap: 4px; padding-inline: 8px; font-size: 12px; }
}
@media (max-width: 400px) {
  .trial-bar:has(.compare-mode:not([hidden])) {
    display: grid;
    grid-template-columns: minmax(0,1fr) 44px;
  }
  .trial-bar .compare-mode { grid-column: 1; grid-row: 2; justify-self: start; max-width: 100%; }
  .trial-bar .dialog-close { grid-column: 2; grid-row: 1 / 3; align-self: start; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .trial-tools { display: flex; justify-content: space-between; padding-block: 3px; }
  .trial-tools #mode-hint { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
  .mode-picker span { padding-inline: 8px; }
  .trial-bar { min-height: 46px; padding-block: 1px; }
}
@media (prefers-reduced-motion: no-preference) {
  .sample-art img {
    opacity: calc(.55 + .45 * var(--sample-reveal, 1));
    transform: translateY(calc(14px * (1 - var(--sample-reveal, 1))));
  }
  #trial-reader[open] { animation: reader-open .18s ease-out; }
  .trial-bar, .trial-tools { animation: reader-open .14s ease-out; }
  @keyframes reader-open { from { opacity: .3; } to { opacity: 1; } }
}
