/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #fbf8f3;
  --bg-soft: #f3ecdf;
  --surface: #fffefb;
  --border: #e7ddc9;
  --text: #2b241c;
  --text-soft: #6b5f4f;
  --text-faint: #9b8f7c;

  --accent: #c1622a;
  --accent-dark: #9e4e20;
  --accent-soft: #fbe9db;
  --accent-contrast: #ffffff;

  --success: #3f7d4f;
  --success-soft: #ecf5ec;
  --warn: #b45309;
  --warn-soft: #fdf3e4;
  --danger: #b3402b;
  --danger-soft: #fbeae6;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 3px rgba(43, 36, 28, .07), 0 1px 2px rgba(43, 36, 28, .05);
  --shadow-md: 0 8px 24px rgba(43, 36, 28, .09);
  --shadow-lg: 0 20px 48px rgba(43, 36, 28, .16);

  --container: 1140px;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.15; letter-spacing: -0.01em; font-weight: 700; }
h1, h2 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.015em; }
ul, ol { padding-left: 1.2em; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.skip-link {
  position: fixed; top: -100px; left: 1rem; padding: .6rem 1rem;
  background: var(--text); color: var(--bg); z-index: 9999;
  border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }

/* =============================================================
   4. Typography
   ============================================================= */
h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); }
h2 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); margin-bottom: .6em; }
h3 { font-size: 1.15rem; margin-bottom: .4em; }
p { color: var(--text-soft); margin-bottom: 1em; }
.lead { font-size: 1.1rem; color: var(--text-soft); }

/* =============================================================
   5. Components
   ============================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 26px; border-radius: var(--radius-pill); font-weight: 700; font-size: .98rem;
  transition: transform .18s var(--ease-out), background .18s var(--ease-out), box-shadow .18s var(--ease-out);
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 10px 24px rgba(79,70,229,.28); }
.btn-primary:hover { background: var(--accent-dark); transform: translateY(-1px); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-secondary { background: var(--bg-soft); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-block { width: 100%; }
.btn-lg { padding: 16px 30px; font-size: 1.05rem; }
.btn-sm { padding: 8px 16px; font-size: .85rem; }
.btn-ghost { color: var(--accent); font-weight: 600; }
.btn-ghost:hover { text-decoration: underline; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600; padding: 5px 12px; border-radius: var(--radius-pill); }
.badge-privacy { background: var(--success-soft); color: var(--success); }
.badge-limit { background: var(--bg-soft); color: var(--text-faint); border: 1px solid var(--border); }

/* =============================================================
   6. Header / footer
   ============================================================= */
.site-header {
  position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.logo { display: flex; align-items: center; gap: 8px; font-size: 1.2rem; font-weight: 800; }
.logo .mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1rem; }
.nav-links { display: flex; align-items: center; gap: 22px; }
.nav-links a { font-size: .92rem; font-weight: 600; color: var(--text-soft); }
.nav-links a:hover { color: var(--accent); }
.nav-toggle { display: none; font-size: 1.4rem; }

@media (max-width: 780px) {
  .nav-links { position: fixed; inset: 64px 0 0 0; background: var(--bg); flex-direction: column; align-items: flex-start; padding: 24px 20px; gap: 16px; transform: translateY(-8px); opacity: 0; pointer-events: none; transition: opacity .2s var(--ease-out), transform .2s var(--ease-out); overflow-y: auto; }
  .nav-links.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
  .nav-toggle { display: block; }
}

.site-footer { background: var(--bg-soft); border-top: 1px solid var(--border); padding: 48px 0 24px; margin-top: 56px; }
.footer-grid { display: grid; grid-template-columns: 1.3fr repeat(3, 1fr); gap: 28px; margin-bottom: 32px; }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
.footer-grid h5 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); margin-bottom: 12px; }
.footer-grid ul { list-style: none; padding: 0; display: grid; gap: 8px; }
.footer-grid a { font-size: .88rem; color: var(--text-soft); }
.footer-grid a:hover { color: var(--accent); }
.footer-bottom { border-top: 1px solid var(--border); padding-top: 18px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; font-size: .8rem; color: var(--text-faint); }
.footer-credits { font-size: .74rem; color: var(--text-faint); max-width: 700px; margin-top: 8px; }
.footer-credits a { text-decoration: underline; }

