:root {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  color-scheme: dark;
  --bg: #111716;
  --ink: #f1f2ed;
  --muted: #a9b7b2;
  --line: rgba(237, 243, 236, .2);
  --panel: rgba(18, 26, 25, .92);
  --accent: #dce9d9;
  --button-ink: #16201b;
  --logo-filter: invert(1);
}
* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; overscroll-behavior: none; }
body { min-height: 100dvh; overflow: hidden; background: var(--bg); color: var(--ink); }
button, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .25; cursor: default; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid #b8d8c2; outline-offset: 3px; }
[hidden] { display: none !important; }
body[data-theme=blueprint] { --bg: #1a292d; --ink: #f0f2ec; --muted: #b4c4c2; --panel: rgba(22, 37, 41, .94); --accent: #d8e9e3; }
body[data-theme=black] { --bg: #0b0d0d; --ink: #f2f2ee; --muted: #a8aaa8; --panel: rgba(15, 16, 16, .94); --accent: #e8e8e4; }
body[data-theme=paper] { color-scheme: light; --bg: #e9ebe7; --ink: #1e2722; --muted: #536259; --line: rgba(30, 45, 35, .22); --panel: rgba(244, 246, 241, .96); --accent: #233a2a; --button-ink: #fff; --logo-filter: none; }
body.cover-mode { --bg: #0b1114; --logo-filter: invert(1); }
.tunnel-canvas { position: fixed; inset: 0; z-index: 0; width: 100%; height: 100%; pointer-events: none; opacity: .68; transition: opacity .6s ease; }
body.is-transitioning .tunnel-canvas { opacity: 1; }
.app { position: relative; z-index: 1; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar { position: absolute; z-index: 5; top: 0; left: 0; right: 0; min-height: 70px; padding: max(14px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)); display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: flex; align-items: center; gap: 18px; flex: none; }
.brand img { width: 132px; height: auto; filter: var(--logo-filter); opacity: .88; }
.offline-status { display: none; font-size: 11px; color: var(--muted); }
.top-actions, .viewer-tools, .cover-buttons { display: flex; align-items: center; gap: 8px; }
.quiet-button, .theme-picker, .back-button { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; border: 1px solid var(--line); border-radius: 4px; background: rgba(25, 35, 32, .38); color: var(--ink); padding: 0 13px; font-size: 12px; white-space: nowrap; backdrop-filter: blur(12px); }
.quiet-button:hover, .back-button:hover { background: rgba(193, 218, 198, .14); }
.theme-picker { gap: 7px; color: var(--muted); }
.theme-picker select, .camera-options select { min-height: 35px; border: 0; outline: 0; color: var(--ink); background: transparent; cursor: pointer; }
.theme-picker option, .camera-options option { background: var(--bg); color: var(--ink); }
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 24px; min-height: 46px; padding: 0 19px; border: 1px solid transparent; border-radius: 4px; background: var(--accent); color: var(--button-ink); font-size: 14px; font-weight: 600; }
.primary-button:hover { filter: brightness(1.07); }
.primary-button.small { min-height: 38px; font-size: 12px; }
main { min-height: 100dvh; display: flex; flex: 1; }
.cover-view { position: relative; isolation: isolate; display: flex; align-items: center; justify-content: center; width: 100%; min-height: 100dvh; overflow: hidden; padding: 95px 24px 88px; }
.cover-view::before { content: ""; position: absolute; z-index: -2; inset: 0; background: transparent; }
.cover-art { position: absolute; z-index: -1; inset: 0; pointer-events: none; }
.cover-art img { display: none; }
.cover-copy { width: min(760px, 100%); display: flex; flex-direction: column; align-items: center; text-align: center; transition: opacity .36s ease, transform .7s ease; }
.cover-logo-button { display: block; padding: 0; border: 0; background: transparent; line-height: 0; cursor: pointer; }
.cover-logo { display: block; width: min(620px, 78vw); max-height: 22vh; object-fit: contain; filter: var(--logo-filter); }
.cover-logo.custom { filter: none; }
.cover-camera-button { position: absolute; z-index: 3; right: max(20px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom)); display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid rgba(225, 236, 230, .22); border-radius: 50%; background: rgba(10, 21, 23, .32); color: rgba(225, 236, 230, .7); opacity: .72; backdrop-filter: blur(8px); transition: opacity .2s ease, border-color .2s ease, background .2s ease; }
.cover-camera-button:hover, .cover-camera-button:focus-visible { opacity: 1; background: rgba(25, 43, 43, .74); }
.cover-camera-button[data-state=on] { opacity: .9; border-color: rgba(178, 222, 188, .75); color: #d8efda; }
.cover-camera-button[data-state=on]::after { content: ""; position: absolute; top: 7px; right: 7px; width: 5px; height: 5px; border-radius: 50%; background: #a9e0b5; }
.cover-camera-button[data-state=loading] { opacity: .42; }
.cover-meta, .cover-copy h1, .cover-copy p, .cover-buttons, .cover-index { display: none; }
body.cover-mode .topbar { display: none; }
.cover-meta { display: flex; justify-content: center; align-items: center; gap: 16px; max-width: 100%; color: var(--muted); font-size: 12px; }
.cover-meta span + span { border-left: 1px solid var(--line); padding-left: 16px; }
.cover-copy h1 { margin: 17px 0 5px; font-size: 18px; font-weight: 500; }
.cover-copy p { margin: 0 0 34px; color: var(--muted); font-size: 13px; }
.cover-buttons { justify-content: center; }
.cover-index { position: absolute; bottom: max(24px, env(safe-area-inset-bottom)); left: max(27px, env(safe-area-inset-left)); color: var(--muted); font-size: 10px; }
.cover-index span { margin-left: 17px; opacity: .65; }
.cover-view .cover-meta, .cover-view .cover-copy h1, .cover-view .cover-copy p, .cover-view .cover-buttons, .cover-view .cover-index { display: none; }
body.is-transitioning .cover-copy { opacity: 0; transform: scale(1.7); pointer-events: none; }
body.is-transitioning .cover-camera-button { opacity: 0; pointer-events: none; }
.viewer-view { position: relative; width: 100%; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.viewer-head { position: absolute; z-index: 4; top: max(73px, env(safe-area-inset-top) + 68px); left: max(22px, env(safe-area-inset-left)); right: max(22px, env(safe-area-inset-right)); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; pointer-events: none; }
.viewer-head > * { pointer-events: auto; }
.back-button { justify-self: start; gap: 6px; }
.viewer-title { color: var(--muted); font-size: 12px; text-align: center; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-count { justify-self: end; font-size: 12px; color: var(--ink); font-variant-numeric: tabular-nums; }
.image-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 118px 20px 96px; }
.image-viewport { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; user-select: none; }
.image-viewport img { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: center center; will-change: transform; transition: opacity .24s ease; pointer-events: none; }
.image-viewport img.is-changing { opacity: .1; }
.nav-button { position: absolute; z-index: 2; top: 50%; transform: translateY(-50%); width: 36px; height: 58px; border: 0; background: rgba(10, 17, 14, .3); color: var(--ink); font-size: 32px; font-weight: 200; line-height: 1; opacity: .65; }
.nav-button:hover { opacity: 1; background: rgba(10, 17, 14, .6); }
.nav-button.prev { left: 0; }
.nav-button.next { right: 0; }
.zoom-badge { position: absolute; top: 120px; right: max(22px, env(safe-area-inset-right)); color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.viewer-foot { position: absolute; z-index: 3; bottom: max(12px, env(safe-area-inset-bottom)); left: max(22px, env(safe-area-inset-left)); right: max(22px, env(safe-area-inset-right)); min-height: 66px; display: grid; grid-template-columns: minmax(100px, 1fr) auto minmax(150px, 1fr); align-items: center; gap: 18px; }
.slide-caption { color: var(--ink); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumbnails { display: flex; align-items: center; gap: 6px; max-width: 52vw; overflow-x: auto; scrollbar-width: none; }
.thumbnails::-webkit-scrollbar { display: none; }
.thumb { flex: none; width: 44px; height: 38px; padding: 0; border: 1px solid transparent; border-radius: 2px; background: transparent; overflow: hidden; opacity: .48; }
.thumb.active { border-color: var(--ink); opacity: 1; }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.viewer-tools { justify-self: end; }
.camera-panel { position: fixed; z-index: 10; right: max(22px, env(safe-area-inset-right)); bottom: max(85px, env(safe-area-inset-bottom) + 72px); width: min(325px, calc(100vw - 28px)); padding: 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); backdrop-filter: blur(24px); box-shadow: 0 20px 65px rgba(0, 0, 0, .35); }
.camera-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.camera-head div { display: flex; flex-direction: column; gap: 4px; }
.camera-head strong { font-size: 15px; }
.camera-head span { font-size: 12px; color: var(--muted); }
.icon-button { width: 28px; height: 28px; border: 0; background: transparent; color: var(--muted); font-size: 24px; }
.camera-frame { position: relative; height: 130px; overflow: hidden; background: #0b1010; }
.camera-frame video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.camera-frame.rear video { transform: none; }
.hand-indicator { position: absolute; bottom: 7px; left: 8px; padding: 4px 7px; background: rgba(0, 0, 0, .72); color: #fff; font-size: 11px; }
.camera-options { display: grid; gap: 7px; margin: 12px 0; font-size: 12px; }
.camera-options label { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.camera-options input { width: 17px; height: 17px; accent-color: #a6c8aa; }
.camera-hint { color: var(--muted); font-size: 12px; line-height: 1.7; margin: 8px 0 14px; }
.camera-actions { display: flex; gap: 8px; }
.camera-actions .primary-button { flex: 1; }
.gesture-toast { position: fixed; z-index: 20; left: 50%; bottom: max(98px, env(safe-area-inset-bottom) + 82px); transform: translate(-50%, 10px); opacity: 0; pointer-events: none; padding: 9px 14px; border-radius: 4px; background: rgba(226, 238, 224, .95); color: #112019; font-size: 12px; white-space: nowrap; transition: opacity .2s ease, transform .2s ease; }
.gesture-toast.visible { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 850px) {
  .topbar { align-items: flex-start; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; max-width: 65vw; }
  .brand img { width: 106px; }
  .image-stage { padding-top: 105px; padding-bottom: 88px; }
  .viewer-foot { grid-template-columns: 1fr auto; }
  .thumbnails { display: none; }
}
@media (max-width: 600px), (orientation: portrait) {
  .topbar { gap: 10px; padding: max(12px, env(safe-area-inset-top)) 14px; }
  .top-actions { max-width: 66vw; gap: 4px; }
  .top-actions .theme-picker:not(.case-picker), #importCoverButton, #importSlidesButton { display: none; }
  .quiet-button, .theme-picker, .back-button { min-height: 34px; padding: 0 8px; font-size: 11px; }
  .cover-logo { width: 82vw; }
  .cover-camera-button { right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); }
  .cover-meta { flex-wrap: wrap; font-size: 11px; }
  .cover-index { left: 14px; }
  .viewer-head { top: max(82px, env(safe-area-inset-top) + 70px); left: 14px; right: 14px; }
  .viewer-title { display: none; }
  .image-stage { padding: 135px 0 90px; }
  .image-viewport { width: 100%; }
  .nav-button { width: 29px; height: 48px; }
  .zoom-badge { top: 126px; right: 14px; }
  .viewer-foot { left: 14px; right: 14px; gap: 6px; }
  .viewer-tools { gap: 4px; }
  .camera-panel { right: 14px; bottom: 64px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
