/* ==========================================================================
   ImageEdit — shared tool page styles (loaded after style.css on /tools/*)
   Contents:
     1. Tool hero + breadcrumb
     2. App shell: upload zone, workspace, panels
     3. Preview: stage, compare slider, file list
     4. Controls: fields, ranges, chips, segmented, switches
     5. Results: stats, actions, progress, busy overlay, alerts
     6. Content: how-to steps, features, article, related, privacy note
   ========================================================================== */

/* 1. TOOL HERO & BREADCRUMB --------------------------------------------- */
.tool-hero { position: relative; isolation: isolate; padding: clamp(20px, 3vw, 36px) 0 clamp(40px, 6vw, 72px); }
.tool-hero::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 420px; z-index: -1; pointer-events: none;
  background:
    radial-gradient(600px 300px at 10% 0%, rgb(var(--cat-compress) / .14), transparent 70%),
    radial-gradient(500px 280px at 95% 0%, rgb(255 93 115 / .10), transparent 70%);
}
.breadcrumb ol { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: .875rem; color: var(--text-soft); }
.breadcrumb li { display: inline-flex; align-items: center; gap: 4px; }
.breadcrumb li + li::before {
  content: ""; width: 14px; height: 14px; opacity: .7;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
}
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--primary); text-decoration: underline; }
.breadcrumb [aria-current="page"] { color: var(--text); font-weight: 600; }

.tool-head { display: flex; gap: 18px; align-items: flex-start; margin: 22px 0 26px; }
.tool-head .tile { width: 56px; height: 56px; border-radius: 16px; }
.tool-head .tile .ico { width: 28px; height: 28px; }
.tool-head h1 { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.75rem); margin-bottom: 8px; }
.tool-intro { color: var(--text-muted); font-size: 1.05rem; max-width: 760px; margin: 0; }
.tool-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.tool-badges span {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px;
  font-size: .8rem; font-weight: 600; color: var(--text-muted); background: var(--surface); border: 1px solid var(--border);
}
.tool-badges .ico { width: 15px; height: 15px; color: var(--success); }
@media (max-width: 599.98px) { .tool-head .tile { display: none; } }

/* 2. APP SHELL ----------------------------------------------------------- */
.tool-app {
  position: relative;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg); padding: clamp(14px, 2.5vw, 24px);
}

/* Upload zone */
.upload-zone {
  position: relative; display: grid; place-items: center; gap: 12px; text-align: center;
  min-height: 300px; padding: 36px 20px;
  border: 2px dashed var(--border-strong); border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 50% 0%, rgb(var(--cat-compress) / .07), transparent 60%),
    var(--surface-2);
  cursor: pointer;
  transition: border-color .2s, background-color .2s, transform .2s var(--ease);
}
.upload-zone:hover { border-color: var(--primary); }
.upload-zone.is-dragover { border-color: var(--primary); background-color: var(--primary-soft); transform: scale(1.005); }
.upload-zone.is-dragover .upload-icon { transform: translateY(-6px) scale(1.06); }
.upload-icon {
  display: grid; place-items: center; width: 72px; height: 72px; border-radius: 22px;
  background: var(--grad); color: #fff; box-shadow: 0 16px 34px -14px rgba(164, 66, 255, .85);
  transition: transform .3s var(--ease);
}
.upload-icon .ico { width: 32px; height: 32px; stroke-width: 2; }
.upload-title { font-family: var(--font-head); font-weight: 800; font-size: clamp(1.15rem, 1rem + .6vw, 1.4rem); margin: 0; }
.upload-hint { margin: 0; color: var(--text-muted); font-size: .95rem; }
.upload-meta { margin: 0; color: var(--text-soft); font-size: .825rem; }
.upload-zone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-zone .btn { margin-top: 4px; }
.upload-zone-sm { min-height: 140px; padding: 20px; }
.upload-zone-sm .upload-icon { width: 48px; height: 48px; border-radius: 14px; }
.upload-zone-sm .upload-icon .ico { width: 22px; height: 22px; }

