/* ==========================================================================
   CV Web — hoja de estilos
   1. Tokens y base            5. Hoja del CV (A4)
   2. App bar                  6. Pasos, configuración y descarga
   3. Layout y editor          7. Navegación, avisos y PDF
   4. Formulario               8. Responsive + impresión
   ========================================================================== */

/* 1. Tokens y base ------------------------------------------------------- */
:root {
  --appbar-h: 68px;
  --nav-h: 68px;
  --bg: #eef1f6;
  --bg-soft: #f7f9fc;
  --surface: #fff;
  --ink: #101828;
  --ink-soft: #475467;
  --muted: #667085;
  --line: #dde3ec;
  --line-strong: #c7d0dd;
  --accent: #0b57a4;
  --accent-dark: #08427c;
  --accent-soft: #e8f0fa;
  --danger: #b42318;
  --success: #067647;
  --font-ui: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-cv: Arial, "Helvetica Neue", Helvetica, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

/* El atributo hidden debe ganarle a cualquier display de clase. */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }

svg.ico {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 2. App bar ------------------------------------------------------------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  height: var(--appbar-h);
  min-height: var(--appbar-h);
  padding: 8px 20px;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; color: inherit; }

.brand-logo {
  display: block;
  height: 46px;
  width: auto;
  flex: none;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: 15.5px; letter-spacing: -.01em; }
.brand-text small { color: var(--muted); font-size: 12px; white-space: nowrap; }

.appbar-actions { display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .12s ease, box-shadow .18s ease;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 6px 16px -10px rgba(11, 87, 164, .9);
}

