/* ── Telefonica Sans ──────────────────────────────────────────── */
@font-face { font-family: 'Telefonica Sans'; font-weight: 100; font-style: normal;
  src: url('/assets/fonts/Telefonica_Sans_Hairline.woff2') format('woff2'); }
@font-face { font-family: 'Telefonica Sans'; font-weight: 100; font-style: italic;
  src: url('/assets/fonts/Telefonica_Sans_Hairline_Italic.woff2') format('woff2'); }
@font-face { font-family: 'Telefonica Sans'; font-weight: 200; font-style: normal;
  src: url('/assets/fonts/Telefonica_Sans_ExtraLight.woff2') format('woff2'); }
@font-face { font-family: 'Telefonica Sans'; font-weight: 200; font-style: italic;
  src: url('/assets/fonts/Telefonica_Sans_ExtraLight_Italic.woff2') format('woff2'); }
@font-face { font-family: 'Telefonica Sans'; font-weight: 300; font-style: normal;
  src: url('/assets/fonts/Telefonica_Sans_Light.woff2') format('woff2'); }
@font-face { font-family: 'Telefonica Sans'; font-weight: 300; font-style: italic;
  src: url('/assets/fonts/Telefonica_Sans_Light_Italic.woff2') format('woff2'); }
@font-face { font-family: 'Telefonica Sans'; font-weight: 350; font-style: normal;
  src: url('/assets/fonts/Telefonica_Sans_Thin.woff2') format('woff2'); }
@font-face { font-family: 'Telefonica Sans'; font-weight: 350; font-style: italic;
  src: url('/assets/fonts/Telefonica_Sans_Thin_Italic.woff2') format('woff2'); }
@font-face { font-family: 'Telefonica Sans'; font-weight: 400; font-style: normal;
  src: url('/assets/fonts/Telefonica_Sans_Regular.woff2') format('woff2'); }
@font-face { font-family: 'Telefonica Sans'; font-weight: 400; font-style: italic;
  src: url('/assets/fonts/Telefonica_Sans_Italic.woff2') format('woff2'); }
@font-face { font-family: 'Telefonica Sans'; font-weight: 500; font-style: normal;
  src: url('/assets/fonts/Telefonica_Sans_Medium.woff2') format('woff2'); }
@font-face { font-family: 'Telefonica Sans'; font-weight: 500; font-style: italic;
  src: url('/assets/fonts/Telefonica_Sans_Medium_Italic.woff2') format('woff2'); }
@font-face { font-family: 'Telefonica Sans'; font-weight: 600; font-style: normal;
  src: url('/assets/fonts/Telefonica_Sans_DemiBold.woff2') format('woff2'); }
@font-face { font-family: 'Telefonica Sans'; font-weight: 600; font-style: italic;
  src: url('/assets/fonts/Telefonica_Sans_DemiBold_Italic.woff2') format('woff2'); }
@font-face { font-family: 'Telefonica Sans'; font-weight: 700; font-style: normal;
  src: url('/assets/fonts/Telefonica_Sans_Bold.woff2') format('woff2'); }
@font-face { font-family: 'Telefonica Sans'; font-weight: 700; font-style: italic;
  src: url('/assets/fonts/Telefonica_Sans_Bold_Italic.woff2') format('woff2'); }
@font-face { font-family: 'Telefonica Sans'; font-weight: 800; font-style: normal;
  src: url('/assets/fonts/Telefonica_Sans_ExtraBold.woff2') format('woff2'); }
@font-face { font-family: 'Telefonica Sans'; font-weight: 800; font-style: italic;
  src: url('/assets/fonts/Telefonica_Sans_ExtraBold_Italic.woff2') format('woff2'); }
@font-face { font-family: 'Telefonica Sans'; font-weight: 900; font-style: normal;
  src: url('/assets/fonts/Telefonica_Sans_Black.woff2') format('woff2'); }
@font-face { font-family: 'Telefonica Sans'; font-weight: 900; font-style: italic;
  src: url('/assets/fonts/Telefonica_Sans_Black_Italic.woff2') format('woff2'); }

@font-face { font-family: 'Playfair Display'; font-weight: 400 700; font-style: normal;
  src: url('/assets/fonts/PlayfairDisplay.woff2') format('woff2'); }

