/* ---------- tokens ---------- */
:root {
  --bg: #0c0c0a;
  --surface: #121210;
  --surface-2: #191916;
  --surface-3: #22221e;
  --line: #24241f;
  --line-2: #33332d;
  --text: #f1f0e8;
  --muted: #a3a296;
  --faint: #6f6e64;
  --accent: #d4f53c;
  --accent-ink: #141700;
  --accent-text: #d4f53c;
  --accent-soft: rgba(212, 245, 60, 0.1);
  --danger: #ff6a55;
  --danger-soft: rgba(255, 106, 85, 0.12);
  --warn: #f5b83c;
  --warn-soft: rgba(245, 184, 60, 0.12);
  --checker-a: #1a1a17;
  --checker-b: #141412;
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.7);
  --radius: 14px;
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Consolas, monospace;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f2f1eb;
    --surface: #fbfaf6;
    --surface-2: #f0eee6;
    --surface-3: #e6e4da;
    --line: #e1dfd5;
    --line-2: #cfccc0;
    --text: #161612;
    --muted: #63625a;
    --faint: #8f8d83;
    --accent: #c9ef2a;
    --accent-ink: #141700;
    --accent-text: #4b6600;
    --accent-soft: rgba(110, 150, 0, 0.1);
    --danger: #d4381f;
    --danger-soft: rgba(212, 56, 31, 0.08);
    --warn: #a86a00;
    --warn-soft: rgba(168, 106, 0, 0.1);
    --checker-a: #e9e7df;
    --checker-b: #f6f5f0;
    --shadow: 0 24px 60px -24px rgba(40, 38, 20, 0.35);
    color-scheme: light;
  }
}

:root[data-theme="light"] {
  --bg: #f2f1eb;
  --surface: #fbfaf6;
  --surface-2: #f0eee6;
  --surface-3: #e6e4da;
  --line: #e1dfd5;
  --line-2: #cfccc0;
  --text: #161612;
  --muted: #63625a;
  --faint: #8f8d83;
  --accent: #c9ef2a;
  --accent-ink: #141700;
  --accent-text: #4b6600;
  --accent-soft: rgba(110, 150, 0, 0.1);
  --danger: #d4381f;
  --danger-soft: rgba(212, 56, 31, 0.08);
  --warn: #a86a00;
  --warn-soft: rgba(168, 106, 0, 0.1);
  --checker-a: #e9e7df;
  --checker-b: #f6f5f0;
  --shadow: 0 24px 60px -24px rgba(40, 38, 20, 0.35);
  color-scheme: light;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent); color: var(--accent-ink); }

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 0.4em;
  margin: 0 1px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 5px;
  font: 500 11px/1.6 var(--mono);
  color: var(--muted);
  text-align: center;
  background: var(--surface-2);
}

/* icons drawn with stroke */
.icon-btn svg, .btn svg, .privacy-pill svg, .note svg, .drop-glyph svg, .drop-overlay-card svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- shell ---------- */
.shell {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.02em;
}
.brand-mark { width: 28px; height: 28px; }
.brand-mark rect { fill: var(--text); }
.brand-mark path { fill: none; stroke: var(--accent); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
:root[data-theme="light"] .brand-mark path { stroke: var(--accent); }
.brand-domain { color: var(--faint); font-weight: 400; margin-left: -9px; }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--muted);
  background: var(--surface);
}
.privacy-pill svg { width: 15px; height: 15px; color: var(--accent-text); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.icon-btn:hover:not(:disabled) { color: var(--text); border-color: var(--line-2); background: var(--surface-2); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn.danger:hover:not(:disabled) { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }

#themeToggle .i-sun { display: none; }
:root[data-theme="light"] #themeToggle .i-sun { display: block; }
:root[data-theme="light"] #themeToggle .i-moon { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) #themeToggle .i-sun { display: block; }
  :root:not([data-theme="dark"]) #themeToggle .i-moon { display: none; }
}

.workspace {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

/* ---------- settings ---------- */
.settings {
  border-right: 1px solid var(--line);
  padding: 8px 22px 22px;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
}

.group {
  padding: 18px 0 20px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 14px;
}

.group-title {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}
.group-title .idx { font: 500 11px var(--mono); color: var(--faint); letter-spacing: 0; }

.field { display: grid; gap: 10px; }
.field-row { display: flex; justify-content: space-between; align-items: baseline; }
.field-row label { color: var(--muted); font-size: 13px; }
.field-row output { font: 500 15px var(--mono); color: var(--text); }

/* segmented control */
.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}
.seg label { position: relative; }
.seg input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.seg span {
  display: grid;
  place-items: center;
  height: 32px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  pointer-events: none;
}
.seg label:hover span { color: var(--text); }
.seg input:checked + span {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line-2), 0 1px 2px rgba(0, 0, 0, 0.2);
}
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg input:disabled + span { opacity: 0.35; text-decoration: line-through; }
.seg-sm span { height: 28px; font-size: 12.5px; }

