/* ==========================================================================
   Fijate Tools - Generador de carta oficial a los Reyes Magos y Papá Noel
   Tema oscuro por defecto en :root / [data-theme="dark"] y claro en [data-theme="light"]
   ========================================================================== */

:root,
[data-theme="dark"] {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-serif-doc: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-script-doc: 'Dancing Script', 'Brush Script MT', cursive;

  --bg-page: #090d16;
  --bg-surface: #111827;
  --bg-card: #111827;
  --bg-card-subtle: #182235;
  --bg-input: #0f172a;
  --border-color: #273549;
  --border-focus: #38bdf8;

  --text-main: #f8fafc;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;

  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --primary-color: #38bdf8;
  --primary-light: rgba(56, 189, 248, 0.14);
  --primary-border: rgba(56, 189, 248, 0.35);

  --festive-gold: #f59e0b;
  --festive-gold-soft: rgba(245, 158, 11, 0.14);
  --festive-gold-border: rgba(245, 158, 11, 0.38);
  --festive-crimson: #ef4444;
  --festive-crimson-soft: rgba(239, 68, 68, 0.14);

  --success: #10b981;
  --danger: #ef4444;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-card: 0 10px 28px -6px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg-page: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-subtle: #f8fafc;
  --bg-input: #ffffff;
  --border-color: #cbd5e1;
  --border-focus: #0284c7;

  --text-main: #0f172a;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #475569;
  --text-subtle: #64748b;

  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-color: #0284c7;
  --primary-light: #e0f2fe;
  --primary-border: #7dd3fc;

  --festive-gold: #d97706;
  --festive-gold-soft: #fffbeb;
  --festive-gold-border: #fcd34d;
  --festive-crimson: #dc2626;
  --festive-crimson-soft: #fef2f2;

  --shadow-card: 0 6px 20px -4px rgba(15, 23, 42, 0.08);
  color-scheme: light;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-page);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  line-height: 1.55;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
.brand-title,
.hero-title,
.editor-title,
.preview-title {
  font-family: var(--font-heading);
}

.mono,
code {
  font-family: var(--font-mono);
}

.tool-layout {
  flex: 1 0 auto;
  margin-top: 1.25rem;
  margin-bottom: 3rem;
}

/* ==========================================================================
   Hero y barra superior del estudio
   ========================================================================== */

.studio-hero {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(56, 189, 248, 0.08));
  border: 1px solid var(--festive-gold-border);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.5rem;
  margin-bottom: 1.25rem;
}