.btn-primary:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-ghost { border-color: var(--line); background: #fff; }
.btn-ghost:hover:not(:disabled) { border-color: var(--line-strong); background: var(--bg-soft); }
.btn-soft { background: var(--accent-soft); color: var(--accent-dark); border-color: #d3e2f5; }
.btn-soft:hover:not(:disabled) { background: #dbe9f9; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn-icon { width: 40px; padding: 0; }
.btn-block { width: 100%; margin-top: 16px; }

/* 3. Layout y editor ----------------------------------------------------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 780px);
  justify-content: center;
  height: calc(100vh - var(--appbar-h) - var(--nav-h));
  height: calc(100dvh - var(--appbar-h) - var(--nav-h));
}

/* El paso 7 muestra solo la vista previa, a pantalla completa. */
body[data-step="7"] .layout {
  grid-template-columns: minmax(0, 1fr);
  justify-content: stretch;
}

body[data-step="7"] .editor { display: none; }
body:not([data-step="7"]) .preview { display: none; }

.editor {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 22px 32px;
  background: linear-gradient(180deg, #f8fafd 0%, #eef1f6 240px);
}

.editor-head {
  position: sticky;
  top: -20px;
  z-index: 6;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 14px;
  margin: -20px -22px 14px;
  padding: 20px 22px 12px;
  background: linear-gradient(180deg, #f8fafd 80%, rgba(248, 250, 253, .72) 100%);
}

.editor-title h1 { font-size: clamp(20px, 2vw, 24px); line-height: 1.2; letter-spacing: -.02em; }
.editor-title p { margin-top: 4px; color: var(--muted); font-size: 13px; max-width: 44ch; }
.editor-actions { display: flex; align-items: flex-start; gap: 8px; }

.save-state { grid-column: 1 / -1; display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12.5px; }
.save-state .dot { width: 7px; height: 7px; border-radius: 50%; background: #12b76a; box-shadow: 0 0 0 3px rgba(18, 183, 106, .16); }
.save-state.is-saving .dot { background: #f79009; box-shadow: 0 0 0 3px rgba(247, 144, 9, .16); }

/* 4. Formulario ---------------------------------------------------------- */
.form { display: flex; flex-direction: column; }

.credits {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.8px;
  text-align: center;
}

.credits a { color: var(--accent-dark); font-weight: 600; text-decoration: none; }
.credits a:hover { text-decoration: underline; }

.step-panel { display: flex; flex-direction: column; gap: 14px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 2px 2px 0; }
.panel-head > div { min-width: 0; }
.list-slot { display: flex; flex-direction: column; gap: 14px; }
.panel-head h2 { font-size: 18px; letter-spacing: -.02em; }
.panel-head p { margin-top: 4px; color: var(--muted); font-size: 13px; max-width: 56ch; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 10px 26px -22px rgba(16, 24, 40, .4);
  padding: 16px;
}

.card-head { display: flex; gap: 11px; align-items: flex-start; margin-bottom: 14px; }
.card-head h2 { font-size: 15.5px; line-height: 1.3; letter-spacing: -.01em; }
.card-head p { margin-top: 3px; color: var(--muted); font-size: 12.8px; line-height: 1.45; }

.step {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.step-aa { font-size: 13px; letter-spacing: -.02em; background: #eef2ff; color: #3538cd; }
.step .ico { width: 16px; height: 16px; }

.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 11px 12px; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.field small { color: var(--muted); font-size: 11.8px; line-height: 1.4; }

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  transition: border-color .16s ease, box-shadow .16s ease;
}

.field textarea { min-height: 84px; resize: vertical; line-height: 1.5; }

.field select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
}

.field input::placeholder, .field textarea::placeholder { color: #98a2b3; }

.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 87, 164, .14);
}

/* Foto opcional */
.photo-row { display: flex; gap: 14px; align-items: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.photo-thumb { flex: none; display: grid; place-items: center; width: 62px; height: 78px; border: 1px dashed var(--line-strong); border-radius: 10px; background: var(--bg-soft); color: var(--muted); overflow: hidden; }
.photo-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo-thumb .ico { width: 26px; height: 26px; }
.photo-actions { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.photo-actions strong { font-size: 13px; color: var(--ink); }
.photo-actions small { color: var(--muted); font-size: 11.8px; line-height: 1.4; }
.photo-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.list-card .items { display: flex; flex-direction: column; gap: 10px; }
.item-card { border: 1px solid var(--line); border-radius: 12px; background: var(--bg-soft); padding: 12px; }
.item-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.item-head span { font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }

.item-remove {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color .16s ease, color .16s ease;
}
.item-remove:hover { background: #fee4e2; color: var(--danger); }
.item-remove .ico { width: 15px; height: 15px; }

.btn-add { width: 100%; height: 40px; margin-top: 10px; border: 1px dashed var(--line-strong); background: #fff; color: var(--accent-dark); font-size: 13.5px; }
.btn-add:hover { background: var(--accent-soft); border-color: #a9c8ea; }
.empty-list { color: var(--muted); font-size: 13px; padding: 2px; }

/* 5. Hoja del CV (A4) ---------------------------------------------------- */
.preview {
  position: relative;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 22px 24px 40px;
  background-color: #e4e9f1;
  background-image: radial-gradient(rgba(16, 24, 40, .055) 1px, transparent 1px);
  background-size: 18px 18px;
}

.preview-toolbar {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -22px -24px 18px;
  padding: 13px 24px;
  background: rgba(228, 233, 241, .92);
  backdrop-filter: blur(8px);
}

.preview-meta { display: flex; align-items: center; gap: 10px; min-width: 0; }
.preview-tag {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent-dark);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}
.preview-info { color: #4b5565; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-actions { display: flex; align-items: center; gap: 8px; }
.btn-print { height: 34px; padding: 0 12px; font-size: 12.5px; }
.btn-print .ico { width: 15px; height: 15px; }

@media (max-width: 560px) {
  .btn-print { width: 38px; padding: 0; }
  .btn-print .btn-print-label { display: none; }
}

.paper-stage { position: relative; width: 100%; display: flex; justify-content: center; }

.paper, .pdf-page {
  font-family: var(--font-body, var(--font-cv));
  font-size: 12pt;
  line-height: 1.32;
  color: #000;
}

.paper {
  position: relative;
  flex: none;
  align-self: flex-start;
  width: 210mm;
  min-height: 297mm;
  padding: 12.7mm;
  background: #fff;
  box-shadow: 0 26px 60px -24px rgba(16, 24, 40, .45), 0 2px 6px rgba(16, 24, 40, .08);
  transform-origin: top left;
}

.cv-titlebar { background: #000; color: #fff; }
.cv-doc-title, .cv-doc-name {
  margin: 0;
  padding: 1.5pt 7pt 2pt;
  font-family: var(--font-title, var(--font-cv));
  font-size: 24pt;
  font-weight: 700;
  line-height: 1.16;
  color: #fff;
}
.cv-doc-name { border-top: 0; }

.cv-photo { margin: 0; line-height: 0; text-align: right; }
.cv-photo img { display: inline-block; width: 24mm; height: 30mm; object-fit: cover; }

.cv-section-title {
  margin: 11pt 0 4pt;
  padding: 1.5pt 6pt 2pt;
  background: #000;
  color: #fff;
  font-family: var(--font-subtitle, var(--font-cv));
  font-size: 14pt;
  font-weight: 700;
  line-height: 1.25;
  break-after: avoid;
  page-break-after: avoid;
}

.cv-para, .cv-personal, .cv-entry, .cv-job-line, .cv-job-desc { margin: 0; text-align: justify; }
.cv-personal strong { font-weight: 700; }

.cv-entry { margin-bottom: 4pt; padding-left: .25in; break-inside: avoid; page-break-inside: avoid; }
.cv-cert, .cv-job, .cv-lang, .cv-skill { break-inside: avoid; page-break-inside: avoid; }
.cv-cert { margin-bottom: 5pt; }
.cv-cert-name { margin: 0; font-weight: 700; }
.cv-cert-meta { margin: 0; }

.cv-skill { display: flex; align-items: baseline; gap: 6pt; }
.cv-skill-name { white-space: nowrap; }
.cv-skill-leader { flex: 1 1 auto; min-width: 10pt; border-bottom: 1px dotted #808080; transform: translateY(-3px); }
.cv-skill-level { white-space: nowrap; }

.cv-list { margin: 2pt 0 0; padding-left: 16pt; }
.cv-list li { margin-bottom: 1pt; }

.cv-job { margin-bottom: 6pt; }
.cv-job-title { font-weight: 700; }
.cv-lang { margin-bottom: 4pt; }
.cv-lang-name { margin: 0; font-weight: 700; }
.cv-lang-sub { margin: 0 0 0 16pt; }

.cv-empty {
  margin-top: 16pt;
  padding: 12pt;
  border: 1pt dashed #b9c3d1;
  color: #475467;
  font-family: var(--font-ui);
  font-size: 10.5pt;
  text-align: center;
}

/* 6. Configuración y descarga ------------------------------------------- */
.type-sample { margin-top: 14px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.type-sample > div { display: flex; gap: 12px; align-items: baseline; padding: 10px 12px; border-top: 1px solid var(--line); }
.type-sample > div:first-child { border-top: 0; }
.type-sample span {
  flex: none;
  min-width: 66px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}
.type-sample p { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sample-title { font-size: 22px; line-height: 1.2; }
.sample-sub { font-size: 16px; font-weight: 700; }
.sample-body { font-size: 14px; }

.spec-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.spec-list li { display: flex; flex-direction: column; gap: 1px; padding: 9px 11px; border-radius: 10px; background: var(--bg-soft); font-size: 13px; }
.spec-list span { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }

.export-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.panel-head .btn { flex: none; }
.export-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  text-align: left;
  cursor: pointer;
  transition: border-color .16s ease, box-shadow .18s ease, transform .12s ease;
}
.export-btn:hover { border-color: var(--accent); box-shadow: 0 10px 24px -18px rgba(11, 87, 164, .9); }
.export-btn:active { transform: translateY(1px); }
.export-btn .ico { width: 22px; height: 22px; color: var(--accent); }
.export-btn strong { font-size: 14px; }
.export-btn small { color: var(--muted); font-size: 11.8px; line-height: 1.4; }

.file-hint { margin-top: 12px; color: var(--muted); font-size: 12.5px; word-break: break-word; }
.file-hint strong { color: var(--ink-soft); font-weight: 600; }
.share-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.share-note { color: var(--muted); font-size: 11.8px; line-height: 1.4; }

/* 7. Pasos, navegación, avisos, PDF ------------------------------------- */
.stepper {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  padding-bottom: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.stepper::-webkit-scrollbar { display: none; }

.stepper-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px 0 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}
.stepper-btn .num { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #eef2f8; color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.stepper-btn:hover { border-color: var(--line-strong); }
.stepper-btn.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.stepper-btn.is-active .num { background: rgba(255, 255, 255, .22); color: #fff; }
.stepper-btn.is-done .num { background: #e7f6ee; color: var(--success); }

.wizard-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 42;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--nav-h);
  padding: 10px 20px calc(10px + env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 30px -26px rgba(16, 24, 40, .6);
}
.wizard-progress { color: var(--muted); font-size: 13px; font-weight: 600; text-align: center; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 16px);
  z-index: 90;
  max-width: calc(100vw - 32px);
  padding: 11px 16px;
  border-radius: 999px;
  background: #101828;
  color: #fff;
  font-size: 13.5px;
  box-shadow: 0 16px 40px -18px rgba(16, 24, 40, .8);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: #7a271a; }

.pdf-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 24px;
  overflow: auto;
  background: #eef1f6;
}
.pdf-pages { display: flex; flex-direction: column; gap: 18px; }
.pdf-status {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 81;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 20px 50px -20px rgba(16, 24, 40, .55);
  font-size: 14px;
  font-weight: 600;
  transform: translate(-50%, -50%);
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #d3e2f5;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pdf-page {
  position: relative;
  width: 210mm;
  height: 297mm;
  padding: 12.7mm;
  overflow: hidden;
  background: #fff;
}
.pdf-page .pdf-flow { display: flow-root; height: 100%; overflow: hidden; }

/* 8. Responsive + impresión --------------------------------------------- */
@media (max-width: 1024px) {
  .layout { display: block; height: auto; min-height: calc(100dvh - var(--appbar-h)); }
  .editor { overflow: visible; padding: 16px 18px 28px; border-right: 0; }
  .editor-head { top: -16px; margin: -16px -18px 12px; padding: 16px 18px 10px; }
  .preview { padding: 16px 12px 28px; min-height: calc(100dvh - var(--appbar-h)); }
  .preview-toolbar { margin: -16px -12px 16px; padding: 11px 12px; }
  body[data-step="7"] .preview { min-height: calc(100dvh - var(--appbar-h) - var(--nav-h)); }
  .wizard-progress { display: none; }
  .wizard-nav { justify-content: space-between; }
  .wizard-nav .btn { min-width: 0; }
  body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
}

@media (max-width: 720px) {
  :root { --appbar-h: 58px; --nav-h: 64px; }
  .appbar { padding: 8px 12px; gap: 8px; }
  .brand-text small { display: none; }
  .brand-logo { height: 40px; }
  .appbar-actions { gap: 6px; }
  .btn { height: 38px; padding: 0 11px; font-size: 13.5px; }
  .btn-icon { width: 38px; }
  .editor { padding: 12px 12px 24px; }
  .editor-head { top: -12px; grid-template-columns: 1fr; margin: -12px -12px 10px; padding: 12px 12px 8px; }
  .editor-title h1 { font-size: 20px; }
  .editor-title p { font-size: 12.5px; }
  .editor-actions { justify-content: flex-start; flex-wrap: wrap; }
  .card { padding: 14px; border-radius: 12px; }
  .panel-head h2 { font-size: 17px; }
  .stepper { margin-bottom: 12px; }
  .grid { gap: 10px; }
  .col-4, .col-5, .col-6, .col-7, .col-8 { grid-column: span 12; }
  .field input, .field textarea, .field select { font-size: 16px; min-height: 44px; }
  .spec-list { grid-template-columns: 1fr; }
  .export-actions { grid-template-columns: 1fr; }
  .preview { padding: 12px 6px 20px; }
  .preview-toolbar { margin: -12px -6px 12px; padding: 10px 10px; }
  .preview-info { display: none; }
  .wizard-nav { padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); }
  .wizard-nav .btn { height: 42px; font-size: 14px; padding: 0 14px; }
  .toast { bottom: calc(var(--nav-h) + 12px); font-size: 13px; }
  .pdf-overlay { padding: 10px; }
}

@media (max-width: 480px) {
  .btn-label { display: none; }
  .btn:has(.btn-label) { width: 38px; padding: 0; }
  .brand-text strong { font-size: 14.5px; }
  .type-sample > div { flex-direction: column; gap: 2px; }
  .type-sample span { min-width: 0; }
  .type-sample p { white-space: normal; }
  .wizard-nav .btn-label { display: inline; }
  .wizard-nav .btn:has(.btn-label) { width: auto; padding: 0 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* 9. Modo oscuro --------------------------------------------------------- */
html[data-theme="dark"] { background: #0a0f16; }

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0f16;
  --bg-soft: #111a24;
  --surface: #131c27;
  --surface-2: #0e1620;
  --ink: #eaf0f8;
  --ink-soft: #c9d5e4;
  --muted: #9dadc1;
  --line: #24303e;
  --line-strong: #35455a;
  --accent: #63a9f0;
  --accent-dark: #84bcf5;
  --accent-soft: #142538;
  --danger: #ff8f85;
  --success: #6fe0a5;
}

.theme-toggle { flex: none; }
.icon-sun { display: none; }
html[data-theme="dark"] .icon-sun { display: block; }
html[data-theme="dark"] .icon-moon { display: none; }

html[data-theme="dark"] .appbar { background: rgba(13, 19, 27, .94); }
html[data-theme="dark"] .brand-logo { filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .55)); }
html[data-theme="dark"] .btn-ghost { background: var(--surface-2); }
html[data-theme="dark"] .btn-primary { color: #06121f; }
html[data-theme="dark"] .btn-primary:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); color: #06121f; }
html[data-theme="dark"] .btn-soft { border-color: #23415f; }
html[data-theme="dark"] .btn-add { background: var(--surface-2); color: var(--accent-dark); border-color: var(--line-strong); }
html[data-theme="dark"] .btn-add:hover { background: var(--accent-soft); border-color: #3a6288; }

html[data-theme="dark"] .editor { background: linear-gradient(180deg, #0d151f 0%, var(--bg) 240px); }
html[data-theme="dark"] .editor-head { background: linear-gradient(180deg, #0d151f 80%, rgba(13, 21, 31, .72) 100%); }
html[data-theme="dark"] .card { box-shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 14px 30px -24px rgba(0, 0, 0, .85); }

html[data-theme="dark"] .field input,
html[data-theme="dark"] .field textarea,
html[data-theme="dark"] .field select { background-color: var(--surface-2); color: var(--ink); border-color: var(--line-strong); }
html[data-theme="dark"] .field input::placeholder,
html[data-theme="dark"] .field textarea::placeholder { color: #74869b; }
html[data-theme="dark"] .field select {
  color-scheme: dark;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239DADC1' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
}
html[data-theme="dark"] .field select option,
html[data-theme="dark"] .field select optgroup {
  background-color: #0e1620;
  color: #eaf0f8;
}
html[data-theme="dark"] .field select option:disabled { color: #74869b; }
html[data-theme="dark"] .field input:focus,
html[data-theme="dark"] .field textarea:focus,
html[data-theme="dark"] .field select:focus { box-shadow: 0 0 0 3px rgba(99, 169, 240, .22); }
html[data-theme="dark"] .item-remove:hover { background: rgba(255, 143, 133, .16); }

html[data-theme="dark"] .preview {
  background-color: #0c141d;
  background-image: radial-gradient(rgba(255, 255, 255, .06) 1px, transparent 1px);
}
html[data-theme="dark"] .preview-toolbar { background: rgba(12, 20, 29, .92); }
html[data-theme="dark"] .preview-tag { background: var(--surface); color: var(--accent-dark); }
html[data-theme="dark"] .preview-info { color: var(--muted); }
html[data-theme="dark"] .paper { box-shadow: 0 26px 60px -24px rgba(0, 0, 0, .85), 0 0 0 1px rgba(255, 255, 255, .08); }

html[data-theme="dark"] .stepper-btn { background-color: var(--surface-2); }
html[data-theme="dark"] .stepper-btn .num { background: var(--bg-soft); color: var(--ink-soft); }
html[data-theme="dark"] .stepper-btn:hover { border-color: var(--line-strong); }
html[data-theme="dark"] .stepper-btn.is-active,
html[data-theme="dark"] .stepper-btn.is-active:hover { background: var(--accent); border-color: var(--accent); color: #06121f; }
html[data-theme="dark"] .stepper-btn.is-active .num { background: rgba(0, 0, 0, .18); color: #06121f; }
html[data-theme="dark"] .stepper-btn.is-done .num { background: rgba(111, 224, 165, .16); color: var(--success); }
html[data-theme="dark"] .step-aa { background: #1b2340; color: #b3bdfb; }

html[data-theme="dark"] .type-sample { background: var(--surface-2); }
html[data-theme="dark"] .export-btn { background: var(--surface-2); }
html[data-theme="dark"] .export-btn:hover { border-color: var(--accent); box-shadow: 0 10px 24px -18px rgba(99, 169, 240, .8); }
html[data-theme="dark"] .wizard-nav { background: var(--surface); }
html[data-theme="dark"] .toast { background: #eaf0f8; color: #0a0f16; }
html[data-theme="dark"] .toast.is-error { background: #ffd9d6; color: #5b1512; }

html[data-theme="dark"] .pdf-overlay { background: var(--bg); }
html[data-theme="dark"] .pdf-status { background: var(--surface); color: var(--ink); }
html[data-theme="dark"] .spinner { border-color: #2a3a4c; border-top-color: var(--accent); }

@media print {
  @page { size: A4 portrait; margin: 0; }

  html, body { background: #fff; height: auto; min-height: 0; overflow: visible; padding-bottom: 0; }
  .appbar, .editor, .preview-toolbar, .wizard-nav, .toast, .pdf-overlay { display: none !important; }
  .layout { display: block; height: auto; }
  .preview { display: block !important; padding: 0; background: #fff; overflow: visible; min-height: 0; }
  .paper-stage { display: block; width: auto !important; height: auto !important; }
  .paper { width: 100%; min-height: 0; padding: 12.7mm; box-shadow: none; transform: none !important; font-size: 12pt; }
}
