.image-gallery-dialog {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  width: 100dvw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  background: #08090b;
  background-color: #08090b !important;
  color: #fff !important;
  color-scheme: dark;
  font: 14px/1.4 system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.image-gallery-dialog::backdrop { background: #08090b !important; }
/* Album canvas and chrome remain independent of the app's dialog theme. */
:root[data-theme="dark"] dialog.image-gallery-dialog a.image-gallery-button[download] { color: #fff; }
.image-gallery-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: zoom-in;
}
.image-gallery-stage.is-zoomed { cursor: grab; }
.image-gallery-stage.is-zoomed:active { cursor: grabbing; }
.image-gallery-image {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  width: 0;
  height: 0;
  max-width: none;
  max-height: none;
  margin: 0;
  object-fit: contain;
  image-orientation: from-image;
  transform-origin: center;
  pointer-events: none;
  -webkit-user-drag: none;
}
.image-gallery-header,
.image-gallery-footer {
  position: absolute;
  z-index: 1;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  opacity: 1;
  visibility: visible;
  transition: opacity 150ms ease, visibility 150ms;
}
.image-gallery-header {
  inset: 0 0 auto;
  min-height: calc(68px + env(safe-area-inset-top, 0px));
  padding: calc(10px + env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 18px max(12px, env(safe-area-inset-left, 0px));
  background: linear-gradient(#08090be6, #08090b99 65%, transparent);
}
.image-gallery-name { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; padding-right: 8px; }
.image-gallery-footer {
  inset: auto 0 0;
  justify-content: center;
  min-height: calc(80px + env(safe-area-inset-bottom, 0px));
  padding: 22px max(12px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  background: linear-gradient(transparent, #08090b99 35%, #08090be6);
}
.image-gallery-dialog .image-gallery-button {
  display: inline-flex;
  flex: 0 0 44px;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #202226b3;
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.image-gallery-dialog .image-gallery-button:hover { background: #3b3d43e6; }
.image-gallery-dialog .image-gallery-button:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.image-gallery-dialog .image-gallery-button:disabled { opacity: .35; cursor: default; }
.image-gallery-dialog .image-gallery-button svg { width: 21px; height: 21px; }
.image-gallery-zoom { min-width: 43px; text-align: center; font: 12px/1.4 system-ui, sans-serif; font-variant-numeric: tabular-nums; color: #f1f1f4; }
.image-gallery-count{font:12px/1.4 system-ui,sans-serif;color:#c8ccc3;white-space:nowrap;padding-right:8px}
.image-gallery-album .image-gallery-footer{flex-wrap:wrap;gap:7px;padding-top:20px}
.image-gallery-album-row{display:flex;align-items:center;gap:6px;flex:0 0 100%;min-width:0;justify-content:center}
.image-gallery-thumbnails{display:flex;gap:8px;overflow-x:auto;max-width:390px;min-width:0;scrollbar-width:thin;padding:3px}
.image-gallery-dialog .image-gallery-thumbnail{display:block;flex:0 0 44px;width:44px;height:44px;padding:2px;border:1px solid transparent;border-radius:8px;background:transparent;opacity:.5;cursor:pointer}
.image-gallery-dialog .image-gallery-thumbnail[aria-pressed=true]{border-color:#eef2e8;opacity:1}
.image-gallery-thumbnail img{display:block;width:100%;height:100%;object-fit:cover;border-radius:5px}
.image-gallery-dialog .image-gallery-thumbnail:focus-visible{outline:2px solid #fff;outline-offset:1px}
.image-gallery-status { position: absolute; inset: 50% 24px auto; margin: 0; transform: translateY(-50%); text-align: center; color: #dedee3; pointer-events: none; }
.image-gallery-status[hidden], .image-gallery-image[hidden] { display: none; }
.image-gallery-dialog.is-chrome-hidden .image-gallery-header,
.image-gallery-dialog.is-chrome-hidden .image-gallery-footer { opacity: 0; visibility: hidden; pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  .image-gallery-header, .image-gallery-footer { transition: none; }
}