[data-theme="light"] .studio-hero {
  background: linear-gradient(135deg, #fffbeb, #f0f9ff);
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.28rem 0.72rem;
  border-radius: 9999px;
  font-size: 0.76rem;
  font-weight: 700;
  background: var(--festive-gold-soft);
  color: var(--festive-gold);
  border: 1px solid var(--festive-gold-border);
  margin-bottom: 0.65rem;
}

.hero-title {
  margin: 0 0 0.45rem 0;
  font-size: clamp(1.22rem, 2.2vw, 1.6rem);
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.25;
}

.hero-desc {
  margin: 0;
  font-size: 0.93rem;
  color: var(--text-muted);
  max-width: 880px;
}

.card-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.studio-toolbar {
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.25rem;
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 1.15rem;
  align-items: end;
}

@media (max-width: 960px) {
  .studio-toolbar {
    grid-template-columns: 1fr;
  }
}

.toolbar-block {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 0;
}

.toolbar-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.mode-tabs,
.style-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.mode-tab,
.style-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 42px;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.mode-tab:hover,
.style-pill:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

.mode-tab.is-active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.style-pill.is-active {
  background: var(--festive-gold-soft);
  border-color: var(--festive-gold);
  color: var(--text-main);
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(15, 23, 42, 0.25);
  flex-shrink: 0;
}

.swatch-pergamino {
  background: linear-gradient(135deg, #f8ecc9, #c99732);
}

.swatch-laponia {
  background: linear-gradient(135deg, #b91c1c, #15803d);
}

.swatch-nordico {
  background: linear-gradient(135deg, #ffffff, #64748b);
}

/* ==========================================================================
   Área de trabajo 2 columnas (editor + vista previa)
   ========================================================================== */

.studio-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.03fr) minmax(0, 0.97fr);
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 1060px) {
  .studio-workspace {
    grid-template-columns: 1fr;
  }
}

.editor-panel {
  padding: 1.25rem;
  min-width: 0;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.85rem;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.editor-title {
  margin: 0 0 0.2rem 0;
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text-main);
}

.editor-subtitle {
  margin: 0;
  font-size: 0.83rem;
  color: var(--text-muted);
}

.editor-quick-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.btn-ghost-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card-subtle);
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.btn-ghost-sm:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-ghost-danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.mode-panel {
  display: none;
}

.mode-panel.is-active {
  display: block;
}

/* Formularios responsivos y accesibles */
.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

@media (max-width: 560px) {
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}

.form-span-2 {
  grid-column: 1 / -1;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.field-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.field-hint {
  display: block;
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.field-input,
.field-select,
.field-textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-input);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.9rem;
  line-height: 1.4;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field-textarea {
  min-height: 70px;
  resize: vertical;
}

.field-input:focus,
.field-select:focus,
.field-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.field-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

.field-select option {
  background-color: var(--bg-input);
  color: var(--text-main);
}

[data-theme="light"] .field-select option {
  background-color: #ffffff;
  color: #0f172a;
}

.input-with-btn {
  display: flex;
  gap: 0.45rem;
  align-items: stretch;
  width: 100%;
  min-width: 0;
}

.input-with-btn .field-input {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
}

.btn-inline {
  min-height: 42px;
  padding: 0 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--primary-border);
  background: var(--primary-light);
  color: var(--primary);
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-inline:hover {
  background: var(--primary);
  color: #090d16;
}

[data-theme="light"] .btn-inline:hover {
  color: #ffffff;
}

.divider-line {
  height: 1px;
  background: var(--border-color);
  margin: 1.15rem 0;
}

.wishes-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
  flex-wrap: wrap;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}

.toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex-shrink: 0;
  cursor: pointer;
}

.wishes-inputs-grid {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.wishes-inputs-grid.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.wish-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.wish-input-row .field-input {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
}

.wish-num {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--festive-gold-soft);
  border: 1px solid var(--festive-gold-border);
  color: var(--festive-gold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  border: 1px solid var(--border-color);
  background: var(--bg-card-subtle);
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.chip-btn:hover {
  border-color: var(--festive-gold);
  background: var(--festive-gold-soft);
  color: var(--text-main);
}

/* Editor de etiquetas (modo 3) */
.tags-bulk-bar {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.tags-editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

@media (max-width: 580px) {
  .tags-editor-grid {
    grid-template-columns: 1fr;
  }
}

.tag-edit-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
}

.tag-edit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--festive-gold);
}

.tag-edit-card .field-input,
.tag-edit-card .field-select {
  min-height: 38px;
  padding: 0.4rem 0.65rem;
  font-size: 0.84rem;
}

.tag-edit-card .field-select {
  padding-right: 34px;
}

/* ==========================================================================
   Columna derecha: Previsualización A4 escalada sin desbordes y exportación
   ========================================================================== */

.preview-panel {
  overflow: hidden;
  min-width: 0;
  position: sticky;
  top: 72px;
}

@media (max-width: 1060px) {
  .preview-panel {
    position: static;
  }
}