/* ─────────────────────────────────────────────────────────────
   Fundación IA — estilos
   Paleta Telefónica + tipografía Telefonica Sans + Playfair Display.
   ───────────────────────────────────────────────────────────── */

:root {
  --bg:           #0066ff;
  --bg-elev:      #131920;
  --ink:          #f0f4f8;
  --ink-dim:      rgba(240, 244, 248, 1);
  --ink-faint:    rgba(240, 244, 248, 0.35);
  --accent:       #0066ff;
  --accent-glow:  rgba(1, 157, 244, 0.45);
  --rule:         rgba(240, 244, 248, 0.1);
  --shadow:       0 14px 48px rgba(0, 0, 0, 0.55);

  --font-serif: 'Playfair Display', Georgia, serif;
  --font-sans:  'Telefonica Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --ease: cubic-bezier(.2, .7, .2, 1);

  --answer-size: clamp(18px, 2.1vw, 24px);
}
body[data-text-size="s"] { --answer-size: clamp(15px, 1.6vw, 19px); }
body[data-text-size="m"] { --answer-size: clamp(18px, 2.1vw, 24px); }
body[data-text-size="l"] { --answer-size: clamp(22px, 2.6vw, 30px); }

/* Temas */
body[data-theme="oscuro"] {
  --bg:           #0a0a0a;
  --bg-elev:      #171717;
}
body[data-theme="claro"] {
  --bg:           #ffffff;
  --bg-elev:      #ffffff;
  --ink:          #1a1514;
  --ink-dim:      rgba(26, 21, 20, 0.7);
  --ink-faint:    rgba(26, 21, 20, 0.4);
  --rule:         rgba(26, 21, 20, 0.1);
  --shadow:       0 10px 40px rgba(0, 0, 0, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible, textarea:focus-visible, input:focus-visible {
  outline: 1px solid var(--accent-glow);
  outline-offset: 2px;
}

/*a.header-logo {
    position: absolute;
    top: 0;
    left: 0;
}*/

a.header-logo img {
    height: 70px;
}
/* ──────────────────────── Escenario 3D / 2D ──────────────────────── */

#stage {
  position: fixed; inset: 0;
  z-index: 0;
  mix-blend-mode: screen;
}
#stage-canvas {
  display: block; width: 100%; height: 100%;
}
#stage-vignette {
  position: absolute; inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.55) 100%),
    radial-gradient(ellipse at center, transparent 70%, var(--accent-glow) 140%);
  mix-blend-mode: overlay;
  opacity: 0;
}
body[data-theme="claro"] #stage-vignette {
  background: radial-gradient(ellipse at center, transparent 65%, rgba(0,0,0,0.08) 100%);
  mix-blend-mode: multiply;
  opacity: 1;
}

/* ──────────────────────── Overlay / layout ──────────────────────── */

#overlay {
  position: relative;
  z-index: 1;
  width: 100%; height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  grid-template-columns: 1fr;
  padding: clamp(18px, 3vw, 36px)!important;
  gap: 16px;
  pointer-events: none;
  padding-top: 0 !important;
    padding-left: 0 !important;
}
#overlay > * { pointer-events: auto; }

/* Marca */
#brand {
  display: inline-flex; align-items: center; gap: 10px;
  justify-self: start;
  font-family: var(--font-sans);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-dim);
  padding:30px;
}
.brand-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent-glow);
}
.brand-title { color: var(--ink); font-weight: 500;}
.brand-sub::before { content: "·"; margin: 0 8px; color: var(--ink-faint); }
.brand-sub, .brand-title{display: none;}

/* Acciones superiores */
#top-actions {
  position: absolute;
  top: clamp(18px, 3vw, 36px);
  right: clamp(18px, 3vw, 36px);
  display: flex; gap: 6px;
}
#top-actions button {
  width: 38px; height: 38px;
  border-radius: 50%;
  color: var(--ink-dim);
  transition: color .2s var(--ease), background .2s var(--ease);
}
#top-actions button:hover { color: var(--ink); background: rgba(255,255,255,0.05); }
#top-actions svg { width: 18px; height: 18px; }

/* Botón música: alterna icono según estado (.muted = sin música) */
#btn-music .icon-music-off { display: none; }
#btn-music.muted .icon-music-on { display: none; }
#btn-music.muted .icon-music-off { display: inline-block; }
#btn-music.muted { color: var(--ink-faint); }

