/* Full-window image canvas; controls remain reachable while the photo scrolls. */
html[data-palette] dialog.attachment-image-viewer,html dialog.attachment-image-viewer{box-sizing:border-box;position:fixed;inset:0;margin:0;padding:0;width:100vw;max-width:100vw;height:100dvh;max-height:100dvh;border:0;border-radius:0;background:#111b22;color:#f5f7fa;overflow:hidden;display:flex;flex-direction:column;gap:0}
html dialog.attachment-image-viewer:not([open]){display:none}
.attachment-image-viewer::backdrop{background:#111b22}
.attachment-image-head{display:flex;align-items:center;gap:12px;padding:max(8px,env(safe-area-inset-top)) 12px 4px;flex:none}
.attachment-image-head strong{min-width:0;flex:1;font-size:16px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.attachment-image-viewer button{border:1px solid #546774;border-radius:10px;background:#233440;color:#fff;min-width:44px;min-height:44px;padding:8px 12px;font:600 17px/1.2 system-ui;cursor:pointer}
.attachment-image-head button{border:0;background:transparent;font-size:28px;padding:0}
.attachment-image-tools{display:flex;align-items:center;justify-content:center;gap:10px;padding:4px 12px 10px;flex:none}
.attachment-image-tools output{min-width:60px;text-align:center;font:14px/1.2 system-ui;font-variant-numeric:tabular-nums}
.attachment-image-tools button:nth-of-type(3){font-size:14px}
.attachment-image-viewer button:disabled{opacity:.45;cursor:default}
.attachment-image-viewer :focus-visible{outline:none;box-shadow:none}
.attachment-image-stage{position:relative;flex:1;min-height:0;min-width:0;overflow:auto;overscroll-behavior:contain;touch-action:pan-x pan-y;box-sizing:border-box;margin-bottom:env(safe-area-inset-bottom);background:#111b22}
.attachment-image-canvas{display:flex;align-items:center;justify-content:center;min-width:100%;min-height:100%}
.attachment-image-viewer .attachment-image-canvas img{display:block;max-width:none;max-height:none;object-fit:contain;flex:none;user-select:none;-webkit-user-select:none}
.attachment-image-canvas[hidden],.attachment-image-status[hidden]{display:none}
.attachment-image-status{position:absolute;inset:0;display:grid;place-items:center;padding:24px;margin:0;text-align:center;overflow-wrap:anywhere;font:16px/1.5 system-ui}
.attachment-image-stage.is-zoomed{cursor:grab}.attachment-image-stage.is-dragging{cursor:grabbing}
@media(max-width:360px){.attachment-image-tools{gap:6px;padding-left:8px;padding-right:8px}.attachment-image-tools output{min-width:52px}}

/* Every attachment keeps its own explicit download action outside the open button. */
.attachment-row{display:flex;align-items:center;gap:8px;max-width:100%;min-width:0}
.attachment-row>.audio-message,.attachment-row>.attachment{flex:1;min-width:0}
.attachment-download{flex:0 0 44px;width:44px;height:44px;padding:0;border:1px solid var(--line,#d6e0e5);border-radius:10px;background:var(--soft,#eff6fa);color:var(--teal,#006590);font:700 24px/1 system-ui;cursor:pointer}
.attachment-download:disabled{opacity:.45;cursor:wait}
.attachment-download:focus-visible{outline:2px solid var(--teal,#006590);outline-offset:2px}

/* Manual image sequence: no autoplay or background media preloading. */
.attachment-image-navigation{display:flex;flex:none;align-items:center;justify-content:center;gap:24px;padding:8px 16px max(8px,env(safe-area-inset-bottom));background:#111b22}
.attachment-image-navigation[hidden]{display:none}
.attachment-image-navigation button{font-size:28px;line-height:1;padding:2px 12px;min-width:48px;min-height:44px}
.attachment-image-counter{min-width:72px;text-align:center;font:15px/1.2 system-ui;font-variant-numeric:tabular-nums}
.attachment-image-viewer.has-image-navigation .attachment-image-stage{margin-bottom:0}
.attachment-image-stage:not(.is-zoomed){touch-action:pan-y}

/* An image preview is a dark media surface in every application theme. */
.attachment-image-download{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;min-width:44px;min-height:44px;padding:8px 12px;border:1px solid #546774;border-radius:10px;font:600 17px/1.2 system-ui;text-decoration:none;cursor:pointer}
.attachment-image-download[aria-disabled=true]{opacity:.45;cursor:default}
html dialog.attachment-image-viewer.attachment-image-viewer.attachment-image-viewer{background:#111b22!important;color:#f5f7fa!important;box-shadow:none!important}
html .attachment-image-viewer .attachment-image-head,
html .attachment-image-viewer .attachment-image-tools,
html .attachment-image-viewer .attachment-image-navigation{background:#111b22!important;color:#f5f7fa!important}
html .attachment-image-viewer .attachment-image-head strong,
html .attachment-image-viewer .attachment-image-tools output,
html .attachment-image-viewer .attachment-image-counter{color:#f5f7fa!important}
html .attachment-image-viewer :is(button,.attachment-image-download){color:#fff!important;background:#233440!important;border-color:#546774!important;flex-shrink:0}
html .attachment-image-viewer .attachment-image-head button{display:inline-flex;align-items:center;justify-content:center;flex:0 0 44px;width:44px;height:44px;border:1px solid #546774;background:#233440;font-size:28px}
html .attachment-image-viewer :is(:focus,:focus-visible,:focus-within){outline:none!important;box-shadow:none!important}
.attachment-image-stage{scrollbar-width:thin;scrollbar-color:#546774 transparent}
@supports selector(::-webkit-scrollbar){.attachment-image-stage{scrollbar-width:auto;scrollbar-color:auto}.attachment-image-stage::-webkit-scrollbar{width:4px;height:4px}.attachment-image-stage::-webkit-scrollbar-thumb{background:#546774;border-radius:4px}.attachment-image-stage::-webkit-scrollbar-track{background:transparent}}
