.photo-editor{border:1px solid var(--line);border-radius:18px;padding:20px;margin:8px 0 16px;min-width:0;background:var(--paper)}
.photo-editor-heading{display:flex;align-items:center;justify-content:space-between;gap:12px}.photo-editor-heading h2{font-size:21px;margin:0}.photo-editor-heading>span{font-size:13px;color:var(--muted);white-space:nowrap}
.photo-editor .photo-upload-label{display:block;border:1px dashed var(--accent);border-radius:12px;background:var(--soft);color:var(--accent);padding:17px;cursor:pointer;text-align:center;margin:16px 0 8px;font-weight:600}
.photo-editor input[type=file]{max-width:100%;font-size:13px}.photo-editor .field-help{line-height:1.6}.photo-error{color:var(--error);font-size:14px}
.photo-editor-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;padding:0;margin:16px 0;list-style:none}
.photo-editor-grid>li{min-width:0;position:relative;border:1px solid var(--line);border-radius:12px;overflow:hidden;background:var(--bg)}
.photo-editor-grid img{display:block;width:100%;aspect-ratio:1.25;object-fit:cover}.photo-editor-item{cursor:grab}.photo-editor-item.dragging{opacity:.4;outline:2px dashed var(--accent)}
.photo-position{position:absolute;top:7px;left:7px;border-radius:6px;background:var(--paper);color:var(--ink);padding:4px 7px;font-size:11px;box-shadow:0 2px 10px #0002}
.photo-editor-actions{display:flex;align-items:center;justify-content:space-between;padding:4px;gap:3px;background:var(--paper)}
.photo-editor-actions button{border:0;border-radius:7px;color:var(--ink);background:var(--soft);min-width:32px;min-height:36px;font-size:20px;cursor:pointer;padding:3px 7px}
.photo-editor-actions button[data-action=remove]{color:var(--error);margin-left:auto}.photo-editor-actions button:disabled{opacity:.3;cursor:default}
.photo-editor-actions button:focus-visible,.photo-gallery a:focus-visible,.photo-gallery button:focus-visible{outline:3px solid var(--accent);outline-offset:2px}
.photo-gallery{min-width:0;max-width:100%;outline-offset:4px}.gallery-viewport{position:relative;background:var(--soft);border:1px solid var(--line);border-radius:20px;overflow:hidden;isolation:isolate}
.gallery-open{display:block;cursor:zoom-in}.photo-gallery .detail-photo{width:100%;aspect-ratio:4/3;object-fit:contain;border-radius:0;background:var(--soft)}
.gallery-expand{position:absolute;top:14px;right:14px;font-size:12px;padding:7px 11px;border-radius:8px;background:var(--paper);color:var(--ink);box-shadow:0 2px 12px #0001}
.gallery-arrow{position:absolute;top:50%;transform:translateY(-50%);width:44px;height:44px;border:1px solid var(--line);border-radius:50%;background:var(--paper);color:var(--ink);font-size:30px;line-height:1;display:grid;place-items:center;box-shadow:0 3px 14px #0002;cursor:pointer;z-index:1;padding:0}
.gallery-arrow[hidden]{display:none}.gallery-previous{left:12px}.gallery-next{right:12px}.gallery-arrow:hover{background:var(--accent);color:var(--on-accent)}
.gallery-count{position:absolute;bottom:14px;left:14px;padding:6px 11px;border-radius:8px;background:var(--paper);color:var(--ink);font-size:12px;font-variant-numeric:tabular-nums;box-shadow:0 2px 12px #0001}
.gallery-thumbs{display:flex;gap:10px;overflow-x:auto;padding:10px 2px 6px;scrollbar-width:thin;position:relative}.gallery-thumbs[hidden]{display:none}
.gallery-thumbs a{display:block;flex:0 0 86px;border:2px solid transparent;border-radius:11px;overflow:hidden;opacity:.65;transition:opacity .16s,border-color .16s;background:var(--soft)}
.gallery-thumbs a[aria-current=true]{border-color:var(--accent);opacity:1}.gallery-thumbs a:hover{opacity:1}.gallery-thumbs img{display:block;width:100%;height:66px;object-fit:cover}
[data-gallery-swipe]{touch-action:pan-y}.photo-lightbox{width:min(1160px,calc(100vw - 32px));max-width:none;max-height:94dvh;border:1px solid var(--line);border-radius:18px;padding:0;background:var(--paper);color:var(--ink);overflow:hidden;box-shadow:0 24px 90px #0008}
.photo-lightbox::backdrop{background:#07110dde;backdrop-filter:blur(5px)}.lightbox-header{display:flex;align-items:center;justify-content:space-between;padding:8px 14px;font-size:14px}.lightbox-close{border:0;background:var(--soft);color:var(--ink);border-radius:50%;width:44px;height:44px;font-size:29px;cursor:pointer}
.lightbox-stage{height:min(76dvh,800px);position:relative;background:var(--soft)}.lightbox-stage>img{width:100%;height:100%;object-fit:contain;display:block}
@media(max-width:760px){.photo-editor{padding:14px}.photo-editor-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.photo-editor-actions button{min-width:38px;min-height:40px}.gallery-expand{top:10px;right:10px}.gallery-arrow{width:40px;height:40px}.gallery-previous{left:8px}.gallery-next{right:8px}.gallery-thumbs a{flex-basis:72px}.gallery-thumbs img{height:56px}.photo-lightbox{width:calc(100vw - 16px)}.lightbox-stage{height:70dvh}}
@media(prefers-reduced-motion:reduce){.gallery-thumbs a{transition:none}}

/* Keep all actions reachable on narrow phones, including 320px viewports. */
.photo-editor-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:5px}
.photo-editor-actions button{min-width:0;width:100%}
.photo-editor-actions button[data-action=remove]{position:absolute;top:6px;right:6px;width:34px;height:34px;min-height:34px;background:var(--paper);box-shadow:0 2px 8px #0002}
.photo-position{top:auto;bottom:52px;max-width:calc(100% - 14px);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.photo-editor[data-enhanced=true] input[type=file]{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
.photo-editor:has(input[type=file]:focus-visible) .photo-upload-label{outline:3px solid var(--accent);outline-offset:3px}
@media(max-width:760px){.photo-editor-actions button{min-width:0;min-height:44px}.photo-editor-actions button[data-action=remove]{width:40px;height:40px;min-height:40px}.photo-position{bottom:60px}}
