/* ============================================================
   QUIZZO v1.7.0 — Design System
   Dark-first · Space Grotesk · Linear × Notion × AI education
   Gradiente reservado: logo, CTA principal, estados activos,
   progreso y highlights. Todo lo demás: neutro.
   ============================================================ */

@font-face {
  font-family: 'Space Grotesk';
  src: url('fonts/SpaceGrotesk-var.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Superficies */
  --bg: #0B0D12;
  --bg-soft: #11141C;
  --card: #171B25;
  --card-2: #1D2230;
  --border: #272D3D;

  /* Texto */
  --text: #F4F5F8;
  --text-dim: #949CAF;
  --text-faint: #858FA3;

  /* Marca */
  --accent: #7C6CF6;
  --accent-2: #5EA2F6;
  --grad: linear-gradient(135deg, #7C6CF6, #5EA2F6);
  --glow: 0 4px 20px rgba(124, 108, 246, .18);
  --glow-strong: 0 6px 28px rgba(124, 108, 246, .32);

  /* Semánticos */
  --ok: #34D399;
  --ok-soft: rgba(52, 211, 153, .12);
  --bad: #F87171;
  --bad-soft: rgba(248, 113, 113, .12);
  --warn: #FBBF24;

  /* Radios estandarizados */
  --r-xs: 4px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;
  --radius: var(--r-md);

  --nav-h: 64px;
  --font: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background:
    radial-gradient(1000px 500px at 85% -10%, rgba(124, 108, 246, .09), transparent 60%),
    radial-gradient(800px 400px at -10% 110%, rgba(94, 162, 246, .07), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100dvh;
}

#app { display: flex; flex-direction: column; min-height: 100dvh; }

.hidden { display: none !important; }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

svg { width: 22px; height: 22px; fill: currentColor; flex-shrink: 0; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(11, 13, 18, .78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex; align-items: center; gap: 8px;
  max-width: 560px; margin: 0 auto;
  padding: 14px 16px;
}
.topbar h1 {
  font-size: 18px; font-weight: 700; letter-spacing: .3px;
}
.icon-btn {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: var(--r-sm);
  color: var(--text-dim);
}
.icon-btn:hover { color: var(--text); background: var(--card); }
.icon-btn:active { background: var(--card-2); }
.progress-track { height: 3px; background: var(--card-2); }
.progress-fill {
  height: 100%; width: 0%;
  background: var(--grad);
  transition: width .35s ease;
}

#main { flex: 1; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px); }

.container { max-width: 560px; margin: 0 auto; padding: 18px 16px 8px; }

.view { display: none; animation: fadeIn .25s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.section-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; letter-spacing: -.01em; }
.section-sub { color: var(--text-dim); font-size: 14.5px; font-weight: 400; line-height: 1.55; margin-bottom: 18px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 50px; padding: 12px 18px;
  border-radius: var(--r-sm); font-weight: 600; font-size: 15px;
  transition: transform .08s ease, opacity .15s ease, background .15s ease,
              border-color .15s ease, box-shadow .25s ease, filter .15s ease;
  user-select: none;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-block { width: 100%; }
.btn-lg { min-height: 58px; font-size: 16px; }
.grow { flex: 1; }
.row { display: flex; align-items: center; }
.gap { gap: 10px; margin-top: 14px; }

.btn-primary {
  background: var(--grad); color: #fff;
  box-shadow: var(--glow);
}
.btn-primary:hover { box-shadow: var(--glow-strong); filter: brightness(1.06); }

/* CTA héroe: el elemento más importante de la vista */
.btn-hero {
  min-height: 58px; font-size: 16.5px; font-weight: 700; letter-spacing: .01em;
  box-shadow: var(--glow-strong);
}
.btn-hero:hover { filter: brightness(1.08); box-shadow: 0 8px 36px rgba(124, 108, 246, .42); }

.btn-secondary { background: var(--card-2); border: 1px solid #3A415A; color: #F2F5FA; }
.btn-secondary:hover { border-color: #4A5470; }
.btn-secondary:hover { border-color: #343B50; background: #232939; }
.btn-ghost { background: transparent; border: 1px dashed var(--border); color: var(--text-dim); font-weight: 500; }
.btn-ghost:hover { color: var(--text); border-color: var(--text-faint); }

/* ---------- Estado vacío ---------- */
.empty {
  text-align: center; padding: 56px 20px;
  color: var(--text-dim); font-size: 15px; font-weight: 400; line-height: 1.65;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.empty-badge {
  width: 104px; height: 104px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(124, 108, 246, .22), rgba(124, 108, 246, .07));
  border: 1px solid rgba(124, 108, 246, .25);
  display: grid; place-items: center;
}
.empty-icon {
  width: 48px; height: 48px;
  fill: none; stroke: var(--accent-2); stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Lista de quizzes ---------- */
.quiz-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.quiz-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 14px;
  transition: transform .08s ease, border-color .15s ease;
}
.quiz-item:hover { border-color: #343B50; }
.quiz-item:active { transform: scale(.985); }
.quiz-item-main { flex: 1; min-width: 0; text-align: left; }
.quiz-item-name { font-weight: 600; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quiz-item-meta { color: #A9B2C3; font-size: 13px; font-weight: 400; margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  font-size: 11.5px; font-weight: 500; padding: 3px 8px; border-radius: var(--r-pill);
  background: var(--card-2); color: var(--text-dim);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.quiz-delete { color: var(--text-faint); padding: 10px; border-radius: var(--r-sm); }
.quiz-delete:hover { color: var(--text); background: var(--card-2); }
.quiz-delete[data-del]:hover { background: var(--bad-soft); color: var(--bad); }

/* ---------- Dropzone / formulario nuevo ---------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 32px 16px; text-align: center;
  background: var(--bg-soft); border: 2px dashed var(--border);
  border-radius: var(--r-md); color: var(--text-dim); font-size: 13.5px;
  transition: border-color .2s ease, background .2s ease;
  margin-bottom: 16px;
}
.dropzone svg { width: 34px; height: 34px; color: var(--accent); margin-bottom: 4px; }
.dropzone strong { color: var(--text); font-size: 15px; font-weight: 600; }
.dropzone:hover { border-color: #3A415A; }
.dropzone.dragover { border-color: var(--accent); background: rgba(124, 108, 246, .06); }

.field-label {
  display: block; font-size: 12.5px; font-weight: 500; color: var(--text-dim);
  margin: 14px 0 8px; text-transform: uppercase; letter-spacing: .8px;
}

textarea, input[type="text"] {
  width: 100%; background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 13px 14px; font: inherit; font-size: 14.5px; font-weight: 400; line-height: 1.5;
  resize: vertical;
}
textarea::placeholder, input[type="text"]::placeholder { color: var(--text-faint); }
textarea:focus, input[type="text"]:focus { outline: none; border-color: var(--accent); }

.preview { margin-top: 22px; animation: fadeIn .25s ease; }
.preview-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip {
  font-size: 12.5px; font-weight: 500; padding: 6px 11px; border-radius: var(--r-pill);
  background: var(--card-2); border: 1px solid var(--border); color: var(--text-dim);
}
.chip b { color: var(--text); font-weight: 600; }
.warnings {
  margin-top: 12px; padding: 12px 14px; border-radius: var(--r-sm);
  background: rgba(251, 191, 36, .08); border: 1px solid rgba(251, 191, 36, .28);
  color: var(--warn); font-size: 13px; line-height: 1.55;
}

/* ---------- Dropdown IA ---------- */
.ai-dropdown { position: relative; margin-top: 12px; }
.ai-dropdown .chev { margin-left: auto; transition: transform .2s ease; }
.ai-dropdown.open .chev { transform: rotate(180deg); }
.ai-menu {
  list-style: none; position: absolute; left: 0; right: 0; top: calc(100% + 8px);
  background: var(--card-2); border: 1px solid var(--border); border-radius: var(--r-md);
  overflow: hidden; z-index: 50; box-shadow: 0 16px 40px rgba(0, 0, 0, .55);
  animation: fadeIn .18s ease;
}
.ai-menu.open-up { top: auto; bottom: calc(100% + 8px); }
.ai-menu li > button {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 15px 16px; font-weight: 500; font-size: 15px; text-align: left;
}
.ai-menu li > button:hover { background: var(--card); }
.ai-menu li + li > button { border-top: 1px solid var(--border); }
.ai-dot { width: 10px; height: 10px; border-radius: 50%; }
.ai-ext { margin-left: auto; font-size: 12px; color: var(--text-faint); font-weight: 400; }

/* ---------- Quiz ---------- */
.quiz-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.quiz-counter { font-weight: 700; font-size: 15px; }
.quiz-score-pill {
  font-size: 12.5px; font-weight: 600; padding: 5px 11px; border-radius: var(--r-pill);
  background: var(--ok-soft); color: var(--ok);
}

.question-card { font-size: 15.5px; line-height: 1.65; }
.q-type-tag {
  display: inline-block; font-size: 11px; font-weight: 500; letter-spacing: .8px;
  text-transform: uppercase; color: var(--accent-2); margin-bottom: 10px;
}
.q-text { font-weight: 600; margin-bottom: 16px; white-space: pre-line; }
.q-context {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 12px 14px; margin-bottom: 16px; font-size: 14px; color: var(--text-dim);
  white-space: pre-line;
}

.options { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.option {
  position: relative;
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--bg-soft); border: 1.5px solid var(--border);
  border-radius: var(--r-sm); padding: 13px 14px; cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
  font-size: 14.5px; line-height: 1.5;
}
.option:hover { border-color: #3A415A; }
/* Input nativo fuera de la vista: la tarjeta entera es el control */
.option input {
  position: absolute; opacity: 0;
  width: 1px; height: 1px; margin: 0; pointer-events: none;
}
.option:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 108, 246, .18); }
.option.selected { border-color: var(--accent); background: rgba(124, 108, 246, .08); }
.option.correct { border-color: var(--ok); background: var(--ok-soft); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.option.missed { border-color: var(--warn); background: rgba(251, 191, 36, .08); }
.option.locked { cursor: default; }
.opt-key {
  font-weight: 600; font-size: 12.5px; color: var(--text-dim);
  background: var(--card-2); border-radius: var(--r-xs); min-width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center; margin-top: 1px;
}
.option.correct .opt-key { background: var(--ok); color: #052e1c; }
.option.wrong .opt-key { background: var(--bad); color: #3a0a0a; }

.blanks-sentence { line-height: 2.4; font-size: 15px; }
.blank-input {
  display: inline-block; width: 120px; max-width: 42vw;
  background: var(--card-2); border: 1.5px solid var(--border); border-radius: var(--r-xs);
  color: var(--text); font: inherit; font-size: 14px; text-align: center;
  padding: 6px 8px; margin: 0 3px;
}
.blank-input:focus { outline: none; border-color: var(--accent); }
.blank-input.correct { border-color: var(--ok); background: var(--ok-soft); }
.blank-input.wrong { border-color: var(--bad); background: var(--bad-soft); }
.blank-answer { font-size: 13px; color: var(--ok); font-weight: 600; }

.feedback {
  margin-top: 14px; padding: 14px 16px; border-radius: var(--r-sm);
  font-weight: 600; font-size: 14.5px; line-height: 1.5;
  animation: fadeIn .25s ease;
}
.feedback.ok { background: var(--ok-soft); color: var(--ok); border: 1px solid rgba(52, 211, 153, .3); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); border: 1px solid rgba(248, 113, 113, .3); }
.feedback.reveal { background: rgba(94, 162, 246, .08); color: var(--accent-2); border: 1px solid rgba(94, 162, 246, .3); }
.feedback small { display: block; font-weight: 400; margin-top: 4px; color: var(--text-dim); }

.quiz-actions { display: flex; gap: 10px; margin-top: 16px; }
.quiz-nav { display: flex; gap: 10px; margin-top: 12px; }
.nav-arrow {
  width: 54px; min-height: 50px; border-radius: var(--r-sm);
  background: var(--card-2); border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
}
.nav-arrow:hover { border-color: #343B50; }
.nav-arrow:disabled { opacity: .4; pointer-events: none; }

/* ---------- Resultados ---------- */
.result-hero { text-align: center; padding: 28px 18px; margin-bottom: 28px; }
.score-ring {
  width: 148px; height: 148px; border-radius: 50%; margin: 0 auto 18px;
  display: grid; place-items: center;
  background: conic-gradient(var(--ring-color, var(--accent)) calc(var(--p, 0) * 1%), var(--card-2) 0);
}
.score-ring-inner {
  width: 118px; height: 118px; border-radius: 50%; background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.score-ring-inner span { font-size: 26px; font-weight: 700; }
.score-ring-inner small { color: var(--text-dim); font-weight: 500; }
#result-msg { font-size: 21px; font-weight: 700; letter-spacing: -.01em; }
.result-detail { color: var(--text-dim); font-size: 14px; margin-top: 6px; line-height: 1.6; }

.review-item { margin-top: 12px; }
.review-head { display: flex; gap: 10px; align-items: flex-start; }
.review-badge {
  min-width: 28px; height: 28px; border-radius: var(--r-xs); font-weight: 700; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center; margin-top: 1px;
}
.review-badge.ok { background: var(--ok-soft); color: var(--ok); }
.review-badge.bad { background: var(--bad-soft); color: var(--bad); }
.review-badge.skip { background: rgba(251, 191, 36, .1); color: var(--warn); }
.review-q { font-weight: 600; font-size: 14.5px; line-height: 1.5; }
.review-body { margin: 10px 0 0 38px; font-size: 13.5px; line-height: 1.7; color: var(--text-dim); }
.review-body b.you-ok { color: var(--ok); }
.review-body b.you-bad { color: var(--bad); }
.review-body b.right { color: var(--ok); }

.result-actions { margin: 22px 0 10px; }

/* ---------- Bottom nav (móvil) ---------- */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: rgba(11, 13, 18, .96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
}
.bottomnav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-faint); font-size: 11px; font-weight: 500;
}
.bottomnav button:hover { color: var(--text-dim); }
.bottomnav button.active { color: var(--accent); }

/* Marca y nav superior (visibles solo en desktop) */
.brand {
  display: none;
  font-weight: 700; font-size: 17px; letter-spacing: .07em;
  color: var(--text); user-select: none;
}
.topnav { display: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 18px);
  transform: translate(-50%, 20px);
  background: #20263A; color: var(--text);
  border: 1px solid var(--border);
  padding: 12px 20px; border-radius: var(--r-pill);
  font-weight: 500; font-size: 14px;
  opacity: 0; pointer-events: none; z-index: 60;
  transition: opacity .25s ease, transform .25s ease;
  white-space: nowrap;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .5);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Chip de version en Ajustes + boton Procesar reactivo ---------- */
.set-version { margin-top: 24px; color: var(--text-faint); font-size: 12px; letter-spacing: .03em; text-align: center; }
#ver-chip { color: var(--text-dim); }
#btn-parse { transition: box-shadow .25s ease; }
#btn-parse.ready { box-shadow: var(--glow-strong); }

/* ---------- Guia de instalacion ---------- */
#install-row .set-row { cursor: pointer; }
.chev-right { width: 18px; height: 18px; fill: var(--text-faint); flex: none; }

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(6, 8, 12, .55);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none;
  transition: opacity .28s ease;
}
.sheet-backdrop.show { opacity: 1; pointer-events: auto; }

.install-sheet {
  position: fixed; left: 50%; bottom: 0; z-index: 71;
  transform: translate(-50%, 105%);
  width: min(94vw, 420px);
  background: var(--card-2);
  border: 1px solid var(--border); border-bottom: none;
  border-radius: 20px 20px 0 0;
  padding: 14px 22px calc(22px + env(safe-area-inset-bottom));
  box-shadow: 0 -18px 50px rgba(0, 0, 0, .5);
  transition: transform .32s cubic-bezier(.32, .72, .24, 1);
}
.install-sheet.show { transform: translate(-50%, 0); }
body.sheet-open { overflow: hidden; }

.sheet-handle { width: 38px; height: 4px; border-radius: 99px; background: #3A415A; margin: 0 auto 16px; }
.install-sheet h3 { font-size: 17px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 16px; text-align: center; }
.sheet-step {
  display: flex; align-items: center; gap: 12px;
  font-size: 13.5px; color: var(--text-dim); line-height: 1.45;
  margin: 0 0 12px;
}
.step-num {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(124, 108, 246, .16); color: #B9ACFA;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.share-badge {
  flex: none; width: 34px; height: 34px; padding: 7px;
  border-radius: 9px; background: var(--grad); fill: #fff;
  margin-left: auto;
}
.install-sheet .btn-block { margin-top: 6px; }

/* ---------- Fondo mesh animado ---------- */
.bg-mesh { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-mesh .blob {
  position: absolute; border-radius: 50%;
  filter: blur(120px); will-change: transform;
}
.blob.b1 {
  width: 52vmax; height: 52vmax; left: -14vmax; top: -18vmax;
  background: #7C6CF6; opacity: .30;
  animation: mesh-drift-1 46s ease-in-out infinite alternate;
}
.blob.b2 {
  width: 46vmax; height: 46vmax; right: -16vmax; bottom: -20vmax;
  background: #274690; opacity: .42;
  animation: mesh-drift-2 58s ease-in-out infinite alternate;
}
@keyframes mesh-drift-1 {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(9vmax, 7vmax) scale(1.15); }
}
@keyframes mesh-drift-2 {
  from { transform: translate(0, 0) scale(1.08); }
  to { transform: translate(-8vmax, -6vmax) scale(.94); }
}
body.no-anim .bg-mesh { display: none; }

/* ---------- Flujo guiado (Prompt → IA → JSON) ---------- */
.flow-steps { display: flex; flex-direction: column; }
.flow-step { position: relative; padding-bottom: 26px; }
.flow-step:last-child { padding-bottom: 0; }
.step-head { margin-bottom: 14px; }
.step-title { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.step-desc { font-size: 13.5px; font-weight: 400; color: var(--text-dim); margin-top: 6px; line-height: 1.55; }

/* Instrucciones numeradas del paso 2 (IA): lista vertical limpia en todos los anchos */
.steps-mini {
  margin: 18px 0 0 0; padding-left: 20px;
  color: var(--text-dim); font-size: 13.5px; font-weight: 400; line-height: 1.65;
}
.steps-mini li::marker { color: var(--text-faint); font-weight: 600; }
.steps-mini strong { color: var(--text); }
.step-body { margin-left: 0; }

/* Nuevo: split archivo/texto (apilado en móvil, dos columnas en desktop) */
.new-split { display: flex; flex-direction: column; }
.split-or {
  display: flex; align-items: center; gap: 12px; margin: 6px 0;
  color: var(--text-faint); font-size: 11px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; user-select: none;
}
.split-or::before, .split-or::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* Texto alternativo del dropzone según dispositivo */
.dz-touch { display: none; }

/* Acciones del paso 3: centradas, ancho contenido */
.new-actions { justify-content: center; gap: 12px; margin-top: 18px; }
.new-actions #btn-parse { flex: 0 1 230px; }
.new-actions #btn-clear-paste { flex: 0 1 140px; }

/* Columnas del split a la misma altura */
.new-col textarea { flex: 1 1 auto; min-height: 220px; }

.quiz-item-actions { display: flex; align-items: center; gap: 2px; }

/* ---------- Tarjeta Datos (backup) ---------- */
.data-card { margin-top: 26px; }
.data-card h3 { font-size: 15px; font-weight: 700; }
.data-card .data-sub { font-size: 13px; font-weight: 400; color: var(--text-dim); margin: 4px 0 2px; line-height: 1.5; }

/* ---------- Config IA ---------- */
.cfg-card { margin-bottom: 0; }
.cfg-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }

.stepper {
  display: flex; align-items: center;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 5px;
}
.stepper button {
  width: 52px; height: 42px; border-radius: 6px;
  background: transparent;
  font-size: 24px; font-weight: 500; color: var(--text-dim); line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s ease, color .15s ease;
}
.stepper button:hover { background: rgba(124, 108, 246, .14); color: var(--text); }
.stepper button:active { transform: scale(.94); }
.stepper input {
  flex: 1; min-width: 0; text-align: center;
  font-size: 19px; font-weight: 700; color: var(--text);
  background: transparent; border: none; height: 42px; padding: 0 4px;
}
.stepper input:focus { outline: none; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.chips-toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-toggle {
  padding: 10px 14px; border-radius: var(--r-pill);
  background: var(--bg-soft); border: 1.5px solid var(--border);
  color: var(--text-dim); font-size: 13.5px; font-weight: 500;
  transition: all .15s ease;
}
.chip-toggle:hover { border-color: #343B50; color: var(--text); }
.chip-toggle.active {
  background: rgba(124, 108, 246, .14);
  border-color: var(--accent);
  color: var(--text);
}

.segmented {
  display: flex; gap: 4px;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 4px;
}
.segmented button {
  flex: 1; min-height: 40px; border-radius: 6px;
  font-size: 13.5px; font-weight: 500; color: var(--text-dim);
  transition: background .15s ease, color .15s ease;
}
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--accent); color: #fff; }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 18px; cursor: pointer;
  font-size: 14.5px; font-weight: 500;
}
.switch-row input { display: none; }
.switch {
  width: 50px; height: 29px; border-radius: var(--r-pill); flex-shrink: 0;
  background: var(--card-2); border: 1px solid var(--border);
  position: relative; transition: background .2s ease;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 21px; height: 21px; border-radius: 50%;
  background: #fff; transition: transform .2s ease;
}
.switch-row input:checked + .switch { background: var(--accent); border-color: var(--accent); }
.switch-row input:checked + .switch::after { transform: translateX(21px); }

.prompt-preview { margin-bottom: 14px; }
.prompt-preview summary {
  cursor: pointer; font-size: 13.5px; font-weight: 500; color: var(--text-dim);
  padding: 10px 0; list-style-position: inside;
}
.prompt-preview summary:hover { color: var(--text); }
.prompt-preview pre {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px; line-height: 1.6; color: var(--text-dim);
  white-space: pre-wrap; word-break: break-word;
  max-height: 420px; overflow-y: auto;
}

.fb-expl { display: block; margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.08); font-weight: 400; }
.review-expl { display: block; margin-top: 6px; color: var(--text-dim); font-style: italic; }

/* ---------- Paginación de la Revisión ---------- */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin-top: 18px; }
.pager button {
  min-width: 38px; height: 38px; padding: 0 10px;
  border-radius: var(--r-xs); font-size: 13.5px; font-weight: 500;
  background: var(--card-2); border: 1px solid var(--border); color: var(--text-dim);
  transition: border-color .15s ease, color .15s ease;
}
.pager button:hover:not(:disabled) { border-color: #3A415A; color: var(--text); }
.pager button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pager button:disabled { opacity: .45; cursor: default; }
.pager .pg-txt { padding: 0 14px; }
.pager .pg-dots { color: var(--text-faint); padding: 0 4px; }

/* ---------- Buscador Inicio ---------- */
.search-wrap { position: relative; margin-bottom: 14px; }
.search-wrap svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; fill: none; stroke: var(--text-faint); stroke-width: 2; pointer-events: none;
}
.search-wrap input {
  width: 100%; padding: 13px 16px 13px 44px; font-size: 15px; color: var(--text);
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-pill); outline: none;
}
.search-wrap input:focus { border-color: var(--accent); }
.no-results { text-align: center; color: var(--text-dim); padding: 26px 10px; font-size: 14.5px; }

/* ---------- Categorías ---------- */
.cat-section { list-style: none; }
.cat-header {
  display: flex; align-items: center; gap: 8px;
  margin: 18px 0 10px; font-size: 12.5px; font-weight: 500;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: .8px;
}
.cat-header .badge { margin-left: 8px; }

/* ---------- Autocomplete categorías ---------- */
.autocomplete { position: relative; }
.ac-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 45;
  background: var(--card-2); border: 1px solid var(--border); border-radius: var(--r-sm);
  overflow: hidden; list-style: none; box-shadow: 0 14px 30px rgba(0, 0, 0, .5);
}
.ac-list button {
  width: 100%; text-align: left; padding: 12px 14px;
  font-size: 14px; font-weight: 500; color: var(--text);
}
.ac-list li + li button { border-top: 1px solid var(--border); }
.ac-list button:hover { background: var(--card); }

/* ---------- Editor de cuestionarios ---------- */
.edit-q-title { margin-top: 22px; }
.eq-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-sm); margin-bottom: 10px; overflow: hidden;
}
.eq-head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 12px 14px; text-align: left; }
.eq-head-main {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0;
  background: transparent; text-align: left; padding: 0;
}
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: var(--r-xs); }
.eq-num { font-weight: 700; color: var(--text-faint); font-size: 12.5px; min-width: 22px; }
.eq-preview { flex: 1; font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eq-tag {
  font-size: 10.5px; font-weight: 500; color: var(--text-dim);
  background: var(--card-2); padding: 3px 7px; border-radius: var(--r-xs); white-space: nowrap;
}
.eq-del { color: var(--text-faint); padding: 6px; border-radius: var(--r-xs); flex-shrink: 0; }
.eq-del:hover { color: var(--text); }
.eq-chev { width: 18px; height: 18px; fill: none; stroke: var(--text-dim); stroke-width: 2; transition: transform .15s; flex-shrink: 0; }
.eq-card.open .eq-chev { transform: rotate(180deg); }
.eq-body { display: none; padding: 4px 14px 16px; border-top: 1px solid var(--border); }
.eq-card.open .eq-body { display: block; }
.eq-label {
  font-size: 11.5px; font-weight: 500; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .5px; margin: 12px 0 6px; display: block;
}
.eq-textarea, .eq-input {
  width: 100%; background: var(--bg-soft); border: 1.5px solid var(--border); border-radius: 6px;
  color: var(--text); font-size: 14px; padding: 10px 12px; outline: none; resize: vertical;
}
.eq-textarea:focus, .eq-input:focus { border-color: var(--accent); }
.eq-type-seg { display: flex; gap: 6px; }
.eq-type-seg button {
  flex: 1; padding: 8px 4px; font-size: 12px; font-weight: 500; color: var(--text-dim);
  background: var(--bg-soft); border: 1.5px solid var(--border); border-radius: 6px;
}
.eq-type-seg button:hover { color: var(--text); }
.eq-type-seg button.active { color: #fff; background: var(--accent); border-color: transparent; }
.eq-opt { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.eq-opt input[type="radio"], .eq-opt input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); flex-shrink: 0; }
.eq-opt .eq-input { flex: 1; min-width: 0; }
.eq-opt-remove { color: var(--text-faint); padding: 6px; border-radius: var(--r-xs); flex-shrink: 0; }
.eq-opt-remove:hover { color: var(--bad); }
.btn-add-question { margin-top: 4px; }
.edit-actions { margin-top: 18px; }

/* ---------- Ajustes ---------- */
.set-card { display: flex; flex-direction: column; gap: 18px; padding: 20px; margin-bottom: 14px; }
.set-card h3 { font-size: 15px; font-weight: 700; }
.set-card .data-sub { font-size: 13px; font-weight: 400; color: #B0B9CA; margin-top: -12px; line-height: 1.5; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.set-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.set-label { font-size: 14.5px; font-weight: 600; }
.set-sub { font-size: 12.5px; font-weight: 400; color: #B0B9CA; line-height: 1.5; }
#lang-seg { min-width: 240px; }
.switch-row.set-switch { margin-top: 0; align-items: center; }
.danger-card { border-color: rgba(229, 72, 77, .35); }
.danger-card h3 { color: #F2777C; }
.btn-danger {
  background: rgba(229, 72, 77, .12); color: #F2777C;
  border: 1px solid rgba(229, 72, 77, .4);
}
.btn-danger:hover { background: rgba(229, 72, 77, .28); border-color: #E5484D; color: #FF8589; }
.set-card > .btn-danger { align-self: flex-start; }

/* ============================================================
   MÓVIL < 900px — ajustes de la vista Nuevo + header condicional
   ============================================================ */
@media (max-width: 899px) {
  /* Header fuera de flujos: el título grande de cada vista basta */
  body:not(.in-flow) .topbar { display: none; }

  /* Tipos de pregunta: botones grandes apilados */
  .chips-toggles { flex-direction: column; align-items: stretch; gap: 10px; }
  .chip-toggle { width: 100%; text-align: center; padding: 14px; }

  /* Pegar JSON sin que los CTA queden fuera del primer pantallazo */
  #paste-area { max-height: 40vh; min-height: 160px; }

  /* Ajustes: texto arriba, control abajo, y scroll que no esconda la última tarjeta */
  .set-row { flex-direction: column; align-items: stretch; gap: 10px; }
  #lang-seg { width: 100%; min-width: 0; }
  #view-settings .container { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 48px); }

  /* En móvil no se arrastra nada: texto táctil */
  .dz-drag { display: none; }
  .dz-touch { display: block; margin-top: 6px; font-size: 13.5px; color: var(--text-faint); }

  /* Cuatro pestañas cómodas en la barra inferior */
  .bottomnav button { flex: 1 1 0; min-width: 0; padding: 8px 2px; gap: 3px; font-size: 10.5px; }

  /* Mesh más ligero en pantallas pequeñas (blur costoso) */
  .bg-mesh .blob { filter: blur(90px); }
}

/* ============================================================
   DESKTOP ≥ 900px — nav superior + contenido centrado
   ============================================================ */
@media (min-width: 900px) {
  body { font-size: 16px; }

  /* Header: brand a la izquierda, pills a la derecha */
  .brand { display: inline-flex; }
  .topbar h1 { display: none; }
  .topnav { display: flex; margin-left: auto; gap: 6px; }
  .topnav button {
    padding: 9px 18px; border-radius: var(--r-pill);
    font-size: 14px; font-weight: 500; color: var(--text-dim);
    transition: background .15s ease, color .15s ease;
  }
  .topnav button:hover { color: var(--text); background: var(--card); }
  .topnav button.active { color: #fff; background: rgba(124, 108, 246, .22); }
  .topbar-inner { max-width: none; padding: 13px 32px; }

  /* La barra inferior es cosa del móvil */
  .bottomnav { display: none; }
  #main { padding-bottom: 56px; }

  /* Contenedores: contenido contenido, no estirado */
  .container { max-width: 780px; padding: 30px 24px 8px; }
  #view-ai .container { max-width: 1020px; }
  #view-new .container { max-width: 850px; }
  #view-edit .container { max-width: 880px; }
  .section-title { font-size: 26px; }

  /* Lista vertical limpia */
  .quiz-list { gap: 12px; }
.quiz-item-actions { display: flex; align-items: center; gap: 2px; }
  .quiz-delete { padding: 9px; }

  /* Búsqueda más contenida */
  .search-wrap { max-width: 460px; }

  /* Vacío centrado con aire */
  .empty { padding: 90px 20px; }
  .empty-badge { width: 124px; height: 124px; }
  .empty-icon { width: 58px; height: 58px; }

  /* Datos: tarjeta secundaria discreta */
  .data-card {
    background: var(--bg-soft);
    border-color: transparent;
    margin-top: 34px;
    padding: 18px 20px;
  }
  .data-card h3 { font-size: 13.5px; color: var(--text-dim); }
  .data-card .data-sub { font-size: 12.5px; color: var(--text-faint); margin-bottom: 2px; }
  .data-card .btn-secondary { background: var(--card); }

  /* Toast sin bottom-nav */
  .toast { bottom: 28px; }

  .dropzone { cursor: pointer; }

  /* ---------- Nuevo: mitad y mitad, columnas integradas ---------- */
  .new-split {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
    align-items: stretch;
    margin-bottom: 4px;
  }
  .split-or { flex-direction: column; margin: 0; }
  .split-or::before, .split-or::after { width: 1px; height: auto; min-height: 28px; }
  .new-col { display: flex; flex-direction: column; min-width: 0; }
  .new-col .dropzone { flex: 1; justify-content: center; min-height: 220px; margin-bottom: 0; }
  #paste-area { flex: 1 1 auto; min-height: 220px; }

  /* Acciones bajo el textarea, alineadas a la derecha */
  .new-actions { margin-top: 12px; }
  .new-actions #btn-parse { flex: 1 1 auto; }
  .new-actions #btn-clear-paste { flex: 0 0 auto; }

  /* Chips de tipos equitativos y geométricos */
  .chips-toggles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .chip-toggle { text-align: center; }

  /* ---------- IA: dos columnas con prompt sticky ---------- */
  #view-ai .ai-desktop-grid {
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    gap: 32px;
    align-items: start;
  }
  #view-ai .ai-col-prompt { position: sticky; top: 86px; }

  /* Aire extra en la columna derecha, compacidad sutil en la izquierda */
  .ai-desktop-grid .flow-step { padding-bottom: 34px; }
  #view-ai .switch-row { margin-top: 14px; }
  #view-ai .field-label { margin: 12px 0 6px; }
}
