/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --ink: #15201b;
  --ink-soft: #55625b;
  --line: #dfe4e0;
  --accent: #0f9d6c;
  --accent-ink: #ffffff;
  --accent-soft: #e3f5ed;
  --danger: #c2410c;
  --danger-soft: #fdeee6;
  --radius: 16px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1512;
    --surface: #171f1b;
    --ink: #eaf1ed;
    --ink-soft: #9aa9a1;
    --line: #2a3530;
    --accent: #24c58b;
    --accent-ink: #06231a;
    --accent-soft: #14352a;
    --danger: #fb923c;
    --danger-soft: #35201a;
  }
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
h1, h2 { text-wrap: balance; line-height: 1.1; letter-spacing: -0.02em; }
p { text-wrap: pretty; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* =============================================================
   3. Utilities
   ============================================================= */
.wrap { width: min(100% - 32px, 860px); margin-inline: auto; }
.skip-link {
  position: fixed; top: -100px; left: 1rem; z-index: 99;
  padding: .6rem 1rem; background: var(--ink); color: var(--bg); border-radius: 8px;
}
.skip-link:focus { top: 1rem; }
[hidden] { display: none !important; }

/* =============================================================
   4. Header / footer
   ============================================================= */
.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.bar-row { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--accent); }
.logo span { color: var(--ink); }
.header-note { color: var(--ink-soft); font-size: .9rem; display: none; }
@media (min-width: 540px) { .header-note { display: block; } }

.site-footer { border-top: 1px solid var(--line); margin-top: 64px; padding: 28px 0; color: var(--ink-soft); font-size: .9rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }

/* =============================================================
   5. Hero + tool card
   ============================================================= */
.hero { padding-top: 40px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 700; }
.hero .sub { margin-top: 12px; color: var(--ink-soft); font-size: 1.05rem; max-width: 56ch; }

.tool-card {
  margin-top: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 12px 32px -16px rgba(0,0,0,.12);
}
@media (min-width: 720px) { .tool-card { padding: 24px; } }

/* Dropzone */
.dropzone {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 220px; padding: 24px; text-align: center;
  border: 2px dashed var(--line); border-radius: 12px;
  background: var(--bg);
  cursor: pointer;
  transition: border-color .2s var(--ease-out), background .2s var(--ease-out);
}
.dropzone:hover, .dropzone.is-over, .dropzone:focus-within { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.dz-icon { color: var(--accent); margin-bottom: 4px; }
.dz-title { font-size: 1.2rem; font-weight: 600; }
.dz-hint { color: var(--ink-soft); }
.dz-hint u { color: var(--accent); text-underline-offset: 3px; }
.dz-limits { color: var(--ink-soft); font-size: .85rem; margin-top: 6px; }
.tool-card:not([data-state="idle"]) .dropzone { min-height: 84px; padding: 14px; flex-direction: row; flex-wrap: wrap; gap: 4px 12px; }
.tool-card:not([data-state="idle"]) .dz-icon { width: 24px; height: 24px; margin: 0; }
.tool-card:not([data-state="idle"]) .dz-title { font-size: 1rem; }
.tool-card:not([data-state="idle"]) .dz-limits { display: none; }

/* Settings */
.settings { display: grid; gap: 18px; margin-top: 18px; }
@media (min-width: 720px) { .settings { grid-template-columns: 1.2fr 1.3fr 1fr; gap: 24px; } }
.field { border: 0; padding: 0; min-width: 0; }
.field > label, .field legend { display: block; font-size: .9rem; font-weight: 600; margin-bottom: 8px; padding: 0; }
.field-note { color: var(--ink-soft); font-size: .8rem; margin-top: 6px; line-height: 1.4; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
select {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px;
}
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg); }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: block; padding: 9px 14px; font-size: .9rem; font-weight: 500; color: var(--ink-soft); }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.seg input:disabled + span { opacity: .4; cursor: not-allowed; }

.field-wide { grid-column: 1 / -1; }
.field-title { display: block; font-size: .9rem; font-weight: 600; margin-bottom: 8px; }
.name-row { display: grid; gap: 10px; }
@media (min-width: 540px) { .name-row { grid-template-columns: 1fr 1fr; } }
.name-row label { display: flex; align-items: center; gap: 10px; font-size: .9rem; color: var(--ink-soft); white-space: nowrap; }
.name-row input {
  flex: 1; min-width: 0; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px;
}

/* Comparador antes / después */
.cmp { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink);
  padding: 16px; width: min(96vw, 1000px); max-width: none; margin: auto; }
