/* The expanded gallery is independent of the correctly proportioned inline phones. */
.screen-dialog.gallery-dialog {
  --gallery-surface: #faf7f2;
  --gallery-well: #e7eadd;
  --gallery-text: #303d35;
  --gallery-muted: #53634f;
  --gallery-border: #aabda2;
  --gallery-button: #fffdfa;
  --gallery-hover: #e0e8d9;
  --gallery-focus: #8f4d34;
  box-sizing: border-box;
  width: min(720px, calc(100vw - 24px));
  height: min(940px, calc(100dvh - 24px));
  max-width: none;
  max-height: none;
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--gallery-border);
  border-radius: 24px;
  background: var(--gallery-surface);
  color: var(--gallery-text);
}
.screen-dialog.gallery-dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; gap: 12px; }
.gallery-dialog .screen-dialog-header { min-width: 0; padding: 0; gap: 12px; }
.gallery-dialog .screen-dialog-title { min-width: 0; margin: 0; font-size: 16px; font-weight: 600; }
.gallery-dialog .screen-dialog-header form { flex-shrink: 0; }
.gallery-dialog .screen-dialog-close,
.gallery-dialog .gallery-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 13px;
  border: 1px solid var(--gallery-border);
  border-radius: 24px;
  background: var(--gallery-button);
  color: var(--gallery-text);
  font: inherit;
  font-size: 13px;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.gallery-dialog .screen-dialog-close:hover,
.gallery-dialog .gallery-button:hover { background: var(--gallery-hover); }
.gallery-dialog .gallery-button:disabled { opacity: .45; cursor: default; }
.gallery-dialog .gallery-button[aria-pressed="true"] { background: var(--gallery-text); border-color: var(--gallery-text); color: var(--gallery-surface); }
.gallery-dialog :is(button, a, [tabindex]):focus-visible { outline: 3px solid var(--gallery-focus); outline-offset: 3px; }
.gallery-dialog .gallery-viewport {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y pinch-zoom;
  background: var(--gallery-well);
  border: 1px solid var(--gallery-border);
  border-radius: 14px;
  scrollbar-color: var(--gallery-muted) var(--gallery-well);
}
.gallery-dialog .gallery-canvas { display: flex; justify-content: center; align-items: center; width: 100%; height: 100%; padding: 24px; box-sizing: border-box; }
.gallery-dialog[data-zoom="fit"] .gallery-viewport { overflow: hidden; }
.gallery-dialog .gallery-device {
  --gallery-device-scale: .2;
  position: relative;
  flex: 0 0 auto;
  box-sizing: content-box;
  width: 216px;
  height: 468px;
  padding: calc(24px * var(--gallery-device-scale));
  border: calc(4px * var(--gallery-device-scale)) solid #6b7b6d;
  border-radius: calc(120px * var(--gallery-device-scale));
  background: linear-gradient(135deg, #405448, #18261e 55%, #3d5145);
  box-shadow: 0 14px 26px #152b2329, 0 0 0 1px #18261e;
}
.gallery-dialog .gallery-device-key {
  position: absolute;
  right: calc(-12px * var(--gallery-device-scale));
  width: calc(12px * var(--gallery-device-scale));
  border-radius: 0 calc(8px * var(--gallery-device-scale)) calc(8px * var(--gallery-device-scale)) 0;
  background: #405448;
  box-shadow: inset -1px 0 #718275;
  pointer-events: none;
}
.gallery-dialog .gallery-device-volume { top: 17%; height: 12%; }
.gallery-dialog .gallery-device-power { top: 34%; height: 7%; }
.gallery-dialog .screen-dialog-image {
  display: block;
  flex-shrink: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  border-radius: calc(92px * var(--gallery-device-scale));
  aspect-ratio: 1080 / 2340;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  cursor: zoom-in;
}
.gallery-dialog[data-zoom="actual"] .gallery-viewport { touch-action: pan-x pan-y pinch-zoom; cursor: grab; }
.gallery-dialog[data-zoom="actual"] .gallery-canvas { width: max-content; height: max-content; min-width: 100%; min-height: 100%; }
.gallery-dialog[data-zoom="actual"] .screen-dialog-image { width: auto; height: auto; max-width: none; max-height: none; cursor: grab; }
.gallery-dialog[data-zoom="actual"] .gallery-viewport.is-panning,
.gallery-dialog[data-zoom="actual"] .gallery-viewport.is-panning img { cursor: grabbing; }
.gallery-dialog .gallery-controls { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.gallery-dialog .gallery-controls[hidden] { display: none; }
.gallery-dialog .gallery-navigation,
.gallery-dialog .gallery-tools { display: flex; align-items: center; gap: 7px; }
.gallery-dialog .gallery-navigation svg { width: 18px; height: 18px; }
.gallery-dialog .gallery-counter { min-width: 43px; color: var(--gallery-muted); font-size: 13px; text-align: center; font-variant-numeric: tabular-nums; }
.gallery-dialog .gallery-hint { margin: 0; color: var(--gallery-muted); font-size: 12px; line-height: 1.5; }
.gallery-dialog .gallery-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
html[data-theme="night"] .screen-dialog.gallery-dialog {
  --gallery-surface: #20382c;
  --gallery-well: #13231b;
  --gallery-text: #f5f0e8;
  --gallery-muted: #c2cebe;
  --gallery-border: #718b67;
  --gallery-button: #294534;
  --gallery-hover: #365741;
  --gallery-focus: #edb89a;
}
html[data-theme="night"] .gallery-dialog .gallery-device { border-color: #829184; box-shadow: 0 14px 28px #0006, 0 0 0 1px #09120c; }
@media (max-width: 440px) {
  .screen-dialog.gallery-dialog { padding: 11px; border-radius: 18px; }
  .screen-dialog.gallery-dialog[open] { gap: 9px; }
  .gallery-dialog .gallery-controls { justify-content: center; }
  .gallery-dialog .gallery-navigation { justify-content: space-between; width: 100%; }
  .gallery-dialog .gallery-tools { justify-content: center; width: 100%; }
  .gallery-dialog .gallery-tools > * { flex: 1; }
  .gallery-dialog .gallery-hint { font-size: 11px; }
}
