*, *::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-warn: #d97706; --color-info: #0284c7;
  --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-warn: #fbbf24; --color-info: #38bdf8;
  --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 20px; 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; }

.notice { display: flex; gap: 12px; padding: 14px 18px; border-radius: var(--radius-md); background: var(--color-accent-soft); color: var(--color-text); font-size: .9rem; margin: 8px 0 20px; border: 1px solid color-mix(in srgb, var(--color-accent) 30%, transparent); }
.notice-icon { width: 22px; height: 22px; color: var(--color-accent); flex-shrink: 0; margin-top: 2px; }
.notice em { color: var(--color-text-muted); }
.notice code { background: color-mix(in srgb, var(--color-accent) 18%, transparent); color: var(--color-accent); padding: 1px 6px; border-radius: 4px; font-size: .9em; }

.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; }
.hint { color: var(--color-text-muted); font-size: .82rem; margin: 10px 0 0; }

.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; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: .88rem; font-weight: 600; margin-bottom: 6px; color: var(--color-text); }
.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 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 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; }

.actions-list { display: flex; flex-direction: column; gap: 6px; margin: 16px 0; padding-top: 16px; border-top: 1px solid var(--color-border); }
.actions-list .btn { padding: 9px 14px; font-size: .88rem; }

.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-ghost:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }
.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); } }

.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: 900px) {
  .workspace { grid-template-columns: 1fr 340px; align-items: start; }
  .options-col { position: sticky; top: 84px; }
}

