/* ============================================================
   Image Compressor & Resizer — monochrome base, emerald accent.
   Same token system as the other base31 tools.
   ============================================================ */
:root {
  --bg: #fafafa;
  --bg-elev: #ffffff;
  --card: #ffffff;
  --line: #e6e6e6;
  --line-strong: #d4d4d4;
  --fg: #0a0a0a;
  --fg-soft: #171717;
  --muted: #6b7280;
  --muted-2: #9ca3af;
  --hover: #f4f4f5;
  --accent: #10b981;
  --accent-strong: #059669;
  --accent-soft: #ecfdf5;
  --warn: #f59e0b;
  --warn-soft: #fffbeb;
  --danger: #ef4444;
  --danger-soft: #fef2f2;
  --ring: rgba(16, 185, 129, 0.35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --grid: rgba(0, 0, 0, 0.035);
  --checker: rgba(0, 0, 0, 0.08);
}
html[data-theme="dark"] {
  --bg: #050505;
  --bg-elev: #0a0a0a;
  --card: #0d0d0e;
  --line: #232326;
  --line-strong: #333336;
  --fg: #f5f5f5;
  --fg-soft: #ededed;
  --muted: #9aa0a6;
  --muted-2: #6b7280;
  --hover: #151517;
  --accent: #3ecf8e;
  --accent-strong: #4ade80;
  --accent-soft: rgba(62, 207, 142, 0.1);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.1);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.1);
  --ring: rgba(62, 207, 142, 0.4);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 12px 32px rgba(0, 0, 0, 0.45);
  --grid: rgba(255, 255, 255, 0.03);
  --checker: rgba(255, 255, 255, 0.08);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
[id] { scroll-margin-top: 5rem; }
body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 44px 44px;
  color: var(--fg);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--fg); color: var(--bg); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -9999px; top: 0; z-index: 100; background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 0 0 8px 0; font-size: 13px; font-weight: 500; }
.skip:focus { left: 0; }
.mono { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }

.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 20px; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.brand-mark { display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 7px; background: var(--fg); color: var(--bg); }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; transition: background 0.15s, color 0.15s; }
.icon-btn:hover { background: var(--hover); color: var(--fg); }
.icon-btn svg { width: 18px; height: 18px; }

main { display: block; padding: 52px 0 0; }
.hero { text-align: center; padding: 4px 0 30px; }
.pill { display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--muted); font-size: 12px; font-weight: 500; box-shadow: var(--shadow-sm); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.hero h1 { margin: 20px 0 12px; font-size: clamp(32px, 5.6vw, 48px); line-height: 1.06; font-weight: 700; letter-spacing: -0.03em; }
.hero h1 .grad { background: linear-gradient(100deg, var(--accent-strong), var(--accent) 60%, var(--accent-strong)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { margin: 0 auto; max-width: 580px; color: var(--muted); font-size: 16px; line-height: 1.6; }

.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.card + .card { margin-top: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.card-head h2 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.card-head p { margin: 3px 0 0; color: var(--muted-2); font-size: 12px; }
.card-body { padding: 18px; }

/* ---------- Drop zone ---------- */
.dz {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 44px 22px; text-align: center;
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--card), var(--bg-elev));
  transition: border-color 0.18s, background 0.18s, transform 0.18s;
}
.dz.is-drag { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.005); }
.dz-icon { display: flex; align-items: center; justify-content: center; width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-elev); color: var(--muted); }
.dz-icon svg { width: 22px; height: 22px; }
.dz-title { margin: 4px 0 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.dz-hint { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; max-width: 420px; }
.dz-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 6px; }