/* range */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  --pct: 50%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(to right, var(--accent) var(--pct), var(--surface-3) var(--pct));
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--surface-3); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--text);
  border: 4px solid var(--bg);
  box-shadow: 0 0 0 1px var(--line-2);
}
input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text);
  border: 4px solid var(--bg);
  box-shadow: 0 0 0 1px var(--line-2);
}
.range-legend {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: var(--faint);
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12px;
  text-decoration: underline;
  text-decoration-color: var(--line-2);
  text-underline-offset: 3px;
}
.link-btn:hover { color: var(--text); text-decoration-color: currentColor; }
.link-btn:disabled { visibility: hidden; }

/* number with unit */
.input-unit {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  cursor: text;
  transition: border-color 0.15s;
}
.input-unit:focus-within { border-color: var(--line-2); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-unit-label { font-size: 13px; color: var(--muted); white-space: nowrap; }
.input-unit input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  outline: none;
  text-align: right;
  font: 500 16px var(--mono);
  -moz-appearance: textfield;
}
.input-unit input::-webkit-outer-spin-button,
.input-unit input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input-unit-suffix { font: 500 13px var(--mono); color: var(--faint); }

.text-input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font: 500 14px var(--mono);
  outline: none;
  transition: border-color 0.15s;
}
.text-input:focus { border-color: var(--line-2); box-shadow: 0 0 0 3px var(--accent-soft); }
.text-input:disabled { opacity: 0.4; }

/* switch rows */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 13.5px;
  cursor: pointer;
}
.switch-row > span { display: grid; gap: 1px; }
.switch-row small { font-size: 12px; color: var(--faint); }
.switch {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  position: relative;
  width: 36px;
  height: 21px;
  margin: 0;
  border-radius: 999px;
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--line-2);
  cursor: pointer;
  transition: background 0.18s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s cubic-bezier(0.3, 0.7, 0.4, 1.2), background 0.18s;
}
.switch:checked { background: var(--accent); box-shadow: none; }
.switch:checked::after { transform: translateX(15px); background: var(--accent-ink); }

