/* ── Base ─────────────────────────────────────────────────────────────────── */
:root {
  --brand: #6d28d9;
  --brand-d: color-mix(in srgb, var(--brand) 80%, #000);
  --brand-50: color-mix(in srgb, var(--brand) 8%, #fff);
  --ink: #0f172a; --ink-2: #334155; --muted: #64748b; --line: #e2e8f0; --bg: #f6f7fb; --card: #fff;
  --r: 14px; --r-sm: 10px;
  --sh: 0 1px 2px rgba(15, 23, 42, .05), 0 10px 30px rgba(15, 23, 42, .07);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.55 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 99; background: #fff; padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ── Encabezado y pie ─────────────────────────────────────────────────────── */
.top { background: #fff; border-bottom: 1px solid var(--line); position: relative; z-index: 20; }
.top-in { max-width: 1180px; margin: 0 auto; padding: 10px 18px; display: flex; align-items: center; gap: 18px; }
.logo { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 20px; color: var(--ink); text-decoration: none; letter-spacing: -.02em; }
.logo svg { width: 32px; height: 32px; }
.nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; align-items: center; }
.nav a { color: var(--ink-2); text-decoration: none; font-size: 14.5px; font-weight: 600; padding: 7px 10px; border-radius: 9px; }
.nav a:hover, .nav a[aria-current="page"] { background: var(--brand-50); color: var(--brand); }
.menu-btn { display: none; margin-left: auto; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 7px 12px; font-size: 18px; cursor: pointer; }

.foot { background: #0f172a; color: #cbd5e1; margin-top: 64px; padding: 40px 18px 28px; font-size: 14.5px; }
.foot-in { max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 28px; }
.foot a { color: #e2e8f0; text-decoration: none; }
.foot a:hover { text-decoration: underline; }
.foot h4 { color: #fff; margin: 0 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; }
.foot ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.foot .logo { color: #fff; }
.foot-legal { max-width: 1180px; margin: 26px auto 0; padding-top: 18px; border-top: 1px solid #1e293b; font-size: 13px; color: #94a3b8; }

main { max-width: 1180px; margin: 0 auto; padding: 0 18px; }

/* ── Héroe ────────────────────────────────────────────────────────────────── */
.hero { text-align: center; padding: 30px 0 20px; max-width: 860px; margin: 0 auto; }
.hero h1 { font-size: clamp(26px, 4vw, 40px); margin: 0 0 12px; font-weight: 850; }
.hero h1 span { color: var(--brand); }
.hero p { font-size: clamp(16px, 2vw, 19px); color: var(--ink-2); margin: 0 auto; max-width: 720px; }
.pills { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; list-style: none; padding: 0; margin: 16px 0 0; }
.pills li { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.crumbs { font-size: 13.5px; color: var(--muted); padding-top: 16px; }
.crumbs a { color: var(--muted); }

/* ── Formularios y botones ────────────────────────────────────────────────── */
.full { grid-column: 1 / -1; }
.fld { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fld > span:first-child { font-size: 12.5px; font-weight: 650; color: var(--muted); }
.fld small { font-size: 12.5px; color: var(--muted); }
input, select, textarea { font: inherit; font-size: 15px; color: var(--ink); background: #fff; border: 1px solid #cbd5e1; border-radius: var(--r-sm); padding: 9px 11px; width: 100%; min-width: 0; }
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
input[type="checkbox"] { width: auto; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 14.5px; color: var(--ink-2); cursor: pointer; grid-column: 1 / -1; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 12px; padding: 12px 16px; font: inherit; font-weight: 750; font-size: 15.5px; cursor: pointer; text-decoration: none; border: 1px solid transparent; line-height: 1.2; text-align: center; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-pri { background: var(--brand); color: #fff; }
.btn-pri:hover { background: var(--brand-d); }
.btn-sec { background: #fff; color: var(--ink); border-color: #cbd5e1; }
.btn-sec:hover { border-color: var(--brand); color: var(--brand); }

/* ── Editor ───────────────────────────────────────────────────────────────── */
.editor { min-height: 420px; }
.ed-loading { padding: 60px 0; text-align: center; color: var(--muted); }
.ed { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 22px; align-items: start; }
.ed-form { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: 0 1px 2px rgba(15, 23, 42, .03); }
.ed-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 12px 14px; }
.ed-prev { position: sticky; top: 14px; }
.ed-avisos .note { margin: 0 0 10px; }
.ed-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.ed-estado { margin: 8px 0 0; min-height: 1.3em; }

/* La hoja (vista previa, ejemplo e impresión) */
.hoja { background: #fff; color: #111827; border-radius: 6px; box-shadow: var(--sh); padding: 46px 50px; font: 15px/1.6 Helvetica, Arial, sans-serif; min-height: 480px; overflow-wrap: anywhere; }
.hoja p { margin: 0 0 12px; }
.hoja .h-derecha { text-align: right; margin-bottom: 22px; }
.hoja .h-titulo { text-align: center; font-size: 17px; font-weight: 700; letter-spacing: .04em; margin: 6px 0 18px; }
.hoja .h-p { white-space: pre-line; }
.h-firmas { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; margin-top: 46px; text-align: center; }
.h-firmas.uno { grid-template-columns: minmax(0, 260px); justify-content: center; }
.h-linea { border-top: 1px solid #374151; margin-bottom: 6px; }
.h-fn { font-weight: 700; }
mark.hueco { background: #fef3c7; color: #92400e; border-radius: 4px; padding: 0 4px; font-style: italic; }
.ejemplo .hoja { min-height: 0; }
.ejemplo .hoja p { color: #111827; line-height: 1.6; }

/* ── Contenido (SEO) ──────────────────────────────────────────────────────── */
.content { max-width: 860px; margin: 44px auto 0; }
.content h2 { font-size: clamp(22px, 3vw, 28px); margin: 42px 0 12px; }
.content p, .content li { color: var(--ink-2); line-height: 1.7; }
.content li { margin: 4px 0; }
.steps { counter-reset: s; list-style: none; padding: 0; display: grid; gap: 12px; }
.steps li { counter-increment: s; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px 14px 58px; position: relative; }
.steps li::before { content: counter(s); position: absolute; left: 16px; top: 14px; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 800; display: grid; place-items: center; font-size: 14px; }
.links { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; list-style: none; padding: 0; }
.links a { display: block; background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 11px 13px; text-decoration: none; color: var(--ink); font-weight: 650; font-size: 15px; height: 100%; }
.links a:hover { border-color: var(--brand); color: var(--brand); }
.links small { display: block; color: var(--muted); font-weight: 500; font-size: 13.5px; margin-top: 2px; }
.faq details { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 13px 16px; margin: 8px 0; }
.faq summary { font-weight: 700; cursor: pointer; }
.faq details p { margin: 10px 0 2px; }
.note { background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px; padding: 12px 14px; color: #78350f; font-size: 15px; }
.cta-box { background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 60%, #1e3a8a)); color: #fff; border-radius: 18px; padding: 22px 24px; margin: 40px 0; display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; }
.cta-box p { color: #ede9fe; margin: 4px 0 0; }
.cta-box h2 { margin: 0; color: #fff; font-size: 22px; }
.cta-box .btn { background: #fff; color: var(--brand); }

/* ── Anuncios (AdSense) ───────────────────────────────────────────────────── */
.ad { max-width: 860px; margin: 36px auto; min-height: 120px; text-align: center; }
.ad-label { display: block; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.ad:has(ins.adsbygoogle[data-ad-status="unfilled"]) { display: none; }
.ad--demo::after { content: "Espacio para anuncio · se llena con Google AdSense cuando publiques el sitio"; display: flex; align-items: center; justify-content: center; min-height: 160px; padding: 12px; border: 2px dashed #cbd5e1; border-radius: 14px; color: var(--muted); font-size: 14px; background: repeating-linear-gradient(45deg, #f8fafc 0 10px, #f1f5f9 10px 20px); }

/* ── Impresión: en las páginas con formato sale solo la carta ─────────────── */
#print-root { display: none; }
@media print {
  @page { margin: 2.5cm; }
  body { background: #fff; }
  body.con-editor > :not(#print-root) { display: none !important; }
  body.con-editor #print-root { display: block !important; }
  #print-root .hoja { box-shadow: none; border-radius: 0; padding: 0; min-height: 0; font-size: 12pt; }
}

/* ── Responsivo ───────────────────────────────────────────────────────────── */
@media (max-width: 1000px) {
  .ed { grid-template-columns: minmax(0, 1fr); }
  .ed-prev { position: static; }
  .foot-in { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .menu-btn { display: block; }
  .nav { display: none; position: absolute; top: 100%; left: 0; right: 0; background: #fff; border-bottom: 1px solid var(--line); padding: 8px 12px 12px; flex-direction: column; align-items: stretch; box-shadow: var(--sh); }
  .nav.open { display: flex; }
  .nav a { padding: 11px 12px; font-size: 16px; }
}
@media (max-width: 560px) {
  main { padding: 0 12px; }
  .hero { padding: 22px 0 14px; }
  .ed-form { padding: 14px; }
  input, select, textarea { font-size: 16px; }
  .hoja { padding: 26px 20px; font-size: 14px; }
  .h-firmas { grid-template-columns: minmax(0, 1fr); gap: 34px; }
  .ed-acts { grid-template-columns: 1fr; }
  .foot-in { grid-template-columns: 1fr; }
}
