.viewer-page { min-height: 100vh; background: #dcd8d0; }
[hidden] { display: none !important; }
.viewer-header { position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; padding: .7rem clamp(1rem, 3vw, 2.5rem); color: white; background: rgba(23,35,49,.98); border-bottom: 2px solid var(--gold); box-shadow: 0 5px 18px rgba(0,0,0,.18); }
.viewer-brand { display: flex; flex-direction: column; }
.viewer-brand a { color: #d6dde2; text-decoration: none; font-size: .78rem; }
.viewer-brand strong { font-family: Georgia, serif; font-size: 1.05rem; font-weight: 500; }
.viewer-modes { display: flex; padding: 3px; background: rgba(255,255,255,.1); border-radius: 6px; }
.mode-button { padding: .5rem .8rem; color: #dce2e6; background: transparent; border: 0; border-radius: 4px; cursor: pointer; }
.mode-button.active { color: var(--ink); background: white; }
.page-jump { display: flex; justify-content: flex-end; align-items: center; gap: .4rem; color: #d6dde2; font-size: .8rem; }
.page-jump input { width: 4.3rem; padding: .35rem; color: var(--ink); text-align: center; background: white; border: 0; border-radius: 4px; }
.viewer-main { width: min(1500px, 100%); margin: auto; }
.reading-view { display: grid; grid-template-columns: 54px minmax(0, 1fr) 54px; gap: clamp(.5rem, 2vw, 1.5rem); align-items: center; min-height: calc(100vh - 72px); padding: clamp(1rem, 3vw, 2.5rem); }
.reading-sheet { width: 100%; margin: auto; padding: clamp(.65rem, 1.5vw, 1.2rem); background: #f9f7f1; border: 1px solid #c8c1b5; border-radius: 5px; box-shadow: 0 15px 45px rgba(20,25,30,.18); }
.reading-image { position: relative; display: block; width: 100%; padding: 0; overflow: hidden; background: white; border: 0; cursor: zoom-in; }
.reading-image img { width: 100%; max-height: calc(100vh - 190px); object-fit: contain; }
.reading-image span { position: absolute; right: .7rem; bottom: .7rem; padding: .4rem .65rem; color: white; background: rgba(23,35,49,.82); border-radius: 4px; opacity: 0; transition: opacity .2s; }
.reading-image:hover span, .reading-image:focus-visible span { opacity: 1; }
.reading-sheet figcaption { display: flex; justify-content: space-between; gap: 1rem; padding: .75rem .25rem 0; }
.reading-sheet figcaption span { color: var(--muted); }
.page-arrow { width: 52px; height: 78px; color: white; background: var(--ink); border: 0; border-radius: 6px; font-family: Georgia, serif; font-size: 3rem; line-height: 1; cursor: pointer; opacity: .88; }
.page-arrow:hover { background: var(--copper); }
.page-arrow:disabled { opacity: .22; cursor: default; }
.thumb-view { display: grid; grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap: 1rem; padding: clamp(1rem, 3vw, 2.5rem); }
.thumb-card { padding: .55rem; color: var(--ink); text-align: left; background: #f9f7f1; border: 1px solid #c8c1b5; border-radius: 5px; box-shadow: 0 5px 15px rgba(20,25,30,.08); cursor: pointer; transition: transform .15s, box-shadow .15s; }
.thumb-card:hover { transform: translateY(-3px); box-shadow: 0 10px 22px rgba(20,25,30,.15); }
.thumb-card img { width: 100%; aspect-ratio: 3.1 / 1; object-fit: contain; background: white; }
.thumb-card span { display: block; padding: .55rem .15rem .1rem; }
.zoom-dialog { width: 98vw; max-width: none; height: 96vh; max-height: none; padding: 0; overflow: hidden; background: #252b30; border: 0; }
.zoom-dialog::backdrop { background: rgba(0,0,0,.85); }
.zoom-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; height: 58px; padding: .5rem 1rem; color: white; background: var(--ink); }
.zoom-toolbar > div { display: flex; align-items: center; gap: .4rem; }
.zoom-toolbar button { min-width: 2.3rem; padding: .45rem .65rem; color: white; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); border-radius: 4px; cursor: pointer; }
.zoom-toolbar button:hover { background: var(--copper); }
#zoomLevel { min-width: 4.2rem; text-align: center; font-size: .8rem; }
.zoom-stage { height: calc(100% - 58px); overflow: auto; padding: 1rem; text-align: center; cursor: grab; }
.zoom-stage.dragging { cursor: grabbing; user-select: none; }
.zoom-stage img { width: auto; max-width: none; height: auto; background: white; transform-origin: top center; }
@media (max-width: 720px) {
  .viewer-header { grid-template-columns: 1fr auto; }
  .viewer-modes { order: 3; grid-column: 1 / -1; justify-self: stretch; }
  .mode-button { flex: 1; }
  .reading-view { grid-template-columns: 38px minmax(0, 1fr) 38px; padding: .65rem; }
  .page-arrow { width: 38px; height: 60px; }
  .reading-sheet figcaption { flex-direction: column; gap: .2rem; }
  .zoom-toolbar strong, #zoomLevel { display: none; }
  .zoom-toolbar { justify-content: flex-end; }
}
