/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --red: #E1251B;
  --red-dark: #B91C1C;
  --red-light: #FDEDEC;
  --bg: #ffffff;
  --bg-alt: #F7F7F8;
  --ink: #1A1A1A;
  --ink-soft: #4B4B50;
  --muted: #74747C;
  --border: #E6E6E9;
  --border-strong: #D3D3D8;
  --yellow: #FFF3B0;
  --yellow-border: #E8C93B;
  --green: #1E8E5A;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(20,20,20,.06);
  --shadow-md: 0 8px 24px rgba(20,20,20,.10);
  --shadow-lg: 0 20px 48px rgba(20,20,20,.16);
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; overflow-x: clip; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  overscroll-behavior-y: none;
}
img, svg, video { display: block; max-width: 100%; }
[hidden] { display: none !important; }
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.12; letter-spacing: -0.01em; font-weight: 800; }
ul, ol { padding: 0; list-style: none; }
input, textarea { font: inherit; }
::selection { background: var(--red-light); color: var(--red-dark); }

:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; border-radius: 4px; }

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* =============================================================
   3. Utilities
   ============================================================= */
.container { max-width: 1180px; margin-inline: auto; padding-inline: 1.25rem; }
.container-narrow { max-width: 760px; }
.accent { color: var(--red); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .75rem 1.25rem; border-radius: 999px; font-weight: 700; font-size: .95rem;
  transition: transform .18s var(--ease-out), background .18s var(--ease-out), box-shadow .18s var(--ease-out);
}
.btn-primary { background: var(--red); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--red-dark); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: scale(.98); }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1.5px solid var(--border-strong); }
.btn-ghost:hover { border-color: var(--ink-soft); color: var(--ink); }
.btn-big { padding: .95rem 1.75rem; font-size: 1.02rem; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* =============================================================
   4. Header
   ============================================================= */
.site-header { border-bottom: 1px solid var(--border); position: sticky; top: 0; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); z-index: 40; }
@supports not (backdrop-filter: blur(8px)) { .site-header { background: #fff; } }
.header-inner { display: flex; align-items: center; gap: 1.25rem; padding-block: .8rem; }
.logo { display: inline-flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; color: var(--ink); flex-shrink: 0; }
.logo b { color: var(--red); font-weight: 800; }
.header-nav { display: none; gap: 1.5rem; margin-left: .5rem; }
.header-nav a { font-weight: 600; font-size: .92rem; color: var(--ink-soft); transition: color .15s var(--ease-out); }
.header-nav a:hover { color: var(--red); }
.header-badge { margin-left: auto; font-size: .78rem; font-weight: 700; color: var(--green); background: #EAF7EF; padding: .35rem .7rem; border-radius: 999px; white-space: nowrap; }
@media (min-width: 720px) { .header-nav { display: flex; } }

/* =============================================================
   5. Hero
   ============================================================= */
.hero { padding-block: 2.6rem 1.6rem; background: linear-gradient(180deg, var(--red-light) 0%, #fff 78%); }
.hero h1 { font-size: clamp(1.9rem, 4.6vw, 3rem); max-width: 16ch; margin-inline: auto; text-align: center; }
.hero-sub { max-width: 46rem; margin: .9rem auto 0; text-align: center; color: var(--ink-soft); font-size: clamp(.98rem, 1.6vw, 1.15rem); }

/* =============================================================
   6. Tool section & modes
   ============================================================= */
.tool-section { padding-block: 1.4rem 0; }
.tool-modes { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; margin-bottom: 1rem; }
.mode-btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .6rem 1.05rem; border-radius: 999px; font-weight: 700; font-size: .92rem;
  background: var(--bg-alt); color: var(--ink-soft); border: 1.5px solid transparent;
  transition: all .16s var(--ease-out);
}
.mode-btn:hover { background: #EFEFF1; }
.mode-btn.is-active { background: var(--red-light); color: var(--red-dark); border-color: #F5C5C1; }

.tool-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 1.4rem; position: relative;
  max-width: 980px; margin-inline: auto;
}
.tool-pane { display: none; }
.tool-pane.is-active { display: block; }

/* Dropzone */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem;
  text-align: center; padding: 2.6rem 1.5rem; border: 2px dashed var(--border-strong); border-radius: var(--radius-sm);
  cursor: pointer; transition: border-color .18s var(--ease-out), background .18s var(--ease-out);
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.is-dragover { border-color: var(--red); background: var(--red-light); }
.dropzone strong { font-size: 1.08rem; }
.dropzone span { color: var(--muted); font-size: .92rem; }
.dz-icon { margin-bottom: .3rem; }

/* Editor toolbar */
.editor-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.tbtn {
  display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .85rem;
  border-radius: 999px; background: var(--bg-alt); font-weight: 600; font-size: .88rem; color: var(--ink-soft);
  border: 1.5px solid transparent; transition: all .16s var(--ease-out);
}
.tbtn:hover { background: #EFEFF1; }
.tbtn.is-active { background: var(--red); color: #fff; }
.editor-hint { font-size: .82rem; color: var(--muted); margin-left: .25rem; }

/* Editor body: preview + page list */
.editor-body { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.page-preview-canvas-wrap {
  position: relative; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-alt); overflow: hidden; max-height: 60vh; overflow-y: auto;
  display: grid; place-items: center;
}
.page-preview-canvas-wrap canvas { display: block; max-width: 100%; height: auto; cursor: crosshair; grid-column: 1; grid-row: 1; }
.page-preview-canvas-wrap.is-idle canvas { cursor: default; }
/* Overlay is stacked in the same grid cell as the canvas (not just absolutely
   inset to the wrap) so it stays pixel-aligned with the canvas even when the
   wrap is wider than the canvas's capped width and centers it. */
.preview-overlay { position: relative; grid-column: 1; grid-row: 1; pointer-events: none; }
.preview-overlay .anno { position: absolute; pointer-events: auto; }
.anno-text {
  font-weight: 600; white-space: pre-wrap; cursor: move; padding: 2px 4px; border: 1px dashed transparent; border-radius: 3px;
}
.anno-text:hover, .anno-text.is-editing { border-color: var(--red); background: rgba(225,37,27,.06); }
.anno-comment {
  width: 26px; height: 26px; border-radius: 50% 50% 50% 4px; background: var(--yellow);
  border: 1.5px solid var(--yellow-border); display: flex; align-items: center; justify-content: center;
  cursor: move; font-size: .8rem; box-shadow: var(--shadow-sm); transform: translate(-4px,-4px);
}
.anno-remove {
  position: absolute; top: -8px; right: -8px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 11px; line-height: 1; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s;
}
.anno-text:hover .anno-remove, .anno-comment:hover .anno-remove, .anno-signature:hover .anno-remove { opacity: 1; }
.anno-signature {
  cursor: move; border: 1px dashed transparent; border-radius: 3px;
}
.anno-signature:hover { border-color: var(--red); }
.anno-signature img { width: 100%; height: 100%; display: block; pointer-events: none; -webkit-user-drag: none; }
.anno-resize {
  position: absolute; right: -6px; bottom: -6px; width: 14px; height: 14px; border-radius: 3px;
  background: var(--red); border: 2px solid #fff; box-shadow: var(--shadow-sm); cursor: nwse-resize;
}
.page-preview-caption { text-align: center; color: var(--muted); font-size: .85rem; margin-top: .5rem; }

.anno-popover {
  position: absolute; z-index: 20; background: #fff; border: 1px solid var(--border-strong); border-radius: 10px;
  box-shadow: var(--shadow-lg); padding: .6rem; width: min(260px, 80vw);
}
.anno-popover textarea {
  width: 100%; min-height: 64px; border: 1px solid var(--border); border-radius: 6px; padding: .45rem .55rem; resize: vertical; font-size: .9rem;
}
.anno-popover-row { display: flex; align-items: center; gap: .5rem; margin-top: .5rem; }
.anno-popover-row input[type="color"] { width: 28px; height: 28px; border: 0; padding: 0; background: none; }
.anno-popover-row input[type="range"] { flex: 1; }
.anno-popover-actions { display: flex; justify-content: flex-end; gap: .4rem; margin-top: .5rem; }
.anno-popover-actions button { font-size: .82rem; padding: .35rem .7rem; border-radius: 6px; }
.anno-popover-actions .btn-done { background: var(--red); color: #fff; font-weight: 700; }
.anno-popover-actions .btn-del { color: var(--muted); }

/* Page thumbnail list */
.page-list { display: flex; gap: .65rem; overflow-x: auto; padding: .3rem .1rem .6rem; }
.page-thumb {
  position: relative; flex: 0 0 auto; width: 84px; border: 2px solid var(--border); border-radius: 8px;
  overflow: hidden; cursor: grab; background: #fff; transition: border-color .15s;
}
.page-thumb.is-selected { border-color: var(--red); }
.page-thumb canvas { width: 100%; display: block; }
.page-thumb-label { font-size: .68rem; text-align: center; color: var(--muted); padding: .15rem 0; background: var(--bg-alt); }
.page-thumb-controls { position: absolute; top: 3px; right: 3px; display: flex; flex-direction: column; gap: 3px; }
.page-thumb-controls button {
  width: 20px; height: 20px; border-radius: 50%; background: rgba(255,255,255,.92); box-shadow: var(--shadow-sm);
  display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--ink-soft);
}
.page-thumb-controls button:hover { color: var(--red); }
.page-thumb.dragging { opacity: .4; }

/* Editor actions / panel actions */
.editor-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; flex-wrap: wrap; }

/* Compress + Convert panels */
.compress-panel { display: flex; flex-direction: column; gap: 1rem; }
.panel-file-name { font-weight: 600; word-break: break-all; }
.range-row { display: flex; align-items: center; gap: .75rem; font-size: .9rem; font-weight: 600; color: var(--ink-soft); }
.range-row input[type="range"] { flex: 1; accent-color: var(--red); }
.compress-warning { background: #FFF7E6; border: 1px solid #F3D385; color: #7A5B00; padding: .75rem 1rem; border-radius: 8px; font-size: .88rem; }
.compress-result { border-top: 1px dashed var(--border); padding-top: 1rem; display: flex; flex-direction: column; gap: .75rem; align-items: flex-start; }
.badge-saved { background: #EAF7EF; color: var(--green); font-weight: 700; font-size: .82rem; padding: .2rem .55rem; border-radius: 999px; }

.convert-subtabs { display: flex; gap: .5rem; margin-bottom: 1rem; }
.subtab { padding: .5rem 1rem; border-radius: 999px; background: var(--bg-alt); font-weight: 700; font-size: .88rem; color: var(--ink-soft); }
.subtab.is-active { background: var(--red); color: #fff; }
.convert-pane { display: none; }
.convert-pane.is-active { display: block; }
.convert-result { margin-top: 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }

/* Progress / error */
.tool-progress { text-align: center; padding: 1.4rem 0; }
.progress-bar { height: 8px; border-radius: 999px; background: var(--bg-alt); overflow: hidden; max-width: 360px; margin-inline: auto; }
.progress-bar-fill { height: 100%; width: 6%; background: var(--red); transition: width .25s var(--ease-out); }
.tool-progress p { margin-top: .6rem; color: var(--muted); font-size: .88rem; }
.tool-error { text-align: center; padding: 1.2rem; background: #FFF3F2; border: 1px solid #F5C5C1; border-radius: var(--radius-sm); }
.tool-error p { color: var(--red-dark); margin-bottom: .6rem; font-weight: 600; }

/* Privacy + limits */
.privacy-badge { text-align: center; font-size: .92rem; color: var(--ink-soft); margin-top: 1.1rem; }
.limits-note { text-align: center; font-size: .82rem; color: var(--muted); margin-top: .3rem; }

@media (min-width: 720px) {
  .editor-body { grid-template-columns: 1fr; }
  .page-list { flex-wrap: wrap; max-height: 220px; overflow-y: auto; overflow-x: hidden; }
}

/* =============================================================
   7. Ad slots
   ============================================================= */
.ad-slot {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm);
  background: var(--bg-alt); color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}
.ad-label::before { content: "▭ "; }
.ad-slot-banner { max-width: 980px; margin: 1.6rem auto; min-height: 90px; }
.ad-slot-incontent { max-width: 728px; margin: 2.2rem auto; min-height: 250px; }
.ad-slot-popup { min-height: 220px; margin-top: .75rem; }
.ad-slot-corner { min-height: 90px; width: 260px; }

.ad-popup {
  border: 0; border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 1.1rem; max-width: 340px; width: 90vw;
  position: fixed; margin: auto; inset: 0;
}
.ad-popup::backdrop { background: rgba(20,20,20,.5); }
.ad-popup-kicker { font-weight: 700; color: var(--green); font-size: .88rem; margin-bottom: .3rem; }
.ad-popup-close {
  position: absolute; top: .6rem; right: .6rem; width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg-alt); font-size: 16px; display: flex; align-items: center; justify-content: center;
}
.ad-popup-close:hover { background: var(--border); }

.ad-corner {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 50; background: #fff; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); padding: .6rem; border: 1px solid var(--border);
  animation: cornerIn .35s var(--ease-out);
}
@keyframes cornerIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.ad-corner-close {
  position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 12px; display: flex; align-items: center; justify-content: center;
}
@media (max-width: 539px) { .ad-slot-corner { width: 68vw; } }

/* =============================================================
   8. Features grid
   ============================================================= */
.features { padding-block: 2.6rem 1rem; }
.features h2 { text-align: center; font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: 1.6rem; }
.features-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.feature-card { background: var(--bg-alt); border-radius: var(--radius-sm); padding: 1.2rem 1.3rem; border: 1px solid var(--border); }
.feature-icon {
  width: 38px; height: 38px; border-radius: 10px; background: var(--red-light); color: var(--red);
  display: flex; align-items: center; justify-content: center; margin-bottom: .7rem;
}
.feature-card h3 { font-size: 1.02rem; margin-bottom: .35rem; }
.feature-card p { font-size: .88rem; color: var(--ink-soft); }

/* =============================================================
   9. Steps
   ============================================================= */
.steps { padding-block: 2.6rem; background: var(--bg-alt); }
.steps h2 { text-align: center; font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: 1.8rem; }
.steps-list { display: grid; gap: 1.2rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); counter-reset: step; }
.steps-list li { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem; }
.steps-list h3 { font-size: 1.05rem; color: var(--red-dark); margin-bottom: .5rem; }
.steps-list p { font-size: .92rem; color: var(--ink-soft); }

/* =============================================================
   10. SEO text
   ============================================================= */
.seo-text { padding-block: 2.8rem 0; }
.seo-text h2 { font-size: clamp(1.4rem, 2.8vw, 1.8rem); margin-bottom: 1rem; }
.seo-text p { color: var(--ink-soft); margin-bottom: 1rem; font-size: .96rem; }
.seo-text p:last-child { margin-bottom: 0; }

/* =============================================================
   11. FAQ
   ============================================================= */
.faq { padding-block: 1rem 2.6rem; }
.faq h2 { font-size: clamp(1.4rem, 2.8vw, 1.8rem); margin-bottom: 1.2rem; }
.faq-item { border-bottom: 1px solid var(--border); }
.faq-item summary {
  padding: 1rem 0; font-weight: 700; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 1rem;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; color: var(--red); font-size: 1.3rem; font-weight: 400; flex-shrink: 0; }
.faq-item[open] summary::after { content: "–"; }
.faq-item p { padding-bottom: 1rem; color: var(--ink-soft); font-size: .93rem; }

/* =============================================================
   12. Other tools
   ============================================================= */
.other-tools { padding-block: 1rem 3rem; }
.other-tools h2 { font-size: clamp(1.4rem, 2.8vw, 1.8rem); margin-bottom: 1.2rem; }
.other-tools-grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.other-tool-card {
  display: block; background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 1rem 1.1rem; transition: border-color .15s, background .15s;
}
.other-tool-card:hover { border-color: var(--red); background: var(--red-light); }
.other-tool-card strong { display: block; font-size: .95rem; margin-bottom: .2rem; }
.other-tool-card span { font-size: .82rem; color: var(--muted); }

/* =============================================================
   13. Footer
   ============================================================= */
.site-footer { border-top: 1px solid var(--border); background: var(--bg-alt); padding-block: 2rem 1.4rem; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.4rem; }
.footer-brand p { color: var(--muted); font-size: .85rem; margin-top: .4rem; max-width: 32ch; }
.logo-footer { font-weight: 800; font-size: 1.05rem; }
.logo-footer b { color: var(--red); }
.footer-links { display: flex; gap: 1.2rem; flex-wrap: wrap; }
.footer-links a { font-size: .88rem; color: var(--ink-soft); font-weight: 600; }
.footer-links a:hover { color: var(--red); }
.footer-credits { font-size: .78rem; color: var(--muted); border-top: 1px solid var(--border-strong); padding-top: 1rem; }
.footer-credits a { color: var(--ink-soft); text-decoration: underline; }

/* =============================================================
   14. Breakpoints (site-wide adjustments)
   ============================================================= */
@media (min-width: 540px) {
  .editor-actions { justify-content: flex-end; }
}
@media (min-width: 960px) {
  .container { padding-inline: 2rem; }
}

/* =============================================================
   15. Legal page (privacidad.html / aviso-legal.html)
   ============================================================= */
.legal-main { padding-block: 2.5rem 4rem; }
.legal-main h1 { font-size: clamp(1.6rem, 3.4vw, 2.2rem); margin-bottom: 1.2rem; }
.legal-main h2 { font-size: 1.15rem; margin-top: 1.8rem; margin-bottom: .6rem; color: var(--red-dark); }
.legal-main p, .legal-main li { color: var(--ink-soft); font-size: .95rem; margin-bottom: .6rem; }
.legal-main ul { list-style: disc; padding-left: 1.3rem; }
.legal-main .todo { background: #FFF7E6; border: 1px dashed #F3D385; padding: .8rem 1rem; border-radius: 8px; font-size: .85rem; color: #7A5B00; }
