:root {
  --background: #f8fafc;
  --title: #172554;
  --text: #0f172a;
  --secondary: #475569;
  --border: #cbd5e1;
  --button: #2563eb;
  --button-hover: #1d4ed8;
  --button-pressed: #1e40af;
  --button-muted: #afc7eb;
  --button-muted-hover: #96b6e5;
  --button-muted-text: #1e3a5f;
  --button-disabled: #d8e4f4;
  --button-disabled-text: #7b8ea8;
  --shadow: 0 22px 64px rgba(15, 23, 42, 0.11);
}

* { box-sizing: border-box; }
html { width: 100%; min-height: 100%; }
body {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-x: hidden;
  background: radial-gradient(circle at 50% 0, #ffffff 0, var(--background) 58%);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 16px;
}
button, select, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: calc(100% - 48px);
  max-width: 1180px;
  margin: 28px auto 56px;
  padding: 38px 42px 34px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid #e2e8f0;
  border-radius: 30px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(9px);
}

.app-header { margin-bottom: 24px; }
.combined-title {
  display: flex;
  justify-content: center;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 14px;
  margin: 0 0 18px;
  color: var(--title);
  text-align: center;
}
.brand-name {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.65rem, 5vw, 3.65rem);
  font-style: italic;
  font-weight: 700;
  letter-spacing: -0.025em;
}
.title-separator { color: #64748b; font-size: clamp(2rem, 4vw, 2.65rem); }
.product-name {
  font-size: clamp(1.8rem, 3.4vw, 2.65rem);
  font-weight: 750;
  letter-spacing: -0.02em;
}
.hero-illustration {
  overflow: hidden;
  border-radius: 24px;
}
.hero-illustration svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 290px;
}
.tagline {
  margin: 17px 0 4px;
  text-align: center;
  color: #334155;
  font-size: 1.08rem;
  line-height: 1.5;
}
.version {
  margin: 0;
  text-align: center;
  color: #64748b;
  font-size: 0.98rem;
  font-style: italic;
}