.preview-header {
  padding: 0.95rem 1.2rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.preview-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

.preview-meta {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.preview-stage-outer {
  padding: 1rem;
  background: var(--bg-card-subtle);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  overflow: hidden;
}

.preview-scale-container {
  position: relative;
  width: 794px;
  height: 1123px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.42);
  border-radius: 4px;
  overflow: hidden;
}

.export-actions {
  padding: 1rem 1.2rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.export-secondary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

@media (max-width: 520px) {
  .export-secondary-grid {
    grid-template-columns: 1fr;
  }
}

.btn-primary-action,
.btn-secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 44px;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.btn-primary-action {
  background: var(--primary);
  color: #06121e;
}

[data-theme="light"] .btn-primary-action {
  color: #ffffff;
}

.btn-primary-action:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary-action {
  background: var(--bg-card-subtle);
  color: var(--text-main);
  border-color: var(--border-color);
  font-size: 0.84rem;
}

.btn-secondary-action:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.privacy-note {
  margin: 0.15rem 0 0 0;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.77rem;
  color: var(--text-muted);
}

.privacy-note svg {
  color: var(--success);
  flex-shrink: 0;
}

/* ==========================================================================
   Lámina A4 imprimible (siempre sobre tonos de papel físicos claros)
   Dimensiones lógicas: 794px × 1123px (210mm × 297mm a 96 DPI)
   ========================================================================== */

.a4-sheet {
  width: 794px;
  height: 1123px;
  position: relative;
  transform-origin: top left;
  overflow: hidden;
  padding: 42px;
  display: flex;
  flex-direction: column;
  color: #2c1e12;
  background: #fbf3df;
  font-family: var(--font-serif-doc);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* Estilo 1: Pergamino clásico de Oriente */
.a4-sheet[data-style="pergamino"] {
  background:
    radial-gradient(circle at 18% 15%, rgba(255, 252, 240, 0.9), transparent 55%),
    radial-gradient(circle at 84% 88%, rgba(226, 198, 138, 0.45), transparent 55%),
    linear-gradient(160deg, #fdf6e4 0%, #f5e5c0 55%, #edd49f 100%);
  color: #2b1d0e;
  --doc-accent: #9a6b16;
  --doc-accent-2: #8c1d18;
  --doc-border: #b8892a;
  --doc-soft: rgba(184, 137, 42, 0.12);
}

/* Estilo 2: Postal roja de Laponia */
.a4-sheet[data-style="laponia"] {
  background:
    repeating-linear-gradient(
      -45deg,
      #991b1b 0px,
      #991b1b 16px,
      #fffdf8 16px,
      #fffdf8 32px,
      #166534 32px,
      #166534 48px,
      #fffdf8 48px,
      #fffdf8 64px
    );
  padding: 20px;
  color: #1f2937;
  --doc-accent: #991b1b;
  --doc-accent-2: #166534;
  --doc-border: #b91c1c;
  --doc-soft: rgba(185, 28, 28, 0.08);
}

.a4-sheet[data-style="laponia"] .sheet-inner-frame {
  background: #fffdf7;
  height: 100%;
  padding: 32px 36px;
  border: 2px solid #d4a84f;
  border-radius: 6px;
  box-shadow: inset 0 0 0 4px rgba(185, 28, 28, 0.08);
}

/* Estilo 3: Minimalista nórdico */
.a4-sheet[data-style="nordico"] {
  background: #ffffff;
  color: #1e293b;
  --doc-accent: #1e3a5f;
  --doc-accent-2: #3b6e57;
  --doc-border: #94a3b8;
  --doc-soft: #f8fafc;
}

.sheet-inner-frame {
  position: relative;
  height: 100%;
  width: 100%;
  border: 2px solid var(--doc-border);
  padding: 34px 40px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.a4-sheet[data-style="pergamino"] .sheet-inner-frame::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(154, 107, 22, 0.55);
  pointer-events: none;
}

.a4-sheet[data-style="nordico"] .sheet-inner-frame {
  border: 1.5px solid #cbd5e1;
  padding: 36px 42px;
}

.a4-sheet[data-style="nordico"] .sheet-inner-frame::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px solid #e2e8f0;
  pointer-events: none;
}

/* Cabecera común de carta y diploma */
.doc-header {
  text-align: center;
  position: relative;
  z-index: 1;
}

.doc-emblem {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  color: var(--doc-accent);
}

.doc-kicker {
  font-family: var(--font-main);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--doc-accent-2);
  margin-bottom: 6px;
}

.doc-main-title {
  font-family: var(--font-serif-doc);
  font-size: 35px;
  font-weight: 700;
  line-height: 1.12;
  margin: 0 0 8px 0;
  color: #1f140a;
}

.a4-sheet[data-style="nordico"] .doc-main-title {
  color: #0f172a;
}

.doc-dateline {
  display: inline-block;
  padding: 4px 14px;
  border-top: 1px solid var(--doc-border);
  border-bottom: 1px solid var(--doc-border);
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 600;
  color: var(--doc-accent);
}

/* Cuerpo de Carta para enviar (Modo 1) */
.letter-body {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  margin-top: 28px;
  gap: 20px;
  font-size: 19.5px;
  line-height: 1.56;
}

.letter-salutation {
  font-family: var(--font-script-doc);
  font-size: 31px;
  font-weight: 700;
  color: var(--doc-accent-2);
  margin: 0;
}

.letter-paragraph {
  margin: 0;
  text-align: left;
}

.wishes-box {
  background: var(--doc-soft);
  border: 1.5px solid var(--doc-border);
  border-radius: 10px;
  padding: 20px 24px;
}

.wishes-box-title {
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--doc-accent);
  margin: 0 0 13px 0;
}

.wishes-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.wish-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 18px;
  line-height: 1.35;
}