/* Workspace: preview + controls */
.workspace { display: grid; gap: 18px; }
.workspace > * { min-width: 0; }
.controls-panel .btn { white-space: normal; text-align: center; }
@media (min-width: 1024px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
  .workspace.controls-wide { grid-template-columns: minmax(0, 1fr) 380px; }
  .controls-panel { position: sticky; top: calc(var(--header-h) + 16px); }
}
.panel { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.panel-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.panel-title { margin: 0; font-family: var(--font-head); font-weight: 700; font-size: .95rem; display: flex; align-items: center; gap: 8px; }
.panel-title .ico { width: 18px; height: 18px; color: var(--primary); }
.panel-body { padding: 16px; }
.controls-panel .panel-body { display: grid; gap: 18px; }

/* 3. PREVIEW ------------------------------------------------------------- */
.preview-stage {
  position: relative; display: grid; place-items: center; overflow: hidden;
  min-height: 280px; max-height: 70vh; padding: 12px;
  border-radius: var(--radius);
  background-color: var(--surface-2);
  background-image:
    linear-gradient(45deg, var(--surface-3) 25%, transparent 25%),
    linear-gradient(-45deg, var(--surface-3) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--surface-3) 75%),
    linear-gradient(-45deg, transparent 75%, var(--surface-3) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.preview-stage.plain { background-image: none; }
.preview-stage > img, .preview-stage > canvas {
  max-width: 100%; max-height: calc(70vh - 24px); width: auto; height: auto; object-fit: contain;
  border-radius: 6px; box-shadow: var(--shadow);
}
.preview-caption { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 14px; margin-top: 10px; font-size: .85rem; color: var(--text-muted); }
.preview-caption b { color: var(--text); font-weight: 600; }

/* Before/after compare slider:
   <div class="compare" style="--pos:50%">
     <img class="compare-before"> <img class="compare-after">
     <input type="range" class="compare-range" aria-label="Compare before and after">
     <span class="compare-label before">Before</span><span class="compare-label after">After</span>
   </div> */
.compare { --pos: 50%; position: relative; display: inline-block; max-width: 100%; line-height: 0; border-radius: 8px; overflow: hidden; box-shadow: var(--shadow); user-select: none; touch-action: pan-y; }
.compare img, .compare canvas { display: block; max-width: 100%; max-height: calc(70vh - 24px); width: auto; height: auto; }
.compare-after { position: absolute; inset: 0; width: 100% !important; height: 100% !important; max-height: none !important; clip-path: inset(0 0 0 var(--pos)); }
/* Transparent results must not show the "before" image through them */
.compare-after.checker {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #e6e3ef 25%, transparent 25%), linear-gradient(-45deg, #e6e3ef 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e6e3ef 75%), linear-gradient(-45deg, transparent 75%, #e6e3ef 75%);
  background-size: 18px 18px; background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}
.compare::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: var(--pos); width: 2px; margin-left: -1px;
  background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.15); pointer-events: none;
}
.compare-handle {
  position: absolute; top: 50%; left: var(--pos); z-index: 2; width: 40px; height: 40px; margin: -20px 0 0 -20px;
  display: grid; place-items: center; border-radius: 50%; background: #fff; color: #3a1fd0; box-shadow: var(--shadow-lg); pointer-events: none;
}
.compare-handle .ico { width: 20px; height: 20px; }
.compare-range { position: absolute; inset: 0; z-index: 3; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize; }
.compare-range:focus-visible + .compare-handle { outline: 3px solid var(--focus); outline-offset: 2px; }
.compare-label {
  position: absolute; top: 10px; z-index: 1; padding: 4px 9px; border-radius: 8px;
  font: 700 .72rem/1.4 var(--font-body); letter-spacing: .04em; text-transform: uppercase;
  color: #fff; background: rgba(13, 11, 28, .65); pointer-events: none;
}
.compare-label.before { left: 10px; }
.compare-label.after { right: 10px; }

/* Batch file list */
.file-list { display: grid; gap: 10px; }
.file-item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 8px 10px 8px 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  transition: border-color .2s, box-shadow .2s;
}
.file-select {
  display: grid; grid-template-columns: 56px minmax(0, 1fr); align-items: center; gap: 12px;
  min-width: 0; padding: 2px; border-radius: 10px; text-align: left; color: var(--text);
}
.file-select > span { min-width: 0; display: grid; gap: 2px; }
.file-status { display: inline-flex; align-items: center; gap: 6px; }
.file-status.ok { color: var(--success); font-weight: 600; }
.file-status.err { color: var(--danger); font-weight: 600; }
.file-status.warn { color: var(--warning); font-weight: 600; }