/* ---------- Buscar y marcar / etiquetas / verificación ---------- */
.options-col .section-title { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--color-border); }
.field textarea, .field input[type="text"] { width: 100%; padding: 9px 12px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-bg); color: var(--color-text); font: inherit; font-size: .9rem; }
.field textarea { resize: vertical; min-height: 84px; }
.field textarea:focus, .field input[type="text"]:focus { border-color: var(--color-accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 20%, transparent); }
.field small code { background: var(--color-bg-alt); padding: 0 4px; border-radius: 4px; }
.patterns { border: 0; padding: 0; margin: 0 0 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.patterns legend { font-size: .88rem; font-weight: 600; margin-bottom: 6px; padding: 0; grid-column: 1 / -1; }
.patterns .check { display: flex; align-items: center; gap: 6px; font-size: .86rem; cursor: pointer; }
.btn-link { background: none; border: 0; padding: 6px 0 0; color: var(--color-accent); font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; text-decoration: underline; }
.spinner-dark { border-color: color-mix(in srgb, var(--color-text) 25%, transparent); border-top-color: var(--color-accent); }
.result-box { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm); font-size: .84rem; line-height: 1.45; border: 1px solid var(--color-border); background: var(--color-bg-alt); }
.result-box ul { margin: 6px 0 0; padding-left: 18px; }
.result-box.is-ok { background: color-mix(in srgb, #16a34a 12%, transparent); border-color: color-mix(in srgb, #16a34a 40%, transparent); }
.result-box.is-warn { background: color-mix(in srgb, var(--color-warn) 14%, transparent); border-color: color-mix(in srgb, var(--color-warn) 45%, transparent); }
@media (min-width: 900px) {
  .options-col { max-height: calc(100vh - 100px); overflow-y: auto; }
}
.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 code { background: var(--color-surface); border: 1px solid var(--color-border); padding: 0 5px; border-radius: 4px; font-size: .9em; }
.site-footer a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.site-footer a:hover { color: var(--color-accent); }

/* ---------- Convertir Word y PDF ---------- */
.dropzone small { color: var(--color-text-muted); font-size: .82rem; }
.output-col { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 18px; min-width: 0; }
.ws-title { font-size: 1.15rem; margin: 0 0 12px; }
.conv-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; padding: 0; list-style: none; }
.conv-list > li.is-current, .conv-item { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; background: var(--color-bg-alt); border: 1px solid var(--color-border); border-radius: 999px; padding: 4px 12px; font: inherit; font-size: .82rem; color: var(--color-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item { cursor: pointer; color: var(--color-text-muted); }
.conv-item:hover { border-color: var(--color-accent); }
.conv-item.is-current { color: var(--color-accent); border-color: var(--color-accent); background: var(--color-accent-soft); font-weight: 600; }
.conv-item.is-bad { text-decoration: line-through; text-decoration-color: var(--color-warn); }
.conv-meta { color: var(--color-text-muted); font-weight: 400; font-size: .76rem; }
.preview-caption { font-size: .82rem; color: var(--color-text-muted); margin: 12px 0 6px; }
.preview-caption[hidden] { display: none; }
.paper-scroll { max-height: 70vh; overflow: auto; background: #e5e7eb; border-radius: var(--radius-md); padding: 18px; margin-top: 12px; }
[data-theme="dark"] .paper-scroll { background: #1e293b; }
.paper { background: #fff; color: #111; max-width: 680px; margin: 0 auto; padding: 48px 56px; box-shadow: 0 2px 10px rgba(0,0,0,.18); min-height: 300px; }
.paper.is-justified p { text-align: justify; }
.paper p { margin: 0 0 .6em; }
.paper h2 { font-size: 1.45em; margin: 1em 0 .4em; } .paper h3 { font-size: 1.25em; margin: .9em 0 .4em; } .paper h4 { font-size: 1.12em; margin: .8em 0 .4em; }
.paper ul { margin: 0 0 .3em; padding-left: 1.6em; }
.paper table { border-collapse: collapse; width: 100%; margin: .4em 0 .9em; font-size: .92em; }
.paper td { border: 1px solid #808080; padding: 3px 7px; vertical-align: top; }
.paper .fn-ref { font-size: .7em; }
.paper-notes { border-top: 1px solid #999; margin-top: 1.5em; padding-top: .5em; font-size: .85em; }
.paper-notes p { margin: 0 0 .3em; }
.paper-break { margin: 1.2em -56px; border-top: 2px dashed #9ca3af; text-align: center; font: 600 .7rem var(--font-sans); color: #6b7280; text-transform: uppercase; letter-spacing: .08em; padding-top: 2px; }
.paper-empty { color: #6b7280; text-align: center; padding: 40px 0; }
.output-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.output-actions .btn { flex: 1 1 200px; }
.output-actions-top { margin-top: 14px; }
.btn[hidden] { display: none; }
.options-col .field-check { margin-bottom: 12px; }
.options-col .field-check small { margin-left: 24px; }
.progress { height: 6px; background: var(--color-bg-alt); border-radius: 999px; overflow: hidden; border: 1px solid var(--color-border); margin-top: 14px; }
.progress-bar { height: 100%; width: 0; background: var(--color-accent); transition: width .15s ease; }
.progress-label { font-size: .85rem; color: var(--color-text-muted); margin-top: 6px; }
.error-box code { background: color-mix(in srgb, var(--color-danger) 15%, transparent); padding: 0 4px; border-radius: 4px; }
.workspace-single { grid-template-columns: 1fr !important; }
.docx-scroll { margin-top: 14px; max-height: 80vh; overflow: auto; border-radius: var(--radius-md); }
.docx-render .docx-wrapper { background: #e5e7eb; padding: 20px 20px 0; }
[data-theme="dark"] .docx-render .docx-wrapper { background: #1e293b; }
.docx-render .docx-wrapper > section.docx { box-shadow: 0 2px 10px rgba(0,0,0,.25); margin-bottom: 20px; }
.docx-render.is-flow .docx-wrapper > section.docx > header, .docx-render.is-flow .docx-wrapper > section.docx > footer { opacity: .35; }
.guide .guide-sub { margin: 18px 0 8px; font-size: 1rem; color: var(--color-text); }
.guide h2 + .guide-sub { margin-top: 0; }
.workspace[hidden], .result-box[hidden], .error-box[hidden] { display: none; }
