.photo-dialog {
  width: min(880px, calc(100% - 36px));
  max-height: min(88vh, 900px);
  max-height: min(88dvh, 900px);
  padding: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid #e3dfeb;
  border-radius: 16px;
  box-shadow: 0 24px 90px #30234440;
}
.photo-dialog[open] { display: flex; flex-direction: column; }
.photo-dialog::backdrop { background: #241e335e; backdrop-filter: blur(3px); }
.photo-dialog button { min-height: 36px; transition-duration: 90ms; }
.photo-dialog button:disabled { cursor: default; opacity: .35; }
.photo-dialog :focus-visible { outline-offset: 2px; }
.photo-heading {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; flex: none; padding: 20px 24px 14px;
}
.photo-heading h2 { margin: 0; font-size: clamp(19px, 2vw, 23px); font-weight: 710; line-height: 1.4; }
.photo-heading p { margin: 4px 0 0; font-size: 13px; color: #6c6578; }
.photo-dialog .photo-icon {
  display: inline-grid; flex: none; place-items: center;
  width: 36px; height: 36px; padding: 0; border-radius: 9px;
}
.photo-icon:hover:not(:disabled), .photo-size:hover { background: var(--tint); color: var(--deep); }
.photo-icon svg.lucide, .photo-size svg.lucide, .photo-search svg.lucide { width: 20px; height: 20px; }
.photo-filters { padding: 0 24px 12px; flex: none; border-bottom: 1px solid var(--line); }
.photo-search {
  display: flex; align-items: center; gap: 9px; padding: 0 12px;
  min-height: 38px; background: #f8f7fa; color: #797285;
  border: 1px solid #e4e0ea; border-radius: 8px;
}
.photo-search:focus-within { border-color: var(--violet); outline: 2px solid var(--tint); }
.photo-search input { width: 100%; padding: 7px 0; color: var(--ink); background: transparent; border: 0; outline: 0; font-size: 15px; }
.photo-search input::placeholder { color: #777180; }
.photo-groups { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.photo-groups button { padding: 5px 12px; border-radius: 6px; font-size: 14px; color: #5d576b; }
.photo-groups button:hover { background: #f6f4f9; }
.photo-groups button[aria-pressed="true"] { font-weight: 650; color: var(--deep); background: var(--tint); }
.photo-results { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.photo-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; padding: 18px 24px 24px; }
.photo-card { min-width: 0; position: relative; }
.photo-card-main {
  position: relative; display: flex; flex-direction: column;
  width: 100%; height: 100%; text-align: left; padding: 0;
  border: 1px solid #ddd9e4; border-radius: 9px; overflow: hidden; background: #fff;
  transition: background .09s, border-color .09s, box-shadow .09s;
}
.photo-card-main:hover { border-color: #afa2c8; box-shadow: 0 3px 12px #3c2d5411; }
.photo-card-main img { display: block; width: 100%; aspect-ratio: 1.55; object-fit: cover; background: #eeecf2; }
.photo-card-title { display: block; padding: 9px 11px 11px; font-size: 14px; font-weight: 600; line-height: 1.55; }
.photo-card.is-selected .photo-card-main { border-color: var(--violet); background: #f6f2ff; box-shadow: 0 0 0 1px var(--violet); }
.photo-check {
  position: absolute; left: 8px; top: 8px; display: grid; place-items: center;
  width: 23px; height: 23px; border: 1px solid #fff; border-radius: 6px;
  background: #ffffffdf; box-shadow: 0 1px 5px #23183650;
}
.photo-check svg.lucide { opacity: 0; width: 16px; height: 16px; stroke-width: 2.5; }
.photo-card.is-selected .photo-check { background: var(--deep); color: white; }
.photo-card.is-selected .photo-check svg { opacity: 1; }
.photo-card .photo-inspect {
  position: absolute; right: 6px; top: 6px; width: 36px; height: 36px;
  background: #fffffff2; box-shadow: 0 1px 5px #21172d33;
}
.photo-empty { padding: 2px 24px 32px; font-size: 15px; color: var(--muted); }
.photo-footer, .photo-preview-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex: none; padding: 10px 24px; border-top: 1px solid var(--line); font-size: 14px;
}
.photo-footer output { color: #5c536e; }
.photo-done { padding: 8px 18px; border-radius: 8px; background: var(--deep); color: #fff; font-weight: 650; }
.photo-done:hover { background: #5234ac; }
#photoPreview { width: min(940px,calc(100% - 36px)); }
#photoPreview .photo-heading h2 { font-size: clamp(17px,2vw,20px); }
.photo-stage {
  display: grid; place-items: center; min-height: 60px; flex: 1 1 auto;
  height: min(52vh, 560px); overflow: auto; background: #272631; overscroll-behavior: contain;
}
.photo-stage img { display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.photo-stage.photo-natural { display: block; }
.photo-stage.photo-natural img { width: auto; height: auto; max-width: none; margin: auto; }
.photo-caption { flex: 0 1 auto; overflow: auto; padding: 12px 24px; font-size: 14px; line-height: 1.6; }
.photo-caption p { margin: 0 0 2px; }
.photo-caption a { display: inline-flex; align-items: center; gap: 4px; color: var(--deep); font-weight: 600; }
.photo-caption a:hover { text-decoration: underline; }
.photo-caption svg.lucide { width: 16px; height: 16px; }
.photo-size, .photo-paging { display: inline-flex; align-items: center; gap: 8px; }
.photo-size { padding: 5px 8px; border-radius: 6px; }
.photo-paging [data-page] { min-width: 45px; text-align: center; font-variant-numeric: tabular-nums; }
@media(max-width: 620px) {
  .photo-dialog, #photoPreview { width: calc(100% - 16px); max-height: calc(100dvh - 24px); border-radius: 12px; }
  .photo-heading { padding: 14px 14px 10px; }
  .photo-filters { padding: 0 14px 8px; }
  .photo-groups { gap: 2px; }
  .photo-groups button { min-height: 36px; padding: 4px 7px; }
  .photo-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; padding: 12px 12px 16px; }
  .photo-card-title { padding: 7px 8px; font-size: 14px; }
  .photo-card-main img { aspect-ratio: 1.35; }
  .photo-footer, .photo-preview-foot, .photo-caption { padding: 9px 14px; }
  .photo-stage { height: min(46dvh, 480px); }
}
@media(max-height: 500px) and (orientation:landscape) {
  .photo-dialog { max-height: calc(100dvh - 12px); }
  .photo-heading, .photo-caption, .photo-footer, .photo-preview-foot { padding-block: 5px; }
  .photo-filters { display: flex; align-items: center; gap: 8px; padding-bottom: 5px; }
  .photo-groups { margin: 0; }
  .photo-search { max-width: 190px; }
  .photo-results { max-height: 55dvh; }
}
@media(prefers-reduced-motion:reduce) {
  .photo-dialog[open], .photo-dialog * { animation: none; transition: none; }
}