.name-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 12px;
  color: var(--faint);
  min-width: 0;
}
.name-preview code {
  font: 500 12.5px var(--mono);
  color: var(--accent-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.note.warn { color: var(--warn); background: var(--warn-soft); padding: 8px 10px; border-radius: 9px; }
.note.subtle { color: var(--faint); }

.settings-foot { padding-top: 18px; display: grid; gap: 8px; justify-items: start; }
.settings-foot .note:first-child { display: flex; gap: 8px; align-items: flex-start; }
.settings-foot .note svg { width: 16px; height: 16px; flex: none; color: var(--accent-text); margin-top: 1px; }
.settings-foot .link-btn { margin-top: 6px; }

/* ---------- queue ---------- */
.queue {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.queue-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 28px 18px;
  border-bottom: 1px solid var(--line);
}

.stats { display: flex; gap: 34px; margin: 0; flex-wrap: wrap; }
.stats div { display: grid; gap: 2px; }
.stats dt { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.stats dd { margin: 0; font: 500 22px/1.2 var(--mono); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-saved dd { color: var(--accent-text); }
.stat-saved.worse dd { color: var(--danger); }

.queue-head-actions { display: flex; gap: 8px; }

.queue-body {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 20px 28px;
  min-height: 0;
  scrollbar-width: thin;
}

/* empty dropzone */
.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 320px;
  flex: 1;
  border-radius: 20px;
  cursor: pointer;
  isolation: isolate;
  overflow: hidden;
  outline: none;
}
.dropzone::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(var(--line-2) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: radial-gradient(ellipse at center, #000 10%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at center, #000 10%, transparent 70%);
  opacity: 0.7;
}
.dropzone::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(circle at 50% 45%, var(--accent-soft), transparent 55%);
  opacity: 0;
  transition: opacity 0.3s;
}
.dropzone:hover::after, .dropzone:focus-visible::after, body.dragging .dropzone::after { opacity: 1; }

.dropzone-border {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.dropzone-border rect {
  fill: none;
  stroke: var(--line-2);
  stroke-width: 1.5;
  stroke-dasharray: 8 8;
  transition: stroke 0.2s;
}
.dropzone:hover .dropzone-border rect,
.dropzone:focus-visible .dropzone-border rect,
body.dragging .dropzone-border rect {
  stroke: var(--accent);
  animation: march 1.2s linear infinite;
}
@keyframes march { to { stroke-dashoffset: -32; } }

.dropzone-inner { text-align: center; padding: 40px 24px; display: grid; justify-items: center; }
.dropzone h1 {
  margin: 28px 0 8px;
  font-size: clamp(26px, 3.4vw, 40px);
  line-height: 1.05;
  font-weight: 600;
  letter-spacing: -0.035em;
}
.dropzone p { margin: 0; color: var(--muted); font-size: 15px; }
.fake-link { color: var(--text); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 4px; }

.drop-glyph { position: relative; width: 120px; height: 96px; }
.drop-glyph .tile {
  position: absolute;
  width: 62px;
  height: 74px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  transition: transform 0.4s cubic-bezier(0.3, 0.7, 0.3, 1.3);
}
.drop-glyph .t1 { left: 4px; top: 14px; transform: rotate(-12deg); }
.drop-glyph .t3 { right: 4px; top: 14px; transform: rotate(12deg); }
.drop-glyph .t2 { left: 29px; top: 4px; background: var(--surface-3); z-index: 1; }
.drop-glyph svg {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 41px;
  width: 26px;
  height: 26px;
  transform: translate(-50%, -50%);
  color: var(--text);
  stroke-width: 2;
}
.dropzone:hover .t1, body.dragging .t1 { transform: rotate(-20deg) translate(-8px, 2px); }
.dropzone:hover .t3, body.dragging .t3 { transform: rotate(20deg) translate(8px, 2px); }
.dropzone:hover .t2, body.dragging .t2 { transform: translateY(-6px); background: var(--accent); border-color: var(--accent); }
.dropzone:hover .drop-glyph svg, body.dragging .drop-glyph svg { color: var(--accent-ink); top: 35px; }

.formats { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 26px 0 0; padding: 0; }
.formats li {
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font: 500 11px var(--mono);
  color: var(--faint);
  background: var(--surface);
}

/* rows */
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) minmax(170px, 230px) auto;
  align-items: center;
  gap: 18px;
  padding: 10px 12px 10px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.2s, background 0.2s;
  animation: rowIn 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.row:hover { border-color: var(--line-2); }
@keyframes rowIn { from { opacity: 0; transform: translateY(6px); } }

.thumb {
  position: relative;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  overflow: hidden;
  background: repeating-conic-gradient(var(--checker-a) 0 25%, var(--checker-b) 0 50%) 0 0 / 12px 12px;
  cursor: zoom-in;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.3s; }
.thumb:hover img { transform: scale(1.06); }
.thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.row-main { min-width: 0; display: grid; gap: 4px; }
.row-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 500;
  font-size: 14px;
}
.row-name .src { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  font: 400 12px var(--mono);
  color: var(--faint);
  min-width: 0;
}
.row-meta .arrow { color: var(--line-2); }
.row-meta .out-name {
  color: var(--accent-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.row[data-status="stale"] .row-meta .out-name { color: var(--muted); }

.pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  font: 500 11px/18px var(--mono);
  color: var(--faint);
  background: var(--surface-2);
  white-space: nowrap;
}
.pill.working { color: var(--text); }
.pill.working::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid var(--line-2);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
.pill.stale { color: var(--warn); background: var(--warn-soft); }
.pill.error { color: var(--danger); background: var(--danger-soft); }
@keyframes spin { to { transform: rotate(360deg); } }

.row-size { display: grid; gap: 7px; }
.size-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font: 400 12px var(--mono);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.size-line .delta { font-weight: 500; font-size: 13px; color: var(--accent-text); }
.size-line .delta.worse { color: var(--danger); }
.size-line .delta.same { color: var(--muted); }
.bar {
  position: relative;
  height: 6px;
  border-radius: 6px;
  background: var(--surface-3);
  overflow: hidden;
}
.bar span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.bar.worse span { background: var(--danger); }
.bar.pending span { width: 100% !important; background: var(--line-2); opacity: 0.5; }
.row[data-status="working"] .bar span {
  width: 40% !important;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: scan 1s ease-in-out infinite;
}
@keyframes scan { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

.row-error { font-size: 12px; color: var(--danger); }

.row-actions { display: flex; gap: 6px; }
.row-actions .icon-btn.go { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.row-actions .icon-btn.go:hover:not(:disabled) { color: var(--accent-ink); background: var(--accent); filter: brightness(1.08); }

.row[data-status="error"] { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }

/* foot */
.queue-foot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
}
.foot-status { margin: 0; font-size: 13px; color: var(--muted); }
.foot-actions { display: flex; gap: 8px; }
.progress { position: absolute; left: 0; right: 0; top: -1px; height: 2px; background: transparent; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.3s; box-shadow: 0 0 12px var(--accent); }

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border: 1px solid var(--line-2);
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, filter 0.15s;
}
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn svg { width: 17px; height: 17px; stroke-width: 2; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn.ghost:hover:not(:disabled) { color: var(--text); border-color: var(--line-2); background: var(--surface); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; gap: 6px; }
.btn.sm svg { width: 15px; height: 15px; }

/* ---------- drop overlay ---------- */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
}
body.dragging.has-items .drop-overlay { opacity: 1; }
.drop-overlay-card {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 40px 56px;
  border: 1.5px dashed var(--accent);
  border-radius: 24px;
  background: var(--surface);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  box-shadow: var(--shadow);
  transform: scale(0.96);
  transition: transform 0.25s cubic-bezier(0.3, 0.7, 0.3, 1.3);
}
body.dragging .drop-overlay-card { transform: scale(1); }
.drop-overlay-card svg { width: 34px; height: 34px; color: var(--accent-text); stroke-width: 2; }

/* ---------- compare dialog ---------- */
.compare {
  width: min(1100px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.compare[open] { display: grid; grid-template-rows: auto 1fr; animation: pop 0.25s cubic-bezier(0.2, 0.8, 0.2, 1); }
.compare::backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); }
@keyframes pop { from { opacity: 0; transform: scale(0.97); } }

.compare-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 14px 20px;
  border-bottom: 1px solid var(--line);
}
.compare-title { display: grid; min-width: 0; }
.compare-title strong { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compare-title span { font: 400 12px var(--mono); color: var(--faint); }

.compare-stage {
  --pos: 50%;
  position: relative;
  height: min(72dvh, 760px);
  background: repeating-conic-gradient(var(--checker-a) 0 25%, var(--checker-b) 0 50%) 0 0 / 20px 20px;
  overflow: hidden;
  user-select: none;
}
.compare-stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.compare-stage #cmpAfter { clip-path: inset(0 0 0 var(--pos)); }
.compare-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--pos);
  width: 2px;
  margin-left: -1px;
  background: var(--accent);
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.compare-handle span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 36px;
  height: 36px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.compare-handle span::before, .compare-handle span::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 0;
  height: 0;
  border: 5px solid transparent;
  transform: translateY(-50%);
}
.compare-handle span::before { left: 6px; border-right-color: var(--accent-ink); }
.compare-handle span::after { right: 6px; border-left-color: var(--accent-ink); }
.compare-tag {
  position: absolute;
  top: 14px;
  padding: 4px 10px;
  border-radius: 999px;
  font: 500 12px var(--mono);
  background: rgba(10, 10, 8, 0.72);
  color: #f1f0e8;
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.compare-tag.left { left: 14px; }
.compare-tag.right { right: 14px; }
.compare-tag.right b { color: #d4f53c; font-weight: 500; }
.compare-stage input[type="range"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: ew-resize;
}
.compare-stage.single .compare-handle, .compare-stage.single #cmpAfter, .compare-stage.single input, .compare-stage.single .compare-tag.right { display: none; }

/* ---------- toasts ---------- */
.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  display: grid;
  gap: 8px;
  justify-items: end;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(380px, calc(100vw - 40px));
  padding: 10px 10px 10px 14px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--surface-2);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  pointer-events: auto;
  animation: toastIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.toast.error::before { background: var(--danger); }
.toast button { flex: none; padding: 4px; border: 0; background: none; color: var(--faint); border-radius: 6px; }
.toast button:hover { color: var(--text); }
.toast button svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.toast.out { animation: toastOut 0.2s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(4px); } }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .row { grid-template-columns: 56px minmax(0, 1fr) auto; }
  .thumb { width: 56px; height: 56px; }
  .row-size { grid-column: 2 / -1; grid-row: 2; }
  .row-actions { grid-column: 3; grid-row: 1; }
}