/* Workspace column + framing canvas */
.ws-main { display: grid; gap: 18px; min-width: 0; align-content: start; }
.framer { display: block; touch-action: none; cursor: grab; border-radius: 6px; box-shadow: var(--shadow); background: var(--surface); }
.framer.is-dragging { cursor: grabbing; }
.framer:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.frame-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; }
.frame-tools .range { width: min(220px, 50vw); }
.frame-tools .icon-btn { width: 38px; height: 38px; border-radius: 10px; }
.result-figure { margin: 0; display: grid; gap: 8px; justify-items: center; padding: 12px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.result-figure img { max-width: 100%; max-height: 200px; width: auto; border: 1px solid var(--border-strong); background: #fff; }
.result-figure figcaption { font-size: .78rem; color: var(--text-soft); text-align: center; }
.spec-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.spec-chips span { padding: 4px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); font-size: .8rem; font-weight: 600; color: var(--text-muted); }
.file-item.is-active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.file-thumb { display: block; width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--surface-2); }
.file-name { font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: .8rem; color: var(--text-muted); }
.file-actions { display: flex; gap: 6px; }
.file-actions .icon-btn { width: 36px; height: 36px; border-radius: 10px; }
.file-actions .icon-btn .ico { width: 17px; height: 17px; }
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 12px; }
.file-card {
  position: relative; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface);
}
.file-card img, .file-card canvas { width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--surface-2); }
.file-card-body { padding: 8px 10px; font-size: .78rem; color: var(--text-muted); }
.file-card .file-name { font-size: .82rem; }
.file-card .icon-btn { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border-radius: 9px; }
.file-card[draggable="true"] { cursor: grab; }
.file-card.is-dragging { opacity: .45; }
.file-card.is-drop-target { outline: 3px dashed var(--primary); outline-offset: 2px; }
.file-card-actions { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 6px; }
.file-card-actions .mini { width: 30px; height: 30px; border-radius: 8px; position: static; }
.file-card-actions .mini .ico { width: 16px; height: 16px; }
.file-card .btn-sm { width: 100%; margin-top: 6px; }

/* Canvas editors (redact, meme, watermark preview) */
.editor-canvas { display: block; max-width: 100%; touch-action: none; border-radius: 6px; box-shadow: var(--shadow); cursor: crosshair; }
.editor-canvas.is-move { cursor: move; }
.editor-canvas:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.preset-btn { display: grid; gap: 4px; padding: 4px; border-radius: 12px; border: 2px solid transparent; background: var(--surface-2); font-size: .75rem; font-weight: 600; color: var(--text-muted); text-align: center; }
.preset-btn img, .preset-btn canvas { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
.preset-btn[aria-pressed="true"] { border-color: var(--primary-strong); color: var(--primary); }
.preset-btn:hover { color: var(--text); }
.item-list { display: grid; gap: 10px; }
.item-card { display: grid; gap: 8px; padding: 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); }
.item-card.is-active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.item-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .82rem; font-weight: 700; color: var(--text-soft); text-transform: uppercase; letter-spacing: .05em; }
.item-card-head .icon-btn { width: 32px; height: 32px; border-radius: 9px; }
.item-card-head .icon-btn .ico { width: 16px; height: 16px; }
.inline-fields { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.inline-fields input[type="color"] { width: 44px; height: 36px; padding: 2px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; }
.inline-fields label { font-size: .8rem; color: var(--text-muted); display: inline-flex; align-items: center; gap: 6px; }

/* Favicon preview */
.browser-mock { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface-2); max-width: 420px; }
.bm-tab { display: inline-flex; align-items: center; gap: 8px; margin: 8px 0 0 10px; padding: 8px 12px; border-radius: 10px 10px 0 0; background: var(--surface); font-size: .8rem; color: var(--text); }
.bm-tab canvas { width: 16px; height: 16px; }
.bm-tab i { font-style: normal; color: var(--text-soft); margin-left: 18px; }
.bm-bar { padding: 8px 12px; background: var(--surface); border-top: 1px solid var(--border); font-size: .8rem; color: var(--text-soft); }
.icon-sizes { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; }
.icon-sizes figure { margin: 0; display: grid; justify-items: center; gap: 6px; padding: 10px; border-radius: 12px; border: 1px solid var(--border);
  background-color: var(--surface); background-image: linear-gradient(45deg, var(--surface-3) 25%, transparent 25%), linear-gradient(-45deg, var(--surface-3) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--surface-3) 75%), linear-gradient(-45deg, transparent 75%, var(--surface-3) 75%);
  background-size: 12px 12px; background-position: 0 0, 0 6px, 6px -6px, -6px 0; }
