/* Photo tool v2: shared visual contract with the other system; keep controls code-native. */
.photo-tool, .photo-editor-shell {
  --photo-ink: #0e2b40; --photo-muted: #617587; --photo-line: #d3dde5;
  --photo-accent: #0f837e; --photo-ground: #f4f6f8;
  color: var(--photo-ink); font-family: inherit; direction: rtl;
}
.photo-tool *, .photo-editor-shell * { box-sizing: border-box; }
.photo-tool [hidden], .photo-editor-shell [hidden] { display: none !important; }
.photo-tool .photo-tool-heading { margin: 0 0 16px; font-size: 18px; font-weight: 700; line-height: 1.6; color: var(--photo-ink); }
.photo-tool-heading b { color: var(--photo-accent); }
.photo-tool-inner { max-width: 270px; margin-inline: auto; text-align: center; }
.photo-tool-drop { position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 3 / 4; padding: 0; border: 1px dashed #629e9b; border-radius: 8px; background: var(--photo-ground); overflow: hidden; cursor: pointer; }
.photo-tool-drop.has-photo { border-style: solid; border-color: var(--photo-line); background: #fff; }
.photo-tool-drop.is-dragging { border: 2px dashed var(--photo-accent); background: #e9f5f3; box-shadow: 0 0 0 4px #0f837e14; }
.photo-tool-drop[aria-disabled=true] { cursor: wait; }
.photo-tool-drop img { display: block; width: 100%; height: 100%; object-fit: contain; }
.photo-tool-placeholder { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 18px; }
.photo-tool-placeholder > svg { width: 60px; height: 60px; margin-bottom: 10px; stroke-width: 1.5; color: #7f929f; }
.photo-tool-placeholder strong { font-size: 16px; font-weight: 500; }
.photo-tool-placeholder small { font-size: 13px; color: var(--photo-muted); }
.photo-tool .photo-tool-status { min-height: 24px; margin: 12px 0; display: flex; align-items: center; justify-content: center; gap: 7px; font-size: 13px; line-height: 1.7; color: var(--photo-muted); }
.photo-tool-status[data-state=saved] { color: var(--photo-accent); }
.photo-tool-status[data-state=pending], .photo-tool-status[data-state=error] { color: #8a571a; }
.photo-tool-status svg { width: 20px; height: 20px; flex: 0 0 auto; }
.photo-tool-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.photo-tool .photo-tool-button, .photo-editor-shell .photo-tool-button {
  min-width: 0; min-height: 48px; margin: 0; padding: 10px 18px; border: 1px solid var(--photo-line);
  border-radius: 8px; background: #fff; color: var(--photo-ink); display: inline-flex;
  align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-size: 14px; font-weight: 600; line-height: 1.6; cursor: pointer; box-shadow: none;
}
.photo-tool .photo-tool-button--primary, .photo-editor-shell .photo-tool-button--primary { background: var(--photo-accent); border-color: var(--photo-accent); color: #fff; }
.photo-tool-button > svg { width: 19px; height: 19px; flex-shrink: 0; }
.photo-tool .photo-tool-button:hover:not(:disabled), .photo-editor-shell button:hover:not(:disabled) { border-color: var(--photo-accent); }
.photo-tool .photo-tool-button--primary:hover:not(:disabled), .photo-editor-shell .photo-tool-button--primary:hover:not(:disabled) { background: #0a716c; color: #fff; }
.photo-tool button:disabled, .photo-editor-shell button:disabled { opacity: .48; cursor: not-allowed; }
.photo-tool :focus-visible, .photo-editor-shell :focus-visible { outline: 3px solid #0f837e; outline-offset: 3px; }
.photo-tool .photo-tool-formats { margin: 12px 0 0; color: var(--photo-muted); font-size: 12px; line-height: 1.8; }
.photo-tool-requirements { margin-top: 18px; padding-top: 8px; border-top: 1px solid var(--photo-line); text-align: right; }
.photo-tool-requirements summary, .photo-editor-advanced summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; cursor: pointer; font-size: 14px; font-weight: 600; }
.photo-tool-requirements summary::-webkit-details-marker, .photo-editor-advanced summary::-webkit-details-marker { display: none; }
.photo-tool-requirements summary svg, .photo-editor-advanced summary svg { width: 18px; height: 18px; flex-shrink: 0; transition: transform 160ms ease; }
.photo-tool-requirements[open] > summary svg, .photo-editor-advanced[open] > summary svg { transform: rotate(180deg); }
.photo-tool .photo-tool-requirements p { color: var(--photo-muted); font-size: 12px; line-height: 1.9; margin: 8px 0; }
.photo-tool-error { color: #a33333; font-size: 13px; line-height: 1.8; margin: 12px 0 0; }
.photo-tool-error:empty { display: none; }
.photo-tool .photo-tool-discard { border: 0; background: none; color: var(--photo-muted); font: inherit; font-size: 12px; min-height: 44px; cursor: pointer; }
.photo-editor-shell.photo-editor-shell { width: min(1020px, calc(100vw - 32px)); max-width: 1020px; max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--photo-line); border-radius: 12px; background: #fff; box-shadow: 0 20px 80px #071d2f50; overflow: hidden; text-align: right; }
dialog.photo-editor-shell { margin: auto; }
dialog.photo-editor-shell[open] { display: flex; flex-direction: column; }
.photo-editor-shell::backdrop { background: #071d2f99; }
.photo-editor-shell > header, .photo-editor-shell > footer { display: flex; align-items: center; justify-content: space-between; flex: 0 0 auto; gap: 16px; padding: 20px 24px; background: #fff; box-shadow: none; }
.photo-editor-shell > header { border-bottom: 1px solid var(--photo-line); }
.photo-editor-shell > header h2 { font-size: 24px; line-height: 1.5; margin: 0; color: var(--photo-ink); }
.photo-editor-shell > header p { font-size: 14px; line-height: 1.7; margin: 5px 0 0; color: var(--photo-muted); }
.photo-editor-shell > header > button { width: 44px; min-width: 44px; height: 44px; min-height: 44px; flex: 0 0 auto; padding: 0; display: grid; place-items: center; border: 1px solid var(--photo-line); border-radius: 8px; background: #fff; color: var(--photo-ink); }
.photo-editor-shell > header > button svg { width: 23px; height: 23px; }
.photo-editor-shell > footer { border-top: 1px solid var(--photo-line); min-height: 84px; }
.photo-editor-shell > footer .photo-tool-button { min-width: 100px; font-size: 16px; }
.photo-editor-shell > footer .photo-tool-button--primary { margin-inline-start: auto; min-width: 220px; }
.photo-editor-shell .photo-editor-content, .photo-editor-shell > .modal-body { flex: 1 1 auto; min-height: 0; padding: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: auto; }
.photo-editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; align-items: start; gap: 32px; padding: 24px; }
.photo-editor-workspace { min-width: 0; padding: 18px; background: var(--photo-ground); border-radius: 8px; text-align: center; }
.photo-editor-stage { position: relative; width: min(100%, 350px); aspect-ratio: 3 / 4; margin: auto; background: #fff; }
.photo-editor-stage > canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.photo-editor-stage > canvas:active { cursor: grabbing; }
.photo-editor-stage[data-mode=source] > canvas { cursor: default; }
.photo-editor-guides { position: absolute; inset: 0; pointer-events: none; }
.photo-editor-guides i { position: absolute; inset: 8% 19% 27%; border: 1.5px dashed #ffffffdc; border-radius: 50%; filter: drop-shadow(0 1px 1px #0e2b4040); }
.photo-editor-guides span { position: absolute; top: 35%; left: 2%; right: 2%; border-top: 1px dashed #ffffffdd; }
.photo-editor-shell .photo-editor-help { margin: 12px 0 0; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px; line-height: 1.7; color: var(--photo-ink); }
.photo-editor-help svg { width: 22px; height: 22px; }
.photo-editor-shell .photo-editor-quality { margin: 8px 0 0; font-size: 12px; line-height: 1.7; color: var(--photo-muted); }
.photo-editor-quality[data-warning=true] { color: #8a571a; background: #fff6e8; border: 1px solid #ecd6ad; padding: 8px; border-radius: 6px; }
.photo-editor-settings { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.photo-editor-shell .photo-editor-label { display: flex; justify-content: space-between; align-items: center; margin: 0 0 10px; font-size: 14px; font-weight: 600; }
.photo-editor-label output { direction: ltr; font-size: 14px; font-variant-numeric: tabular-nums; font-weight: 400; }
.photo-editor-zoom-row { display: grid; grid-template-columns: 44px minmax(0,1fr) 44px; align-items: center; gap: 12px; direction: ltr; }
.photo-editor-shell input[type=range] { width: 100%; min-width: 0; height: 44px; min-height: 44px; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; accent-color: var(--photo-accent); direction: ltr; cursor: pointer; }
.photo-editor-shell .photo-editor-settings button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px; border: 1px solid #b9c8d3; border-radius: 7px; background: #fff; color: var(--photo-ink); font-family: inherit; font-size: 14px; line-height: 1.5; cursor: pointer; }
.photo-editor-settings button svg { width: 20px; height: 20px; flex-shrink: 0; }
.photo-editor-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo-editor-history { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.photo-editor-shell .photo-editor-history button { flex-direction: column; gap: 6px; min-height: 68px; font-size: 13px; }
.photo-editor-advanced { padding-block: 4px; border-block: 1px solid var(--photo-line); }
.photo-editor-advanced > summary { font-size: 16px; }
.photo-editor-shell .photo-editor-advanced-hint { display: block; margin: 4px 0 8px; font-size: 12px; font-weight: 400; color: var(--photo-muted); }
.photo-editor-advanced-body { display: flex; flex-direction: column; gap: 14px; padding-block: 12px; }
.photo-editor-shell .photo-editor-toggle { display: flex; align-items: center; gap: 9px; min-height: 44px; font-size: 13px; line-height: 1.7; cursor: pointer; margin: 0; }
.photo-editor-shell .photo-editor-toggle input { width: 18px; height: 18px; min-height: 18px; padding: 0; margin: 0; accent-color: var(--photo-accent); flex: 0 0 auto; }
.photo-editor-output { display: flex; align-items: center; gap: 18px; padding-top: 2px; }
.photo-editor-output canvas { display: block; width: 72px; height: 96px; background: #fff; object-fit: contain; }
.photo-editor-output strong { display: block; font-size: 14px; margin-bottom: 8px; }
.photo-editor-output small { display: block; color: var(--photo-muted); font-size: 12px; line-height: 1.9; }
.photo-editor-shell .photo-editor-note { margin: 0; font-size: 12px; line-height: 1.8; color: var(--photo-muted); }
.photo-editor-shell .photo-editor-consent { margin-top: 12px; padding: 10px; background: #fff6e8; color: #8a571a; border-radius: 6px; text-align: right; }
.photo-editor-shell .photo-tool-error { margin: 0 24px 16px; }
.photo-editor-loading { min-height: 280px; display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--photo-muted); }
.photo-editor-loading svg { width: 24px; height: 24px; }
.photo-editor-shell .modal-title-mark, .photo-editor-shell .modal-title-icon, .photo-editor-shell .modal-close-button > span { display: none; }
.photo-editor-shell.modal::before { display: none; }
.photo-editor-save-note { font-size: 12px; color: var(--photo-muted); margin: 0; text-align: center; }
@media (max-width: 640px) {
  .photo-editor-shell.photo-editor-shell { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); border-radius: 10px; }
  .modal-backdrop:has(> .photo-editor-shell) { padding: 8px; }
  .photo-editor-shell > header { padding: 12px; gap: 10px; min-height: 80px; }
  .photo-editor-shell > header h2 { font-size: 18px; }
  .photo-editor-shell > header p { font-size: 12px; margin-top: 4px; }
  .photo-editor-layout { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
  .photo-editor-workspace { padding: 12px; }
  .photo-editor-stage { width: min(210px, max(130px, calc((100dvh - 490px) * .75))); }
  .photo-editor-shell .photo-editor-help { font-size: 13px; margin-top: 8px; }
  .photo-editor-shell .photo-editor-quality { font-size: 11px; margin-top: 4px; }
  .photo-editor-settings { gap: 10px; }
  .photo-editor-shell .photo-editor-label { font-size: 13px; margin-bottom: 4px; }
  .photo-editor-shell .photo-editor-history button { min-height: 44px; flex-direction: row; font-size: 12px; gap: 6px; }
  .photo-editor-output, .photo-editor-shell .photo-editor-advanced-hint { display: none; }
  .photo-editor-advanced > summary { font-size: 14px; }
  .photo-editor-shell > footer { padding: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); min-height: 74px; gap: 10px; flex-wrap: wrap; }
  .photo-editor-shell > footer .photo-tool-button { flex: 1; min-width: 0; font-size: 13px; padding-inline: 10px; min-height: 48px; }
  .photo-editor-shell > footer .photo-tool-button--primary { flex: 2.1; }
  .photo-editor-save-note { flex-basis: 100%; order: -1; font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  .photo-tool *, .photo-editor-shell * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
