/* Copy-specific photo uploads and the read-only preview gallery. */
.card-photo-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-photo-heading label { margin: 0; }
.card-photo-heading span,.card-photo-sharing,.card-photo-status { color: var(--muted); font-size: 11px; }
.card-photo-list { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 8px; margin: 10px 0; }
.card-photo-list:empty { display: none; }
.card-photo-thumbnail { position: relative; aspect-ratio: .8; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.card-photo-thumbnail img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-photo-thumbnail button { position: absolute; right: 3px; bottom: 3px; width: 40px; height: 40px; padding: 0 !important; display: grid; place-items: center; background: var(--box); }
.card-photo-thumbnail .btn-ico { width: 18px; height: 18px; }
.card-photo-thumbnail button:hover { color: var(--danger); }
.card-photo-upload { min-height: 56px !important; cursor: pointer; display: grid; place-items: center; margin-top: 10px; }
.card-photo-upload.is-disabled { opacity: .45; cursor: default; }
.card-photo-sharing { display: block; margin-top: 8px; line-height: 1.5; }
.card-photo-status { margin: 8px 0 0; line-height: 1.5; overflow-wrap: anywhere; }
.card-photo-status:empty { display: none; }
.card-photo-editor[aria-busy="true"] .card-photo-status { color: var(--accent); }
#retryCardPhotos[hidden] { display: none !important; }
.card-photo-upload:focus-visible,.preview-gallery-item:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.preview-workspace { position: relative; min-height: 0; display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(0,1fr); }
.has-photo-gallery .preview-workspace { grid-template-columns: minmax(0,1fr) 132px; }
.preview-workspace .preview-stage { grid-column: 1; grid-row: 1; min-width: 0; }
.preview-workspace .preview-card { width: min(72vw,calc((100dvh - 175px) * .72),520px); }
.preview-real-photo { position: relative; z-index: 2; grid-column: 1; grid-row: 1; margin: 12px; min-width: 0; min-height: 0; display: grid; grid-template-rows: minmax(0,1fr) auto auto; gap: 12px; }
.preview-photo-viewport { min-width: 0; min-height: 0; overflow: hidden; border-radius: 8px; touch-action: none; user-select: none; }
.preview-photo-viewport:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.preview-photo-viewport.is-zoomed { cursor: grab; }
.preview-photo-viewport.is-zoomed:active { cursor: grabbing; }
.preview-real-photo img { display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain; border-radius: 8px; }
.preview-photo-tools { display: flex; align-items: center; justify-content: center; gap: 8px; }
.preview-photo-tools button { min-width: 44px; min-height: 44px; padding: 6px 12px !important; display: grid; place-items: center; }
.preview-photo-tools output { min-width: 48px; text-align: center; color: var(--text); font-size: 12px; }
.preview-real-photo figcaption { text-align: center; font-size: 11px; color: var(--muted); }
.preview-gallery { position: relative; z-index: 3; grid-column: 2; display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow-y: auto; margin: 12px; padding: 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--box); scrollbar-width: thin; scrollbar-color: var(--muted) transparent; }
.preview-gallery-item { flex: none; display: flex; flex-direction: column; align-items: center; gap: 7px; width: 100%; min-height: 44px; padding: 8px !important; border: 2px solid transparent; border-radius: 9px; background: transparent; color: var(--text); transition: border-color .15s ease,background .15s ease; }
.preview-gallery-item img { width: 100%; height: 85px; object-fit: contain; border-radius: 5px; pointer-events: none; }
.preview-gallery-item span { font-size: 11px; line-height: 1.5; }
.preview-gallery-item.selected { border-color: var(--accent); background: var(--panel); }
.preview-gallery-item:hover { border-color: var(--accent); }
#previewStage[hidden],#previewRealPhoto[hidden],#previewFlip[hidden],.preview-controls[hidden] { display: none !important; }

@media(max-width:700px) {
  .has-photo-gallery .preview-workspace { grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(0,1fr) 104px; }
  .preview-gallery { grid-column: 1; grid-row: 2; flex-direction: row; overflow-y: hidden; overflow-x: auto; margin: 6px 12px; padding: 5px; gap: 6px; }
  .preview-gallery-item { width: 74px; padding: 4px !important; gap: 3px; }
  .preview-gallery-item img { height: 54px; }
  .preview-gallery-item span { font-size: 10px; }
  .preview-workspace .preview-card { width: min(82vw,calc((100dvh - 170px) * .72)); }
  .has-photo-gallery .preview-workspace .preview-card { width: min(80vw,calc((100dvh - 280px) * .72)); }
  .card-photo-list { gap: 5px; }
  .card-photo-thumbnail button { right: 1px; bottom: 1px; }
}
@media(prefers-reduced-motion:reduce) { .preview-gallery-item { transition: none; } }
