/* =============================================================
   Nitidoc — herramienta primero, papelería oficial como identidad.
   Layout: columna centrada; la tarjeta de la herramienta es el único
   objeto con sombra; el resto es tipografía y reglas finas.
   ============================================================= */

/* 1. Tokens */
:root {
  --bg: #f4f6f4;
  --surface: #ffffff;
  --surface-2: #eef2f0;
  --ink: #15222a;
  --muted: #56666e;
  --line: #d6dedb;
  --accent: #0b6e5e;
  --accent-ink: #ffffff;
  --accent-soft: #dcefe9;
  --warn: #9a5b00;
  --danger: #b3261e;
  --ad-bg: #f7f3e8;
  --ad-line: #c9b98a;
  --ad-ink: #8a7740;
  --stage: #2a3439;
  --shadow: 0 1px 2px rgba(21, 34, 42, .06), 0 12px 32px -12px rgba(21, 34, 42, .18);

  --display: "Bricolage Grotesque", "Public Sans", system-ui, sans-serif;
  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --radius: 12px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --maxw: 1120px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1517; --surface: #172024; --surface-2: #1d292e; --ink: #e5ecea; --muted: #9aaab0;
    --line: #2b393f; --accent: #3cc2a6; --accent-ink: #062a23; --accent-soft: #163a33;
    --warn: #f0b354; --danger: #ff8a80; --ad-bg: #24221b; --ad-line: #6b6044; --ad-ink: #c8b47c;
    --stage: #0a0e10; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px -12px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1517; --surface: #172024; --surface-2: #1d292e; --ink: #e5ecea; --muted: #9aaab0;
  --line: #2b393f; --accent: #3cc2a6; --accent-ink: #062a23; --accent-soft: #163a33;
  --warn: #f0b354; --danger: #ff8a80; --ad-bg: #24221b; --ad-line: #6b6044; --ad-ink: #c8b47c;
  --stage: #0a0e10; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px -12px rgba(0,0,0,.6);
  color-scheme: dark;
}

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

/* 3. Utilities */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: 16px; }
@media (min-width: 720px) { .wrap { padding-inline: 28px; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: fixed; top: -100px; left: 1rem; padding: .6rem 1rem; background: var(--surface); z-index: 999; border-radius: 8px; }
.skip-link:focus { top: 1rem; }

/* 4. Header */
.site-header { border-bottom: 1px solid var(--line); background: var(--bg); }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 12px; }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-family: var(--display); font-weight: 800; font-size: 1.25rem; letter-spacing: -0.02em; }
.brand-mark { width: 28px; height: 28px; }
.header-nav { display: flex; gap: 20px; font-size: .9rem; color: var(--muted); }
.header-nav a { text-decoration: none; }
.header-nav a:hover { color: var(--ink); }
@media (max-width: 539px) { .header-nav { display: none; } }

/* 5. Hero */
.hero { padding-block: 22px 14px; }
.hero h1 { font-family: var(--display); font-weight: 800; font-size: clamp(1.55rem, 1.1rem + 2.2vw, 2.6rem); max-width: 22ch; }
.lede { margin-top: 8px; color: var(--muted); max-width: 62ch; font-size: clamp(.95rem, .9rem + .2vw, 1.05rem); }
@media (max-width: 539px) { .lede { font-size: .92rem; } }

/* 6. Tool card */
.tool-wrap { padding-bottom: 8px; }
.tool-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 16px; }
@media (min-width: 720px) { .tool-card { padding: 22px; } }
.pane { display: none; }
.tool-card[data-state="idle"] .pane-idle,
.tool-card[data-state="loading"] .pane-loading,
.tool-card[data-state="edit"] .pane-edit { display: block; }
.noscript { padding: 12px; color: var(--danger); }

.url-row { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 6px 6px 12px; background: var(--surface-2); }
.url-row:focus-within { border-color: var(--accent); }
.url-ico { width: 20px; height: 20px; color: var(--muted); flex: none; }
.url-row input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 8px 0; outline: none; }

