*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img, svg { display: block; max-width: 100%; }
:root {
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --color-bg: #ffffff; --color-bg-alt: #f8fafc; --color-surface: #ffffff;
  --color-border: #e5e7eb; --color-text: #0f172a; --color-text-muted: #475569;
  --color-accent: #4f46e5; --color-accent-hover: #4338ca; --color-accent-soft: #eef2ff;
  --color-danger: #dc2626; --color-ok: #059669; --color-warn: #d97706;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow-md: 0 6px 18px rgba(15,23,42,.10);
  --shadow-lg: 0 18px 40px rgba(15,23,42,.18);
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 18px;
}
[data-theme="dark"] {
  --color-bg: #0b1020; --color-bg-alt: #0f172a; --color-surface: #111a2e;
  --color-border: #1f2a44; --color-text: #e6eaf2; --color-text-muted: #94a3b8;
  --color-accent: #818cf8; --color-accent-hover: #a5b4fc; --color-accent-soft: #1e1b4b;
  --color-danger: #f87171; --color-ok: #34d399; --color-warn: #fbbf24;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow-md: 0 6px 20px rgba(0,0,0,.5); --shadow-lg: 0 20px 50px rgba(0,0,0,.65);
}
body { font-family: var(--font-sans); background: var(--color-bg); color: var(--color-text); line-height: 1.55; -webkit-font-smoothing: antialiased; transition: background-color .25s ease, color .25s ease; }
:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; border-radius: 6px; }
.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 20px; }
.skip-link { position: absolute; left: -9999px; top: 0; background: var(--color-accent); color: #fff; padding: 10px 16px; z-index: 100; border-radius: 0 0 8px 0; }
.skip-link:focus { left: 0; }

.site-header { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--color-bg) 88%, transparent); backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--color-border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 64px; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--color-text); font-weight: 700; font-size: 1.1rem; }
.brand-logo { width: 32px; height: 32px; }
.brand-accent { color: var(--color-accent); }
.header-actions { display: flex; align-items: center; gap: 12px; }
.back-link { text-decoration: none; color: var(--color-text-muted); font-size: .92rem; font-weight: 500; transition: color .2s ease; }
.back-link:hover { color: var(--color-accent); }
.theme-toggle { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: background .2s ease; }
.theme-toggle:hover { background: var(--color-bg-alt); }
.theme-toggle .icon-sun { display: none; width: 20px; height: 20px; }
.theme-toggle .icon-moon { display: block; width: 20px; height: 20px; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.tool-main { padding-bottom: 60px; }
.tool-hero { padding: 40px 0 24px; max-width: 780px; }
.tool-hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); letter-spacing: -0.02em; margin: 0 0 12px; }
.tool-hero p { color: var(--color-text-muted); font-size: 1.05rem; margin: 0; }

.dropzone-section { margin: 8px 0 24px; }
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 40px 24px; text-align: center; cursor: pointer; border: 2px dashed var(--color-border); border-radius: var(--radius-lg); background: var(--color-bg-alt); color: var(--color-text); transition: border-color .2s ease, background .2s ease, transform .15s ease; }
.dropzone:hover, .dropzone:focus-visible { border-color: var(--color-accent); background: var(--color-accent-soft); }
.dropzone.is-dragover { border-color: var(--color-accent); background: var(--color-accent-soft); transform: scale(1.01); }
.dropzone-icon { width: 38px; height: 38px; color: var(--color-accent); margin-bottom: 6px; }
.dropzone strong { font-size: 1.05rem; }
.dropzone span { color: var(--color-text-muted); font-size: .95rem; }
.dropzone u { text-decoration-color: var(--color-accent); }
.error-box { margin-top: 16px; padding: 12px 16px; border-radius: var(--radius-md); background: color-mix(in srgb, var(--color-danger) 12%, transparent); color: var(--color-danger); font-size: .92rem; font-weight: 500; border: 1px solid color-mix(in srgb, var(--color-danger) 35%, transparent); }