/* =============================================================
   7. Sections
   ============================================================= */
.section { padding: 52px 0; }
.section-tight { padding: 32px 0; }
.section-head { max-width: 640px; margin: 0 auto 32px; text-align: center; }
.section-alt { background: var(--bg-soft); }

.hero { padding: 48px 0 8px; text-align: center; }
.hero h1 { max-width: 780px; margin: 0 auto .4em; }
.hero .lead { max-width: 560px; margin: 0 auto 28px; }

/* Tool grid + cards (home / related) */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.tool-card-link {
  display: flex; flex-direction: column; gap: 10px; padding: 20px; border-radius: var(--radius-md);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out), border-color .18s var(--ease-out);
}
.tool-card-link:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--accent); }
.tool-card-link .icon { font-size: 1.8rem; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); border-radius: 12px; }
.tool-card-link h3 { font-size: 1rem; margin: 0; }
.tool-card-link p { font-size: .86rem; margin: 0; color: var(--text-faint); }

/* Steps (cómo funciona) */
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; max-width: 980px; margin: 0 auto; }
@media (max-width: 900px) { .steps { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .steps { grid-template-columns: 1fr; } }
.step { text-align: center; padding: 24px; }
.step .num { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; margin: 0 auto 14px; }

/* Use-case grid */
.usecase-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.usecase-item { display: flex; gap: 12px; align-items: flex-start; padding: 16px; border-radius: var(--radius-sm); background: var(--bg-soft); }
.usecase-item .icon { font-size: 1.3rem; }
.usecase-item p { margin: 0; font-size: .9rem; }

/* =============================================================
   8. Tool card (the hero component)
   ============================================================= */
.tool-page-head { padding: 36px 0 4px; }
.breadcrumbs { font-size: .82rem; color: var(--text-faint); margin-bottom: 14px; }
.breadcrumbs a { color: var(--accent); }
.tool-page-head h1 { margin-bottom: .3em; }
.tool-page-head .lead { margin-bottom: 22px; }

.tool-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md); padding: 24px; max-width: 760px; margin: 0 auto;
}

.dropzone {
  /* Es un <label>, que por defecto es "inline": sin display:block/flex aquí,
     el navegador fragmenta el borde punteado en varios trozos con esquinas
     redondeadas sueltas alrededor de sus hijos en bloque (el efecto de
     "recuadros feos" a los lados). */
  display: flex; flex-direction: column; align-items: center;
  border: 2px dashed var(--border); border-radius: var(--radius-md); padding: 44px 20px;
  text-align: center; cursor: pointer; transition: all .18s var(--ease-out); background: var(--bg-soft);
}
.dropzone:hover, .dropzone.drag-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .dz-icon { font-size: 2.6rem; margin-bottom: 10px; }
.dropzone .dz-title { font-weight: 700; font-size: 1.05rem; margin-bottom: 4px; }
.dropzone .dz-sub { font-size: .86rem; color: var(--text-faint); margin: 0; }
.dropzone input[type="file"] { display: none; }

.tool-card[data-state="idle"] .tc-working,
.tool-card[data-state="idle"] .tc-done,
.tool-card[data-state="idle"] .tc-error { display: none; }
.tool-card[data-state="working"] .tc-idle,
.tool-card[data-state="working"] .tc-done,
.tool-card[data-state="working"] .tc-error { display: none; }
.tool-card[data-state="done"] .tc-idle,
.tool-card[data-state="done"] .tc-working,
.tool-card[data-state="done"] .tc-error { display: none; }
.tool-card[data-state="error"] .tc-idle,
.tool-card[data-state="error"] .tc-working,
.tool-card[data-state="error"] .tc-done { display: none; }

/* #fileListWrap y #cropWrap son paneles del estado "idle" que viven fuera de
   .tc-idle (para que el JS los pueda mostrar/ocultar de forma independiente
   mientras se seleccionan archivos); en cualquier otro estado deben ocultarse
   siempre, pase lo que pase con su estilo inline. */
