.story-gallery-dialog { width: min(1260px, calc(100% - 32px)); height: min(880px, calc(100dvh - 32px)); max-width: none; max-height: none; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); color: var(--ink); box-shadow: 0 18px 64px #24181144; }
.story-gallery-dialog::backdrop { background: #2219119c; }
.story-gallery-frame { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; min-height: 0; }
.story-gallery-header { display: grid; grid-template-columns: minmax(0, 1fr) 44px; align-items: start; gap: 12px 18px; padding: 16px 20px 12px; border-bottom: 1px solid var(--line); }
.story-gallery-counter { color: var(--muted); font-size: 12px; line-height: 1.4; }
.story-gallery-heading { min-width: 0; }
.story-gallery-heading h2 { margin-top: 4px; font-size: 20px; line-height: 1.35; text-wrap: pretty; }
.story-gallery-close { width: 44px; height: 44px; padding: 0; border: 0; border-radius: 7px; background: var(--soft); color: var(--muted); font-size: 27px; line-height: 1; }
.story-gallery-close:hover { background: #eae2d9; }
.story-gallery-toolbar { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; }
.story-gallery-navigation, .story-gallery-zoom { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.story-gallery-toolbar button, .story-gallery-error button { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--orange-dark); font-size: 14px; font-weight: 550; white-space: nowrap; }
.story-gallery-toolbar button:hover, .story-gallery-error button:hover { background: var(--orange-soft); }
.story-gallery-toolbar [aria-pressed="true"] { border-color: #caa691; background: #f2e8df; }
.story-gallery-toolbar button:disabled { opacity: .4; cursor: default; }
.story-gallery-scale { min-width: 40px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; text-align: center; }
.story-gallery-stage { position: relative; min-width: 0; min-height: 0; overflow: auto; overscroll-behavior: contain; background: #eae7e2; }
.story-gallery-stage:focus-visible { outline-offset: -4px; }
.story-gallery-canvas { display: grid; place-items: center; width: max-content; min-width: 100%; height: max-content; min-height: 100%; }
.story-gallery-image { display: block; max-width: none; max-height: none; object-fit: contain; background: #fff; }
.story-gallery-image[hidden] { display: none; }
.story-gallery-loading, .story-gallery-error { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px; padding: 20px; color: var(--muted); font-size: 14px; text-align: center; }
.story-gallery-loading[hidden], .story-gallery-error[hidden] { display: none; }
.story-gallery-footer { padding: 12px 20px 14px; border-top: 1px solid var(--line); }
.story-gallery-footer > p:first-child { color: var(--ink); font-size: 14px; line-height: 1.6; }
.story-gallery-hint { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.5; }

@media (max-width: 760px) {
  .story-gallery-dialog { width: calc(100% - 20px); height: calc(100dvh - 20px); border-radius: 11px; }
  .story-gallery-header { padding: 12px; gap: 10px; }
  .story-gallery-heading h2 { font-size: 17px; }
  .story-gallery-toolbar { gap: 7px; }
  .story-gallery-navigation { justify-content: space-between; width: 100%; }
  .story-gallery-navigation button { flex: 1; }
  .story-gallery-zoom { flex-wrap: nowrap; width: 100%; gap: 5px; }
  .story-gallery-zoom button { flex: 1; padding-inline: 7px; font-size: 12px; }
  .story-gallery-scale { min-width: 31px; }
  .story-gallery-footer { padding: 10px 12px; }
}
@media (max-height: 480px) {
  .story-gallery-dialog { height: calc(100dvh - 12px); }
  .story-gallery-header { grid-template-columns: minmax(0, 1fr) 44px; gap: 5px 10px; padding-block: 5px; }
  .story-gallery-heading h2 { font-size: 16px; }
  .story-gallery-counter { font-size: 11px; }
  .story-gallery-toolbar { flex-wrap: nowrap; }
  .story-gallery-navigation, .story-gallery-zoom { width: auto; flex-wrap: nowrap; }
  .story-gallery-toolbar button { min-height: 44px; min-width: 44px; padding: 4px 7px; font-size: 12px; }
  .story-gallery-footer { padding-block: 6px; }
  .story-gallery-hint { display: none; }
}