.workspace { display: grid; grid-template-columns: 1fr; gap: 24px; }
.list-col { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 18px; }
.list-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.list-col h2 { font-size: 1rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--color-text-muted); margin: 0; }
.savings-summary { font-size: .88rem; color: var(--color-text-muted); }
.savings-summary strong { color: var(--color-ok); font-variant-numeric: tabular-nums; }
.list-col .hint { margin: 0 0 12px; }
.options-col { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 22px; align-self: start; box-shadow: var(--shadow-sm); }
.options-col h2 { font-size: 1rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--color-text-muted); margin: 0 0 14px; }

.img-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 460px; overflow-y: auto; }
.img-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--color-bg-alt); border: 1px solid var(--color-border); border-radius: 10px; cursor: pointer; transition: border-color .15s, background .15s; }
.img-row:hover { border-color: color-mix(in srgb, var(--color-accent) 50%, var(--color-border)); }
.img-row.is-active { border-color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 6%, var(--color-bg-alt)); }
.thumb { width: 44px; height: 44px; border-radius: 6px; background: #fff; border: 1px solid var(--color-border); overflow: hidden; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.thumb canvas { display: block; }
.info { flex: 1; min-width: 0; }
.name { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sizes { font-size: .78rem; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.arrow { color: var(--color-accent); margin: 0 3px; }
.save-chip { font-size: .72rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.save-good { color: var(--color-ok); background: color-mix(in srgb, var(--color-ok) 14%, transparent); }
.save-bad  { color: var(--color-danger); background: color-mix(in srgb, var(--color-danger) 14%, transparent); }
.save-neutral { color: var(--color-text-muted); background: color-mix(in srgb, var(--color-text-muted) 14%, transparent); }
.row-dl { background: transparent; border: 1px solid var(--color-border); border-radius: 6px; padding: 4px 9px; cursor: pointer; color: var(--color-text-muted); font-size: .82rem; flex-shrink: 0; }
.row-dl:hover:not(:disabled) { color: var(--color-accent); border-color: var(--color-accent); }
.row-dl:disabled { opacity: .4; cursor: not-allowed; }

.actions-row { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.actions-row .btn { padding: 8px 14px; font-size: .85rem; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: .88rem; font-weight: 600; margin-bottom: 6px; color: var(--color-text); }
.field input[type="number"], .field select { width: 100%; padding: 10px 12px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-bg); color: var(--color-text); font: inherit; font-size: .95rem; }
.field input[type="range"] { width: 100%; accent-color: var(--color-accent); }
.field input:focus, .field select:focus { border-color: var(--color-accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 20%, transparent); }
.field output { color: var(--color-accent); font-weight: 700; }
.field small { display: block; margin-top: 6px; color: var(--color-text-muted); font-size: .78rem; }
.field-check .check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.field-check input { margin: 0; }
.color-row { display: flex; align-items: center; gap: 10px; }
.color-row input[type="color"] { width: 46px; height: 36px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: transparent; cursor: pointer; padding: 2px; }
.color-row output { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88rem; color: var(--color-text-muted); }

.banner-dirty { margin-top: 12px; padding: 10px 14px; border-radius: var(--radius-md); background: color-mix(in srgb, var(--color-warn) 15%, transparent); color: var(--color-warn); font-size: .85rem; border: 1px solid color-mix(in srgb, var(--color-warn) 40%, transparent); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 12px 20px; border-radius: var(--radius-md); font-weight: 600; font-size: .98rem; cursor: pointer; border: 1px solid transparent; transition: background .2s ease, transform .1s ease, box-shadow .2s ease; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--color-accent); color: #fff; box-shadow: var(--shadow-md); }
.btn-primary:hover:not(:disabled) { background: var(--color-accent-hover); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn-ghost:hover:not(:disabled) { background: var(--color-bg-alt); }
.btn-block { width: 100%; margin-top: 4px; }
.btn-label { display: inline-block; }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: none; }
.btn.is-loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.hint { color: var(--color-text-muted); font-size: .82rem; margin: 10px 0 0; }

.preview-section { margin-top: 32px; }
.preview-section h2 { font-size: 1rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--color-text-muted); margin: 0 0 16px; }
.preview-section h2 span { text-transform: none; letter-spacing: 0; color: var(--color-text); font-weight: 600; }
.preview-pair { display: grid; grid-template-columns: 1fr; gap: 16px; }
.preview-box { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 12px; }
.preview-label { font-size: .8rem; font-weight: 600; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.preview-img { background: var(--color-bg-alt); border-radius: 6px; display: flex; align-items: center; justify-content: center; overflow: hidden; min-height: 220px; }
.preview-img img { max-width: 100%; max-height: 380px; object-fit: contain; display: block; }
.preview-meta { margin-top: 8px; font-size: .82rem; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.preview-actions { margin-top: 16px; text-align: right; }

.site-footer { border-top: 1px solid var(--color-border); padding: 20px 0; color: var(--color-text-muted); text-align: center; font-size: .85rem; margin-top: 40px; }
.site-footer p { margin: 0; }

@media (min-width: 640px) {
  .preview-pair { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 900px) {
  .workspace { grid-template-columns: 1fr 340px; align-items: start; }
  .options-col { position: sticky; top: 84px; }
}
.site-footer a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.site-footer a:hover { color: var(--color-accent); }

/* Aviso de privacidad, preajustes, peso máximo e informe de metadatos */
.tool-hero .privacy-note { margin-top: 8px; font-size: .95rem; }
.field-label { display: block; font-size: .88rem; font-weight: 600; margin-bottom: 6px; color: var(--color-text); }
.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.preset { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 10px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-bg); color: var(--color-text); font: inherit; text-align: left; cursor: pointer; transition: border-color .15s, background .15s; }
.preset strong { font-size: .82rem; line-height: 1.25; }
.preset span { font-size: .72rem; color: var(--color-text-muted); }
.preset:hover { border-color: var(--color-accent); }
.preset[aria-pressed="true"] { border-color: var(--color-accent); background: var(--color-accent-soft); box-shadow: inset 0 0 0 1px var(--color-accent); }
.target-row { display: grid; grid-template-columns: 1fr 84px; gap: 6px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.tag { font-size: .68rem; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: color-mix(in srgb, var(--color-text-muted) 12%, transparent); color: var(--color-text-muted); white-space: nowrap; }
.tag-ok { background: color-mix(in srgb, var(--color-ok) 14%, transparent); color: var(--color-ok); }
.tag-warn { background: color-mix(in srgb, var(--color-warn) 16%, transparent); color: var(--color-warn); }
.meta-report { margin-top: 14px; padding: 12px 16px; border-radius: var(--radius-md); background: var(--color-bg-alt); border: 1px solid var(--color-border); font-size: .88rem; color: var(--color-text-muted); }
.meta-report strong { color: var(--color-text); }
.meta-report ul { margin: 6px 0 0; padding-left: 1.2em; }
@media (max-width: 420px) { .presets { grid-template-columns: 1fr; } }

/* Guía de uso */
.guide { margin-top: 48px; padding: 24px 28px; background: var(--color-bg-alt); border: 1px solid var(--color-border); border-radius: var(--radius-lg); }
.guide h2 { margin: 0 0 14px; font-size: 1.15rem; }
.guide ol { margin: 0; padding-left: 1.3em; display: grid; gap: 10px; }
.guide li { line-height: 1.55; }
.guide li::marker { color: var(--color-accent); font-weight: 700; }
.guide h3 { margin: 22px 0 8px; font-size: .95rem; }
.guide ul { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; color: var(--color-text-muted); font-size: .92rem; }
.guide a { color: var(--color-accent); }