/* Acepta con y sin espacio tras los dos puntos (display:none / display: none):
   un desajuste aquí deja la zona de subida oculta de forma permanente, así
   que este selector no debe depender de un único formato exacto. */
.tool-card[data-state="idle"]:has(#fileListWrap:not([style*="display: none"])):has(#fileListWrap:not([style*="display:none"])) .tc-idle,
.tool-card[data-state="idle"]:has(#cropWrap:not([style*="display: none"])):has(#cropWrap:not([style*="display:none"])) .tc-idle { display: none; }

.tool-card[data-state="working"] #fileListWrap,
.tool-card[data-state="done"] #fileListWrap,
.tool-card[data-state="error"] #fileListWrap,
.tool-card[data-state="working"] #cropWrap,
.tool-card[data-state="done"] #cropWrap,
.tool-card[data-state="error"] #cropWrap { display: none !important; }

.file-list { display: grid; gap: 10px; margin-top: 16px; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-soft); }
.file-row .thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: var(--border); }
.file-row .meta { flex: 1; min-width: 0; }
.file-row .meta .name { font-size: .86rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .meta .size { font-size: .78rem; color: var(--text-faint); }
.file-row .remove { font-size: 1.1rem; color: var(--text-faint); padding: 4px; }
.file-row .remove:hover { color: var(--danger); }
.file-row .status { font-size: .78rem; font-weight: 700; }
.file-row .status.pct { color: var(--accent); }
.file-row .status.ok { color: var(--success); }
.file-row .status.err { color: var(--danger); }

.tool-options { display: grid; gap: 16px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.opt-row { display: flex; flex-direction: column; gap: 6px; }
.opt-row.inline { flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.opt-row label.label { font-size: .82rem; font-weight: 700; color: var(--text-soft); }
.opt-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.opt-row select, .opt-row input[type="number"], .opt-row input[type="text"] {
  padding: 10px 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--bg); color: var(--text); font-size: .92rem;
}
.opt-row input[type="range"] { width: 100%; accent-color: var(--accent); }
.opt-value { font-weight: 700; color: var(--accent); font-size: .88rem; }
.chip-select { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-select button { padding: 8px 14px; border-radius: var(--radius-pill); border: 1.5px solid var(--border); font-size: .85rem; font-weight: 600; background: var(--surface); }
.chip-select button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dims-row { display: flex; align-items: center; gap: 10px; }
.dims-row input { width: 100px; }
.lock-ratio { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--text-soft); }

.crop-stage { position: relative; max-width: 100%; margin: 0 auto; touch-action: none; user-select: none; overflow: hidden; border-radius: var(--radius-sm); background: #000; }
.crop-stage img { display: block; max-width: 100%; pointer-events: none; }
.crop-box { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,.5); cursor: move; }
.crop-box .handle { position: absolute; width: 16px; height: 16px; background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.crop-box .handle.nw { top: -8px; left: -8px; cursor: nwse-resize; }
.crop-box .handle.ne { top: -8px; right: -8px; cursor: nesw-resize; }
.crop-box .handle.sw { bottom: -8px; left: -8px; cursor: nesw-resize; }
.crop-box .handle.se { bottom: -8px; right: -8px; cursor: nwse-resize; }

.progress-bar { height: 8px; border-radius: var(--radius-pill); background: var(--bg-soft); overflow: hidden; margin: 16px 0 8px; }
.progress-bar .fill { height: 100%; background: var(--accent); width: 0%; transition: width .2s var(--ease-out); }
.progress-label { font-size: .86rem; color: var(--text-soft); text-align: center; }

.result-figure { display: flex; align-items: center; justify-content: center; gap: 18px; margin-bottom: 18px; flex-wrap: wrap; }
.result-figure img { max-height: 220px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.result-stats { display: flex; justify-content: center; gap: 26px; text-align: center; margin-bottom: 18px; flex-wrap: wrap; }
.result-stats .stat strong { display: block; font-size: 1.3rem; }
.result-stats .stat.save strong { color: var(--success); }
.result-stats .stat span { font-size: .78rem; color: var(--text-faint); }

/* Antes/después de Quitar fondo, con fondo de cuadros para ver la transparencia */
.bg-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
@media (max-width: 560px) { .bg-compare { grid-template-columns: 1fr; } }
.bg-compare-col { text-align: center; }
.bg-compare-label { display: block; font-size: .78rem; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.bg-compare-col img { max-width: 100%; max-height: 260px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.checkerboard {
  display: inline-block; border-radius: var(--radius-sm); overflow: hidden;
  background-image: linear-gradient(45deg, #ccc 25%, transparent 25%), linear-gradient(-45deg, #ccc 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ccc 75%), linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.tc-error-box { display: flex; gap: 12px; align-items: flex-start; padding: 16px; background: var(--danger-soft); color: var(--danger); border-radius: var(--radius-sm); margin-bottom: 14px; }

.tc-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }

.tool-footer { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; margin-top: 20px; }

/* =============================================================
   9. Ad slots
   ============================================================= */
.ad-slot {
  display: flex; align-items: center; justify-content: center; margin: 28px auto;
  background: repeating-linear-gradient(135deg, var(--bg-soft), var(--bg-soft) 10px, var(--border) 10px, var(--border) 20px);
  border: 1.5px dashed var(--border); border-radius: var(--radius-sm);
  color: var(--text-faint); font-size: .76rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
}
.ad-slot--leaderboard { max-width: 970px; min-height: 90px; }
.ad-slot--incontent { max-width: 728px; min-height: 100px; }
.ad-slot--sidebar { min-height: 250px; width: 100%; }
.ad-slot--mobile-sticky {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; min-height: 56px; margin: 0;
  border-radius: 0; border-width: 1.5px 0 0; display: none;
}
@media (max-width: 720px) { .ad-slot--mobile-sticky.is-active { display: flex; } body.has-sticky-ad { padding-bottom: 64px; } }
.ad-slot--mobile-sticky .ad-slot-close { position: absolute; right: 8px; top: 6px; font-size: 1rem; color: var(--text-faint); padding: 4px; }

.tool-layout { display: grid; grid-template-columns: 1fr; gap: 24px; }
.tool-layout .tool-main { min-width: 0; }
@media (min-width: 1024px) {
  .tool-layout { grid-template-columns: 1fr 300px; align-items: start; }
  .tool-layout .tool-side { position: sticky; top: 84px; }
}

/* Download interstitial dialog */
.ad-dialog { border: none; border-radius: var(--radius-lg); padding: 0; box-shadow: var(--shadow-lg); max-width: 420px; width: 92vw; }
.ad-dialog::backdrop { background: rgba(10,10,20,.5); }
.ad-dialog-inner { padding: 22px; text-align: center; position: relative; }
.ad-dialog-close { position: absolute; top: 10px; right: 12px; font-size: 1.3rem; color: var(--text-faint); padding: 6px; }
.ad-dialog-inner .ad-slot { margin: 14px auto 18px; }

/* =============================================================
   10. FAQ / content
   ============================================================= */
.faq-list { max-width: 760px; margin: 0 auto; display: grid; gap: 10px; }
.faq-item { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.faq-item summary { padding: 16px 18px; font-weight: 700; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-size: 1.3rem; color: var(--accent); flex-shrink: 0; }
.faq-item[open] summary::after { content: "−"; }
.faq-item .faq-answer { padding: 0 18px 16px; }
.faq-item .faq-answer p { margin: 0; font-size: .92rem; }

.prose { max-width: 760px; margin: 0 auto; }
.prose p { font-size: .96rem; }
.prose h2 { margin-top: 1.4em; }

.legal-content { max-width: 760px; }
.legal-content h2 { margin-top: 1.6em; }
.demo-notice { background: var(--warn-soft); border: 1px solid #f2d38a; color: var(--warn); padding: 14px 16px; border-radius: var(--radius-sm); font-size: .88rem; margin-bottom: 24px; }

/* =============================================================
   11. Responsive
   ============================================================= */
@media (max-width: 540px) {
  .tool-card { padding: 18px; }
  .dropzone { padding: 30px 14px; }
  .result-figure img { max-height: 160px; }
}
