/* kolaj.css (W3, img_merge / img_side / screenshot_merge): the collage editor in the chosen-files state — sortable
   tiles (drag or arrow keys), the live preview that is the file, the output size line — and the side options.
   Builds on tool.css + local.css (seg, lfield, lcheck, lnote, lfacts); the look of gorsel.css's editors (W2), which
   this page does not load. The tiles are always laid out left to right (also on RTL pages): they mirror the image,
   whose first picture is on the left / at the top. Radius 0–6 px, the site's tokens only. */

.km { display: grid; gap: 12px; min-width: 0; border: 1px solid var(--ink); background: var(--paper); padding-bottom: 12px; }
.km__bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--ink); min-width: 0; flex-wrap: wrap; }
[dir="rtl"] .km__bar { padding: 8px 14px 8px 8px; }
.km__cnt { margin: 0; font: 600 13px/1.2 var(--f-mono); letter-spacing: .04em; color: var(--ink-2); }
.km__acts { display: flex; gap: 6px; flex-wrap: wrap; }
.km__b { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 12px; border: 1px solid var(--ink); border-radius: var(--r-1); font-size: 13.5px; font-weight: 560; background: var(--paper); color: var(--ink); transition: background-color .3s var(--e-out), color .3s var(--e-out); }
.km__b:hover { background: var(--ink); color: var(--paper); }
.km__b:focus-visible { outline: 2px solid var(--signal-strong); outline-offset: 2px; }

/* tiles: a wrapping grid (no sideways scroll to fight a drag); the thumbnail is the handle */
.km__tiles { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; padding: 4px 12px 0; list-style: none; }
.km__li { position: relative; flex: none; transition: opacity .2s var(--e-out); }
.km__th { position: relative; display: grid; place-items: center; width: 64px; height: 64px; padding: 0; border: 1px solid var(--rule); border-radius: var(--r-1); background: var(--paper-2); overflow: hidden; touch-action: none; cursor: grab; transition: border-color .2s var(--e-out), box-shadow .2s var(--e-out); }
.km__th canvas { display: block; max-width: 52px; max-height: 52px; pointer-events: none; }
.km__th:hover { border-color: var(--ink); }
.km__th:focus-visible { outline: 2px solid var(--signal-strong); outline-offset: 2px; }
.km__n { position: absolute; left: 0; bottom: 0; padding: 1px 4px; font-size: 10.5px; line-height: 1.3; background: var(--ink); color: var(--paper); pointer-events: none; }
[dir="rtl"] .km__n { left: auto; right: 0; }
.km__li[data-st="err"] .km__th { border-color: var(--signal-strong); }
.km__li[data-st="busy"] .km__th { opacity: .5; }
.km__li.is-drag { z-index: 3; opacity: .92; }
.km__li.is-drag .km__th { cursor: grabbing; border-color: var(--ink); box-shadow: 4px 4px 0 var(--ink); pointer-events: none; }
.km__tiles.is-sorting .km__li:not(.is-drag) { transition: transform .15s var(--e-out); }
.km__x { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; display: grid; place-items: center; border: 1px solid var(--ink); border-radius: 50%; background: var(--paper); }
[dir="rtl"] .km__x { right: auto; left: -6px; }
.km__x .ico { width: 12px; height: 12px; }
.km__x::before { content: ""; position: absolute; inset: -10px; }   /* 44 px touch target */
.km__x:hover { background: var(--ink); color: var(--paper); }
.km__add { width: 64px; height: 64px; display: grid; place-items: center; border: 1px dashed var(--ink); border-radius: var(--r-1); background: var(--paper); }
.km__add:hover { background: var(--ink); color: var(--paper); border-style: solid; }
.km__add .ico { width: 18px; height: 18px; }
.km__hint { margin: 0 12px; }

/* the preview: fits the column; a long stack of screenshots scrolls inside its own box */
.km__view { position: relative; margin: 0 12px; min-height: 200px; max-height: 72vh; overflow: auto; background: var(--paper-3); display: grid; justify-items: center; align-items: start; overscroll-behavior: contain; }
.km__cv { display: block; max-width: 100%; background-color: #fff; background-image: linear-gradient(45deg, #e3e3df 25%, transparent 25%, transparent 75%, #e3e3df 75%), linear-gradient(45deg, #e3e3df 25%, transparent 25%, transparent 75%, #e3e3df 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px; }
.km__st { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 16px; text-align: center; font-size: 15px; font-weight: 560; background: var(--paper-2); }
.km__st[hidden] { display: none; }
.km[data-st="err"] .km__st { color: var(--signal-ink); }
.km__st a { color: var(--ink); font-weight: 600; }
.motion .km[data-st="busy"] .km__st { animation: kmPulse 1.2s var(--e-io) infinite alternate; }
@keyframes kmPulse { to { background: var(--paper-3); } }
.km__info { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 12px; font-size: 13.5px; color: var(--ink-2); }
.km__info:empty { display: none; }
.km__sz b { color: var(--ink); font-weight: 600; }
.km__note { color: var(--ink-2); }
.km__note:first-of-type { position: relative; padding-inline-start: 12px; }
.km__note:first-of-type::before { content: ""; position: absolute; inset-inline-start: 0; top: .45em; width: 6px; height: 6px; background: var(--signal-strong); }

/* result */
.km__res { max-width: 260px; margin: 0 0 14px; background: #fff; box-shadow: 5px 5px 0 var(--ink); }
[dir="rtl"] .km__res { box-shadow: -5px 5px 0 var(--ink); }
.km__res img { display: block; width: 100%; height: auto; max-height: 420px; object-fit: contain; object-position: top; }
.km__warn { margin-top: 10px; border-inline-start-color: var(--signal-strong); }

.km__also { margin-top: 12px; }
.km__also a { color: var(--ink); font-weight: 600; }

/* side options */
.km-rng { gap: 4px; }
.km-rng .lfield__l { display: flex; justify-content: space-between; gap: 8px; }
.km-rng input { width: 100%; min-height: 36px; accent-color: var(--ink); }
.km-grp { display: grid; gap: 10px; min-width: 0; margin: 0; padding: 0; border: 0; }
.km-grp[hidden], .km-color[hidden], [data-km-q][hidden] { display: none; }
.km-shot { padding: 10px 12px 12px; border: 1px solid var(--rule); border-radius: var(--r-1); }
.km-shot > .seg__lg { padding: 0 4px; }
.km-note { margin: 0; font-size: 12.5px; }
.km-mode .seg__row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.km-cols .seg__row, .km-bg .seg__row, .km-w .seg__row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.km-fmt .seg__row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.km-bg .seg__n, .km-w .seg__n { font-size: 13.5px; }
.km-color { display: grid; }
.km-pick { grid-template-columns: minmax(0, 1fr) 64px; align-items: center; }
.km-ci { width: 64px; height: 44px; padding: 2px; border: 1px solid var(--ink); border-radius: var(--r-1); background: var(--paper); }

@media (max-width: 719.98px) {
  .km__bar { padding-inline-start: 10px; }
  .km__tiles { padding-inline: 10px; gap: 8px; }
  .km__view, .km__info, .km__hint { margin-inline: 10px; }
  .km__view { max-height: 60vh; }
  .km-bg .seg__row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .km-bg .seg__o:nth-child(n+3) { border-top: 1px solid var(--ink); }
  .km-bg .seg__o:nth-child(3) { border-inline-start: 0; }
  .km__res { max-width: 200px; }
}
