:root {
  --bg: #f5f2ec; --surface: #fffdf9; --ink: #1c1b18; --muted: #6a665d; --line: #d9d3c7;
  --accent: #e4410f; --accent-ink: #fff; --accent-soft: #fde6dc; --ok: #1f7a4d; --bad: #b3261e;
  --check: #e8e3d8; --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14130f; --surface: #1d1c17; --ink: #f0ece2; --muted: #a39e90; --line: #36332a;
    --accent: #ff6a3a; --accent-ink: #1a0a03; --accent-soft: #3a2118; --ok: #5fcf90; --bad: #ff8a80; --check: #26241d; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--sans); }
a { color: var(--accent); }
.wrap { max-width: 920px; margin: 0 auto; padding: 0 16px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
header.site { border-bottom: 1px solid var(--line); background: var(--surface); }
header.site .wrap { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; padding-bottom: 10px; }
.brand { font: 800 1.15rem var(--mono); text-decoration: none; color: var(--ink); letter-spacing: -.02em; }
.brand b { color: var(--accent); }
nav.tools { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
nav.tools a { white-space: nowrap; text-decoration: none; color: var(--ink); font-size: .9rem; padding: 4px 10px; border: 1px solid var(--line); border-radius: 99px; }
nav.tools a[aria-current] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
h1 { font-size: clamp(1.6rem, 6vw, 2.5rem); line-height: 1.1; margin: 22px 0 8px; letter-spacing: -.03em; }
h2 { font-size: 1.15rem; margin: 26px 0 6px; }
h3 { font-size: 1rem; margin: 14px 0 4px; }
.lead { color: var(--muted); margin: 0 0 8px; max-width: 60ch; }
.privacy { display: inline-block; margin: 6px 0 14px; padding: 6px 12px; border-radius: 8px; background: var(--accent-soft); font-size: .92rem; }
.slot { min-height: 0; }
main.tool { padding-bottom: 8px; }
.tool-root { margin: 6px 0 12px; }
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; min-height: 220px; padding: 24px 16px;
  border: 2.5px dashed var(--accent); border-radius: var(--radius); background: var(--surface); cursor: pointer; transition: background .15s, transform .15s; }
.dropzone:hover, .dropzone.over, .dropzone:focus-within { background: var(--accent-soft); }
.dropzone.over { transform: scale(1.01); }
.dropzone.compact { min-height: 0; padding: 14px; }
.dz-title { font: 800 clamp(1.3rem, 5vw, 1.8rem) var(--sans); letter-spacing: -.02em; }
.dz-sub { color: var(--muted); font-size: .95rem; }
.errors p { margin: 8px 0 0; color: var(--bad); font-weight: 600; }
.panel { margin-top: 14px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); display: flex; flex-direction: column; gap: 12px; }
.panel[hidden], [hidden] { display: none !important; }
.controls-row { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; }
.field-label { color: var(--muted); font: 600 .75rem var(--mono); text-transform: uppercase; letter-spacing: .04em; }
.field.muted { opacity: .45; }
input[type=number], select, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
input[type=number] { width: 8.5em; }
input[type=range] { width: min(260px, 70vw); accent-color: var(--accent); }
input[type=color] { width: 56px; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: none; padding: 2px; }
textarea { width: 100%; font-family: var(--mono); font-size: .8rem; }
.check, .radio { display: inline-flex; align-items: center; gap: 6px; font-size: .92rem; }
.btn { font: 600 .95rem var(--sans); display: inline-flex; align-items: center; justify-content: center; text-decoration: none; cursor: pointer; padding: 9px 14px; border-radius: 10px;
  border: 1.5px solid var(--ink); background: var(--surface); color: var(--ink); }
.btn:hover { background: var(--ink); color: var(--bg); }
.btn.on, .chip-btn.on { background: var(--ink); color: var(--bg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); color: var(--accent-ink); }
.btn.big { font-size: 1.1rem; padding: 14px 22px; width: 100%; }
.btn[aria-disabled=true], .btn:disabled { opacity: .4; pointer-events: none; }
@media (min-width: 640px) { .btn.big { width: auto; min-width: 260px; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 5px 12px; border: 1px solid var(--line); border-radius: 99px; }
.chip-btn { padding: 5px 12px; font-size: .88rem; }
.status { margin: 0; min-height: 1.2em; color: var(--muted); font-size: .92rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.stats:empty { display: none; }
.stat { display: flex; flex-direction: column; padding: 8px 10px; border-radius: 10px; background: var(--bg); }
.stat-label { font: 600 .7rem var(--mono); text-transform: uppercase; color: var(--muted); }
.preview { background: repeating-conic-gradient(var(--check) 0 25%, transparent 0 50%) 0 0 / 18px 18px; border-radius: 10px; overflow: hidden; }
.preview img, .preview canvas { display: block; max-width: 100%; height: auto; margin: 0 auto; max-height: 70vh; width: auto; }
.compare { display: flex; flex-direction: column; gap: 6px; --pos: 50%; }
.compare-box { position: relative; display: grid; }
.compare-box img { grid-area: 1 / 1; width: 100%; max-height: 70vh; object-fit: contain; }
.compare-box img.after { clip-path: inset(0 0 0 var(--pos)); }
.compare-box::after { content: ""; position: absolute; top: 0; bottom: 0; left: var(--pos); width: 2px; background: var(--accent); pointer-events: none; }
.cmp-tag { position: absolute; top: 8px; padding: 2px 8px; border-radius: 6px; background: rgba(0,0,0,.6); color: #fff; font: 600 .72rem var(--mono); pointer-events: none; }
.cmp-tag.left { left: 8px; } .cmp-tag.right { right: 8px; }
.compare input[type=range] { width: 100%; }
.crop-stage { position: relative; display: inline-block; max-width: 100%; touch-action: none; user-select: none; -webkit-user-select: none; line-height: 0; align-self: center; }
.crop-stage img { max-width: 100%; max-height: 65vh; height: auto; width: auto; }
.crop-box { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,.55); cursor: move; outline-offset: 2px; touch-action: none; }
.handle { position: absolute; width: 22px; height: 22px; background: var(--accent); border: 2px solid #fff; border-radius: 6px; transform: translate(-50%, -50%); }
.h-nw { left: 0; top: 0; cursor: nwse-resize; } .h-n { left: 50%; top: 0; cursor: ns-resize; } .h-ne { left: 100%; top: 0; cursor: nesw-resize; }
.h-e { left: 100%; top: 50%; cursor: ew-resize; } .h-se { left: 100%; top: 100%; cursor: nwse-resize; } .h-s { left: 50%; top: 100%; cursor: ns-resize; }
.h-sw { left: 0; top: 100%; cursor: nesw-resize; } .h-w { left: 0; top: 50%; cursor: ew-resize; }
.scan-box { padding: 10px 12px; border-radius: 10px; background: var(--bg); }
.scan { margin: 0; font-weight: 600; }
.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-list li { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--bg); }
.fname { font-weight: 600; word-break: break-all; } .fmeta { color: var(--muted); font-size: .88rem; } .ferr { color: var(--bad); font-size: .9rem; }
.file-list .btn { padding: 4px 10px; font-size: .85rem; margin-left: auto; }
.pick-canvas { max-width: 100%; height: auto; max-height: 65vh; cursor: crosshair; touch-action: none; align-self: center; border-radius: 8px; }
.picked { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.swatch { width: 84px; height: 84px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); }
.picked > div > div { margin: 3px 0; }
.code { font-family: var(--mono); font-weight: 700; margin-right: 6px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.sw { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; font-size: 0; }
.note { margin-top: 18px; padding-top: 4px; border-top: 1px solid var(--line); }
.note p, .note li { max-width: 68ch; }
.note ul { padding-left: 1.2em; }
.related { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; list-style: none; }
.related a { display: inline-block; padding: 4px 10px; border: 1px solid var(--line); border-radius: 99px; text-decoration: none; font-size: .88rem; color: var(--ink); }
.related a:hover { border-color: var(--accent); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; padding: 0; list-style: none; }
.cards a { display: block; height: 100%; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-decoration: none; color: var(--ink); }
.cards a:hover { border-color: var(--accent); transform: translateY(-2px); }
.cards b { display: block; font-size: 1.05rem; } .cards span { color: var(--muted); font-size: .9rem; }
footer.site { margin-top: 36px; padding: 18px 0 30px; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
footer.site a { color: var(--muted); margin-right: 12px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