/* Centro */
#stage-text {
  grid-row: 2;
  align-self: center;
  justify-self: center;
  width: min(780px, 90%);
  min-height: 40vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
  overflow: visible;
}

.hint-initial {
  transition: opacity .8s var(--ease);
}
.hint-initial .hint-line {
  font-family: var(--font-serif);
  font-size: clamp(22px, 3vw, 32px);
  color: var(--ink-dim);
  font-weight: 400;
}
.hint-initial .hint-sub {
  margin-top: 8px;
  font-family: var(--font-sans);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.hint-hidden { opacity: 0; pointer-events: none; }

/* Respuesta */
.answer {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: var(--answer-size);
  line-height: 1.45;
  color: var(--ink);
  letter-spacing: 0.005em;
  max-width: 100%;
  opacity: 0;
  transition: opacity .45s var(--ease);
  text-shadow: 0 1px 30px rgba(0,0,0,0.6);
}
.answer.visible { opacity: 1; }
.answer p + p { margin-top: 0.6em; }

/* Modo "sync" */
.answer.sync {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: min(760px, 92vw);
  transition: opacity .35s var(--ease);
}
.answer.sync p { margin: 0; }

.answer.faded {
  opacity: 0;
  filter: blur(14px);
  transform: translateY(-50px);
  transition: opacity 8s var(--ease), filter 8s var(--ease), transform 8s var(--ease);
  pointer-events: none;
}

/* Modo "off" */
.answer.hidden { display: none !important; }
.answer em { font-style: italic; color: var(--ink-dim); }
.answer strong { color: var(--ink); font-weight: 500; }
.answer h1, .answer h2, .answer h3 {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 0.82em;
  color: var(--accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 0.6em;
  margin-bottom: 0.3em;
}
.answer ul, .answer ol {
  list-style: none;
  padding: 0;
  text-align: left;
  display: inline-block;
  margin: 0.3em auto;
}
.answer ul li::before { content: "·"; color: var(--accent); margin-right: 10px; }
.answer ol { counter-reset: i; }
.answer ol li { counter-increment: i; }
.answer ol li::before { content: counter(i) "  "; color: var(--accent); }

/* Cursor de streaming */
.caret {
  display: inline-block;
  width: 0.5ch;
  margin-left: 0.1ch;
  border-right: 2px solid var(--accent);
  animation: blink 1s steps(2) infinite;
  vertical-align: middle;
  height: 0.9em;
}
@keyframes blink { 50% { border-color: transparent; } }

/* Indicador de tool en curso */
.tool-indicator {
  margin-top: 18px;
  font-family: var(--font-sans);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
  min-height: 14px;
  opacity: 0;
  transition: opacity .3s var(--ease);
}
.tool-indicator.visible { opacity: 1; }
.tool-indicator::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 10px;
  vertical-align: middle;
  animation: pulse-dot 1.4s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%,100% { opacity: 0.3; transform: scale(1); }
  50%     { opacity: 1;   transform: scale(1.4); }
}

/* ──────────────────────── Archivos losas ──────────────────────── */

#archivos-layer {
  position: absolute;
  left: 50%;
  bottom: 180px;
  transform: translateX(-50%);
  display: flex; gap: 14px;
  max-width: 90%;
  overflow-x: auto;
  padding: 10px 4px;
  pointer-events: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-faint) transparent;
}
#archivos-layer::-webkit-scrollbar { height: 6px; }
#archivos-layer::-webkit-scrollbar-thumb { background: var(--ink-faint); border-radius: 3px; }

.losa {
  flex: 0 0 auto;
  width: 160px; height: 110px;
  position: relative;
  border-radius: 2px;
  overflow: hidden;
  background: var(--bg-elev);
  box-shadow: var(--shadow), 0 0 0 1px var(--rule);
  cursor: pointer;
  opacity: 0;
  transform: translateY(20px);
  animation: losa-in .8s var(--ease) forwards;
  transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}
