:root { color-scheme: dark; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: #080808; color: #e9e9e9; --top: 68px; --bottom: 88px; }
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { height: 100dvh; }
button, input, a { -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; }
button { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 10px; border: 0; border-radius: 8px; background: transparent; color: #c7c7c7; cursor: pointer; transition: background .16s, color .16s; flex-shrink: 0; }
button:hover { background: #ffffff10; color: white; }
button:disabled { opacity: .25; cursor: default; background: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
a { color: inherit; }
.topbar { position: fixed; z-index: 5; top: 0; left: 0; right: 0; height: var(--top); padding: env(safe-area-inset-top) 28px 0; display: flex; align-items: center; justify-content: space-between; background: #080808; }
.identity { display: flex; gap: 16px; align-items: center; text-decoration: none; font-size: 14px; font-weight: 500; letter-spacing: .13em; white-space: nowrap; }
.identity span { color: #787878; font-size: 11px; font-weight: 400; letter-spacing: .2em; }
.top-actions { display: flex; gap: 3px; }
.quiet { color: #999; }
#viewer { position: absolute; inset: var(--top) 0 calc(var(--bottom) + env(safe-area-inset-bottom)); overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #333 transparent; touch-action: none; outline: none; }
#surface { display: flex; align-items: center; justify-content: center; min-width: 100%; min-height: 100%; padding: 14px 20px; }
#sheet { position: relative; flex-shrink: 0; width: min(960px, calc(100vw - 40px)); aspect-ratio: 16 / 9; background: #080808; user-select: none; }
#sheet img, #sheet canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
#sheet img { object-fit: contain; }
#sheet canvas { opacity: 0; }
#sheet.rendered canvas { opacity: 1; }
#links { position: absolute; inset: 0; }
#links a { position: absolute; display: block; border-radius: 2px; }
#links a:hover { background: #ffffff0d; outline: 1px solid #ffffff50; }
#links a:focus-visible { outline: 2px solid #fff; background: #0003; }
#viewer.zoomed { cursor: grab; }
#viewer.dragging { cursor: grabbing; }
.toolbar { position: fixed; z-index: 6; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 8px; border: 1px solid #ffffff19; border-radius: 12px; padding: 4px 8px; background: #171717ed; box-shadow: 0 4px 32px #0004; }
.control-group { display: flex; align-items: center; gap: 1px; }
.separator { width: 1px; height: 20px; background: #ffffff18; }
.page-count { display: flex; align-items: center; gap: 7px; font-size: 12px; font-variant-numeric: tabular-nums; color: #777; margin: 0 3px; }
.page-count input { width: 27px; height: 34px; padding: 0; text-align: center; border: 0; border-radius: 4px; color: #f3f3f3; background: transparent; font-size: 12px; font-variant-numeric: tabular-nums; }
.page-count input:hover { background: #ffffff09; }
#zoom-value { width: 44px; text-align: center; font-size: 11px; color: #999; font-variant-numeric: tabular-nums; }
.fit { width: 46px; padding: 0; font-size: 11px; color: #999; }
#notice { position: fixed; z-index: 4; top: calc(var(--top) + 3px); left: 50%; transform: translateX(-50%); max-width: 90vw; border-radius: 5px; font-size: 11px; color: #999; background: #080808d9; padding: 5px 10px; pointer-events: none; text-align: center; }
#notice:empty { display: none; }
#error { position: fixed; z-index: 4; inset: 40% 20px auto; text-align: center; font-size: 13px; color: #aaa; background: #111f; padding: 16px; border-radius: 8px; max-width: 380px; margin: auto; }
#error[hidden] { display: none; }
#error button, #error a { width: auto; padding: 8px 12px; font-size: 12px; }
dialog { width: min(1100px, calc(100vw - 40px)); max-height: calc(100dvh - 60px); padding: 0; border: 1px solid #333; border-radius: 12px; color: #ddd; background: #151515; box-shadow: 0 20px 80px #0008; }
dialog::backdrop { background: #000b; backdrop-filter: blur(8px); }
.dialog-header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 12px 18px 12px 24px; background: #151515f5; border-bottom: 1px solid #292929; }
.dialog-header h1 { margin: 0; font-size: 14px; font-weight: 500; letter-spacing: .08em; }
.dialog-header h1 span { font-size: 11px; color: #777; margin-left: 12px; font-variant-numeric: tabular-nums; }
.close { font-size: 17px; }
.thumbnails { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px 16px; padding: 24px; }
.thumbnail { width: 100%; height: auto; padding: 5px; border-radius: 4px; display: flex; flex-direction: column; gap: 8px; border: 1px solid transparent; }
.thumbnail[aria-current="page"] { border-color: #bbb; background: #ffffff09; }
.thumbnail img { width: 100%; aspect-ratio: 16/9; object-fit: contain; background: #080808; }
.thumbnail span { font-size: 11px; color: #888; font-variant-numeric: tabular-nums; }
#help-dialog { max-width: 500px; }
.help-content { padding: 8px 24px 24px; font-size: 13px; line-height: 1.8; }
.help-content dl { display: grid; grid-template-columns: 40px 1fr; gap: 14px 18px; margin: 24px 0; }
.help-content dt { color: #eee; }
.help-content dd { margin: 0; color: #999; }
.muted { color: #666; font-size: 11px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.no-script { position: fixed; inset: 35% 10% auto; padding: 24px; background: #222; text-align: center; }
body.immersive { --top: 0px; --bottom: 76px; }
body.immersive .topbar { height: 46px; background: linear-gradient(#0009,transparent); opacity: .3; }
body.immersive .identity { visibility: hidden; }
body.immersive .topbar:hover, body.immersive .topbar:focus-within { opacity: 1; }
@media (max-width: 600px) {
  :root { --top: calc(58px + env(safe-area-inset-top)); --bottom: 80px; }
  .topbar { padding-left: 16px; padding-right: 10px; }
  .identity { font-size: 13px; gap: 10px; }
  .identity span { font-size: 10px; }
  .top-actions { gap: 0; }
  #surface { padding: 8px 0; }
  .toolbar { bottom: calc(14px + env(safe-area-inset-bottom)); gap: 4px; padding: 3px 4px; max-width: calc(100vw - 16px); }
  .control-group { gap: 0; }
  .toolbar button { width: 40px; }
  .page-count { gap: 4px; margin: 0; font-size: 11px; }
  #zoom-value { width: 39px; font-size: 10px; }
  .toolbar .fit { width: 36px; }
  dialog { width: calc(100vw - 20px); max-height: calc(100dvh - 30px); }
  .thumbnails { grid-template-columns: repeat(2, 1fr); gap: 14px 10px; padding: 16px; }
  .dialog-header { padding-left: 20px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  :root { --top: 42px; --bottom: 62px; }
  .topbar { padding-top: 0; }
  .toolbar { bottom: calc(5px + env(safe-area-inset-bottom)); }
  #surface { padding: 0 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
