/* =====================================================================
   Réduire une image — styles (limités à .img / .img-*), variables --ot-*
   ===================================================================== */
.img { --img-accent: #2563eb; --img-ok: #16a34a; --img-warn: #b45309; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .img { --img-accent: #60a5fa; --img-ok: #4ade80; --img-warn: #fbbf24; } }
:root[data-theme="dark"] .img { --img-accent: #60a5fa; --img-ok: #4ade80; --img-warn: #fbbf24; }

.img-head h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); }
.img-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; cursor: pointer;
  min-height: 190px; padding: 24px; border: 2px dashed color-mix(in srgb, var(--img-accent) 45%, var(--ot-border)); border-radius: var(--ot-radius);
  background: color-mix(in srgb, var(--img-accent) 5%, var(--ot-surface)); transition: background .15s, border-color .15s; }
.img-drop:hover, .img-drop:focus-visible, .img-drop.is-over { border-color: var(--img-accent); background: color-mix(in srgb, var(--img-accent) 11%, var(--ot-surface)); outline: none; }
.img-drop svg { width: 44px; height: 44px; color: var(--img-accent); }
.img-drop strong { font-size: 1.1rem; }
.img-drop span { color: var(--ot-text-soft); font-size: .9rem; }
.has-items .img-drop { min-height: 96px; padding: 14px; }
.has-items .img-drop svg { width: 30px; height: 30px; }

.img-settings { display: grid; gap: 12px 18px; margin-top: var(--ot-space); grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); align-items: end; }
.img-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.img-field > label, .img-label { font-size: .85rem; font-weight: 700; }
.img-field .ot-select, .img-field .ot-input { min-height: 42px; padding: 8px 10px; width: 100%; }
.img-radios { display: flex; gap: 6px; flex-wrap: wrap; }
.img-radios label { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--ot-border); border-radius: 999px; font-size: .88rem; font-weight: 600; cursor: pointer; background: var(--ot-surface); }
.img-radios label:has(input:checked) { border-color: var(--img-accent); background: color-mix(in srgb, var(--img-accent) 12%, var(--ot-surface)); }
.img-radios input { accent-color: var(--img-accent); }
.img-range { display: flex; align-items: center; gap: 10px; min-height: 42px; }
.img-range input { flex: 1; accent-color: var(--img-accent); }
.img-range output { min-width: 2.5em; font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.img-unit { display: flex; align-items: center; gap: 8px; }
.img-unit span { color: var(--ot-text-soft); font-weight: 600; }

.img-results { margin-top: var(--ot-space); display: none; }
.has-items .img-results { display: block; }
.img-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.img-bar p { margin: 0; font-weight: 700; }
.img-bar div { display: flex; gap: 8px; }
.img-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.img-item { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 10px 12px;
  border: 1px solid var(--ot-border); border-radius: var(--ot-radius-s); background: var(--ot-surface); }
.img-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 12px 12px; }
.img-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.img-info { font-size: .85rem; color: var(--ot-text-soft); font-variant-numeric: tabular-nums; }
.img-info strong { color: var(--ot-text); }
.img-note { font-size: .8rem; }
.img-warn { color: var(--img-warn); }
.img-gain { font-weight: 800; font-size: 1.05rem; min-width: 4.5em; text-align: right; font-variant-numeric: tabular-nums; }
.img-gain[data-dir="down"] { color: var(--img-ok); }
.img-gain[data-dir="up"] { color: var(--img-warn); }
.img-gain[data-dir="0"] { color: var(--ot-text-soft); font-size: .85rem; }
.img-acts { display: flex; gap: 6px; align-items: center; }
.img-mini { min-height: 34px; padding: 5px 12px; font-size: .85rem; }
.img-acts a:not([href]) { opacity: .5; pointer-events: none; }
.img-x { border: 0; background: transparent; color: var(--ot-text-soft); cursor: pointer; font-size: 1rem; padding: 4px 8px; border-radius: 6px; }
.img-x:hover { background: var(--ot-surface-2); color: var(--ot-text); }
.img-item[data-status="work"] .img-info { color: var(--img-accent); }
@media (max-width: 640px) {
  .img-item { grid-template-columns: 52px minmax(0, 1fr) auto; }
  .img-thumb { width: 52px; height: 52px; }
  .img-acts { grid-column: 1 / -1; justify-content: flex-end; }
}

/* Comparaison avant / après */
.img-cmp { border: 0; padding: 0; border-radius: var(--ot-radius); width: min(96vw, 1100px); max-height: 94vh; background: var(--ot-surface); color: var(--ot-text); }
.img-cmp::backdrop { background: rgba(0,0,0,.65); }
.img-cmp-head { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--ot-border); }
.img-cmp-head p { margin: 0; font-weight: 700; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.img-cmp-view { display: flex; justify-content: center; background: var(--ot-surface-2); }
/* la scène a exactement la taille de l'image : la ligne et la découpe coïncident */
.img-cmp-stage { position: relative; display: inline-block; max-width: 100%; background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.img-cmp-stage img { display: block; max-width: 100%; max-height: calc(94vh - 120px); }
.img-cmp-stage #img-cmp-b { position: absolute; inset: 0; width: 100%; height: 100%; }
.img-cmp-line { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.4); pointer-events: none; }
.img-cmp-tag { position: absolute; top: 8px; padding: 2px 8px; border-radius: 999px; background: rgba(0,0,0,.6); color: #fff; font-size: .78rem; font-weight: 700; }
.img-cmp-tag--a { left: 8px; } .img-cmp-tag--b { right: 8px; }
.img-cmp input[type=range] { width: calc(100% - 28px); margin: 10px 14px 14px; accent-color: var(--img-accent); }

.img-help { margin-top: calc(var(--ot-space) * 2.5); }
