
:root {
  --bg: #ECEFEA; --surface: #FFFFFF; --surface-2: #F5F7F3; --ink: #141B18; --muted: #56615B; --line: #D3D9D1; --line-strong: #B9C1B7;
  --accent: #2741D3; --accent-ink: #FFFFFF; --accent-soft: #E2E6FB; --dot: #C7CEC4; --danger: #B3261E; --ok: #1B7A4B; --warn-bg: #FFF4D6; --warn-ink: #6B4B00;
  --f-display: "Archivo", "Helvetica Neue", Arial, sans-serif; --f-body: "Archivo", "Helvetica Neue", Arial, sans-serif; --f-mono: "Fragment Mono", ui-monospace, Menlo, Consolas, monospace;
  --shadow: 0 1px 2px rgba(20,27,24,.12), 0 8px 24px -12px rgba(20,27,24,.35);
  --check-a: #ffffff; --check-b: #E3E7E1;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0E1210; --surface: #161B18; --surface-2: #1C221F; --ink: #E4EAE6; --muted: #98A49D; --line: #2A322E; --line-strong: #3A443F;
  --accent: #8E9DFF; --accent-ink: #0E1210; --accent-soft: #232A4E; --dot: #29312D; --danger: #FF8A80; --ok: #6FD39E; --warn-bg: #3A3016; --warn-ink: #F5D98A; color-scheme: dark;
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 10px 30px -12px rgba(0,0,0,.8); --check-a: #2A302D; --check-b: #222825; } }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 14px; line-height: 1.5; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
h1, h2, h3 { margin: 0; text-wrap: balance; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.top { position: sticky; top: 0; z-index: 30; background: var(--bg); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; padding: 10px 20px; height: 57px; }
.mark { display: inline-flex; align-items: center; gap: 10px; font-family: var(--f-display); font-stretch: 125%; font-weight: 800; font-size: 19px; letter-spacing: -0.01em; white-space: nowrap; color: var(--ink); text-decoration: none; }
.mark svg { width: 26px; height: 26px; flex: none; }
.tool-name { color: var(--muted); font-weight: 600; font-size: 14px; border-left: 1px solid var(--line-strong); padding-left: 14px; white-space: nowrap; }
.top .links { margin-left: auto; display: flex; gap: 16px; font-size: 13.5px; }
.top .links a { color: var(--muted); white-space: nowrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 8px; padding: 7px 12px; font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; min-height: 34px; }
.btn:hover:not(:disabled) { border-color: var(--ink); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); border-color: var(--accent); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn.quiet:hover:not(:disabled) { color: var(--ink); background: var(--surface-2); }
.btn.icon { padding: 6px; min-width: 34px; }
.btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.sm { min-height: 28px; padding: 4px 9px; font-size: 12.5px; }
.fld { display: grid; gap: 5px; min-width: 0; }
.fld > label, .fld-label { font-size: 12.5px; font-weight: 600; }
.fld input[type=text], .fld input[type=number], .fld select, .inp { width: 100%; border: 1px solid var(--line-strong); border-radius: 7px; padding: 6px 8px; background: var(--surface); min-width: 0; }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.fgrid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.wide { grid-column: 1 / -1; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
.chk input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.note { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; flex-wrap: wrap; max-width: 100%; }
.seg label { padding: 5px 10px; font-size: 12.5px; font-weight: 600; cursor: pointer; border-left: 1px solid var(--line); white-space: nowrap; }
.seg label:first-child { border-left: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--ink); color: var(--bg); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.seg label:has(input:disabled) { opacity: .4; cursor: default; }
.seg.full { display: flex; } .seg.full label { flex: 1; text-align: center; }
.range { display: flex; align-items: center; gap: 10px; }
.range input { flex: 1; accent-color: var(--accent); min-width: 0; }
.range output { font-family: var(--f-mono); font-size: 12px; color: var(--muted); min-width: 3.4em; text-align: right; }
.unitin { display: flex; } .unitin input { border-radius: 7px 0 0 7px !important; flex: 1; } .unitin select { width: auto !important; min-width: 4.4em; flex: none; border-radius: 0 7px 7px 0 !important; border-left: 0 !important; }
.colour { display: flex; gap: 6px; align-items: center; }
.colour input[type=color] { width: 34px; height: 30px; border: 1px solid var(--line-strong); border-radius: 7px; padding: 2px; background: var(--surface); cursor: pointer; }
.colour input[type=text] { width: 7.5em !important; font-family: var(--f-mono); font-size: 12.5px; }

/* Start screen */
.start { max-width: 1080px; margin: 0 auto; padding: 44px 24px 64px; }
.start h1 { font-family: var(--f-display); font-stretch: 112%; font-weight: 800; font-size: clamp(32px, 5vw, 50px); line-height: 1.04; letter-spacing: -0.025em; max-width: 17ch; }
.start .lede { color: var(--muted); font-size: 18px; max-width: 40em; margin: 14px 0 26px; }
.drop { display: grid; place-items: center; text-align: center; gap: 10px; border: 2px dashed var(--line-strong); border-radius: 16px; padding: 44px 20px; background: var(--surface);
  background-image: radial-gradient(var(--dot) 1px, transparent 1.2px); background-size: 18px 18px; cursor: pointer; transition: border-color .15s, background-color .15s; }
.drop:hover, body.dragging .drop { border-color: var(--accent); background-color: var(--accent-soft); }
.drop strong { font-size: 19px; }
.drop .btn { pointer-events: none; }
.privacy-line { display: flex; gap: 8px; align-items: center; justify-content: center; color: var(--muted); font-size: 13.5px; margin-top: 14px; text-align: center; flex-wrap: wrap; }
.privacy-line svg { color: var(--ok); }
.tiles-h { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 40px 0 14px; font-weight: 700; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 12px; }
.tile { display: grid; grid-template-columns: 38px 1fr; gap: 4px 12px; align-items: start; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 14px; cursor: pointer; }
.tile:hover { border-color: var(--ink); }
.tile .ic { grid-row: span 2; width: 38px; height: 38px; border-radius: 9px; background: var(--surface-2); display: grid; place-items: center; color: var(--accent); }
.tile b { font-size: 14.5px; }
.tile span:last-child { color: var(--muted); font-size: 12.5px; line-height: 1.4; }

/* Workspace */
.work { display: flex; flex-direction: column; height: calc(100dvh - 57px); }
.bar { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; }
.bar .sum { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.bar .sum b { color: var(--ink); }
.bar .grp { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ws { flex: 1; min-height: 0; display: grid; grid-template-columns: 236px minmax(0, 1fr) 320px; }

.list { border-right: 1px solid var(--line); background: var(--bg); overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.item { position: relative; display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 4px 10px; align-items: center; padding: 7px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; background: transparent; text-align: left; width: 100%; }
.item:hover { background: var(--surface); }
.item.cur { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.item .th { width: 52px; height: 52px; border-radius: 7px; background: var(--surface-2) center / contain no-repeat; grid-row: span 2; position: relative; overflow: hidden; }
.item .nm { font-weight: 600; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 20px; }
.item .st { font-size: 11.5px; color: var(--muted); font-family: var(--f-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .st .down { color: var(--ok); } .item .st .up { color: var(--danger); } .item .st .err { color: var(--danger); font-family: var(--f-body); }
.item .x { position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; border-radius: 6px; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; padding: 0; opacity: 0; }
.item:hover .x, .item.cur .x, .item:focus-within .x { opacity: 1; }
@media (hover: none) { .item .x { opacity: 1; } }
.item .x:hover { background: var(--surface-2); color: var(--ink); }
.item .x svg { width: 14px; height: 14px; }
.item .spin { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255,255,255,.55); }
.spinner { width: 18px; height: 18px; border: 2.5px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.addmore { border: 2px dashed var(--line-strong); border-radius: 10px; padding: 12px; text-align: center; color: var(--muted); font-weight: 600; font-size: 12.5px; cursor: pointer; }
.addmore:hover { border-color: var(--accent); color: var(--accent); }

.stage { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.stagebar { display: flex; gap: 6px; align-items: center; padding: 7px 12px; border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; }
.stagebar .sp { flex: 1; }
.stagebar .vsep { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }
.viewport { flex: 1; min-height: 0; overflow: auto; position: relative; background-color: var(--bg); background-image: radial-gradient(var(--dot) 1px, transparent 1.2px); background-size: 18px 18px; }
/* Grows with its content (so zoomed pictures can be scrolled to every edge) and centres it when it's smaller. */
.viewport-inner { width: max-content; min-width: 100%; min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 22px; gap: 18px; box-sizing: border-box; }
.viewport-inner > * { flex: none; }
.pane { position: relative; flex: none; box-shadow: var(--shadow); background-color: var(--check-a);
  background-image: linear-gradient(45deg, var(--check-b) 25%, transparent 25%, transparent 75%, var(--check-b) 75%), linear-gradient(45deg, var(--check-b) 25%, transparent 25%, transparent 75%, var(--check-b) 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px; user-select: none; -webkit-user-select: none; touch-action: none; }
.pane img, .pane canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; image-rendering: auto; -webkit-user-drag: none; }
.pane.pixelated img { image-rendering: pixelated; }
.pane .after { clip-path: inset(0 0 0 var(--split, 50%)); }
.pane .before { clip-path: inset(0 calc(100% - var(--split, 50%)) 0 0); }
.pane .handle { position: absolute; top: 0; bottom: 0; left: var(--split, 50%); width: 0; cursor: ew-resize; }
.pane .handle::before { content: ""; position: absolute; top: 0; bottom: 0; left: -1px; width: 2px; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.pane .handle span { position: absolute; top: 50%; left: -17px; width: 34px; height: 34px; margin-top: -17px; border-radius: 50%; background: #fff; color: #141B18; box-shadow: 0 2px 10px rgba(0,0,0,.35); display: grid; place-items: center; }
.pane .handle span svg { width: 18px; height: 18px; }
.pane .tag { position: absolute; top: 8px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: rgba(20,27,24,.72); color: #fff; pointer-events: none; }
.pane .tag.l { left: 8px; } .pane .tag.r { right: 8px; }
.pane-cap { text-align: center; font-size: 12px; color: var(--muted); margin-top: 6px; font-family: var(--f-mono); }
.side { display: flex; flex-direction: column; align-items: center; }
.cropbox { position: absolute; border: 1.5px solid #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,.5), 0 0 0 1px rgba(0,0,0,.4); cursor: move; touch-action: none; }
.cropbox::before, .cropbox::after { content: ""; position: absolute; inset: 33.33% 0; border-top: 1px solid rgba(255,255,255,.45); border-bottom: 1px solid rgba(255,255,255,.45); pointer-events: none; }
.cropbox::after { inset: 0 33.33%; border: 0; border-left: 1px solid rgba(255,255,255,.45); border-right: 1px solid rgba(255,255,255,.45); }
.cropbox .h { position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; background: #fff; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0,0,0,.35); touch-action: none; }
.cropbox .h[data-h=nw], .cropbox .h[data-h=se] { cursor: nwse-resize; } .cropbox .h[data-h=ne], .cropbox .h[data-h=sw] { cursor: nesw-resize; }
.brushcur { position: absolute; border: 1.5px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0,0,0,.5); pointer-events: none; transform: translate(-50%, -50%); }
.pane[data-mode=brush] { cursor: none; }
.modebar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 12px; background: var(--accent-soft); border-bottom: 1px solid var(--line); font-size: 13px; }
.modebar b { margin-right: 4px; }
.modebar .sp { flex: 1; }
.infobar { display: flex; gap: 10px 24px; padding: 7px 14px; border-top: 1px solid var(--line); background: var(--surface); font-size: 12px; color: var(--muted); flex-wrap: wrap; align-items: center; min-height: 36px; }
.infobar b { color: var(--ink); font-weight: 600; }
.infobar .warn { color: var(--warn-ink); background: var(--warn-bg); border-radius: 6px; padding: 1px 8px; }
.progress { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); padding: 14px 18px; min-width: 260px; z-index: 5; font-size: 13px; }
.progress .barx { height: 6px; border-radius: 3px; background: var(--line); margin-top: 8px; overflow: hidden; }
.progress .barx i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.settings { border-left: 1px solid var(--line); background: var(--surface); overflow-y: auto; padding: 6px 0 40px; }
.settings .lead { font-size: 12.5px; color: var(--muted); padding: 8px 16px 6px; margin: 0; }
.sec { border-bottom: 1px solid var(--line); }
.sec summary { cursor: pointer; font-weight: 700; font-size: 14px; list-style: none; display: flex; gap: 9px; align-items: center; padding: 12px 16px; }
.sec summary::-webkit-details-marker { display: none; }
.sec summary::after { content: "+"; margin-left: auto; color: var(--muted); font-weight: 400; font-size: 20px; line-height: 1; }
.sec[open] summary::after { content: "–"; }
.sec summary svg { color: var(--accent); }
.sec summary .on { font-size: 10.5px; font-weight: 700; color: var(--ok); text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.sec .body { padding: 0 16px 16px; display: grid; gap: 12px; }
.sec .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.warnbox { background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; padding: 8px 11px; font-size: 12.5px; }
.okbox { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); border-radius: 8px; padding: 8px 11px; font-size: 12.5px; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 90; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 13.5px; box-shadow: 0 10px 30px -10px rgba(0,0,0,.5); max-width: calc(100vw - 32px); }
.busy { position: fixed; inset: 0; z-index: 85; display: grid; place-items: center; background: rgba(14, 18, 16, .35); }
.busy > div { background: var(--surface); border-radius: 12px; padding: 18px 22px; display: flex; gap: 12px; align-items: center; box-shadow: 0 20px 60px -20px rgba(0,0,0,.5); min-width: 240px; }
@keyframes spin { to { transform: rotate(360deg); } }
.hint { position: absolute; z-index: 95; max-width: 260px; background: var(--ink); color: var(--bg); font-size: 12.5px; line-height: 1.4; font-weight: 500; padding: 7px 10px; border-radius: 7px; box-shadow: 0 8px 22px -8px rgba(20,27,24,.45); pointer-events: none; animation: hint-in .12s ease-out; }
.hint::after { content: ""; position: absolute; left: var(--ax, 50%); bottom: -5px; width: 10px; height: 10px; margin-left: -5px; background: inherit; transform: rotate(45deg); border-radius: 2px; }
.hint.below::after { bottom: auto; top: -5px; }
@keyframes hint-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .hint, .spinner { animation: none; } }

@media (max-width: 1360px) { .stagebar { gap: 3px; } .stagebar .vsep { display: none; } #dl-one span { display: none; } .seg label { padding: 5px 8px; } }
@media (max-width: 1180px) { .ws { grid-template-columns: 180px minmax(0, 1fr) 290px; } .item { grid-template-columns: 44px minmax(0, 1fr); } .item .th { width: 44px; height: 44px; } }
@media (max-width: 900px) {
  .top { padding: 10px 14px; } .tool-name { display: none; }
  .work { height: auto; min-height: calc(100dvh - 57px); }
  .ws { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; }
  .list { flex-direction: row; overflow-x: auto; overflow-y: hidden; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .item { grid-template-columns: 52px; width: auto; flex: none; padding: 5px; }
  .item .nm, .item .st { display: none; }
  .item .x { opacity: 1; top: 0; right: 0; background: var(--surface); }
  .addmore { flex: none; display: grid; place-items: center; width: 62px; padding: 4px; }
  .stage { height: 62dvh; }
  .settings { border-left: 0; border-top: 1px solid var(--line); }
  .bar { padding: 6px 10px; } .bar .sum { flex-basis: 100%; order: 3; }
  .start { padding: 26px 16px 50px; }
  .stagebar { padding: 6px 8px; gap: 4px; }
}

@media (max-width: 440px) { .top { gap: 10px; padding-left: 12px; padding-right: 12px; } .top .mark { font-size: 16px; gap: 8px; } .top .links .all { display: none; } .top .mark svg { width: 24px; height: 24px; } .top .links { gap: 10px; font-size: 13px; } }

a.mark { color: inherit; text-decoration: none; }