.wish-item-index {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--doc-accent);
  color: #ffffff;
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wish-item-text {
  flex: 1;
  border-bottom: 1px dotted rgba(100, 116, 139, 0.45);
  padding-bottom: 3px;
}

.wish-item-blank-line {
  flex: 1;
  height: 24px;
  border-bottom: 1.5px dashed rgba(100, 116, 139, 0.55);
}

.promise-banner {
  border-left: 4px solid var(--doc-accent-2);
  background: var(--doc-soft);
  padding: 11px 16px;
  border-radius: 0 8px 8px 0;
  font-size: 17px;
  line-height: 1.45;
}

.letter-footer-sign {
  position: relative;
  z-index: 1;
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  padding-top: 10px;
}

.sign-block {
  min-width: 220px;
}

.sign-caption {
  font-size: 15px;
  margin-bottom: 4px;
}

.sign-handwritten {
  font-family: var(--font-script-doc);
  font-size: 34px;
  font-weight: 700;
  color: var(--doc-accent);
  line-height: 1.1;
  border-bottom: 1px solid var(--doc-border);
  padding-bottom: 4px;
  min-height: 40px;
}

.postmark-badge {
  border: 1.5px dashed var(--doc-accent-2);
  border-radius: 10px;
  padding: 8px 14px;
  text-align: center;
  font-family: var(--font-main);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--doc-accent-2);
  text-transform: uppercase;
}

/* Modo 2: Carta de respuesta oficial + Diploma de buen comportamiento */
.reply-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 1.5px solid var(--doc-border);
  padding-bottom: 10px;
  margin-bottom: 14px;
  position: relative;
  z-index: 1;
}

.reply-org {
  font-family: var(--font-main);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--doc-accent);
}

.reply-reg-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--doc-soft);
  border: 1px solid var(--doc-border);
  color: #1e293b;
}

.reply-body {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 18px;
  line-height: 1.5;
}

.achievement-highlight {
  background: var(--doc-soft);
  border: 1px solid var(--doc-border);
  border-left: 4px solid var(--doc-accent);
  border-radius: 8px;
  padding: 13px 17px;
  font-style: italic;
  font-size: 17.5px;
}

.doc-ornament-divider {
  text-align: center;
  color: var(--doc-accent);
  font-size: 14px;
  letter-spacing: 0.55em;
  margin: 12px 0 4px 0;
  opacity: 0.85;
}

.diploma-certificate-box {
  position: relative;
  z-index: 1;
  margin-top: 12px;
  border: 2.5px double var(--doc-border);
  border-radius: 12px;
  padding: 24px 28px;
  background: rgba(255, 255, 255, 0.58);
  text-align: center;
}

.a4-sheet[data-style="nordico"] .diploma-certificate-box {
  background: #f8fafc;
}