.icon-sizes figcaption { font-size: .72rem; font-weight: 600; color: var(--text-muted); background: var(--surface); padding: 1px 6px; border-radius: 6px; }

/* Colour picker */
.picker-stage { position: relative; }
.loupe { position: absolute; width: 132px; height: 132px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 6px 20px rgba(0,0,0,.35); pointer-events: none; overflow: hidden; z-index: 5; image-rendering: pixelated; }
.loupe canvas { width: 100%; height: 100%; image-rendering: pixelated; }
.loupe::after { content: ""; position: absolute; left: 50%; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.7); }
.color-readout { display: grid; grid-template-columns: 72px 1fr; gap: 14px; align-items: center; }
.color-big { width: 72px; height: 72px; border-radius: 16px; border: 1px solid var(--border-strong); box-shadow: inset 0 0 0 1px rgba(0,0,0,.05); }
.code-rows { display: grid; gap: 6px; }
.code-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 6px 6px 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-family: var(--font-mono); font-size: .85rem; }
.code-row span b { font-family: var(--font-body); font-size: .72rem; color: var(--text-soft); margin-right: 6px; }
.code-row .icon-btn { width: 30px; height: 30px; border-radius: 8px; }
.code-row .icon-btn .ico { width: 15px; height: 15px; }
.swatch-btn { display: grid; gap: 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); text-align: left; transition: transform .15s var(--ease), box-shadow .15s; }
.swatch-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.swatch-btn > span:first-child { height: 64px; }
.swatch-btn > span:last-child { padding: 6px 8px; font: 600 .78rem var(--font-mono); color: var(--text); }
.history { display: flex; flex-wrap: wrap; gap: 6px; }
.history button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border-strong); }

