:is(.photo-match, .photo-crop-dialog) {
  --photo-surface: var(--dash-bg-1, var(--paper));
  --photo-muted: var(--dash-muted, var(--muted));
  --photo-line: var(--dash-line, var(--line));
  --photo-accent: var(--dash-accent, var(--blue));
}
.photo-empty p, .photo-idle p { margin: 0; color: var(--photo-muted); }
.photo-grid { display: grid; grid-template-columns: minmax(240px, 0.8fr) minmax(0, 1.2fr); gap: var(--ps-ui-page-gap, 20px); align-items: start; }
.photo-capture-only .photo-grid { grid-template-columns: minmax(0, 1fr); max-width: 640px; margin-inline: auto; }
.photo-input, .photo-result { min-width: 0; padding: 16px; border: 1px solid var(--photo-line); border-radius: 12px; background: var(--photo-surface); }
.photo-stage { min-height: 200px; display: grid; place-items: center; overflow: hidden; border: 1px dashed var(--photo-line); border-radius: 8px; background: var(--chrome); }
.photo-stage.has-photo { min-height: 0; border: 0; background: var(--dash-bg-2, var(--chrome)); }
.photo-stage img { display: block; width: 100%; max-height: 440px; object-fit: contain; }
.photo-empty { padding: 18px; text-align: center; }
.photo-frame { position: relative; display: block; width: 64px; height: 44px; margin: 0 auto 16px; color: var(--photo-accent); }
.photo-frame i { position: absolute; width: 15px; height: 15px; border-color: currentColor; border-style: solid; border-width: 0; }
.photo-frame i:nth-child(1) { inset: 0 auto auto 0; border-width: 2px 0 0 2px; border-top-left-radius: 5px; }
.photo-frame i:nth-child(2) { inset: 0 0 auto auto; border-width: 2px 2px 0 0; border-top-right-radius: 5px; }
.photo-frame i:nth-child(3) { inset: auto auto 0 0; border-width: 0 0 2px 2px; border-bottom-left-radius: 5px; }
.photo-frame i:nth-child(4) { inset: auto 0 0 auto; border-width: 0 2px 2px 0; border-bottom-right-radius: 5px; }
.photo-actions, .photo-candidates { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.photo-input > .photo-actions:first-child { margin-top: 0; }
.photo-candidates { margin: 0 0 12px; }
.photo-candidates button { display: grid; gap: 2px; padding-block: 6px; font-size: 13px; text-align: start; overflow-wrap: anywhere; }
.photo-candidates small { color: var(--photo-muted); font-weight: 400; }
.photo-access { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; padding: 12px; border: 1px solid var(--photo-line); border-radius: 8px; }
.photo-access p { flex: 1 1 230px; margin: 0; color: var(--photo-muted); }
.photo-candidates button[aria-pressed="true"] { border-color: var(--photo-accent); color: var(--photo-accent); }
.photo-feedback:not(:empty) { padding-top: 10px; color: var(--photo-muted); }
.photo-feedback .photo-error { margin: 0; color: var(--red); }
.photo-result h2, .photo-result h3 { margin: 0 0 10px; font-size: 16px; }
.photo-bank-paper { margin: 0; border: 1px solid var(--photo-line); border-radius: 8px; overflow: hidden; }
.photo-bank-paper figcaption { padding: 10px 12px; overflow-wrap: anywhere; }
.photo-preview-trigger:not([hidden]) { display: block; width: 100%; padding: 0; border: 0; background: transparent; color: inherit; cursor: zoom-in; }
.photo-preview-trigger:focus-visible { outline-offset: -3px; }
.photo-preview-trigger img { display: block; width: 100%; height: auto; background: #fff; }
.photo-preview-action { min-height: 40px; display: flex; align-items: center; justify-content: flex-end; padding: 0 12px; color: var(--photo-accent); font-size: 13px; font-weight: 600; }
.photo-preview-trigger:hover .photo-preview-action { text-decoration: underline; }
.photo-bank-paper p { margin: 0; padding: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.photo-answer { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--photo-line); }
.photo-answer .photo-preview-trigger { overflow: hidden; border: 1px solid var(--photo-line); border-radius: 8px; }
.photo-teacher { width: 100%; max-width: 1280px; margin: 0 auto; padding: var(--ps-ui-page-gap, 24px); }
.photo-capture-only :is(#photo-batch-panel, .photo-draft-link) { max-width: 640px; margin-inline: auto; }
.photo-draft-link { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; margin-bottom: 16px; }
.photo-crop-dialog {
  width: min(720px, calc(100% - 20px)); max-width: none; max-height: calc(100dvh - 20px);
  padding: 0; overflow: hidden; border: 1px solid var(--photo-line); border-radius: 14px;
  background: var(--photo-surface); color: inherit; box-shadow: 0 12px 48px rgb(10 26 24 / .22);
}
.photo-crop-dialog[open] { display: flex; flex-direction: column; }
.photo-crop-dialog::backdrop { background: rgb(12 27 29 / .52); }
.photo-crop-dialog [hidden] { display: none; }
.photo-crop-head, .photo-crop-actions { display: flex; align-items: center; gap: 8px; padding: 8px 14px; }
.photo-crop-head { justify-content: space-between; border-bottom: 1px solid var(--photo-line); }
.photo-crop-head > div { min-width: 0; }
.photo-crop-head h2 { margin: 0; font-size: 16px; }
.photo-crop-name { margin: 2px 0 0; color: var(--photo-muted); font-size: 12px; overflow-wrap: anywhere; }
.photo-crop-head button, .photo-crop-actions button { min-height: 44px; }
.photo-crop-head button { flex-shrink: 0; }
.photo-crop-editor { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 10px 14px 14px; }
.photo-crop-hint, .photo-crop-status { color: var(--photo-muted); font-size: 13px; margin: 0 0 10px; }
.photo-crop-status:empty { display: none; }
.photo-crop-stage {
  position: relative; width: fit-content; max-width: 100%; margin-inline: auto;
  overflow: hidden; border-radius: 4px; touch-action: none; user-select: none; cursor: crosshair;
}
.photo-crop-stage img {
  display: block; width: auto; height: auto; max-width: 100%; max-height: min(52dvh, 510px);
  pointer-events: none;
}
.photo-crop-selection { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 2000px rgb(8 20 23 / .62), inset 0 0 0 1px #087d69; }
.photo-crop-selection:focus-visible { outline: 2px solid var(--photo-accent); outline-offset: -4px; }
.photo-crop-selection button {
  position: absolute; width: 44px; height: 44px; min-width: 0;
  min-height: 0; padding: 0; border: 0; background: transparent; touch-action: none;
}
.photo-crop-selection button::after {
  position: absolute; content: ""; width: 14px; height: 14px;
  border: 2px solid #fff; border-radius: 3px; background: #087d69;
}
.photo-crop-selection button:focus-visible { outline: none; }
.photo-crop-selection button:focus-visible::after { box-shadow: 0 0 0 2px #14212b, 0 0 0 4px #fff; }
.photo-crop-selection [data-crop-handle$="w"] { left: -19px; }
.photo-crop-selection [data-crop-handle$="w"]::after { left: 17px; }
.photo-crop-selection [data-crop-handle$="e"] { right: -19px; }
.photo-crop-selection [data-crop-handle$="e"]::after { right: 17px; }
.photo-crop-selection [data-crop-handle^="n"] { top: -19px; }
.photo-crop-selection [data-crop-handle^="n"]::after { top: 17px; }
.photo-crop-selection [data-crop-handle^="s"] { bottom: -19px; }
.photo-crop-selection [data-crop-handle^="s"]::after { bottom: 17px; }
.photo-crop-selection :is([data-crop-handle="nw"], [data-crop-handle="se"]) { cursor: nwse-resize; }
.photo-crop-selection :is([data-crop-handle="ne"], [data-crop-handle="sw"]) { cursor: nesw-resize; }
.photo-crop-actions { justify-content: flex-end; flex-wrap: wrap; border-top: 1px solid var(--photo-line); }
.photo-crop-actions > div { margin-inline-start: auto; display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.photo-crop-actions [data-crop-whole] { white-space: nowrap; }
.photo-crop-actions [data-crop-rest] { margin-inline-end: auto; }
.photo-draft-link span, .photo-related-text, .photo-related-item small { color: var(--photo-muted); overflow-wrap: anywhere; }
.photo-draft-link span { font-size: 13px; }
.photo-related { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--photo-line); }
.photo-related ul { list-style: none; padding: 0; margin: 0; }
.photo-related li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--photo-line); }
.photo-related-toolbar, .photo-batch-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.photo-related-text { margin: 4px 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.photo-related-actions { display: flex; flex-wrap: wrap; gap: 8px; flex-shrink: 0; }
.photo-related-check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.photo-related-check input, .photo-batch input { width: 18px; height: 18px; margin: 0; flex: 0 0 18px; accent-color: var(--photo-accent); }
.photo-related-item { flex: 1; min-width: 0; }
.photo-related-item small { margin-inline-start: 8px; }
.photo-batch { margin-bottom: 16px; padding: 12px 16px; border: 1px solid var(--photo-line); border-radius: 12px; background: var(--photo-surface); }
.photo-batch-head h2 { margin: 0; font-size: 16px; }
.photo-batch-head small, .photo-batch li small, .photo-batch-actions span { color: var(--photo-muted); }
.photo-batch-head small { margin-inline-start: 8px; font-variant-numeric: tabular-nums; }
.photo-batch ul { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 8px; max-height: 252px; overflow-y: auto; margin: 0; padding: 0; list-style: none; }
.photo-batch li { display: flex; align-items: center; gap: 8px; padding: 0 8px; border: 1px solid var(--photo-line); border-radius: 8px; }
.photo-batch li:has(button[aria-pressed="true"]) { border-color: var(--photo-accent); }
.photo-batch-check { display: grid; place-items: center; min-width: 44px; min-height: 44px; cursor: pointer; }
.photo-batch [data-photo-batch-open] { flex: 1; min-width: 0; min-height: 48px; padding: 4px 4px 4px 0; border: 0; background: none; color: inherit; text-align: start; }
.photo-batch [data-photo-batch-remove] { display: grid; place-items: center; flex: 0 0 44px; min-height: 44px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--photo-muted); }
.photo-batch [data-photo-batch-remove]:hover:not(:disabled) { background: var(--dash-bg-2, var(--chrome)); color: var(--dash-danger, var(--red)); }
.photo-batch [data-photo-batch-remove] svg { width: 18px; height: 18px; }
.photo-batch li strong, .photo-batch li small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-batch-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.photo-batch-actions .photo-error { color: var(--red); }
@media (max-width: 800px) {
  .photo-grid { grid-template-columns: 1fr; gap: 12px; }
  .photo-stage { min-height: 160px; }
  .photo-stage img { max-height: 220px; }
  .photo-match button { min-height: 44px; }
  .photo-preview-action { min-height: 44px; }
  .photo-related-toolbar { align-items: flex-start; }
  .photo-batch ul { max-height: 192px; }
}
