.reference-photo-open {
  display: block; position: relative; width: 100%; padding: 0; margin: .75rem 0 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm, 6px); overflow: hidden;
  background: var(--bg); color: var(--text); cursor: zoom-in;
}
.reference-photo-open img, .reference-photo-open #stash-photo-modal-image {
  display: block; width: 100%; height: auto; max-height: 60vh; object-fit: contain; margin: 0;
}
.reference-photo-open span {
  display: block; padding: .45rem .65rem; background: var(--surface-raised); font: inherit; font-weight: 600; font-size: .85rem; line-height: 1.3;
}
.reference-photo-open:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.reference-photo-viewer {
  width: calc(100vw - 32px); height: calc(100dvh - 32px); max-width: 1600px; max-height: none;
  padding: 0; margin: auto; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-raised, #181e25); color: var(--text, #eee); overflow: hidden;
  box-shadow: 0 16px 80px #0008;
}
.reference-photo-viewer[open] { display: flex; flex-direction: column; }
.reference-photo-viewer::backdrop { background: rgba(0, 0, 0, .88); }
.reference-photo-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .65rem;
  padding: .75rem; border-bottom: 1px solid var(--border);
}
.reference-photo-title { flex: 1 1 180px; min-width: 0; margin: 0; font-size: .95rem; overflow-wrap: anywhere; }
.reference-photo-controls { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; }
.reference-photo-controls .btn { min-width: 44px; min-height: 44px; }
.reference-photo-controls output { min-width: 3rem; text-align: center; font-variant-numeric: tabular-nums; }
.reference-photo-stage { flex: 1; min-height: 100px; position: relative; overflow: hidden; touch-action: none; background: #080c10; cursor: zoom-out; }
.reference-photo-stage:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.reference-photo-stage img { position: absolute; left: 50%; top: 50%; max-width: none; max-height: none; user-select: none; pointer-events: none; transform-origin: center; }
.reference-photo-stage img[hidden], .reference-photo-status[hidden] { display: none; }
.reference-photo-stage.can-pan { cursor: grab; }
.reference-photo-stage.is-panning { cursor: grabbing; }
.reference-photo-status { position: absolute; inset: 0; display: grid; place-items: center; padding: 1rem; margin: 0; color: #eee; text-align: center; }
.reference-photo-help { margin: 0; padding: .6rem .8rem; color: var(--text-muted); font-size: .8rem; line-height: 1.5; }
@media (max-width: 600px) {
  .reference-photo-viewer { width: calc(100vw - 12px); height: calc(100dvh - 12px); border-radius: 6px; }
  .reference-photo-toolbar { gap: .45rem; padding: .5rem; }
  .reference-photo-title { flex-basis: 100%; font-size: .85rem; }
  .reference-photo-controls { width: 100%; justify-content: center; }
  .reference-photo-help { font-size: .75rem; padding: .45rem .6rem; }
}