.dropzone { margin-top: 12px; display: grid; justify-items: center; gap: 4px; text-align: center; padding: 26px 16px; border: 2px dashed var(--line); border-radius: var(--radius); cursor: pointer; transition: border-color .2s var(--ease-out), background .2s var(--ease-out); }
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dz-ico { width: 44px; height: 44px; color: var(--muted); margin-bottom: 4px; }
.dz-title { font-weight: 700; font-size: 1.08rem; }
.dz-sub { color: var(--muted); font-size: .92rem; }
.dz-formats { margin-top: 6px; font-family: var(--mono); font-size: .72rem; letter-spacing: .04em; color: var(--muted); }
.idle-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: .95rem; line-height: 1.2; border: 1px solid transparent; transition: background .15s, border-color .15s, transform .1s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { border-color: var(--line); background: var(--surface); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-small { padding: 7px 12px; font-size: .86rem; border: 1px solid var(--line); background: var(--surface); }
.btn-small[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-quiet { border-color: transparent; color: var(--muted); }
.btn-block { width: 100%; margin-top: 10px; white-space: normal; }
.btn-download { width: 100%; margin-top: 14px; padding: 15px 18px; font-size: 1.08rem; background: var(--accent); color: var(--accent-ink); border-radius: 12px; font-weight: 700; }
.btn-download:hover { filter: brightness(1.08); }
.btn[disabled] { opacity: .55; cursor: progress; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { border-color: var(--accent); }

.msg { margin-top: 10px; font-size: .9rem; padding: 8px 12px; border-radius: 8px; background: var(--surface-2); }
.msg.is-error { color: var(--danger); }
.msg.is-ok { color: var(--accent); }

/* Loading */
.pane-loading { text-align: center; padding-block: 40px; }
.spinner { width: 34px; height: 34px; margin: 0 auto 12px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bar { margin: 12px auto 0; max-width: 320px; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* Editor */
.editor { display: grid; gap: 16px; }
@media (min-width: 960px) { .editor { grid-template-columns: minmax(0, 1.45fr) minmax(300px, 1fr); align-items: start; } }
.stage-col { min-width: 0; }
.stage { position: relative; background: var(--stage); border-radius: var(--radius); display: grid; place-items: center; height: clamp(260px, 58vh, 560px); overflow: hidden; touch-action: none;
  background-image: linear-gradient(45deg, rgba(255,255,255,.03) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.03) 75%), linear-gradient(45deg, rgba(255,255,255,.03) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.03) 75%);
  background-size: 20px 20px; background-position: 0 0, 10px 10px; }
@media (max-width: 539px) { .stage { height: 52vh; min-height: 240px; } }
#stageCanvas { max-width: 100%; max-height: 100%; box-shadow: 0 6px 24px rgba(0,0,0,.35); }
.crop-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.crop-overlay[hidden] { display: none !important; }
.crop-shade { fill: rgba(0,0,0,.45); fill-rule: evenodd; }
.crop-poly { fill: none; stroke: #3cc2a6; stroke-width: 2; }
.crop-handle { fill: #fff; stroke: #0b6e5e; stroke-width: 3; pointer-events: all; cursor: grab; }
.crop-handle-hit { fill: transparent; pointer-events: all; cursor: grab; }
.stage-badge { position: absolute; left: 10px; top: 10px; background: rgba(0,0,0,.65); color: #fff; font-size: .78rem; padding: 4px 9px; border-radius: 6px; pointer-events: none; }
.stage-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.dims { margin-left: auto; font-family: var(--mono); font-size: .76rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.panel { min-width: 0; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--surface-2); border-radius: 10px; padding: 4px; }
.tab { padding: 9px 4px; border-radius: 7px; font-size: .86rem; font-weight: 600; color: var(--muted); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.tabpanel { padding-top: 14px; display: grid; gap: 10px; }
.hint { font-size: .88rem; color: var(--muted); }

.field { display: grid; gap: 5px; font-size: .84rem; font-weight: 600; color: var(--muted); }
.field select, .field input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font-weight: 500; font-size: .95rem; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

fieldset { border: 0; padding: 0; min-width: 0; }
legend { font-size: .84rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips legend { width: 100%; }
.chips label, .seg label { position: relative; }
.chips input, .seg input { position: absolute; opacity: 0; pointer-events: none; }
.chips span { display: inline-block; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); font-size: .86rem; cursor: pointer; }
.chips input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chips input:focus-visible + span, .seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; }
.seg legend { grid-column: 1 / -1; }
.seg span { display: block; text-align: center; padding: 10px 4px; border: 1px solid var(--line); font-weight: 700; font-family: var(--mono); font-size: .9rem; cursor: pointer; margin-left: -1px; }
.seg label:first-of-type span { border-radius: 10px 0 0 10px; margin-left: 0; }
.seg label:last-of-type span { border-radius: 0 10px 10px 0; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); position: relative; }

.sliders { display: grid; gap: 10px; }
.slider { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; font-size: .86rem; }
.slider label { font-weight: 600; }
.slider output { font-family: var(--mono); font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 3.2em; text-align: right; }
.slider input { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); }

/* Pages strip */
.pages { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.pages-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; font-size: .9rem; }
.pages-help { color: var(--muted); font-size: .82rem; }
.pages-strip { list-style: none; padding: 10px 2px; display: flex; gap: 10px; overflow-x: auto; }
.page-item { flex: none; width: 104px; display: grid; gap: 4px; }
.page-thumb { position: relative; height: 120px; border-radius: 8px; border: 2px solid var(--line); background: var(--surface-2); display: grid; place-items: center; overflow: hidden; cursor: pointer; padding: 0; }
.page-thumb canvas { max-width: 100%; max-height: 100%; }
.page-item.is-active .page-thumb { border-color: var(--accent); }
.page-num { position: absolute; left: 4px; top: 4px; font-family: var(--mono); font-size: .7rem; background: var(--ink); color: var(--bg); padding: 1px 5px; border-radius: 4px; }
.page-ctrl { display: flex; justify-content: space-between; }
.page-ctrl button { width: 30px; height: 26px; border-radius: 6px; border: 1px solid var(--line); font-size: .85rem; line-height: 1; background: var(--surface); }
.page-ctrl button:hover { border-color: var(--accent); }
.page-ctrl button:disabled { opacity: .35; cursor: default; }
.pages-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.privacy { display: flex; gap: 8px; align-items: flex-start; margin-top: 14px; font-size: .9rem; }
.privacy svg { width: 18px; height: 18px; flex: none; margin-top: 3px; color: var(--accent); }
.limits { margin-top: 4px; color: var(--muted); font-size: .82rem; padding-left: 26px; max-width: 80ch; }

/* Ad placeholders */
.ad-slot { display: grid; place-content: center; justify-items: center; gap: 2px; background: var(--ad-bg); border: 1px dashed var(--ad-line); border-radius: 10px; color: var(--ad-ink); text-align: center; }
.ad-slot span { font-family: var(--mono); font-weight: 500; letter-spacing: .18em; font-size: .9rem; }
.ad-slot small { font-size: .72rem; opacity: .8; }
.ad-leaderboard { margin-top: 24px; min-height: 100px; max-width: 728px; margin-inline: auto; }
.ad-incontent { margin-block: 8px; min-height: 280px; max-width: 336px; margin-inline: auto; }
@media (min-width: 720px) { .ad-incontent { max-width: 728px; min-height: 250px; } }
.ad-modal { min-height: 250px; width: 100%; max-width: 300px; margin: 14px auto 4px; }
.ad-small { min-height: 100px; width: 100%; }

/* 7. Content sections */
.section { padding-block: 44px 8px; }
.section h2 { font-family: var(--display); font-weight: 800; font-size: clamp(1.4rem, 1.1rem + 1.2vw, 2rem); margin-bottom: 18px; }
.steps { list-style: none; padding: 0; display: grid; gap: 14px; counter-reset: step; }
@media (min-width: 720px) { .steps { grid-template-columns: repeat(3, 1fr); gap: 22px; } }
.steps li { counter-increment: step; display: grid; gap: 8px; align-content: start; padding-top: 14px; border-top: 2px solid var(--ink); }
.steps li svg { width: 40px; height: 40px; color: var(--ink); }
.steps h3::before { content: counter(step) ". "; color: var(--accent); }
.steps h3 { font-size: 1.08rem; }
.steps p, .idea p { color: var(--muted); font-size: .95rem; }
.ideas { display: grid; gap: 14px; }
@media (min-width: 720px) { .ideas { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .ideas { grid-template-columns: repeat(3, 1fr); } }
.idea { display: grid; gap: 8px; align-content: start; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.idea h3 { font-size: 1.05rem; }
.idea-spec { justify-self: start; font-family: var(--mono); font-size: .72rem; letter-spacing: .03em; color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 4px; }
.prose { max-width: 760px; }
.prose h3 { margin-top: 20px; margin-bottom: 6px; font-size: 1.08rem; }
.prose p { color: var(--ink); }
.prose > p:first-of-type { color: var(--muted); }
.faq { display: grid; border-top: 1px solid var(--line); max-width: 860px; }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; padding: 14px 32px 14px 0; font-weight: 600; list-style: none; position: relative; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 4px; top: 10px; font-size: 1.4rem; color: var(--accent); }
.faq details[open] summary::after { content: "−"; }
.faq details p { padding-bottom: 14px; color: var(--muted); max-width: 70ch; }

/* Footer */
.site-footer { margin-top: 56px; border-top: 1px solid var(--line); padding-block: 24px 40px; font-size: .88rem; color: var(--muted); }
.footer-row { display: grid; gap: 10px; }
.footer-row nav { display: flex; gap: 18px; flex-wrap: wrap; }
.credits { font-size: .78rem; }

/* Modal & toast */
.modal-backdrop { position: fixed; inset: 0; background: rgba(8, 14, 16, .6); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { position: relative; background: var(--surface); color: var(--ink); border-radius: 16px; padding: 22px 18px 18px; width: min(380px, 100%); box-shadow: var(--shadow); animation: pop .25s var(--ease-out); }
.modal-title { font-weight: 700; text-align: center; padding-inline: 20px; }
.modal-x, .toast-x { position: absolute; top: 6px; right: 8px; width: 32px; height: 32px; border-radius: 8px; font-size: 1.4rem; line-height: 1; color: var(--muted); }
.modal-x:hover, .toast-x:hover { background: var(--surface-2); color: var(--ink); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.ad-toast { position: fixed; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); width: min(300px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px 10px 10px; box-shadow: var(--shadow); z-index: 90; animation: pop .3s var(--ease-out); }
.toast-x { top: 2px; right: 4px; width: 26px; height: 26px; font-size: 1.15rem; }

/* 9. Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .modal, .ad-toast { animation: none; }
}

/* Páginas legales */
.legal h1 { font-family: var(--display); font-weight: 800; font-size: clamp(1.6rem, 1.2rem + 1.5vw, 2.3rem); margin-bottom: 14px; }
.legal h2 { font-size: 1.1rem; margin-top: 22px; margin-bottom: 6px; }
.legal p { margin-bottom: 8px; }
.legal a { color: var(--accent); }
