@import './tokens.css';
* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 500 1rem/1.4 var(--font-display); }
a { color: inherit; }
button, input { font: inherit; }
button, .book-bar a, dialog a { min-height: 44px; }
button { border: 0; background: transparent; color: inherit; padding: 0.4rem 0.65rem; cursor: pointer; }
button:disabled { opacity: 0.4; cursor: default; }
:focus-visible { outline: 3px solid currentColor; outline-offset: -4px; }
[hidden] { display: none !important; }
.book-shell { height: 100dvh; display: grid; grid-template-rows: 56px minmax(0, 1fr); }
.book-bar { display: flex; align-items: center; gap: 0.2rem; padding: 0.25rem 1rem; background: var(--field-b); color: var(--on-b); }
.book-brand { margin-right: auto; text-decoration: none; font-weight: 700; letter-spacing: 0.04em; }
.book-controls { display: flex; align-items: center; gap: 0.2rem; }
.book-bar button { min-width: 44px; }
.page-number { width: 4.3rem; height: 44px; border: 0; text-align: center; background: var(--ground); color: var(--ink); appearance: textfield; }
.page-number::-webkit-inner-spin-button, .page-number::-webkit-outer-spin-button { appearance: none; }
.page-total { white-space: nowrap; padding-inline: 0.25rem; font-variant-numeric: tabular-nums; }
.book-stage { min-height: 0; overflow: auto; padding: 12px; overscroll-behavior: contain; }
.book-spread { display: flex; width: max-content; gap: 12px; margin-inline: auto; align-items: start; }
.book-page { position: relative; flex: none; background: #fff; }
.book-page canvas { display: block; }
.book-page .textLayer { z-index: 1; }
.book-page .pdf-links { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.pdf-links a { position: absolute; display: block; pointer-events: auto; }
.pdf-links a:hover { outline: 2px solid var(--wada-black); }
.textLayer ::selection { background: #b7d1ed; }
.book-fallback { max-width: 46rem; margin: 1rem auto; display: grid; grid-template-columns: minmax(0, 280px) minmax(0, 1fr); gap: 1.5rem; align-items: center; }
.book-fallback img { width: 100%; height: auto; display: block; }
.book-fallback h1 { font-size: clamp(2rem, 4vw, 3rem); line-height: 1.05; margin: 0 0 1rem; }
.book-fallback p { margin: 0 0 0.75rem; }
.book-fallback a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 700; }
dialog { background: var(--ground); color: var(--ink); border: 0; padding: 1rem; width: min(36rem, calc(100vw - 24px)); max-height: calc(100dvh - 32px); overflow: auto; }
dialog::backdrop { background: #111314b3; }
.dialog-heading { display: flex; align-items: center; gap: 1rem; justify-content: space-between; margin-bottom: 0.5rem; }
.dialog-heading h2 { margin: 0; font-size: 1.5rem; line-height: 1.15; }
.dialog-heading button { flex: none; min-width: 44px; }
.book-contents { list-style: none; padding: 0; margin: 0; }
.book-contents a, .book-options > a { display: flex; align-items: center; padding: 0.5rem; gap: 0.75rem; text-decoration: none; }
.book-contents a span { flex: 1; }
.book-contents a small { flex: none; font: inherit; }
.book-contents a:hover, .book-options > a:hover { background: var(--field-q); }
.book-options fieldset { border: 0; padding: 0.5rem 0; margin: 0; }
.book-options label { display: flex; align-items: center; gap: 0.6rem; min-height: 44px; }
.book-options input { width: 1.25rem; height: 1.25rem; }
.zoom-controls { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.zoom-controls button { background: var(--field-q); min-width: 44px; }
.zoom-controls input { width: 5rem; min-height: 44px; text-align: center; }
.zoom-modes { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.zoom-modes button { background: var(--field-q); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 759px) {
  .book-bar { padding-inline: 0.5rem; justify-content: space-between; gap: 0; }
  .book-brand { display: none; }
  .book-controls { gap: 0; width: 100%; justify-content: space-between; }
  .page-number { width: 3rem; }
  .book-bar button { padding-inline: 0.35rem; }
  .page-total { padding-inline: 0.15rem; }
  .book-stage { padding: 8px; }
  .book-fallback { display: block; max-width: 24rem; }
  .book-fallback > a { max-width: 18rem; margin: 0 auto 1rem; display: block; }
  .book-fallback h1 { font-size: 2rem; }
  .wide-book-option { display: none !important; }
}
/* Contents needs room for titles; small tools earn only their content width. */
#bookZoomDialog, #bookOptionsDialog { width: max-content; max-width: calc(100vw - 24px); }