.panel {
  width: 100%;
  margin-bottom: 18px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.055);
}
.panel h2 {
  margin: 0;
  padding: 19px 24px 8px;
  font-size: 1.28rem;
  line-height: 1.25;
}
.panel-content { padding: 13px 24px 22px; }
.panel-document { background: linear-gradient(135deg, #e0f2fe, #dbeafe); }
.panel-options { background: linear-gradient(135deg, #f3e8ff, #ede9fe); }
.panel-actions { background: linear-gradient(135deg, #dcfce7, #ccfbf1); }
.panel-progress { background: linear-gradient(135deg, #fff7ed, #fef3c7); }

.document-grid {
  display: grid;
  grid-template-columns: 195px minmax(0, 1fr);
  gap: 13px 22px;
  align-items: start;
  font-size: 1.04rem;
  line-height: 1.45;
}
.field-label, .options-grid label { font-weight: 750; }
.word-count { color: var(--title); font-size: 1.22rem; }

.options-grid {
  display: grid;
  grid-template-columns: max-content minmax(260px, 1fr) max-content minmax(170px, 0.45fr);
  align-items: center;
  gap: 14px 16px;
  font-size: 1.04rem;
}
select {
  width: 100%;
  min-height: 48px;
  padding: 11px 42px 11px 14px;
  border: 1px solid #94a3b8;
  border-radius: 11px;
  background: #fff;
  color: var(--text);
  font-size: 1.02rem;
}
select:focus-visible, button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.3);
  outline-offset: 3px;
}

.actions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
}
.action-button {
  min-height: 58px;
  border: 2px solid transparent;
  border-radius: 13px;
  padding: 13px 18px;
  background: var(--button-muted);
  color: var(--button-muted-text);
  font-size: 1.04rem;
  font-weight: 750;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}
.action-button:hover:not(:disabled) {
  background: var(--button-muted-hover);
  transform: translateY(-1px);
}
.action-button.is-current {
  background: var(--button);
  color: #fff;
  border-color: #1e3a8a;
  box-shadow: 0 9px 22px rgba(37, 99, 235, 0.3);
}
.action-button.is-current:hover:not(:disabled) { background: var(--button-hover); }
.action-button.is-working {
  background: var(--button-pressed);
  color: #fff;
  border-color: #172554;
  cursor: wait;
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.17);
}
.action-button:disabled {
  background: var(--button-disabled);
  color: var(--button-disabled-text);
  cursor: not-allowed;
  opacity: 0.8;
}
.step-guide {
  margin: 19px 2px 0;
  color: var(--title);
  font-size: 1.02rem;
  font-weight: 750;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 22px;
  font-size: 1.04rem;
}
.progress-track {
  height: 22px;
  margin: 15px 0 10px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #e2e8f0;
}
.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #60a5fa);
  transition: width 280ms ease;
}
.progress-note {
  margin: 0;
  color: var(--secondary);
  font-size: 0.96rem;
  line-height: 1.45;
}
audio {
  width: 100%;
  min-height: 48px;
  margin-top: 17px;
}
.status-area {
  padding: 8px 4px 0;
  border-top: 1px solid #e2e8f0;
  font-size: 1rem;
}
.status-area p { margin: 10px 0; }

.preview-dialog {
  width: min(92vw, 980px);
  max-height: 86vh;
  padding: 0;
  border: 0;
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}
.preview-dialog::backdrop {
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px);
}
.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid #e2e8f0;
}
.dialog-header h2 { margin: 0; font-size: 1.28rem; }
.dialog-close {
  border: 0;
  background: transparent;
  color: #475569;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}
.preview-dialog pre {
  margin: 0;
  max-height: 69vh;
  overflow: auto;
  padding: 24px;
  white-space: pre-wrap;
  font: 1.05rem/1.62 "Segoe UI", sans-serif;
}
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(460px, calc(100vw - 48px));
  padding: 14px 18px;
  border-radius: 13px;
  background: #991b1b;
  color: #fff;
  font-size: 1rem;
  box-shadow: 0 16px 42px rgba(15, 23, 42, 0.25);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (min-width: 1380px) {
  .app-shell { max-width: 1240px; }
}

@media (max-width: 860px) {
  body { display: block; }
  .app-shell {
    width: calc(100% - 24px);
    margin: 12px auto 34px;
    padding: 22px;
    border-radius: 23px;
  }
  .app-header { margin-bottom: 18px; }
  .hero-illustration svg { min-height: 170px; }
  .options-grid { grid-template-columns: 1fr; }
  .actions-grid { grid-template-columns: 1fr; gap: 11px; }
  .document-grid { grid-template-columns: 1fr; gap: 4px; }
  .document-grid .field-label:not(:first-child) { margin-top: 9px; }
  .title-separator { display: none; }
  .panel h2 { padding: 17px 18px 7px; }
  .panel-content { padding: 11px 18px 19px; }
}

@media (max-width: 520px) {
  body { font-size: 15px; }
  .app-shell {
    width: calc(100% - 12px);
    margin-top: 6px;
    padding: 14px;
    border-radius: 18px;
  }
  .combined-title { gap: 5px; margin-bottom: 12px; }
  .brand-name { font-size: 2.25rem; }
  .product-name { width: 100%; font-size: 1.42rem; }
  .hero-illustration svg { min-height: 132px; }
  .tagline { font-size: 0.98rem; }
  .panel { border-radius: 17px; margin-bottom: 12px; }
  .panel h2 { font-size: 1.12rem; }
  .action-button { min-height: 52px; font-size: 0.98rem; }
  .progress-header { align-items: flex-start; font-size: 0.96rem; }
  .progress-track { height: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}


.save-dialog {
  width: min(92vw, 650px);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 22px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 28px 90px rgba(15, 23, 42, 0.30);
}
.save-dialog::backdrop {
  background: rgba(15, 23, 42, 0.54);
  backdrop-filter: blur(4px);
}
.save-dialog-header {
  padding: 24px 26px 18px;
  background: linear-gradient(135deg, #dbeafe, #ede9fe);
  border-bottom: 1px solid #cbd5e1;
}
.save-dialog-kicker {
  margin: 0 0 7px;
  color: #1d4ed8;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}
.save-dialog-header h2 {
  margin: 0;
  color: var(--title);
  font-size: 1.48rem;
  line-height: 1.28;
}
.save-dialog-body { padding: 23px 26px 26px; }
.save-file-label {
  margin: 0 0 5px;
  color: var(--secondary);
  font-size: 0.95rem;
  font-weight: 700;
}
.save-file-name {
  margin: 0 0 17px;
  padding: 12px 14px;
  overflow-wrap: anywhere;
  border: 1px solid #bfdbfe;
  border-radius: 11px;
  background: #eff6ff;
  color: var(--title);
  font-size: 1.04rem;
  font-weight: 800;
}
.save-help {
  margin: 0;
  color: #334155;
  font-size: 1rem;
  line-height: 1.55;
}
.save-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}
.primary-button, .secondary-button {
  min-height: 48px;
  border-radius: 11px;
  padding: 11px 18px;
  font-weight: 800;
  cursor: pointer;
}
.primary-button {
  border: 1px solid #1d4ed8;
  background: var(--button);
  color: #fff;
}
.primary-button:hover:not(:disabled) { background: var(--button-hover); }
.secondary-button {
  border: 1px solid #94a3b8;
  background: #f8fafc;
  color: #334155;
}
.secondary-button:hover:not(:disabled) { background: #e2e8f0; }
.primary-button:disabled, .secondary-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

@media (max-width: 520px) {
  .save-dialog-header, .save-dialog-body { padding-left: 18px; padding-right: 18px; }
  .save-dialog-actions { flex-direction: column-reverse; }
  .primary-button, .secondary-button { width: 100%; }
}

/* StellaVox Web 1.4: modal propio para asegurar que la pregunta de guardado
   sea visible incluso cuando el navegador no permite abrir el selector nativo
   automáticamente después de un proceso asíncrono. */
body.modal-open { overflow: hidden; }
.save-modal[hidden] { display: none !important; }
.save-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(4px);
}
.save-modal-card {
  width: min(92vw, 650px);
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.65);
  border-radius: 22px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 28px 90px rgba(15, 23, 42, 0.34);
  animation: saveModalIn 180ms ease-out;
}
@keyframes saveModalIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