@media (max-width: 860px) {
  .shell { height: auto; min-height: 100dvh; }
  .workspace { grid-template-columns: 1fr; overflow: visible; }
  .queue { order: -1; }
  .settings { overflow: visible; border-right: 0; border-top: 1px solid var(--line); padding: 4px 16px 32px; }
  .queue-head, .queue-body { padding-left: 16px; padding-right: 16px; }
  .queue-head { flex-direction: column; align-items: stretch; }
  .stats { gap: 18px 26px; }
  .stats dd { font-size: 19px; }
  .queue-foot { position: sticky; bottom: 0; z-index: 5; padding: 12px 16px; flex-wrap: wrap; }
  .foot-status { flex: 1 1 100%; }
  .foot-actions { flex: 1; }
  .foot-actions .btn { flex: 1; }
  .dropzone { min-height: 340px; }
  .topbar { padding: 12px 16px; }
  .privacy-pill span { display: none; }
  .privacy-pill { padding: 8px; }
}

@media (max-width: 520px) {
  .row { gap: 12px; padding: 10px; }
  .row-actions .icon-btn { width: 32px; height: 32px; }
  .row { grid-template-columns: 52px minmax(0, 1fr); }
  .thumb { width: 52px; height: 52px; }
  .row-actions { grid-column: 1 / -1; grid-row: 3; justify-content: flex-end; }
  .row-size { grid-column: 1 / -1; }
  .brand-domain { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* keep settings controls inside their column */
.settings { overflow-x: hidden; }
.group, .field { grid-template-columns: minmax(0, 1fr); }
.group > *, .field > * { min-width: 0; }