/* ---------- Controls ---------- */
.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; margin-top: 18px; }
.presets-field { margin-top: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > label, .field > .field-label { color: var(--fg-soft); font-size: 12px; font-weight: 600; }
.control {
  width: 100%; height: 38px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-elev); color: var(--fg); font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.control:hover { border-color: var(--line-strong); }
.control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.hint { margin: 0; color: var(--muted-2); font-size: 11.5px; line-height: 1.5; }

.range-row { display: flex; align-items: center; gap: 12px; }
input[type="range"] { flex: 1; min-width: 0; height: 22px; accent-color: var(--accent); }
.range-value { min-width: 46px; text-align: right; color: var(--fg-soft); font-size: 12px; font-variant-numeric: tabular-nums; }

.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.preset {
  height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg-elev); color: var(--muted); font-size: 11.5px; cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.preset:hover { border-color: var(--line-strong); color: var(--fg); }
.preset[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border: 1px solid transparent; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
}
.btn-primary { background: var(--fg); color: var(--bg); }
.btn-primary:hover { opacity: 0.88; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-ghost { border-color: var(--line); background: var(--bg-elev); color: var(--fg-soft); }
.btn-ghost:hover { border-color: var(--line-strong); background: var(--hover); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; }
.btn svg { width: 15px; height: 15px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 18px; }
.toolbar .spacer { flex: 1; }

/* ---------- Results ---------- */
.summary { display: flex; flex-wrap: wrap; gap: 18px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.summary-item { display: flex; flex-direction: column; gap: 2px; }
.summary-label { color: var(--muted-2); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; }
.summary-value { color: var(--fg-soft); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.summary-value.is-good { color: var(--accent-strong); }

.list { display: flex; flex-direction: column; }
.row { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 18px; }
.row + .row { border-top: 1px solid var(--line); }
.thumb {
  width: 56px; height: 56px; border-radius: 10px; border: 1px solid var(--line);
  object-fit: cover;
  background-color: var(--bg-elev);
  background-image:
    linear-gradient(45deg, var(--checker) 25%, transparent 25%, transparent 75%, var(--checker) 75%),
    linear-gradient(45deg, var(--checker) 25%, transparent 25%, transparent 75%, var(--checker) 75%);
  background-size: 14px 14px;
  background-position: 0 0, 7px 7px;
}
.row-body { min-width: 0; }
.row-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-soft); font-size: 13.5px; font-weight: 500; }
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 5px; color: var(--muted); font-size: 12px; }
.row-arrow { color: var(--muted-2); }
.row-saved { color: var(--accent-strong); font-weight: 600; }
.row-actions { display: flex; align-items: center; gap: 8px; }
.row.is-error .row-meta { color: var(--danger); }
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg-elev); color: var(--muted); font-size: 10.5px; letter-spacing: 0.04em; text-transform: uppercase; }
.badge.is-good { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); background: var(--accent-soft); color: var(--accent-strong); }
.badge.is-warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); background: var(--warn-soft); color: var(--warn); }

.empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 34px 20px; text-align: center; }
.empty p { margin: 0; color: var(--muted); font-size: 13px; }
.empty-hint { color: var(--muted-2); font-size: 12px; }

.status { margin: 14px 0 0; color: var(--muted); font-size: 12.5px; }
.status.is-error { color: var(--danger); }

/* ---------- Notes + FAQ ---------- */
.notes { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-top: 20px; }
.note { display: flex; gap: 11px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.note svg { flex: 0 0 auto; width: 17px; height: 17px; color: var(--accent); }
.note h3 { margin: 0; font-size: 13px; font-weight: 600; }
.note p { margin: 5px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.6; }

.faq { margin-top: 20px; }
.faq h2 { margin: 0 0 12px; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.faq details { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.faq details + details { margin-top: 8px; }
.faq summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; cursor: pointer; font-size: 13.5px; font-weight: 500; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--muted); font-family: "JetBrains Mono", monospace; font-size: 15px; }
.faq details[open] summary::after { content: "–"; color: var(--accent); }
.faq p { margin: 0; padding: 0 16px 15px; color: var(--muted); font-size: 13px; line-height: 1.7; }

.site-foot { margin-top: 48px; padding: 24px 0 40px; border-top: 1px solid var(--line); color: var(--muted-2); font-size: 12.5px; }
.site-foot a { color: var(--muted); }
.site-foot a:hover { color: var(--fg); }
.site-foot .foot-row { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }

@media (max-width: 720px) {
  main { padding-top: 36px; }
  .workspace { grid-template-columns: 1fr; }
  .row { grid-template-columns: 44px minmax(0, 1fr); }
  .row-actions { grid-column: 1 / -1; }
  .thumb { width: 44px; height: 44px; }
  .toolbar .spacer { display: none; }
  .toolbar .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .dz, .btn, .control, .preset, .icon-btn { transition: none; }
  .dz.is-drag { transform: none; }
}