.diploma-ribbon {
  display: inline-block;
  padding: 4px 18px;
  border-radius: 9999px;
  background: var(--doc-accent);
  color: #ffffff;
  font-family: var(--font-main);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.diploma-title {
  margin: 0 0 6px 0;
  font-family: var(--font-serif-doc);
  font-size: 27px;
  font-weight: 700;
  color: #1e140a;
}

.diploma-awarded-to {
  font-family: var(--font-script-doc);
  font-size: 38px;
  font-weight: 700;
  color: var(--doc-accent-2);
  margin: 4px 0 6px 0;
  line-height: 1.1;
}

.diploma-subtext {
  font-size: 15.5px;
  line-height: 1.4;
  margin: 0 auto 12px auto;
  max-width: 560px;
}

.diploma-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 8px;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
}

.diploma-signatures {
  text-align: left;
  flex: 1;
}

.diploma-sign-names {
  font-family: var(--font-script-doc);
  font-size: 26px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.15;
}

.diploma-sign-role {
  font-family: var(--font-main);
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
}

.wax-seal-wrap {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Modo 3: Pliego de 8 etiquetas recortables */
.tags-sheet-wrap {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.tags-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dashed var(--doc-border);
  padding-bottom: 10px;
  margin-bottom: 16px;
  font-family: var(--font-main);
  font-size: 12px;
  color: var(--doc-accent);
  font-weight: 700;
}

.tags-a4-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.gift-tag-card {
  position: relative;
  border: 1.5px dashed rgba(100, 116, 139, 0.65);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.72);
}

.a4-sheet[data-style="pergamino"] .gift-tag-card {
  background: #fdf6e3;
}

.a4-sheet[data-style="nordico"] .gift-tag-card {
  background: #ffffff;
}

.gift-tag-inner {
  border: 1.5px solid var(--doc-border);
  border-radius: 7px;
  height: 100%;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
}

.tag-punch-hole {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--doc-border);
  background: rgba(255, 255, 255, 0.9);
}

.tag-top-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-main);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--doc-accent-2);
}

.tag-fields {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 4px 0;
}

.tag-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  border-bottom: 1px dotted rgba(100, 116, 139, 0.45);
  padding-bottom: 3px;
}

.tag-line-label {
  font-family: var(--font-main);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--doc-accent);
  flex-shrink: 0;
}

.tag-line-value {
  font-family: var(--font-script-doc);
  font-size: 24px;
  font-weight: 700;
  color: #1e1b18;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-line-sender {
  font-family: var(--font-serif-doc);
  font-size: 17px;
  font-weight: 700;
  color: #334155;
}

.tag-note {
  font-family: var(--font-serif-doc);
  font-style: italic;
  font-size: 13.5px;
  color: #475569;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   Modal accesible, Toast y montaje de impresión
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.74);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1200;
}

.modal-backdrop.is-open {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 460px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

.modal-body {
  padding: 1.15rem 1.25rem;
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.modal-footer {
  padding: 0.9rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

.modal-footer .btn-primary-action,
.modal-footer .btn-secondary-action {
  width: auto;
  min-width: 110px;
}

.toast-banner {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
  z-index: 1300;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast-banner.visible {
  opacity: 1;
  transform: translateY(0);
}

#print-mount {
  display: none;
}

/* ==========================================================================
   Impresión A4 limpia (oculta toda la interfaz de fijate.com)
   ========================================================================== */

@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  html,
  body {
    width: 210mm !important;
    height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    overflow: hidden !important;
  }

  body > *:not(#print-mount) {
    display: none !important;
  }

  #print-mount {
    display: block !important;
    width: 210mm !important;
    height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  #print-mount .a4-sheet {
    transform: none !important;
    width: 210mm !important;
    height: 297mm !important;
    margin: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }
}

/* ==========================================================================
   Ajustes móviles (375 px)
   ========================================================================== */

@media (max-width: 640px) {
  .studio-hero {
    padding: 1rem 1.05rem;
  }

  .studio-toolbar,
  .editor-panel {
    padding: 1rem;
  }

  .mode-tab,
  .style-pill {
    width: 100%;
    justify-content: flex-start;
  }

  .preview-stage-outer {
    padding: 0.75rem;
  }

  .preview-header,
  .export-actions {
    padding: 0.9rem 1rem;
  }

  .tags-bulk-bar {
    flex-direction: column;
    align-items: stretch;
  }
}
