.image-viewer {
  --viewer-accent: #f2c45c;
  position: fixed; inset: 0; width: 100%; max-width: none; height: 100dvh; max-height: none;
  margin: 0; padding: 0; border: 0; border-radius: 0; overflow: hidden;
  background: #101113ed; color: #f5f5f5; z-index: 1000;
  font: 14px/1.4 system-ui, sans-serif; color-scheme: dark;
}
.image-viewer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.image-viewer, .image-viewer * { box-sizing: border-box; }
.image-viewer::backdrop { background: #000c; backdrop-filter: blur(8px); }
.image-viewer [hidden] { display: none !important; }
.image-viewer button {
  appearance: none; display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto; min-width: 40px; min-height: 40px; margin: 0; padding: 8px 12px;
  border: 1px solid transparent; border-radius: 8px; background: transparent; color: inherit;
  font: inherit; font-weight: 500; line-height: 1; cursor: pointer; touch-action: manipulation;
}
.image-viewer button:hover { background: #ffffff14; border-color: #ffffff25; color: #fff; }
.image-viewer button:focus-visible, .image-viewer input:focus-visible { outline: 2px solid var(--viewer-accent); outline-offset: 3px; }
.image-viewer button:disabled { opacity: .25; cursor: default; }
.image-viewer button[aria-pressed="true"] { color: var(--viewer-accent); background: #f2c45c14; }
.viewer-bar { height: auto; min-height: 64px; min-width: 0; max-width: none; margin: 0; border: 0; display: flex; gap: 20px; align-items: center; justify-content: flex-start; padding: 12px 22px; z-index: 2; }
.viewer-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 500; color: #dadbdd; }
.viewer-position { font-size: 12px; color: #a8aaaf; font-variant-numeric: tabular-nums; white-space: nowrap; }
.image-viewer .viewer-close { font-size: 30px; font-weight: 300; }
.viewer-frame { position: relative; overflow: hidden; min-height: 0; min-width: 0; touch-action: none; user-select: none; }
.viewer-frame .viewer-image { display: block; position: absolute; left: 50%; top: 50%; max-width: none; max-height: none; object-fit: contain; user-select: none; -webkit-user-drag: none; transform-origin: center; }
.viewer-frame.zoomed { cursor: grab; }
.viewer-frame.zoomed:active { cursor: grabbing; }
.image-viewer > .viewer-previous, .image-viewer > .viewer-next {
  position: absolute; top: calc(50% - 32px); z-index: 3; width: 48px; height: 64px;
  padding: 0; border: 1px solid #ffffff16; border-radius: 12px;
  background: #1113158f; color: #e3e4e6; font-size: 45px; font-weight: 200;
  box-shadow: 0 4px 24px #0002; backdrop-filter: blur(10px);
}
.image-viewer > .viewer-previous { left: 20px; }
.image-viewer > .viewer-next { right: 20px; }
.viewer-footer { display: block; z-index: 2; width: 100%; min-width: 0; max-width: none; margin: 0; border: 0; padding: 10px 24px 12px; background: linear-gradient(transparent, #111214ba); color: inherit; }
.viewer-filmstrip { display: flex; gap: 8px; width: max-content; max-width: 100%; margin: 0 auto 12px; padding: 4px; overflow-x: auto; scrollbar-width: thin; scrollbar-color: #55585e transparent; overscroll-behavior: contain; }
.image-viewer .viewer-thumb { position: relative; width: 60px; height: 60px; min-width: 60px; padding: 3px; border: 2px solid transparent; border-radius: 7px; background: #ffffff09; overflow: hidden; opacity: .58; }
.image-viewer .viewer-thumb:hover { opacity: 1; }
.image-viewer .viewer-thumb[aria-current="true"] { border-color: var(--viewer-accent); opacity: 1; box-shadow: 0 0 0 1px #0005; }
.viewer-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.viewer-thumb img:not([src]) { visibility: hidden; }
.viewer-thumb span { position: absolute; right: 3px; bottom: 2px; padding: 1px 4px; background: #000a; border-radius: 3px; font-size: 9px; color: #f5f5f5; }
.viewer-tools { display: flex; align-items: center; justify-content: center; gap: 4px; width: max-content; max-width: 100%; margin: auto; padding: 5px 10px; border: 1px solid #ffffff1c; border-radius: 14px; background: #292b2ee8; box-shadow: 0 8px 32px #0005; }
.viewer-tools .viewer-play { margin-right: 10px; border-right: 1px solid #ffffff1c; border-radius: 6px 0 0 6px; color: var(--viewer-accent); }
.viewer-zoom { appearance: none; flex: 0 1 auto; width: clamp(65px, 12vw, 160px); min-width: 0; height: 3px; margin: 0 8px; padding: 0; border: 0; border-radius: 2px; background: #606269; accent-color: var(--viewer-accent); cursor: pointer; }
.viewer-zoom::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; border-radius: 50%; background: #e3e4e6; }
.viewer-zoom::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: #e3e4e6; }
.viewer-percent { width: 48px; text-align: center; color: #bfc2c8; font-size: 11px; font-variant-numeric: tabular-nums; }
.viewer-status, .viewer-hint { margin: 0; padding: 0; text-align: center; color: #8e929a; font-size: 11px; line-height: 1.5; }
.viewer-status:empty { display: none; }
.viewer-status:not(:empty) { margin-top: 10px; color: #e3c686; }
.image-viewer .viewer-retry { display: flex; margin: 8px auto 0; border-color: #ffffff30; color: var(--viewer-accent); }
.viewer-hint { margin-top: 10px; }
@media (max-width: 600px) {
  .viewer-bar { padding: 8px 10px; gap: 8px; }
  .viewer-title { font-size: 12px; }
  .viewer-footer { padding: 8px 6px max(10px, env(safe-area-inset-bottom)); }
  .image-viewer .viewer-thumb { width: 48px; min-width: 48px; height: 48px; }
  .viewer-filmstrip { gap: 5px; margin-bottom: 8px; }
  .viewer-tools { gap: 0; padding: 4px; border-radius: 12px; }
  .viewer-tools button { min-width: 36px; padding: 7px; font-size: 12px; }
  .viewer-tools .viewer-play { margin-right: 4px; }
  .viewer-percent { width: 35px; font-size: 10px; }
  .viewer-zoom { width: 54px; margin: 0 4px; }
  .viewer-hint { display: none; }
  .image-viewer > .viewer-previous, .image-viewer > .viewer-next { width: 32px; height: 48px; font-size: 32px; border-radius: 8px; }
  .image-viewer > .viewer-previous { left: 6px; }
  .image-viewer > .viewer-next { right: 6px; }
}
@media (max-height: 480px) {
  .viewer-bar { padding-block: 3px; }
  .viewer-filmstrip { display: none; }
  .viewer-hint { display: none; }
  .viewer-footer { padding-top: 4px; padding-bottom: 6px; }
}
@media (max-width: 380px) {
  .viewer-tools { flex-wrap: wrap; width: 100%; row-gap: 4px; }
  .viewer-zoom { order: 1; flex: 1 1 65%; min-width: 80px; }
  .viewer-percent { order: 2; }
}
@media (prefers-reduced-motion: reduce) { .image-viewer * { scroll-behavior: auto; } }
