.photo-dialog,
.app-shell dialog.photo-dialog {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: var(--app-height, 100dvh);
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background: var(--paper, #fff);
  color: var(--ink, #23362f);
  font: 14px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
  overscroll-behavior: contain;
}

.photo-dialog[open] { display: flex; flex-direction: column; }
.photo-dialog::backdrop { background: #23362f55; }
.photo-dialog *, .photo-library-entry { box-sizing: border-box; }
.photo-dialog [hidden] { display: none !important; }
.photo-dialog h2, .photo-dialog h3, .photo-dialog h4, .photo-dialog p { margin: 0; }
.photo-dialog h2 { font-size: 20px; font-weight: 600; letter-spacing: -.4px; }
.photo-dialog h3 { font-size: 18px; font-weight: 550; }
.photo-dialog h4 { font-size: 13px; font-weight: 600; }
.photo-dialog button, .photo-dialog input, .photo-dialog select { font: inherit; }
.photo-dialog button { cursor: pointer; }
.photo-dialog button:disabled { cursor: default; opacity: .45; }
.photo-dialog :focus-visible, .photo-library-entry:focus-visible { outline: 2px solid var(--green, #176d53); outline-offset: 3px; }
.photo-dialog input[aria-invalid=true] { border-color: var(--danger, #b7583d); }
.photo-dialog svg, .photo-library-entry svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.photo-header { display: flex; align-items: center; justify-content: space-between; flex: none; gap: 12px; padding: max(12px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 12px max(18px, env(safe-area-inset-left)); border-bottom: 1px solid var(--line, #e4e9e2); }
.photo-header .photo-eyebrow { margin-bottom: 2px; color: var(--green, #176d53); font-size: 9px; font-weight: 600; letter-spacing: 2px; }
.photo-icon-button { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--green-light, #eef6ef); color: var(--green, #176d53); }
.photo-scroll { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 18px max(16px, env(safe-area-inset-right)) 28px max(16px, env(safe-area-inset-left)); -webkit-overflow-scrolling: touch; }
.photo-scroll > * { width: 100%; max-width: 800px; margin-left: auto; margin-right: auto; }
.photo-scroll > * + * { margin-top: 20px; }
.photo-steps { display: flex; align-items: center; gap: 12px; padding: 0; list-style: none; counter-reset: photo-step; color: var(--muted, #77837c); font-size: 12px; }
.photo-steps li { counter-increment: photo-step; display: flex; align-items: center; gap: 7px; flex: 1; }
.photo-steps li::before { content: counter(photo-step, decimal-leading-zero); font-size: 10px; font-variant-numeric: tabular-nums; }
.photo-steps li[aria-current=step] { color: var(--green, #176d53); font-weight: 600; }
.photo-picker > * + *, .photo-local-preview > * + *, .photo-job > * + *, .photo-review > * + * { margin-top: 12px; }
.photo-hint { color: var(--muted, #77837c); font-size: 12px; line-height: 1.65; overflow-wrap: anywhere; }
.photo-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.photo-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px; border: 1px solid var(--line, #e4e9e2); border-radius: 10px; color: var(--ink, #23362f); background: var(--paper, #fff); font-weight: 500; }
.photo-button.photo-primary { border-color: var(--green, #176d53); background: var(--green, #176d53); color: #fff; }
.photo-danger { color: var(--danger, #b7583d); }
.photo-button.photo-danger { background: #fff9f5; }
.photo-picker > .photo-row .photo-button { flex: 1; }
.photo-notice, .photo-error { padding: 12px 14px; border-radius: 10px; font-size: 13px; line-height: 1.65; }
.photo-notice { background: var(--green-light, #eef6ef); color: var(--green, #176d53); }
.photo-error { border: 1px solid #ecd7c7; background: #fff9f5; color: var(--danger, #b7583d); overflow-wrap: anywhere; }
.photo-error .photo-button { margin-top: 10px; }
.photo-crop-stage { position: relative; width: fit-content; max-width: 100%; margin-inline: auto; overflow: hidden; border-radius: 8px; background: #f5f6f2; }
.photo-crop-stage canvas { display: block; width: auto; height: auto; max-width: 100%; max-height: 42dvh; }
.photo-crop-frame { position: absolute; border: 2px solid var(--green, #176d53); box-shadow: 0 0 0 200vmax #23362f55; pointer-events: none; }
.photo-crop-frame .photo-crop-handle { position:absolute;pointer-events:auto;touch-action:none;background:transparent;border:0;border-radius:0;padding:0;min-width:44px;min-height:44px;box-shadow:none; }
.photo-crop-handle:focus-visible { outline:3px solid #176d53;outline-offset:-3px; }
.photo-crop-frame .crop-move { inset:0;width:100%;height:100%;cursor:move;min-width:0;min-height:0; }
.photo-crop-frame .crop-top,.photo-crop-frame .crop-bottom { left:25%;width:50%;height:44px;cursor:ns-resize; }
.photo-crop-frame .crop-top { top:-22px; }.photo-crop-frame .crop-bottom { bottom:-22px; }
.photo-crop-frame .crop-left,.photo-crop-frame .crop-right { top:25%;height:50%;width:44px;cursor:ew-resize; }
.photo-crop-frame .crop-left { left:-22px; }.photo-crop-frame .crop-right { right:-22px; }
.photo-crop-frame .crop-top-left { top:-22px;left:-22px;cursor:nwse-resize; }
.photo-crop-frame .crop-top-right { top:-22px;right:-22px;cursor:nesw-resize; }
.photo-crop-frame .crop-bottom-left { bottom:-22px;left:-22px;cursor:nesw-resize; }
.photo-crop-frame .crop-bottom-right { bottom:-22px;right:-22px;cursor:nwse-resize; }
.photo-crop-handle:not(.crop-move)::after { content:'';position:absolute;left:50%;top:50%;width:12px;height:12px;transform:translate(-50%,-50%);background:#fff;border:2px solid #176d53;border-radius:3px; }
.photo-local-preview details { font-size:13px; }.photo-local-preview summary { min-height:44px;display:flex;align-items:center;cursor:pointer; }
.photo-picker.has-photo > h3,.photo-picker.has-photo > p,.photo-picker.has-photo > .photo-row { display:none; }
.photo-picker.has-photo .photo-local-preview { margin-top:0; }
.photo-picker.has-photo .photo-row { gap:8px;flex-wrap:wrap; }
.photo-picker.has-photo .photo-row button { font-size:13px;min-height:44px;padding:8px 10px; }
.photo-crop-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 20px; }
.photo-crop-controls .photo-field { display: grid; grid-template-columns: 1fr auto; gap: 0; }
.photo-crop-controls input[type=range] { grid-row: 2; grid-column: 1 / -1; width: 100%; min-height: 44px; height: 44px; margin: 0; accent-color: var(--green, #176d53); }
.photo-crop-controls output { grid-column: 2; grid-row: 1; font-size: 11px; font-variant-numeric: tabular-nums; }
.photo-check { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding-block: 10px; line-height: 1.65; font-size: 13px; cursor: pointer; }
.photo-check input[type=checkbox] { flex: none; width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--green, #176d53); }
.photo-check span { overflow-wrap: anywhere; }
.photo-job { padding: 14px 16px; border: 1px solid var(--line, #e4e9e2); border-radius: 12px; background: #fafcf9; }
.photo-status { color: var(--green, #176d53); font-weight: 550; }
.photo-job progress { display: block; width: 100%; height: 5px; accent-color: var(--green, #176d53); }
.photo-tabs { display: flex; gap: 4px; padding: 4px; background: var(--green-light, #eef6ef); border-radius: 10px; }
.photo-tabs .photo-button { flex: 1; min-width: 0; padding: 8px; border: 0; background: transparent; color: var(--muted, #77837c); }
.photo-tabs .photo-button[aria-pressed=true] { color: var(--green, #176d53); background: #fff; box-shadow: 0 1px 4px #23362f0a; }
.photo-preview { max-height: 46dvh; overflow: auto; border: 1px solid var(--line, #e4e9e2); border-radius: 8px; background: #fff; overscroll-behavior: contain; touch-action: pan-x pan-y pinch-zoom; }
.photo-preview img { display: block; width: 100%; height: auto; margin: auto; }
.photo-editor { min-inline-size: 0; padding: 16px 0 0; margin: 16px 0 0; border: 0; border-top: 1px solid var(--line, #e4e9e2); }
.photo-editor legend { padding: 0 12px 0 0; font-size: 16px; font-weight: 600; }
.photo-editor:disabled { opacity: .68; }
.photo-metadata { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 16px 0 20px; }
.photo-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; color: var(--muted, #77837c); font-size: 12px; }
.photo-title-field { grid-column: 1 / -1; }
.photo-partial-banner { grid-column: 1 / -1; padding: 12px; border-radius: 8px; background: var(--green-light, #eef6ef); color: var(--green, #176d53); font-size: 13px; }
.photo-review-warning { margin-block: 8px; padding: 8px 10px; border-left: 2px solid var(--orange, #d99842); background: #fff9f5; color: var(--danger, #b7583d); font-size: 12px; }
.photo-review-warning summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; }
.photo-source-link { border: 0; background: transparent; padding: 8px 0; min-height: 44px; color: var(--green, #176d53); font-size: 12px !important; text-decoration: underline; text-underline-offset: 3px; }
.photo-uncertain-note { border-left: 2px solid var(--orange, #d99842); padding-left: 4px; }
.photo-candidate-warning { grid-column: 2 / -1; color: var(--danger, #b7583d); font-size: 11px; overflow-wrap: anywhere; }
.photo-field input:not([type=range]), .photo-field select, .photo-note-row > input, .photo-note-row > select { width: 100%; min-width: 0; min-height: 44px; padding: 8px 10px; color: var(--ink, #23362f); background: #fff; border: 1px solid var(--line, #e4e9e2); border-radius: 8px; font-size: 16px; }
.photo-measure { border-top: 1px solid var(--line, #e4e9e2); padding-block: 12px; }
.photo-measure > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; font-size: 12px; }
.photo-measure-listen { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 44px; padding: 6px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--green, #176d53); font-size: 12px !important; }
.photo-measure-listen svg { width: 16px; height: 16px; }
.photo-measure-listen[aria-pressed=true] { background: var(--green-light, #eef6ef); }
.photo-audition-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-block: 1px solid var(--line, #e4e9e2); padding-block: 6px; color: var(--green, #176d53); font-size: 12px; }
.photo-audition-stop { flex: none; padding: 6px 10px; }
.photo-note-row { display: grid; grid-template-columns: 20px minmax(66px, 1fr) minmax(64px, .8fr) 58px 44px; gap: 6px; align-items: center; margin-top: 6px; }
.photo-note-index { font-size: 10px; color: var(--muted, #77837c); font-variant-numeric: tabular-nums; text-align: center; }
.photo-note-row .photo-check { align-items: center; gap: 4px; font-size: 11px; white-space: nowrap; }
.photo-note-row .photo-check input { margin: 0; }
.photo-note-remove { width: 44px; height: 44px; border: 0; border-radius: 8px; background: #faf5f1; color: var(--danger, #b7583d); font-size: 20px !important; }
.photo-add-note { min-height: 44px; margin-top: 6px; padding: 8px 10px; border: 0; border-radius: 8px; background: var(--green-light, #eef6ef); color: var(--green, #176d53); font-size: 12px !important; }
.photo-validation { padding: 10px 12px; border-left: 2px solid var(--danger, #b7583d); color: var(--danger, #b7583d); background: #fff9f5; font-size: 13px; }
.photo-issues { border-top: 1px solid var(--line, #e4e9e2); padding-top: 16px; }
.photo-issues h3 { font-size: 16px; margin-bottom: 4px; }
.photo-footer { flex: none; padding: 10px max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); border-top: 1px solid var(--line, #e4e9e2); background: var(--paper, #fff); }
.photo-footer > * { max-width: 800px; margin-inline: auto; }
.photo-footer .photo-hint { margin-bottom: 8px; font-size: 11px; }
.photo-footer-info { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.photo-footer-info .photo-hint { margin: 0; flex: 1; }
.photo-notices { display: inline-flex; align-items: center; flex: none; min-height: 44px; color: var(--green, #176d53); font-size: 11px; text-decoration: underline; text-underline-offset: 3px; }
.photo-footer .photo-row { flex-wrap: nowrap; }
.photo-footer .photo-button { flex: 1; padding-inline: 10px; }
.photo-library-entry { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 72px; margin: 0 0 18px; padding: 14px; border: 1px solid var(--green-mid, #92b6a3); border-radius: 12px; background: var(--green-light, #eef6ef); color: var(--green, #176d53); font: inherit; text-align: left; cursor: pointer; }
.photo-library-entry strong, .photo-library-entry small { display: block; }
.photo-library-entry strong { font-size: 14px; font-weight: 600; }
.photo-library-entry small { margin-top: 3px; color: var(--muted, #77837c); font-size: 11px; }
.photo-entry-arrow { margin-left: auto; font-size: 24px; font-weight: 300; }
body.app-shell .app-actions:has(.photo-action) button { min-width: 0; }

@media (min-width: 760px) {
  .photo-header { padding-inline: max(24px, calc((100vw - 800px) / 2)); }
  .photo-metadata { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .photo-crop-controls { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .photo-note-row { grid-template-columns: 30px minmax(100px, 1fr) minmax(100px, 1fr) 80px 44px; gap: 10px; }
  .photo-note-row .photo-check { font-size: 13px; gap: 8px; }
  .photo-footer .photo-row { justify-content: flex-end; }
  .photo-footer .photo-button { flex: 0 1 240px; min-width: 180px; }
}

@media (max-width: 359px) {
  .photo-scroll { padding-inline: 10px; }
  .photo-note-row { grid-template-columns: 16px minmax(62px, 1fr) minmax(60px, .8fr) 52px 44px; gap: 4px; }
  .photo-note-row > input, .photo-note-row > select { padding-inline: 5px; }
  .photo-steps { gap: 5px; font-size: 11px; }
  .photo-button { padding-inline: 10px; }
}

@media (max-height: 500px) and (orientation: landscape) {
  .photo-header { padding-block: 4px; }
  .photo-header .photo-eyebrow { display: none; }
  .photo-header h2 { font-size: 16px; }
  .photo-scroll { padding-top: 10px; }
  .photo-footer { padding-top: 6px; }
  .photo-footer .photo-hint { display: none; }
  .photo-preview { max-height: 60dvh; }
}

@media (prefers-reduced-motion: reduce) {
  .photo-dialog *, .photo-library-entry { scroll-behavior: auto !important; transition: none !important; }
}
