* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  font-family: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  background: #c9b288 url("background.jpg") center / cover no-repeat;
  color: #eee;
  overflow: hidden;
}
body.noscroll { touch-action: none; }
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

#bar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px;
  background: #17335e;
  color: #fff;
  flex: 0 0 auto;
}
#bar a { color: #cfe0ff; text-decoration: none; white-space: nowrap; }
#bar a:hover { color: #fff; }
#bar-title { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#bar-logo { height: 20px; vertical-align: -4px; margin-right: 8px; }
#bar-date { font-weight: 400; margin-left: 10px; font-size: 0.9em; color: #cfe0ff; }
#bar-right { display: flex; align-items: center; gap: 14px; font-size: 0.9em; }
#strip-toggle {
  border: 0; background: none; color: #cfe0ff;
  font-size: 17px; cursor: pointer; padding: 2px 4px; border-radius: 5px;
}
#strip-toggle:hover { color: #fff; background: rgba(255,255,255,.12); }
#strip-toggle.off { opacity: .45; }

#stage {
  flex: 1 1 auto; min-height: 0;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  gap: 6px; padding: 10px;
  user-select: none;
  touch-action: none; /* keep pointer events alive so tap/swipe detection works on touch */
}
#spread {
  height: 100%; min-width: 0;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
#spread img {
  max-height: 100%;
  max-width: 100%;
  box-shadow: 0 2px 14px rgba(0,0,0,.55);
  background: #fff;
  cursor: zoom-in;
  flex: 0 1 auto;
  object-fit: contain;
  min-width: 0;
}
.nav {
  flex: 0 0 auto;
  width: 42px; height: 84px;
  border: 0; border-radius: 8px;
  background: rgba(255,255,255,.12);
  color: #fff; font-size: 30px; cursor: pointer;
}
.nav:hover:not(:disabled) { background: rgba(255,255,255,.25); }
.nav:disabled { opacity: .25; cursor: default; }

#strip[hidden] { display: none; } /* author display:flex would override [hidden] */
#strip {
  flex: 0 0 auto;
  display: flex; gap: 6px;
  overflow-x: auto;
  padding: 8px 10px;
  background: #1d1d20;
}
#strip img {
  height: 72px;
  border: 2px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  opacity: .75;
}
#strip img:hover { opacity: 1; }
#strip img.active { border-color: #6ea8ff; opacity: 1; }

#overlay {
  position: fixed; inset: 0;
  background: #161618;
  z-index: 50;
  display: flex; flex-direction: column;
}
#overlay[hidden] { display: none; }
#zoom-viewport {
  flex: 1; position: relative; overflow: hidden;
  touch-action: none; cursor: grab;
}
#zoom-viewport:active { cursor: grabbing; }
#zoom-content { position: absolute; transform-origin: 0 0; }
#zoom-content img, #zoom-content canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  background: #fff;
}
#overlay-bar {
  transition: opacity .2s;
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px;
  background: rgba(20,20,24,.92);
  border-radius: 10px;
  padding: 6px 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,.5);
}
#overlay-bar button, #overlay-bar a {
  border: 0; background: none; color: #ddd;
  font-size: 19px; min-width: 38px; height: 38px; line-height: 38px;
  text-align: center; cursor: pointer; border-radius: 7px;
  text-decoration: none;
}
#overlay-bar button:hover:not(:disabled), #overlay-bar a:hover { background: rgba(255,255,255,.14); color: #fff; }
#overlay-bar button:disabled { opacity: .3; cursor: default; }
#z-label { padding: 0 8px; font-size: 15px; color: #fff; white-space: nowrap; }
#overlay-bar.bar-hidden { opacity: 0; pointer-events: none; }

/* single-page mode: class set by JS (buildSpreads) so layout and styling never disagree */
body.single .nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  z-index: 5;
  width: 38px; height: 66px; font-size: 25px;
  background: rgba(20,20,24,.45);
}
body.single #nav-prev { left: 4px; }
body.single #nav-next { right: 4px; }

@media (max-width: 760px) {
  #bar { padding: 6px 10px; font-size: 14px; }
  #bar-logo { height: 16px; vertical-align: -3px; margin-right: 6px; }
  #strip img { height: 56px; }
  #overlay-bar { gap: 2px; padding: 5px 6px; bottom: 12px; }
  #overlay-bar button, #overlay-bar a { min-width: 34px; height: 36px; line-height: 36px; font-size: 17px; }
}