.losa:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow), 0 0 0 1px var(--accent-glow);
}
@keyframes losa-in {
  to { opacity: 1; transform: translateY(0); }
}
.losa img, .losa .losa-icon {
  width: 100%; height: 100%;
  object-fit: cover;
  filter: saturate(0.9);
  transition: filter .4s var(--ease);
}
.losa:hover img { filter: saturate(1.1); }
.losa .losa-icon {
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-dim);
}
.losa .losa-icon svg { width: 36px; height: 36px; }
.losa .losa-caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 6px 8px;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ──────────────────────── Input ──────────────────────── */

#input-form {
  grid-row: 3;
  justify-self: center;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  width: min(720px, 92%);
  padding: 10px 14px;
  background: rgba(13, 17, 23, 0.72);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid var(--rule);
  border-radius: 16px;
  box-shadow: var(--shadow);
  transition: border-color .3s var(--ease), box-shadow .3s var(--ease);
}
body[data-theme="claro"] #input-form {
  background: rgba(255, 253, 249, 0.9);
}
#input-form:focus-within {
  border-color: rgba(1, 157, 244, 0.4);
  box-shadow: var(--shadow), 0 0 0 4px rgba(1, 157, 244, 0.08);
}
#input-form.listening {
  border-color: rgba(1, 157, 244, 0.7);
  box-shadow: var(--shadow), 0 0 0 5px rgba(1, 157, 244, 0.15);
}
#input-field {
  flex: 1;
  background: transparent;
  border: 0;
  resize: none;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  max-height: 160px;
  padding: 8px 0;
  overflow: hidden;
}
#input-field::placeholder { color: var(--ink-faint); }
#input-field:focus { outline: none; }

#btn-mic, #btn-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  color: var(--ink-dim);
  display: inline-flex; align-items: center; justify-content: center;
  transition: color .2s var(--ease), background .2s var(--ease), transform .2s var(--ease);
}
#btn-mic:hover, #btn-send:hover { color: var(--ink); background: rgba(255,255,255,0.05); }
#btn-mic.active {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(1, 157, 244, 0.18);
}
#btn-mic svg, #btn-send svg { width: 18px; height: 18px; }
#btn-send:disabled { opacity: 0.4; cursor: not-allowed; }
#btn-send.sending .icon-send { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toggle enviar ↔ stop */
#btn-send .icon-stop { display: none; }
#btn-send.speaking {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(1, 157, 244, 0.18);
  opacity: 1;
  cursor: pointer;
}
#btn-send.speaking .icon-send { display: none; }
#btn-send.speaking .icon-stop { display: inline-block; animation: none; }
#btn-send.speaking:disabled { opacity: 1; cursor: pointer; }

#input-hint {
  grid-row: 4;
  justify-self: center;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-top: 4px;
  transition: color .25s ease;
}
#input-hint.hint-error {
  color: #d66;
  letter-spacing: 0.04em;
  text-transform: none;
  font-size: 12px;
}

/* Sugerencias iniciales */
#suggestions {
  position: absolute;
  bottom: 150px;
  left: 50%;
  transform: translateX(-50%)!important;
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center;
  max-width: 790px;
  transition: opacity .4s var(--ease);
}
#suggestions.hidden { opacity: 0!important; pointer-events: none; }
.sug {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: rgba(13, 17, 23, 0.72);
  backdrop-filter: blur(8px);
  color: var(--ink-dim);
  font-size: 12px;
  font-family: var(--font-sans);
  transition: color .2s var(--ease), border-color .2s var(--ease);
}
.sug:hover { color: var(--ink); border-color: rgba(1, 157, 244, 0.5); }

body[data-theme="claro"] .sug { background:transparent; }

/* ──────────────────────── Drawers ──────────────────────── */

#config-drawer, #history-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(420px, 92vw);
  background: var(--bg-elev);
  border-left: 1px solid var(--rule);
  transform: translateX(100%);
  transition: transform .35s var(--ease);
  z-index: 40;
  display: flex; flex-direction: column;
}
#config-drawer.open, #history-drawer.open { transform: translateX(0); }
#config-backdrop, #history-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none;
  transition: opacity .3s var(--ease);
  z-index: 39;
}
#config-backdrop.open, #history-backdrop.open {
  opacity: 1; pointer-events: auto;
}

