:root{color-scheme:light dark;--bg:var(--tg-theme-bg-color,#faf8f5);--fg:var(--tg-theme-text-color,#211d19);--muted:var(--tg-theme-hint-color,#776e64);--panel:var(--tg-theme-secondary-bg-color,#eee9e2);--accent:#d95812;--line:#b6aa9c}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--fg);font:16px/1.4 system-ui,-apple-system,sans-serif}main{max-width:900px;margin:auto;padding:16px 16px calc(16px + env(safe-area-inset-bottom));padding-top:max(16px,env(safe-area-inset-top))}header{display:flex;gap:12px;align-items:center;justify-content:space-between;margin-bottom:20px}.brand{font-size:10px;letter-spacing:.14em;color:var(--muted);margin:0 0 3px}h1{font-size:24px;line-height:1.15;margin:0}button{font:inherit;border:1px solid var(--line);background:var(--bg);color:var(--fg);border-radius:12px;min-height:46px;padding:10px 16px;cursor:pointer;touch-action:manipulation}button:focus-visible{outline:3px solid var(--accent);outline-offset:2px}button:disabled{opacity:.38;cursor:default}#close{white-space:nowrap;flex-shrink:0}.caption{display:flex;justify-content:space-between;gap:12px;align-items:start;margin-bottom:12px}h2{font-size:16px;line-height:1.45;margin:0;overflow-wrap:anywhere}#counter{white-space:nowrap;color:var(--muted);font-size:14px;padding-top:2px}.stage{position:relative;display:flex;align-items:center;justify-content:center;width:100%;height:clamp(220px,55dvh,540px);background:var(--panel);border-radius:16px;overflow:hidden;touch-action:pan-y pinch-zoom}#photo{width:100%;height:100%;object-fit:contain}#loading{position:absolute;inset:auto 18px;text-align:center;color:var(--muted)}#document{text-align:center;padding:25px;overflow-wrap:anywhere}#document p{font-size:14px;color:var(--muted)}#download{background:var(--accent);color:white;border-color:var(--accent)}#note{font-size:14px;white-space:pre-wrap;overflow-wrap:anywhere;margin:12px 0;color:var(--muted)}#note:empty{display:none}nav{display:flex;gap:12px;margin-top:16px}nav button{flex:1}#thumbs{display:flex;gap:8px;overflow-x:auto;padding:4px 3px 8px;margin-top:14px}#thumbs button{flex-shrink:0;min-width:46px;padding:8px 12px}#thumbs button[aria-current=true]{background:var(--accent);border-color:var(--accent);color:white}.foot{font-size:12px;color:var(--muted);margin-top:18px}#status{padding:36px 8px;text-align:center;color:var(--muted)}[hidden]{display:none!important}@media(max-width:360px){main{padding-left:12px;padding-right:12px}h1{font-size:22px}#close{padding:10px 12px}}@media(max-height:440px){.stage{height:55dvh;min-height:130px}header{margin-bottom:12px}}
#retry{display:block;margin:12px auto 0}