/* Tabs (Base64 tool etc.) */
.tablist { display: inline-flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 18px; max-width: 100%; overflow-x: auto; }
.tab { min-height: 40px; padding: 8px 16px; border-radius: 10px; font-family: var(--font-head); font-weight: 700; font-size: .92rem; color: var(--text-muted); white-space: nowrap; }
.tab[aria-selected="true"] { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.tab:hover { color: var(--text); }
.two-col { display: grid; gap: 18px; }
@media (min-width: 900px) { .two-col { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: .9rem; }
.kv dt { color: var(--text-soft); font-weight: 600; }
.kv dd { margin: 0; color: var(--text); word-break: break-word; }

/* Cropper stage */
.crop-stage { position: relative; height: min(62vh, 560px); min-height: 280px; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.crop-stage img { display: block; max-width: 100%; }
.tool-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tool-row .icon-btn { width: 40px; height: 40px; }
.file-card .order {
  position: absolute; top: 6px; left: 6px; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 8px;
  display: grid; place-items: center; font-size: .75rem; font-weight: 700; color: #fff; background: rgba(13, 11, 28, .7);
}

/* 4. CONTROLS ------------------------------------------------------------ */
.field { display: grid; gap: 8px; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.label, .field > label, .field-label {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: .85rem; font-weight: 600; color: var(--text);
}
.label output, .field-label output, .field > label output { font-family: var(--font-mono); font-size: .8rem; font-weight: 600; color: var(--primary); background: var(--primary-soft); padding: 2px 8px; border-radius: 7px; }
.help { margin: 0; font-size: .8rem; color: var(--text-soft); }
.group-title { margin: 0; font-family: var(--font-head); font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-soft); }

.input, .select, .textarea {
  width: 100%; min-height: 42px; padding: 9px 12px;
  border: 1px solid var(--border-strong); border-radius: 11px;
  background: var(--surface); color: var(--text); font-size: .95rem;
  transition: border-color .18s, box-shadow .18s;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.input::placeholder, .textarea::placeholder { color: var(--text-soft); opacity: 1; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a85a8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 18px;
}
.textarea { min-height: 140px; resize: vertical; line-height: 1.5; }
.textarea.mono, .input.mono { font-family: var(--font-mono); font-size: .85rem; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group .addon {
  display: grid; place-items: center; padding: 0 12px; font-size: .85rem; font-weight: 600; color: var(--text-muted);
  border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 11px 11px 0; background: var(--surface-2);
}
input[type="color"].input { padding: 4px; height: 42px; cursor: pointer; }

/* Range slider */
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; cursor: pointer; --val: 50%; }
.range::-webkit-slider-runnable-track { height: 6px; border-radius: 99px; background: linear-gradient(90deg, var(--primary-strong) var(--val), var(--surface-3) var(--val)); }
.range::-moz-range-track { height: 6px; border-radius: 99px; background: var(--surface-3); }
.range::-moz-range-progress { height: 6px; border-radius: 99px; background: var(--primary-strong); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 20px; height: 20px; margin-top: -7px; border-radius: 50%;
  background: #fff; border: 3px solid var(--primary-strong); box-shadow: 0 2px 6px rgba(0,0,0,.25); transition: transform .15s;
}
.range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--primary-strong); box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.range:active::-webkit-slider-thumb { transform: scale(1.15); }
.range:focus-visible { outline: none; }
.range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 5px var(--primary-soft-2); }
.range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 5px var(--primary-soft-2); }

/* Chips (presets) — use <button class="chip" aria-pressed="true|false"> */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 13px;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface);
  font-size: .85rem; font-weight: 600; color: var(--text);
  transition: border-color .15s, background-color .15s, color .15s;
}
.chip small { color: var(--text-soft); font-weight: 500; }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip[aria-pressed="true"], .chip.is-active { background: var(--primary-strong); border-color: transparent; color: #fff; }
.chip[aria-pressed="true"] small, .chip.is-active small { color: rgba(255,255,255,.85); }
.chips-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.chips-grid .chip { flex-direction: column; align-items: flex-start; gap: 0; padding: 9px 12px; text-align: left; line-height: 1.35; }

/* Segmented control — radio inputs:
   <div class="seg" role="radiogroup"><label><input type="radio" name="x" checked><span>PX</span></label>…</div> */
.seg { display: flex; padding: 4px; gap: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.seg label { flex: 1; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span {
  display: grid; place-items: center; min-height: 34px; padding: 4px 8px; border-radius: 9px;
  font-size: .85rem; font-weight: 600; color: var(--text-muted); transition: background-color .15s, color .15s, box-shadow .15s;
}
.seg input:checked + span { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.seg input:disabled + span { opacity: .45; cursor: not-allowed; }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }

/* Switch — <label class="switch"><input type="checkbox"><span class="switch-ui"></span>Text</label> */
.switch { display: flex; align-items: center; gap: 10px; font-size: .9rem; font-weight: 500; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { position: relative; flex: none; width: 42px; height: 24px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--border-strong); transition: background-color .2s; }
.switch-ui::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s var(--ease); }
.switch input:checked + .switch-ui { background: var(--primary-strong); border-color: transparent; }
.switch input:checked + .switch-ui::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-ui { outline: 3px solid var(--focus); outline-offset: 2px; }

/* 9-position grid (watermark etc.) */
.pos-grid { display: grid; grid-template-columns: repeat(3, 40px); gap: 6px; }
.pos-grid button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); position: relative; }
.pos-grid button::after { content: ""; position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px; border-radius: 50%; background: var(--border-strong); }
.pos-grid button[aria-pressed="true"] { background: var(--primary-strong); border-color: transparent; }
.pos-grid button[aria-pressed="true"]::after { background: #fff; }

/* 5. RESULTS ------------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.stat { padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.stat-label { display: block; font-size: .75rem; font-weight: 600; color: var(--text-soft); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { display: block; margin-top: 2px; font-family: var(--font-head); font-weight: 800; font-size: 1.15rem; color: var(--text); }
.stat.good { background: var(--success-soft); border-color: transparent; }
.stat.good .stat-value { color: var(--success); }
.save-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; color: var(--success); background: var(--success-soft); }
.save-badge.up { color: var(--warning); background: var(--warning-soft); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions .btn { flex: 1 1 auto; }
.actions-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border);
}

.progress { position: relative; height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > span { position: absolute; inset: 0 auto 0 0; width: var(--p, 0%); border-radius: inherit; background: var(--grad); transition: width .25s ease; }
.progress.indeterminate > span { width: 35%; animation: indeterminate 1.2s ease-in-out infinite; }
@keyframes indeterminate { 0% { left: -35%; } 100% { left: 100%; } }

.spinner { width: 40px; height: 40px; border-radius: 50%; border: 4px solid var(--surface-3); border-top-color: var(--primary-strong); animation: spin .8s linear infinite; }
.spinner-sm { width: 18px; height: 18px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: spin 1.6s linear infinite !important; } }

.busy-overlay {
  position: absolute; inset: 0; z-index: 20; display: grid; place-content: center; justify-items: center; gap: 14px;
  padding: 24px; text-align: center; border-radius: inherit;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
@supports not (background: color-mix(in srgb, red 50%, transparent)) { .busy-overlay { background: var(--surface); opacity: .95; } }
.busy-overlay p { margin: 0; font-weight: 600; color: var(--text); }
.busy-overlay small { color: var(--text-muted); }
.busy-overlay .progress { width: min(280px, 70vw); }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); font-size: .9rem; border: 1px solid transparent; }
.alert .ico { width: 20px; height: 20px; margin-top: 1px; }
.alert p { margin: 0; }
.alert-info { background: var(--primary-soft); color: var(--text); }
.alert-info .ico { color: var(--primary); }
.alert-warn { background: var(--warning-soft); color: var(--text); }
.alert-warn .ico { color: var(--warning); }
.alert-error { background: var(--danger-soft); color: var(--text); }
.alert-error .ico { color: var(--danger); }
.alert-success { background: var(--success-soft); color: var(--text); }
.alert-success .ico { color: var(--success); }

.output-box { position: relative; }
.output-box .btn { position: absolute; top: 8px; right: 8px; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }

/* 6. CONTENT ------------------------------------------------------------- */
.tool-section { padding-block: clamp(40px, 5vw, 72px); }
.tool-section + .tool-section { padding-top: 0; }
.tool-section h2 { margin-bottom: 18px; font-size: clamp(1.4rem, 1.15rem + 1vw, 1.9rem); }
.tool-section:last-child { padding-bottom: 0; }
.how-steps { display: grid; gap: 14px; counter-reset: how; }
@media (min-width: 768px) { .how-steps { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .how-steps.cols-4 { grid-template-columns: repeat(4, 1fr); } }
.how-steps li {
  position: relative; padding: 18px 18px 18px 64px; border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--border); color: var(--text-muted);
}
.how-steps li::before {
  counter-increment: how; content: counter(how);
  position: absolute; left: 18px; top: 18px; width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center; font-family: var(--font-head); font-weight: 800; color: #fff; background: var(--grad);
}
.how-steps strong { display: block; color: var(--text); font-family: var(--font-head); margin-bottom: 2px; }

.feature-list { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.feature-list li { display: flex; gap: 12px; padding: 18px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); }
.feature-list .tile { width: 40px; height: 40px; border-radius: 11px; }
.feature-list h3 { font-size: 1rem; margin: 0 0 4px; }
.feature-list p { margin: 0; color: var(--text-muted); font-size: .92rem; }

.article { max-width: 820px; }
.article h2 { margin-top: 0; }
.article h3 { margin-top: 1.5em; }
.article p, .article li { color: var(--text-muted); }
.article ul { padding-left: 1.2em; }
.article strong { color: var(--text); }
.tool-layout { display: grid; gap: 32px; }
@media (min-width: 1100px) { .tool-layout { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; } .tool-aside { position: sticky; top: calc(var(--header-h) + 20px); } }
.aside-card { padding: 20px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); }
.aside-card h2 { font-size: 1rem; margin-bottom: 12px; }
.aside-card li + li { margin-top: 4px; }
.aside-card a { display: flex; align-items: center; gap: 10px; padding: 7px 8px; margin-inline: -8px; border-radius: 10px; color: var(--text); text-decoration: none; font-size: .92rem; font-weight: 500; }
.aside-card a:hover { background: var(--surface-2); color: var(--primary); }
.aside-card a .ico { width: 18px; height: 18px; color: rgb(var(--cat, var(--cat-compress))); }

.tool-faq .faq { margin-inline: 0; max-width: 860px; }

.privacy-note {
  display: flex; align-items: center; gap: 16px; padding: 20px 22px; border-radius: var(--radius-lg);
  background: var(--success-soft); border: 1px solid rgb(var(--cat-privacy) / .25);
}
.privacy-note .tile { --cat: var(--cat-privacy); background: rgb(var(--cat-privacy) / .16); }
.privacy-note p { margin: 0; color: var(--text); font-weight: 500; }
.privacy-note strong { font-family: var(--font-head); }