.drawer-head {
  padding: 20px 24px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--rule);
}
.drawer-head h2 {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 20px;
  letter-spacing: 0.01em;
}
.drawer-head button {
  width: 32px; height: 32px; border-radius: 50%;
  color: var(--ink-dim);
}
.drawer-head button:hover { color: var(--ink); background: rgba(255,255,255,0.05); }
.drawer-head svg { width: 16px; height: 16px; }

.drawer-body {
  flex: 1;
  padding: 20px 24px 40px;
  overflow-y: auto;
}

/* Config fields */
.cfg-group {
  margin-bottom: 26px;
}
.cfg-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 10px;
  font-weight: 500;
}
.cfg-radio-row {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.cfg-radio-row .opt {
  padding: 8px 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--ink-dim);
  font-size: 13px;
  cursor: pointer;
  transition: all .2s var(--ease);
}
.cfg-radio-row .opt:hover { color: var(--ink); border-color: rgba(1, 157, 244, 0.5); }
.cfg-radio-row .opt.selected {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
.cfg-select, .cfg-input {
  width: 100%;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 9px 12px;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13px;
}
.cfg-select option {
  background: var(--bg-elev);
  color: var(--ink);
}
.cfg-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0;
}
.cfg-toggle .label { font-size: 13px; color: var(--ink); }
.cfg-toggle .hint { font-size: 11px; color: var(--ink-faint); margin-top: 2px; }
.switch {
  position: relative;
  width: 36px; height: 20px;
  border-radius: 20px;
  background: var(--rule);
  cursor: pointer;
  transition: background .2s var(--ease);
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--ink);
  transition: transform .2s var(--ease);
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(16px); background: #fff; }

.cfg-note {
  font-size: 11px;
  color: var(--ink-faint);
  margin-top: 6px;
  line-height: 1.5;
}

.cfg-section {
  font-family: var(--font-serif, inherit);
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--ink);
  margin: 18px 0 14px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}

.cfg-sub-section {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 14px 0 8px;
  padding-left: 2px;
}

/* Slider */
.cfg-slider-top {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 8px;
}
.cfg-slider-val {
  font-size: 12px;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.cfg-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--rule);
  outline: none;
  cursor: pointer;
  padding: 0;
  margin: 0;
}
.cfg-range:focus { outline: none; }
.cfg-range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: var(--rule);
}
.cfg-range::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--rule);
}
.cfg-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px; height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-elev, #111);
  box-shadow: 0 0 0 1px var(--rule), 0 0 10px var(--accent-glow);
  cursor: grab;
  transition: transform .1s var(--ease);
}
.cfg-range::-webkit-slider-thumb:active { transform: scale(1.15); cursor: grabbing; }
.cfg-range::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-elev, #111);
  box-shadow: 0 0 0 1px var(--rule), 0 0 10px var(--accent-glow);
  cursor: grab;
}
.cfg-range::-moz-range-thumb:active { transform: scale(1.15); cursor: grabbing; }

/* Color picker */
.cfg-color-row {
  display: flex; align-items: center; gap: 10px;
}
.cfg-color {
  width: 44px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}
.cfg-color::-webkit-color-swatch-wrapper { padding: 3px; }
.cfg-color::-webkit-color-swatch { border: none; border-radius: 4px; }
.cfg-color::-moz-color-swatch { border: none; border-radius: 4px; }

.cfg-save-status {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.cfg-save-status.saved { color: #7fd184; }
.cfg-save-status.error { color: var(--accent); }

/* Historial */
.hist-msg {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--rule);
}
.hist-msg:last-child { border-bottom: 0; }
.hist-msg .role {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 6px;
}
.hist-msg.user .role { color: var(--accent); }
.hist-msg .body {
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
}
.hist-msg.user .body {
  font-family: var(--font-sans);
}
.hist-msg.assistant .body {
  font-family: var(--font-serif);
  font-weight: 400;
}
.hist-empty {
  font-size: 13px;
  color: var(--ink-faint);
  text-align: center;
  padding: 40px 20px;
  font-style: italic;
}

/* ──────────────────────── Lightbox ──────────────────────── */

#lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
}
#lightbox.open { display: flex; }
#lb-content {
  max-width: 92vw; max-height: 85vh;
  display: flex; align-items: center; justify-content: center;
}
#lb-content img, #lb-content iframe {
  max-width: 92vw; max-height: 85vh;
  background: #fff;
  box-shadow: 0 10px 60px rgba(0,0,0,0.6);
}
#lb-content iframe { width: 85vw; height: 85vh; }
#lb-close {
  position: absolute;
  top: 20px; right: 20px;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  transition: background .2s var(--ease);
}
#lb-close:hover { background: rgba(255,255,255,0.16); }
#lb-close svg { width: 20px; height: 20px; }
#lb-info {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--ink-dim);
  background: rgba(0,0,0,0.6);
  padding: 6px 14px;
  border-radius: 999px;
  max-width: 80vw;
  text-align: center;
}