.cmp::backdrop { background: rgba(0,0,0,.6); }
.cmp-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.cmp-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-stage {
  --ratio: 1.5; position: relative; margin: 0 auto; overflow: hidden; border-radius: 10px; touch-action: none; cursor: ew-resize;
  aspect-ratio: var(--ratio); width: min(100%, calc(68vh * var(--ratio)));
  background: repeating-conic-gradient(#d5d9d6 0% 25%, #eef0ee 0% 50%) 50% / 16px 16px;
}
.cmp-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.cmp-line { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.35); pointer-events: none; }
.cmp-caps { display: flex; justify-content: space-between; gap: 12px; margin: 10px auto 0; width: min(100%, 680px); font-size: .9rem; font-weight: 600; }
.cmp-tag { padding: 3px 12px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); }
.cmp-tag:last-child { background: var(--accent-soft); border-color: transparent; }
.cmp input[type="range"] { margin-top: 14px; }

/* Messages */
.msg { margin-top: 16px; padding: 10px 14px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: .9rem; }

/* Summary */
.summary {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 20px; padding: 14px 16px; border-radius: 12px; background: var(--accent-soft);
}
.sum-text { font-weight: 600; }
.sum-text small { display: block; font-weight: 400; color: var(--ink-soft); }
.sum-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Buttons */
.btn { padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: .95rem; transition: transform .15s var(--ease-out), background .15s; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { border: 1px solid var(--line); background: var(--surface); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

/* List */
.list { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 10px; }
.row {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: 56px 1fr auto; gap: 4px 14px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg);
}
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; background:
  repeating-conic-gradient(#d5d9d6 0% 25%, #eef0ee 0% 50%) 50% / 12px 12px; }
.info { min-width: 0; }
.name { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-row { display: block; color: var(--ink-soft); font-size: .85rem; }
.result { grid-column: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: .9rem; }
.sizes { color: var(--ink-soft); }
.sizes strong { color: var(--ink); }
.badge { background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 1px 10px; font-size: .8rem; font-weight: 700; }
.badge.is-zero { background: var(--line); color: var(--ink-soft); }
.actions { grid-column: 3; grid-row: 1 / span 2; display: flex; align-items: center; gap: 6px; }
.btn-dl { background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: .85rem; padding: 8px 12px; border-radius: 8px; }
.btn-cmp { border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: .85rem; padding: 7px 12px; border-radius: 8px; }
.btn-cmp:hover { border-color: var(--accent); }
.thumb { cursor: zoom-in; }
.row:not([data-status="done"]) .btn-cmp, .row:not([data-status="done"]) .thumb { cursor: default; }
.row:not([data-status="done"]) .btn-cmp { display: none; }
.btn-x { width: 32px; height: 32px; border-radius: 8px; color: var(--ink-soft); font-size: 1.3rem; line-height: 1; }
.btn-x:hover { background: var(--line); }
.row[data-status="working"] .btn-dl, .row[data-status="queued"] .btn-dl, .row[data-status="error"] .btn-dl { display: none; }
.row[data-status="error"] { border-color: var(--danger); }
.row[data-status="error"] .sizes { color: var(--danger); }
.row[data-status="working"] .badge, .row[data-status="queued"] .badge, .row[data-status="error"] .badge { display: none; }
.bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; display: none; background: var(--line); }
.bar i { display: block; height: 100%; width: 35%; background: var(--accent); animation: slide 1s linear infinite; }
.row[data-status="working"] .bar { display: block; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
@media (max-width: 539px) {
  .row { grid-template-columns: 48px 1fr; }
  .thumb { width: 48px; height: 48px; }
  .actions { grid-column: 1 / -1; grid-row: auto; justify-content: flex-end; }
  .result { grid-column: 2; }
}

.privacy { margin-top: 16px; color: var(--ink-soft); font-size: .95rem; }
.privacy strong { color: var(--ink); }

/* =============================================================
   6. Info section
   ============================================================= */
.about { margin-top: 56px; }
.about h2 { font-size: 1.5rem; margin: 0 0 14px; }
.about h2:not(:first-child) { margin-top: 40px; }
.steps { padding-left: 1.2em; display: grid; gap: 6px; color: var(--ink-soft); }
.steps strong { color: var(--ink); }
details { border-bottom: 1px solid var(--line); padding: 14px 0; }
summary { cursor: pointer; font-weight: 600; }
details p { margin-top: 8px; color: var(--ink-soft); }

/* =============================================================
   7. Reduced motion (solo efectos intrusivos)
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .bar i { animation-duration: 2.4s; }
}