/* ──────────────────────── Responsive ──────────────────────── */

@media (max-width: 640px) {
  #stage-text { min-height: 30vh; }
  .answer { font-size: 20px; }
  #suggestions { bottom: 160px; max-width: 92%; }
  #archivos-layer { bottom: 210px; gap: 10px; }
  .losa { width: 130px; height: 88px; }
  #brand .brand-sub { display: none; }
  a.header-logo img {
    height: 100px;
}
}

@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ──────────────────────── Onboarding ──────────────────────── */

body[data-onboarding="1"] #overlay,
body[data-onboarding="1"] #stage {
  opacity: 0;
  pointer-events: none;
}

body:not([data-boot="reveal"]) #overlay,
body:not([data-boot="reveal"]) #stage {
  opacity: 0;
}

#onboarding {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--bg);
  display: grid;
  place-items: center;
  padding: 32px;
  animation: onb-in .8s var(--ease);
}
#onboarding .step {
  width: 100%;
  max-width: 620px;
  text-align: center;
  opacity: 0;
  transform: translateY(12px);
  animation: onb-step .7s var(--ease) forwards;
}
#onboarding h1 {
  font-family: var(--font-serif);
  font-size: clamp(22px, 3vw, 32px);
  color: var(--ink-dim);
  font-weight: 400;
  line-height: 1.15;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}
#onboarding p.sub {
  color: var(--ink-dim);
  font-size: 15px;
  margin-bottom: 28px;
}
#onboarding .onb-input {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule);
  padding: 14px 4px;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 22px;
  text-align: center;
  transition: border-color .3s var(--ease);
  margin-bottom: 22px;
}
#onboarding .onb-input:focus {
  outline: none;
  border-bottom-color: var(--accent);
}
#onboarding .onb-primary {
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 12px 28px;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity .25s var(--ease), transform .2s var(--ease);
}
#onboarding .onb-primary:hover:not(:disabled) { transform: translateY(-1px); }
#onboarding .onb-primary:disabled { opacity: 0.35; cursor: not-allowed; }
#onboarding .opts {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}
#onboarding .opt {
  padding: 8px 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--ink-dim);
  font-size: 13px;
  cursor: pointer;
  transition: all .2s var(--ease);
  background: transparent;
}
#onboarding .opt:hover {
  color: var(--ink);
  border-color: rgba(1, 157, 244, 0.5);
}
#onboarding .opt.big {
  padding: 18px 22px;
  font-size: 17px;
  font-family: var(--font-sans);
  letter-spacing: 0.02em;
}
#onboarding .loader-dots {
  margin-top: 24px;
  display: inline-flex;
  gap: 10px;
  justify-content: center;
}
#onboarding .loader-dots span {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-dot 1.1s ease-in-out infinite;
}
#onboarding .loader-dots span:nth-child(2) { animation-delay: .15s; }
#onboarding .loader-dots span:nth-child(3) { animation-delay: .30s; }

@keyframes onb-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes onb-step {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

body[data-boot="reveal"] #stage        { animation: reveal-stage 1.4s var(--ease) 0s both; }
body[data-boot="reveal"] #brand        { animation: reveal .9s var(--ease) .00s both; }
body[data-boot="reveal"] #top-actions  { animation: reveal .9s var(--ease) .15s both; }
body[data-boot="reveal"] #stage-text   { animation: reveal .9s var(--ease) .30s both; }
body[data-boot="reveal"] #input-form   { animation: reveal .9s var(--ease) .55s both; }
body[data-boot="reveal"] #input-hint   { animation: reveal .9s var(--ease) .70s both; }
body[data-boot="reveal"] #suggestions  { animation: reveal .9s var(--ease) .85s both; }

@keyframes reveal-stage {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
