/* ════════════════════════════════════════════════
   LTH IA Web · estilo neon cyber (negro + cian)
   Mobile-first, instalable como PWA.
   ════════════════════════════════════════════════ */
:root {
  --bg: #02060a;
  --bg-2: #04121a;
  --panel: rgba(6, 20, 28, 0.86);
  --panel-solid: #061018;
  --line: rgba(110, 96, 235, 0.18);
  --line-strong: rgba(122, 100, 255, 0.36);
  --cyan: #4da3ff;
  --cyan-2: #2e78ff;
  --cyan-soft: rgba(165, 150, 255, 0.82);
  --violet: #7a5cff;
  --violet-2: #6a4dff;
  --grad: linear-gradient(120deg, var(--cyan), var(--violet));
  --text: #d6dcff;
  --text-dim: rgba(170, 172, 225, 0.66);
  --text-bright: #eef0ff;
  --field: rgba(0, 0, 0, 0.4);
  --user: linear-gradient(180deg, #2a2f63, #15183a);
  --danger: #ff5c7a;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  /* Tipografia estilo Claude (alternativas gratuitas a Styrene/Tiempos):
     sans 'Inter' para la interfaz, serif 'Source Serif 4' para mensajes y
     titulos, mono 'Fira Code' (con ligaduras) para el codigo. */
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-mono: 'Fira Code', ui-monospace, 'Cascadia Code', 'Cascadia Mono', Consolas, monospace;
  --font-display: var(--font-serif);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  overscroll-behavior: none;
}
body { overflow: hidden; }
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }

/* ───── Fondo animado ───── */
.bg-grid, .bg-glow, .bg-scan { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.bg-grid {
  background-image:
    linear-gradient(rgba(74, 163, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(74, 163, 255, 0.05) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 50% 30%, #000 0%, transparent 78%);
  animation: gridMove 22s linear infinite;
}
@keyframes gridMove { to { background-position: 44px 44px; } }
.bg-glow {
  background:
    radial-gradient(60% 45% at 50% 8%, rgba(46, 125, 255, 0.22), transparent 70%),
    radial-gradient(70% 55% at 80% 100%, rgba(74, 163, 255, 0.14), transparent 70%),
    radial-gradient(60% 50% at 10% 90%, rgba(0, 140, 255, 0.12), transparent 70%);
  animation: glowPulse 9s ease-in-out infinite alternate;
}
@keyframes glowPulse { from { opacity: .7; } to { opacity: 1; } }
.bg-scan {
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(74, 163, 255, 0.025) 3px 4px);
  mix-blend-mode: screen; opacity: .5;
}

/* ════════ PANTALLA DE ACCESO ════════ */
.auth-screen {
  position: relative; z-index: 2;
  height: 100vh; height: 100dvh;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; align-items: center;
  padding: calc(28px + var(--safe-top)) 20px calc(28px + var(--safe-bot));
}
/* display:grid de arriba anula el [hidden] del navegador; hay que forzar el
   ocultado o login y chat se muestran a la vez. */
.auth-screen[hidden] { display: none; }
.auth-card {
  width: 100%; max-width: 400px;
  margin: auto 0; flex: none;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  padding: 30px 24px 24px;
  backdrop-filter: blur(14px);
  box-shadow: 0 0 0 1px rgba(74,163,255,.05), 0 24px 80px rgba(46, 125, 255, 0.16), inset 0 0 40px rgba(74,163,255,.04);
  animation: rise .6s cubic-bezier(.2,.9,.25,1);
}
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.98); } }
.brand { text-align: center; margin-bottom: 22px; }
.brand-mark {
  width: 84px; height: 84px; margin: 0 auto 14px; display: grid; place-items: center;
  border-radius: 24px; border: 1px solid var(--line-strong);
  background: radial-gradient(circle at 50% 35%, rgba(74,163,255,.12), transparent 70%);
  box-shadow: 0 0 40px rgba(74,163,255,.18);
  animation: float 5s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-6px); } }
.brand-title {
  font-family: var(--font-display); font-weight: 900; font-size: 38px; letter-spacing: 3px;
  margin: 0; color: var(--text-bright); text-shadow: 0 0 18px rgba(74,163,255,.45);
}
.brand-title span { color: var(--cyan); }
.brand-sub { margin: 8px 0 0; color: var(--text-dim); font-size: 12.5px; line-height: 1.6; }
.brand-sub b { color: var(--cyan-soft); }

.auth-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  background: rgba(0,0,0,.3); border: 1px solid var(--line); border-radius: 12px; padding: 5px; margin-bottom: 18px;
}
.auth-tab {
  border: 0; background: transparent; color: var(--text-dim);
  padding: 11px; border-radius: 8px; font-size: 13px; letter-spacing: 1px; transition: .2s;
}
.auth-tab.on { background: linear-gradient(180deg, rgba(74,163,255,.16), rgba(46,125,255,.08)); color: var(--text-bright); box-shadow: inset 0 0 0 1px var(--line-strong), 0 0 18px rgba(74,163,255,.15); }

.field { display: block; margin-bottom: 14px; }
.field[hidden] { display: none; }
.field > span { display: block; font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-dim); margin-bottom: 7px; }
.field input {
  width: 100%; background: rgba(0,0,0,.34); border: 1px solid var(--line);
  border-radius: 11px; padding: 14px 14px; color: var(--text-bright); font-size: 15px; outline: none; transition: .2s;
}
.field input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(74,163,255,.12), 0 0 22px rgba(74,163,255,.14); }

.btn-primary {
  width: 100%; margin-top: 6px; border: 0; border-radius: 12px;
  padding: 15px; font-size: 15px; letter-spacing: 1.5px; color: #001226; font-weight: 700;
  background: var(--grad);
  box-shadow: 0 10px 30px rgba(74,163,255,.28), inset 0 1px 0 rgba(255,255,255,.4);
  display: flex; align-items: center; justify-content: center; gap: 10px; transition: transform .12s, filter .2s;
}
.btn-primary:active { transform: translateY(1px) scale(.99); }
.btn-primary:disabled { filter: saturate(.5) brightness(.8); cursor: default; }
.btn-spinner { width: 16px; height: 16px; border: 2px solid rgba(0,18,14,.35); border-top-color: #001226; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.auth-msg { min-height: 18px; margin: 12px 2px 0; font-size: 12.5px; text-align: center; color: var(--danger); line-height: 1.5; }
.auth-msg.ok { color: var(--cyan); }
.auth-foot { text-align: center; color: var(--text-dim); font-size: 11.5px; margin: 18px 0 0; }
.auth-foot b { color: var(--cyan-soft); }

/* ════════ APP DE CHAT ════════ */
.app-screen {
  position: relative; z-index: 2;
  height: 100dvh; display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto 1fr auto;
  grid-template-areas: "top" "usage" "msg" "composer";
}
.app-screen[hidden] { display: none; }
.topbar { grid-area: top; }
.usage-strip { grid-area: usage; }
.messages { grid-area: msg; }
.composer { grid-area: composer; }
.drawer { grid-area: side; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  background: linear-gradient(180deg, rgba(2,8,12,.96), rgba(2,8,12,.55));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px); position: relative; z-index: 6;
}
.icon-btn {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center;
  background: rgba(74,163,255,.06); border: 1px solid var(--line); border-radius: 11px; color: var(--cyan);
}
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.topbar-title { flex: 1; display: flex; align-items: center; gap: 9px; min-width: 0; }
.topbar-title .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); animation: blink 2.4s ease-in-out infinite; }
.dot.busy { background: var(--cyan-2); animation: blink .7s ease-in-out infinite; }
.dot.off { background: #466; box-shadow: none; animation: none; }
@keyframes blink { 50% { opacity: .35; } }
.tt-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.tt-text strong { font-family: var(--font-display); font-size: 15px; letter-spacing: 1.5px; color: var(--text-bright); }
.tt-text span { font-size: 10.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.engine-badge { flex: none; font-size: 10px; letter-spacing: .5px; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line-strong); white-space: nowrap; }
.engine-badge[hidden] { display: none; }
.engine-badge.on { color: #5bffd0; border-color: rgba(74,214,160,.45); background: rgba(74,214,160,.1); box-shadow: 0 0 12px rgba(74,214,160,.18); }
.engine-badge.off { color: #ffd15b; border-color: rgba(255,180,60,.4); background: rgba(255,180,60,.08); }
/* Barra de uso (siempre visible) */
.usage-strip {
  position: relative; z-index: 5;
  display: flex; align-items: center; gap: 11px;
  padding: 9px 14px;
  background: linear-gradient(180deg, rgba(2,10,14,.7), rgba(2,8,12,.4));
  border-bottom: 1px solid var(--line);
}
.us-plan {
  flex: none; font-size: 10px; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--cyan); background: rgba(74,163,255,.08); border: 1px solid var(--line-strong);
  border-radius: 999px; padding: 5px 11px;
}
.us-main { flex: 1; min-width: 0; }
.us-head { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; color: var(--text-dim); margin-bottom: 6px; }
.us-head #usageVal { color: var(--text-bright); white-space: nowrap; }
.us-track { height: 9px; border-radius: 6px; background: rgba(0,0,0,.45); border: 1px solid var(--line); overflow: hidden; }
.us-track i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--cyan), var(--cyan-2));
  box-shadow: 0 0 12px var(--cyan); transition: width .55s cubic-bezier(.2,.9,.25,1), background .3s;
}
.us-track i.warn { background: linear-gradient(90deg, #ffd15b, #ff9d3b); box-shadow: 0 0 12px rgba(255,180,60,.5); }
.us-track i.danger { background: linear-gradient(90deg, #ff7a93, #ff5c7a); box-shadow: 0 0 12px rgba(255,92,122,.55); }
.us-more { flex: none; width: 32px; height: 32px; border: 1px solid var(--line); background: rgba(74,163,255,.05); color: var(--cyan); border-radius: 9px; font-size: 14px; line-height: 1; }

.credits-panel {
  position: absolute; top: calc(100% + 6px); right: 12px; z-index: 7;
  width: min(320px, calc(100vw - 24px));
  background: var(--panel-solid); border: 1px solid var(--line-strong); border-radius: 14px; padding: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,.5), 0 0 30px rgba(74,163,255,.1); animation: rise .25s ease;
}
.cp-row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 12px; }
.cp-row b { color: var(--cyan); text-transform: uppercase; }
.cp-bar { display: grid; grid-template-columns: 58px 1fr auto; align-items: center; gap: 9px; margin-bottom: 10px; font-size: 11px; color: var(--text-dim); }
.cp-bar .bar { height: 7px; border-radius: 4px; background: rgba(0,0,0,.4); border: 1px solid var(--line); overflow: hidden; }
.cp-bar .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--cyan-2)); box-shadow: 0 0 10px var(--cyan); transition: width .5s; }
.cp-bar em { font-style: normal; color: var(--text); font-size: 10.5px; }
.cp-note { margin: 6px 0 0; font-size: 10.5px; color: var(--text-dim); line-height: 1.5; }

/* Drawer */
.drawer {
  position: absolute; top: 0; left: 0; bottom: 0; z-index: 9;
  width: min(82vw, 320px); display: flex; flex-direction: column;
  background: var(--panel-solid); border-right: 1px solid var(--line-strong);
  padding: calc(12px + var(--safe-top)) 12px calc(12px + var(--safe-bot));
  box-shadow: 14px 0 50px rgba(0,0,0,.55); animation: slideIn .25s cubic-bezier(.2,.9,.25,1);
}
/* CLAVE: [hidden] del navegador NO basta porque .drawer fija display:flex (un
   display de autor vence al [hidden] del user-agent). Sin esto, el drawer queda
   SIEMPRE visible y rompe el movil (panel pegado a la izquierda). */
.drawer[hidden] { display: none; }
@keyframes slideIn { from { transform: translateX(-100%); } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 12px; border-bottom: 1px solid var(--line); }
.drawer-head strong { font-family: var(--font-display); letter-spacing: 1.5px; font-size: 14px; color: var(--text-bright); }
.dh-actions { display: flex; align-items: center; gap: 6px; }
.dh-close { padding: 7px 11px; font-size: 13px; line-height: 1; }
.mini-btn { background: rgba(74,163,255,.1); border: 1px solid var(--line-strong); color: var(--cyan); border-radius: 9px; padding: 7px 11px; font-size: 12px; }
.mini-btn.ghost { background: transparent; color: var(--text-dim); border-color: var(--line); }
.convo-list { flex: 1; overflow-y: auto; padding: 10px 2px; display: flex; flex-direction: column; gap: 7px; }
.convo-item { text-align: left; background: rgba(74,163,255,.03); border: 1px solid var(--line); border-radius: 11px; padding: 11px 12px; color: var(--text); display: block; transition: .15s; cursor: pointer; }
.convo-item.on { border-color: var(--cyan); background: rgba(74,163,255,.1); box-shadow: inset 0 0 0 1px var(--line-strong); }
.convo-item .ci-title { font-size: 13px; color: var(--text-bright); display: flex; align-items: center; gap: 6px; }
.convo-item .ci-title .ci-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.convo-item .ci-sub { font-size: 10.5px; color: var(--text-dim); margin-top: 3px; display: flex; justify-content: space-between; gap: 8px; }
.convo-item .ci-del { color: var(--danger); opacity: .8; font-size: 11px; }
/* Chat en modo Programar: acento verde + etiqueta */
.convo-item.is-program { border-color: rgba(40,224,160,.32); background: rgba(40,224,160,.06); box-shadow: inset 3px 0 0 0 #1fd98a; }
.convo-item.is-program.on { border-color: rgba(40,224,160,.7); background: rgba(40,224,160,.13); box-shadow: inset 3px 0 0 0 #1fd98a, inset 0 0 0 1px rgba(40,224,160,.3); }
.convo-item .ci-badge { flex: none; display: inline-flex; align-items: center; gap: 3px; font-size: 9px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: #052016; background: linear-gradient(135deg,#36e7a3,#19c37d); border-radius: 6px; padding: 2px 6px; line-height: 1.4; box-shadow: 0 2px 8px -3px rgba(40,224,160,.7); }
.drawer-foot { border-top: 1px solid var(--line); padding-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.user-mini { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 38px; height: 38px; flex: none; border-radius: 11px; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; color: #001226; background: var(--grad); box-shadow: 0 0 16px rgba(74,163,255,.3); }
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-meta strong { font-size: 12.5px; color: var(--text-bright); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta span { font-size: 10.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
/* cursor:pointer es OBLIGATORIO para que iOS Safari dispare el evento click en
   un <div> (sin esto, tocar el fondo no cierra el drawer en iPhone). */
.scrim { position: absolute; inset: 0; z-index: 8; background: rgba(0,4,6,.6); backdrop-filter: blur(2px); animation: fade .2s ease; cursor: pointer; }
@keyframes fade { from { opacity: 0; } }

/* Mensajes */
.messages { overflow-y: auto; padding: 18px 14px 8px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }
.welcome { margin: auto; text-align: center; padding: 24px 8px; max-width: 440px; }
.welcome-mark { width: 92px; height: 92px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 26px; border: 1px solid var(--line); background: radial-gradient(circle at 50% 35%, rgba(74,163,255,.1), transparent 70%); box-shadow: 0 0 40px rgba(74,163,255,.14); animation: float 5s ease-in-out infinite; }
.welcome h2 { font-family: var(--font-display); font-weight: 700; font-size: 24px; letter-spacing: 1.5px; margin: 0 0 6px; color: var(--text-bright); }
.welcome h2 span { color: var(--cyan); text-shadow: 0 0 16px rgba(74,163,255,.4); }
.welcome p { color: var(--text-dim); font-size: 13px; margin: 0 0 20px; }
.suggest { display: grid; gap: 9px; }
.suggest button { background: rgba(74,163,255,.05); border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; color: var(--text); font-size: 13px; text-align: left; transition: .15s; }
.suggest button:active { border-color: var(--cyan); background: rgba(74,163,255,.1); }

.msg { display: flex; gap: 10px; max-width: 100%; animation: msgIn .3s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } }
.msg.user { flex-direction: row-reverse; }
.msg .av { width: 30px; height: 30px; flex: none; border-radius: 9px; display: grid; place-items: center; font-size: 12px; font-family: var(--font-display); }
.msg.ai .av { color: #001226; background: var(--grad); box-shadow: 0 0 14px rgba(74,163,255,.3); }
.msg.user .av { color: var(--cyan); background: rgba(74,163,255,.08); border: 1px solid var(--line-strong); }
/* Conversaciones en serif (el look de las respuestas de Claude). */
.bubble { font-family: var(--font-serif); padding: 12px 14px; border-radius: 14px; font-size: 15px; line-height: 1.62; max-width: 82%; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.ai .bubble { background: var(--panel); border: 1px solid var(--line); border-top-left-radius: 4px; }
.msg.user .bubble { background: var(--user); border: 1px solid var(--line-strong); border-top-right-radius: 4px; color: var(--text-bright); }
.bubble p { margin: 0 0 9px; } .bubble p:last-child { margin-bottom: 0; }
.bubble strong { color: var(--text-bright); }
/* El codigo SIEMPRE en monospace (antes heredaba la mono global del body). */
.bubble code, .bubble pre, .bubble pre code { font-family: var(--font-mono); font-feature-settings: 'liga' 1, 'calt' 1; }
.bubble code { background: rgba(0,0,0,.45); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; font-size: 12.5px; color: var(--cyan); }
/* Bloques de codigo: editor oscuro estilo VS Code en AMBOS temas. */
.bubble pre { background: #1e1e1e; border: 1px solid #3a3a3a; border-radius: 10px; padding: 12px; overflow-x: auto; margin: 8px 0; }
.bubble pre code { background: none; border: 0; padding: 0; color: #d4d4d4; }
.bubble ul, .bubble ol { margin: 6px 0; padding-left: 20px; } .bubble li { margin: 3px 0; }
.bubble a { color: var(--cyan-2); }
/* Imagenes generadas */
.gen-media { margin: 10px 0 2px; }
.gen-img { width: 100%; max-width: 420px; border-radius: 12px; border: 1px solid var(--line-strong); background: rgba(0,0,0,.35); display: block; cursor: pointer; min-height: 64px; }
.media-note { margin-top: 6px; font-size: 10.5px; color: var(--text-dim); letter-spacing: .3px; }
.gen-img-loading { display: inline-flex; align-items: center; gap: 1px; color: var(--cyan); font-size: 13.5px; }
.gen-img-loading .dots i { animation: blink 1.2s infinite; font-style: normal; }
.gen-img-loading .dots i:nth-child(2) { animation-delay: .2s; }
.gen-img-loading .dots i:nth-child(3) { animation-delay: .4s; }
/* Tarjeta de PDF generado */
.gen-pdf { display: flex; align-items: center; gap: 12px; margin: 10px 0 2px; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line-strong); background: rgba(74,163,255,.06); flex-wrap: wrap; }
.pdf-ic { flex: none; width: 42px; height: 50px; border-radius: 7px; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 12px; color: #001226; background: linear-gradient(160deg, var(--cyan), var(--cyan-2)); box-shadow: 0 0 14px rgba(74,163,255,.3); }
.pdf-meta { flex: 1; min-width: 120px; display: flex; flex-direction: column; gap: 2px; }
.pdf-meta strong { font-size: 13px; color: var(--text-bright); word-break: break-word; }
.pdf-actions { display: flex; gap: 7px; }
.pdf-btn { background: var(--grad); color: #001226; border: 0; border-radius: 9px; padding: 8px 13px; font-size: 12px; font-weight: 700; }
.pdf-btn.ghost { background: transparent; color: var(--cyan); border: 1px solid var(--line-strong); font-weight: 600; }

/* Configuración */
.foot-actions { display: flex; align-items: center; gap: 7px; flex: none; }
.settings-modal { position: absolute; inset: 0; z-index: 12; display: grid; place-items: center; padding: 20px; background: rgba(0,4,8,.66); backdrop-filter: blur(4px); animation: fade .2s ease; }
.settings-modal[hidden] { display: none; }
.settings-card { width: min(440px, 100%); background: var(--panel-solid); border: 1px solid var(--line-strong); border-radius: 18px; padding: 18px; box-shadow: 0 24px 70px rgba(0,0,0,.55), 0 0 40px rgba(74,163,255,.1); animation: rise .25s ease; }
.settings-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.settings-head strong { font-family: var(--font-display); letter-spacing: 1.2px; font-size: 15px; color: var(--text-bright); }
.setting-row { display: flex; align-items: center; gap: 14px; }
.setting-info { flex: 1; min-width: 0; }
.setting-info strong { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-bright); }
.setting-info span { display: block; margin-top: 4px; font-size: 11.5px; color: var(--text-dim); line-height: 1.5; }
.eng-dot { width: 8px; height: 8px; border-radius: 50%; background: #466; }
.eng-dot.on { background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
.eng-dot.busy { background: #ffd15b; box-shadow: 0 0 10px rgba(255,180,60,.6); animation: blink .8s infinite; }
.switch { flex: none; width: 50px; height: 28px; border-radius: 999px; border: 1px solid var(--line-strong); background: rgba(0,0,0,.4); position: relative; transition: background .2s, border-color .2s; }
.switch i { position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: var(--text-dim); transition: transform .2s, background .2s; }
.switch[aria-checked="true"] { background: var(--grad); border-color: transparent; }
.switch[aria-checked="true"] i { transform: translateX(22px); background: #001226; }
.engine-status { margin: 14px 0 0; font-size: 12px; color: var(--text-dim); padding: 9px 11px; border-radius: 10px; background: rgba(74,163,255,.05); border: 1px solid var(--line); }
.engine-status.ok { color: var(--cyan); border-color: var(--line-strong); }
.engine-status.warn { color: #ffd15b; border-color: rgba(255,180,60,.3); background: rgba(255,180,60,.06); }
.settings-note { margin: 14px 0 0; font-size: 11px; color: var(--text-dim); line-height: 1.6; }
.settings-note b { color: var(--cyan-soft); }
.engine-pin-entry { display: flex; gap: 9px; margin-top: 12px; }
.engine-pin-entry[hidden] { display: none; }
#enginePinInput { flex: 1; min-width: 0; background: rgba(0,0,0,.4); border: 1px solid var(--line-strong); border-radius: 11px; padding: 12px 14px; color: var(--text-bright); font-family: var(--font-mono); font-size: 22px; letter-spacing: 8px; text-align: center; outline: none; }
#enginePinInput:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(74,163,255,.12); }
.engine-pin-entry .pdf-btn { flex: none; }
.cursor::after { content: '▍'; color: var(--cyan); animation: blink 1s step-end infinite; margin-left: 1px; }
.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); opacity: .4; animation: typing 1.2s ease-in-out infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes typing { 30% { opacity: 1; transform: translateY(-3px); } }
.msg-err { align-self: center; max-width: 90%; text-align: center; font-size: 12.5px; color: var(--danger); background: rgba(255,92,122,.08); border: 1px solid rgba(255,92,122,.3); border-radius: 11px; padding: 10px 14px; }
.msg-err b { color: #ffd3dc; }
/* Me gusta / no me gusta (iconos, no emojis) */
.msg-feedback { display: flex; gap: 6px; margin-top: 9px; padding-top: 8px; border-top: 1px solid rgba(120,180,255,.1); }
.fb-btn { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); background: rgba(74,163,255,.04); color: var(--text-dim); transition: .15s; }
.fb-btn svg { width: 16px; height: 16px; fill: currentColor; }
.fb-btn:hover { color: var(--cyan); border-color: var(--line-strong); }
.fb-btn.up.on { color: #4ad6a0; border-color: rgba(74,214,160,.4); background: rgba(74,214,160,.1); }
.fb-btn.down.on { color: var(--danger); border-color: rgba(255,92,122,.4); background: rgba(255,92,122,.1); }

/* Composer */
.composer { padding: 8px 12px calc(10px + var(--safe-bot)); background: linear-gradient(0deg, rgba(2,8,12,.96), rgba(2,8,12,.4)); border-top: 1px solid var(--line); }
.composer-inner { display: flex; align-items: flex-end; gap: 9px; background: rgba(0,0,0,.4); border: 1px solid var(--line-strong); border-radius: 18px; padding: 7px 7px 7px 15px; transition: border-color .2s, box-shadow .2s; }
.composer-inner:focus-within { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(74,163,255,.1), 0 0 26px rgba(74,163,255,.12); }
#input { flex: 1; background: transparent; border: 0; outline: none; resize: none; color: var(--text-bright); font-size: 15px; line-height: 1.5; max-height: 130px; padding: 7px 0; }
#input::placeholder { color: var(--text-dim); }
.send-btn { width: 42px; height: 42px; flex: none; border: 0; border-radius: 14px; display: grid; place-items: center; background: var(--grad); box-shadow: 0 6px 18px rgba(74,163,255,.3); transition: transform .12s, filter .2s; }
.send-btn:active { transform: scale(.94); }
.send-btn:disabled { filter: saturate(.4) brightness(.7); }
.send-btn svg { width: 20px; height: 20px; }
.ic-send { fill: #001226; }
.ic-stop { fill: #001226; }
.send-btn.stopping { background: linear-gradient(120deg, #ff7a93, var(--danger)); }
.composer-hint { margin: 7px 4px 0; text-align: center; font-size: 10px; color: var(--text-dim); }
/* ── Banner / modal de upsell a Plan Pro ── */
.pro-card {
  position: relative; width: min(92vw, 420px); margin: auto;
  padding: 26px 22px 20px; border-radius: 22px; text-align: center;
  border: 1px solid rgba(122,92,255,.45);
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(122,92,255,.28), transparent 60%),
    linear-gradient(180deg, #121a2e 0%, #0b1322 100%);
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
}
.pro-close { position: absolute; top: 12px; right: 12px; }
.pro-mark { width: 64px; height: 64px; margin: 0 auto 10px; display: grid; place-items: center;
  border-radius: 18px; background: rgba(122,92,255,.16); border: 1px solid rgba(122,92,255,.4); }
.pro-badge { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: 2px;
  color: #cdbcff; background: rgba(122,92,255,.18); border: 1px solid rgba(122,92,255,.4);
  padding: 3px 12px; border-radius: 999px; margin-bottom: 8px; }
.pro-title { font-size: 21px; margin: 4px 0 6px; color: #fff; }
.pro-sub { font-size: 13px; color: var(--text-dim, #93a6c4); margin: 0 0 14px; }
.pro-feats { list-style: none; padding: 0; margin: 0 0 16px; text-align: left; display: grid; gap: 8px; }
.pro-feats li { display: flex; gap: 9px; align-items: flex-start; font-size: 12.5px; color: var(--text, #dce8f7); }
.pro-feats li span { flex: 0 0 auto; width: 20px; text-align: center; }
.pro-feats li b { color: #fff; }
.pro-buy {
  width: 100%; padding: 14px; border: none; border-radius: 14px; cursor: pointer;
  font-size: 15px; font-weight: 800; letter-spacing: .3px; color: #fff;
  background: linear-gradient(120deg, #7a5cff, #3aa0ff);
  box-shadow: 0 10px 28px rgba(122,92,255,.45); transition: .15s;
}
.pro-buy:active { transform: scale(.98); }
.pro-soon { font-size: 11.5px; color: var(--text-dim, #8aa0bd); margin: 9px 0 0; }

/* ── Aviso de descarga de LTH OS OUP (solo PC) ── */
.os-promo-card {
  position: relative; width: min(92vw, 440px); margin: auto;
  padding: 26px 24px 20px; border-radius: 22px; text-align: center;
  border: 1px solid rgba(77, 163, 255, .42);
  background:
    radial-gradient(120% 90% at 50% -12%, rgba(77, 163, 255, .26), transparent 58%),
    linear-gradient(180deg, #0a1626 0%, #07111d 100%);
  box-shadow: 0 28px 80px rgba(0, 0, 0, .62), 0 0 60px rgba(46, 125, 255, .12);
  animation: rise .3s cubic-bezier(.2, .9, .25, 1);
}
.os-promo-close { position: absolute; top: 12px; right: 12px; }
.os-promo-mark {
  width: 66px; height: 66px; margin: 2px auto 12px; display: grid; place-items: center;
  border-radius: 19px; border: 1px solid var(--line-strong);
  background: radial-gradient(circle at 50% 35%, rgba(77, 163, 255, .2), transparent 70%);
  box-shadow: 0 0 36px rgba(74, 163, 255, .22);
}
.os-promo-badge {
  display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: 2px;
  color: var(--cyan); background: rgba(74, 163, 255, .12);
  border: 1px solid var(--line-strong); padding: 4px 12px; border-radius: 999px; margin-bottom: 10px;
}
.os-promo-badge span { color: var(--violet); margin-left: 2px; }
.os-promo-title {
  font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: .5px;
  margin: 2px 0 8px; color: var(--text-bright);
}
.os-promo-sub { font-size: 13px; line-height: 1.6; color: var(--text-dim); margin: 0 0 16px; }
.os-promo-sub b { color: var(--cyan-soft); }
.os-promo-feats { list-style: none; padding: 0; margin: 0 0 18px; text-align: left; display: grid; gap: 9px; }
.os-promo-feats li { display: flex; gap: 10px; align-items: flex-start; font-size: 12.5px; color: var(--text); line-height: 1.45; }
.os-promo-feats li span { flex: 0 0 auto; width: 20px; text-align: center; }
.os-promo-feats li b { color: var(--text-bright); }
.os-promo-dl {
  display: block; width: 100%; padding: 14px; border: 0; border-radius: 14px;
  font-size: 15px; font-weight: 800; letter-spacing: .3px; color: #001226;
  background: var(--grad); box-shadow: 0 12px 30px rgba(74, 163, 255, .4);
  text-decoration: none; text-align: center; transition: transform .12s, filter .2s;
}
.os-promo-dl:hover { filter: brightness(1.06); }
.os-promo-dl:active { transform: scale(.98); }
.os-promo-skip {
  width: 100%; margin: 10px 0 0; padding: 11px; border: 1px solid var(--line);
  background: transparent; color: var(--text-dim); border-radius: 12px;
  font-size: 13px; font-weight: 600; transition: .15s;
}
.os-promo-skip:hover { color: var(--text-bright); border-color: var(--line-strong); }
.os-promo-note { font-size: 11px; color: var(--text-dim); margin: 12px 0 0; line-height: 1.5; }

.composer-modes { display: grid; grid-template-columns: auto repeat(3, minmax(0, 1fr)); gap: 7px; margin: 0 2px 7px; align-items: stretch; }

.model-badge {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 34px; padding: 7px 12px 7px 10px;
  border-radius: 999px; border: 1px solid rgba(77,163,255,.28);
  background:
    linear-gradient(135deg, rgba(77,163,255,.18), rgba(18,68,120,.08)),
    rgba(74,163,255,.04);
  color: var(--text-bright);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.03), 0 0 18px rgba(77,163,255,.12);
  letter-spacing: .2px;
}
.model-badge-mark {
  width: 10px; height: 10px; flex: none; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #dff7ff, #58b6ff 58%, #2a66ff);
  box-shadow: 0 0 0 3px rgba(77,163,255,.12), 0 0 12px rgba(77,163,255,.55);
  animation: modeDotLive 1.45s ease-in-out infinite;
}
.model-badge span:last-child { font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.mode-chip { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-width: 0; min-height: 34px; font-size: 11.5px; padding: 7px 10px; border-radius: 999px; border: 1px solid var(--line); background: rgba(74,163,255,.05); color: var(--text-dim); white-space: nowrap; overflow: hidden; transition: .15s; }
.mode-chip > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.mode-chip:active { transform: scale(.97); }
.mode-chip.on { color: #001226; border-color: transparent; background: var(--grad); box-shadow: 0 0 16px rgba(74,163,255,.3); font-weight: 700; }
/* Botón Razonar (premium) */
.mode-chip-reason { letter-spacing: .25px; }
.mode-dot { width: 10px; height: 10px; flex: none; border-radius: 50%; background: var(--mode-dot, var(--cyan)); box-shadow: 0 0 0 3px var(--mode-dot-halo, rgba(74,163,255,.12)), 0 0 12px var(--mode-dot-glow, rgba(74,163,255,.55)); animation: modeDotLive 1.45s ease-in-out infinite; }
.mode-dot-reason { --mode-dot: radial-gradient(circle at 35% 35%, #efeaff, #7a5cff 58%, #3aa0ff); --mode-dot-halo: rgba(122,92,255,.14); --mode-dot-glow: rgba(150,120,255,.62); }
.mode-dot-code { --mode-dot: radial-gradient(circle at 35% 35%, #d9fff0, #34e6a3 55%, #0fac6a); --mode-dot-halo: rgba(52,230,163,.14); --mode-dot-glow: rgba(52,230,163,.62); }
.mode-dot-create { --mode-dot: radial-gradient(circle at 35% 35%, #fff8cf, #ffd33d 55%, #ff9d1b); --mode-dot-halo: rgba(255,211,61,.16); --mode-dot-glow: rgba(255,190,50,.68); }
@keyframes modeDotLive { 0%, 100% { transform: scale(.82); opacity: .78; } 50% { transform: scale(1.16); opacity: 1; } }
.mode-chip-reason.on { color: #fff; border-color: transparent; background: linear-gradient(120deg, #7a5cff, #3aa0ff); box-shadow: 0 0 20px rgba(150,120,255,.4); font-weight: 700; }
.mode-chip-reason.on .mode-dot-reason { --mode-dot: radial-gradient(circle at 35% 35%, #fff, #d8c9ff 58%, #8fa7ff); --mode-dot-glow: rgba(255,255,255,.76); }
@media (max-width: 430px) {
  .mode-chip { gap: 5px; font-size: 10.5px; padding-inline: 6px; }
  .mode-dot { width: 9px; height: 9px; }
  .model-badge { gap: 6px; padding-inline: 8px; }
  .model-badge span:last-child { font-size: 10.5px; }
  .model-badge-mark { width: 9px; height: 9px; }
}
/* Indicador de razonamiento en vivo (premium, sin emojis) */
.reason-live { display: inline-flex; align-items: center; gap: 9px; font-size: 13.5px; color: #cfe2ff; }
.reason-orb { width: 11px; height: 11px; flex: none; border-radius: 50%; background: radial-gradient(circle at 35% 32%, var(--text-bright), #7a5cff 55%, #3aa0ff); box-shadow: 0 0 14px rgba(120,110,255,.55); animation: reasonOrb 1.2s ease-in-out infinite; }
@keyframes reasonOrb { 0%,100% { transform: scale(.82); opacity: .75; } 50% { transform: scale(1.18); opacity: 1; } }
.reason-label { background: linear-gradient(90deg, #9ec5ff, #c9bbff, #9ec5ff); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: reasonShine 2.4s linear infinite; }
@keyframes reasonShine { to { background-position: 200% 0; } }
.reason-live .reason-dots { display: inline-flex; gap: 3px; }
.reason-live .reason-dots i { width: 4px; height: 4px; border-radius: 50%; background: #8aa9ff; opacity: .4; animation: blink 1.2s infinite; }
.reason-live .reason-dots i:nth-child(2) { animation-delay: .2s; }
.reason-live .reason-dots i:nth-child(3) { animation-delay: .4s; }
/* Ventana de espera del juez (modo razonamiento): borrador listo + verificacion en curso */
.reason-review { margin: 1px 0; }
.reason-review-bar { display: flex; align-items: center; gap: 11px; padding: 11px 13px; border-radius: 14px; border: 1px solid rgba(122,140,255,.3); background: linear-gradient(120deg, rgba(77,163,255,.13), rgba(122,92,255,.13)); box-shadow: 0 6px 20px -12px rgba(90,110,255,.6); }
.reason-review-orb { width: 26px; height: 26px; flex: none; border-radius: 50%; background: radial-gradient(circle at 35% 32%, #eaf0ff, #7a5cff 55%, #3aa0ff); box-shadow: 0 0 16px rgba(120,110,255,.6); animation: reasonOrb 1.2s ease-in-out infinite; }
.reason-review-tx { display: flex; flex-direction: column; gap: 2px; line-height: 1.25; min-width: 0; }
.reason-review-tx strong { font-size: 13.5px; }
.reason-review-tx span { font-size: 11.5px; color: var(--text-dim); }
.reason-review-dots { display: inline-flex; gap: 4px; margin-left: auto; flex: none; align-self: center; }
.reason-review-dots i { width: 5px; height: 5px; border-radius: 50%; background: #9ab0ff; opacity: .4; animation: blink 1.2s infinite; }
.reason-review-dots i:nth-child(2) { animation-delay: .2s; }
.reason-review-dots i:nth-child(3) { animation-delay: .4s; }
.reason-review-draft { position: relative; margin-top: 9px; max-height: 230px; overflow: hidden; border-radius: 12px; border: 1px solid var(--line); background: var(--field); }
.reason-review-peek { padding: 12px 14px; opacity: .5; font-size: 13.5px; }
.reason-review-peek p:first-child { margin-top: 0; }
.reason-review-fade { position: absolute; left: 0; right: 0; bottom: 0; height: 96px; background: linear-gradient(180deg, transparent, var(--panel-solid)); pointer-events: none; }
.reason-review-draft::after { content: ''; position: absolute; left: 0; bottom: 0; height: 3px; width: 36%; border-radius: 3px; background: linear-gradient(90deg, transparent, #7a5cff, #3aa0ff, transparent); animation: reasonSweep 1.6s ease-in-out infinite; }
@keyframes reasonSweep { 0% { transform: translateX(-70%); } 100% { transform: translateX(300%); } }
/* Panel de actividad del modo Programar: muestra en vivo lo que escribe + pausas/continuaciones */
.pg-live { margin: 1px 0; padding: 11px 13px; border-radius: 14px; border: 1px solid rgba(122,140,255,.28); background: linear-gradient(120deg, rgba(77,163,255,.10), rgba(122,92,255,.10)); }
.pg-live-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pg-live-part { font-size: 11.5px; font-weight: 600; color: #cfe2ff; padding: 2px 9px; border-radius: 999px; border: 1px solid rgba(122,140,255,.4); background: rgba(122,140,255,.12); }
.pg-live-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; }
.pg-live-writing { display: inline-flex; align-items: center; gap: 7px; color: #9ec5ff; }
.pg-live-writing .reason-orb { width: 9px; height: 9px; }
.pg-live-paused { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: #ffce6e; padding: 2px 9px; border-radius: 999px; border: 1px solid rgba(255,180,60,.45); background: rgba(255,180,60,.10); animation: blink 1.1s ease-in-out infinite; }
.pg-live-count { color: var(--text-dim); margin-left: auto; }
.pg-live-codewrap { margin-top: 9px; }
.pg-live-codewrap summary { cursor: pointer; font-size: 11.5px; color: var(--text-dim); list-style: none; user-select: none; }
.pg-live-codewrap summary::-webkit-details-marker { display: none; }
.pg-live-code { margin: 7px 0 0; padding: 10px 12px; max-height: 180px; overflow: auto; border-radius: 10px; border: 1px solid var(--line); background: var(--field); font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 11.5px; line-height: 1.45; color: #b9d4c9; white-space: pre-wrap; word-break: break-word; }
/* Tarjeta de veredicto del juez */
.verdict-card { margin-top: 11px; padding: 11px 13px; border-radius: 13px; border: 1px solid var(--line); background: rgba(74,163,255,.05); }
.verdict-card.v-ok { border-color: rgba(74,214,160,.4); background: rgba(74,214,160,.07); }
.verdict-card.v-warn { border-color: rgba(255,180,60,.4); background: rgba(255,180,60,.07); }
.verdict-card.v-bad { border-color: rgba(255,92,122,.4); background: rgba(255,92,122,.07); }
.vc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.vc-badge { font-weight: 700; font-size: 11px; letter-spacing: .4px; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.v-ok .vc-badge { color: #00231a; background: #5bffd0; }
.v-warn .vc-badge { color: #2a1c00; background: #ffd15b; }
.v-bad .vc-badge { color: #2a0010; background: #ff7a93; }
.verdict-card.v-idle { border-color: var(--line); background: rgba(150,160,210,.06); }
.v-idle .vc-badge { color: #dbe2ff; background: rgba(150,160,210,.28); }
.vc-conf { font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.vc-bar { height: 6px; border-radius: 4px; background: rgba(0,0,0,.35); border: 1px solid var(--line); overflow: hidden; margin: 9px 0 1px; }
.vc-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--cyan-2)); box-shadow: 0 0 8px var(--cyan); }
.v-ok .vc-bar i { background: linear-gradient(90deg, #4ad6a0, #5bffd0); box-shadow: 0 0 8px rgba(74,214,160,.5); }
.v-bad .vc-bar i { background: linear-gradient(90deg, #ff7a93, #ff5c7a); }
.vc-warn { margin-top: 9px; font-size: 11.5px; color: #ffd15b; line-height: 1.5; }
.vc-sources { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.vc-srctitle { font-size: 9.5px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-dim); margin-right: 2px; }
.vc-src { font-size: 11px; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--cyan-2); background: rgba(74,163,255,.06); text-decoration: none; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.vc-src:active, a.vc-src:hover { border-color: var(--cyan); color: var(--text-bright); }
/* ════════════════════════════════════════════════
   PC / pantallas anchas — layout de DOS PANELES
   (barra lateral + chat centrado), estilo app de IA.
   Mobile-first arriba; todo lo de aquí es solo ≥880px.
   La barra lateral se puede colapsar a una franja de
   iconos (clase .sidebar-collapsed la gestiona app.js).
   ════════════════════════════════════════════════ */
@media (min-width: 880px) {
  .app-screen {
    width: 100vw;
    max-width: none;
    margin: 0;
    grid-template-columns: var(--side-w, 260px) minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      "side top"
      "side usage"
      "side msg"
      "side composer";
    border: 0;
    box-shadow: none;
    transition: grid-template-columns .26s cubic-bezier(.4, 0, .2, 1);
  }
  .app-screen.sidebar-collapsed { --side-w: 62px; }

  /* ── Barra lateral fija (el drawer se vuelve estático en PC) ── */
  .app-screen .drawer,
  .app-screen .drawer[hidden] {
    position: static; display: flex; width: auto; inset: auto;
    grid-row: 1 / -1; animation: none; box-shadow: none;
    overflow: hidden;
    padding: calc(13px + var(--safe-top)) 13px calc(13px + var(--safe-bot));
    border-right: 1px solid rgba(120, 150, 255, .14);
    background:
      linear-gradient(180deg, rgba(4, 11, 20, .99), rgba(6, 14, 24, .97)),
      radial-gradient(120% 55% at 50% -8%, rgba(77, 163, 255, .10), transparent 56%);
  }
  /* El botón ☰ del header es el toggle de colapso en PC (no un panel flotante). */
  #menuBtn { display: grid; transition: background .15s, color .15s, border-color .15s; }
  #menuBtn[aria-pressed="true"] {
    background: rgba(74, 163, 255, .14);
    color: var(--text-bright);
    border-color: var(--line-strong);
  }
  #scrim { display: none !important; }
  .dh-close { display: none; }

  .drawer-head { padding: 0 2px 11px; gap: 7px; }
  .drawer-head strong { font-size: 13px; letter-spacing: .8px; white-space: nowrap; }
  .dh-actions { gap: 6px; }
  .mini-btn { min-height: 30px; padding: 6px 10px; font-size: 10.5px; border-radius: 9px; }
  .convo-list { gap: 3px; padding: 11px 0; }
  .convo-item {
    padding: 8px 9px; border-radius: 9px;
    background: transparent; border-color: transparent;
  }
  .convo-item:hover { background: rgba(74, 163, 255, .07); border-color: rgba(74, 163, 255, .16); }
  .convo-item.on {
    background: rgba(74, 163, 255, .12);
    border-color: rgba(74, 163, 255, .34);
    box-shadow: inset 3px 0 0 var(--cyan);
  }
  .convo-item .ci-title { font-size: 11.5px; }
  .convo-item .ci-sub { font-size: 9.5px; margin-top: 2px; }
  .drawer-foot { margin-top: auto; padding-top: 11px; }
  .avatar { width: 30px; height: 30px; border-radius: 9px; font-size: 12px; }
  .user-meta strong { font-size: 11px; }
  .user-meta span { max-width: 120px; font-size: 9.5px; }
  .foot-actions { gap: 6px; }

  /* ── Sidebar colapsada: franja de iconos ── */
  .app-screen.sidebar-collapsed .drawer { padding-inline: 10px; }
  .app-screen.sidebar-collapsed .drawer-head { justify-content: center; padding: 0 0 10px; }
  .app-screen.sidebar-collapsed .drawer-head strong { display: none; }
  .app-screen.sidebar-collapsed .dh-actions { width: 100%; justify-content: center; }
  .app-screen.sidebar-collapsed #newChatBtn {
    width: 40px; height: 40px; padding: 0; border-radius: 11px;
    font-size: 0; display: grid; place-items: center;
  }
  .app-screen.sidebar-collapsed #newChatBtn::before {
    content: "+"; font-size: 19px; line-height: 1; font-weight: 400;
  }
  .app-screen.sidebar-collapsed .convo-list { display: none; }
  .app-screen.sidebar-collapsed .drawer-foot {
    flex-direction: column; gap: 7px; align-items: stretch;
  }
  .app-screen.sidebar-collapsed .user-mini { justify-content: center; }
  .app-screen.sidebar-collapsed .user-meta { display: none; }
  .app-screen.sidebar-collapsed .foot-actions {
    flex-direction: column; width: 100%; align-items: center; gap: 7px;
  }
  .app-screen.sidebar-collapsed .foot-actions .mini-btn {
    width: 38px; height: 38px; padding: 0; display: grid; place-items: center; font-size: 14px;
  }

  /* ── Header ── */
  .topbar {
    min-height: 50px;
    padding: 8px 18px;
    gap: 11px;
    background: rgba(3, 9, 14, .86);
    backdrop-filter: blur(14px);
  }
  .topbar .icon-btn { width: 34px; height: 34px; border-radius: 9px; }
  .topbar .icon-btn svg { width: 18px; height: 18px; }
  .tt-text strong { font-size: 14px; letter-spacing: .8px; }
  .tt-text span { font-size: 10px; }

  /* ── Barra de uso ── */
  .usage-strip {
    padding: 6px 18px;
    gap: 9px;
    background: rgba(3, 9, 14, .5);
  }
  .us-main { max-width: none; }
  .us-head { font-size: 10.5px; margin-bottom: 4px; }
  .us-track { height: 6px; }
  .us-plan { font-size: 9.5px; padding: 4px 9px; }
  .us-more { width: 30px; height: 30px; border-radius: 9px; font-size: 13px; }

  /* ── Mensajes: columna de lectura centrada ── */
  .messages {
    align-items: stretch;
    gap: 13px;
    padding: 18px clamp(20px, 5.5vw, 96px) 12px;
    scrollbar-gutter: stable;
  }
  .messages > * {
    width: min(100%, 820px);
    max-width: none;
    margin-inline: auto;
  }
  .msg { gap: 9px; }
  .msg .av { width: 26px; height: 26px; border-radius: 8px; font-size: 10px; }
  .bubble {
    max-width: min(88%, 640px);
    font-size: 13.5px;
    line-height: 1.58;
    border-radius: 12px;
    padding: 10px 13px;
  }

  /* ── Estado de chat vacío (bienvenida centrada) ── */
  .app-screen.is-empty-chat .messages {
    display: grid;
    place-items: center;
    padding: clamp(24px, 6vh, 60px) clamp(24px, 6vw, 120px) clamp(26px, 7vh, 72px);
  }
  .app-screen.is-empty-chat .welcome {
    width: min(100%, 680px);
    max-width: none;
    margin: 0 auto;
    padding: 0;
    text-align: center;
  }
  .app-screen.is-empty-chat .welcome-mark {
    width: 58px; height: 58px; margin: 0 auto 14px; border-radius: 17px;
  }
  .app-screen.is-empty-chat .welcome-mark img { width: 44px; height: 44px; }
  .app-screen.is-empty-chat .welcome h2 {
    font-size: clamp(22px, 2.2vw, 30px);
    letter-spacing: .8px;
    margin-bottom: 8px;
  }
  .app-screen.is-empty-chat .welcome p {
    max-width: 480px;
    margin: 0 auto 20px;
    font-size: 12.5px;
  }
  .app-screen.is-empty-chat .suggest {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }
  .app-screen.is-empty-chat .suggest button {
    min-height: 44px;
    padding: 10px 14px;
    border-radius: 11px;
    font-size: 12px;
    text-align: center;
    background: rgba(74, 163, 255, .05);
  }

  /* ── Composer (premium, centrado bajo la columna) ── */
  .composer {
    position: sticky;
    bottom: 0;
    z-index: 7;
    padding: 8px clamp(20px, 5.5vw, 96px) calc(13px + var(--safe-bot));
    border-top: 0;
    background:
      linear-gradient(180deg, rgba(2, 8, 12, 0), rgba(2, 8, 12, .88) 30%, rgba(2, 8, 12, .98) 100%);
    backdrop-filter: blur(16px);
  }
  .composer-modes {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: min(100%, 820px);
    margin: 0 auto 7px;
    gap: 7px;
  }
  .model-badge,
  .mode-chip {
    justify-content: center;
    min-height: 32px;
    border-radius: 10px;
    font-size: 11px;
  }
  .model-badge span:last-child { font-size: 11px; }
  .mode-dot, .model-badge-mark { width: 9px; height: 9px; }
  .composer-inner,
  .composer-hint {
    width: min(100%, 820px);
    margin-inline: auto;
  }
  .composer-inner {
    min-height: 50px;
    border-radius: 16px;
    padding: 7px 7px 7px 16px;
    background: rgba(8, 16, 26, .72);
    box-shadow:
      0 14px 38px -16px rgba(0, 0, 0, .7),
      0 0 0 1px rgba(255, 255, 255, .02),
      inset 0 0 0 1px rgba(120, 150, 255, .04);
  }
  #input { font-size: 14px; }
  .send-btn { width: 38px; height: 38px; border-radius: 11px; }
  .send-btn svg { width: 18px; height: 18px; }
}

@media (min-width: 1200px) {
  .app-screen { grid-template-columns: var(--side-w, 272px) minmax(0, 1fr); }
  .app-screen.sidebar-collapsed { --side-w: 64px; }
  .messages > *,
  .composer-modes,
  .composer-inner,
  .composer-hint { width: min(100%, 840px); }
  .bubble { max-width: min(84%, 660px); }
}

@media (min-width: 1500px) {
  .app-screen { grid-template-columns: var(--side-w, 284px) minmax(0, 1fr); }
  .app-screen.sidebar-collapsed { --side-w: 64px; }
  .messages { padding-inline: clamp(40px, 11vw, 200px); }
  .composer { padding-inline: clamp(40px, 11vw, 200px); }
  .messages > *,
  .composer-modes,
  .composer-inner,
  .composer-hint { width: min(100%, 880px); }
}

/* ════════ MODO CLARO — paleta CREMA LILA (tinte morado de Mady) ════════
   Fondo crema con tinte violeta suave, texto índigo oscuro para máximo
   contraste/legibilidad, acentos azul/violeta conservados. La barra lateral
   también es lila (nunca oscura) para integrarse con el resto. */
body.light {
  --bg: #f0ecf9;
  --bg-2: #e6def4;
  --panel: #ece5f7;                     /* burbuja IA / tarjetas: lila crema con cuerpo */
  --panel-solid: #efe9fa;               /* lila sólido: modales, menús, drawer móvil */
  --line: rgba(108, 80, 200, 0.24);     /* bordes violeta suave */
  --line-strong: rgba(108, 80, 200, 0.40);
  --cyan: #2e78ff;
  --cyan-2: #1f5fe0;
  --cyan-soft: #6a4dff;
  --violet: #6a4dff;
  --violet-2: #5a3de0;
  --text: #3a2f5c;                      /* índigo oscuro: buen contraste sobre lila */
  --text-dim: rgba(82, 66, 124, 0.76);
  --text-bright: #241a40;               /* casi negro violeta para títulos/énfasis */
  --field: rgba(96, 72, 168, 0.10);
  /* TUS mensajes en AZUL (Mady va en amarillo) para distinguirse de un vistazo. */
  --user: linear-gradient(180deg, #c6def9, #a9caf2);
}
/* Superficies que estaban hardcodeadas en oscuro -> crema lila con cuerpo */
body.light .topbar { background: linear-gradient(180deg, rgba(240,234,251,.97), rgba(240,234,251,.72)); }
body.light .usage-strip { background: linear-gradient(180deg, rgba(236,229,248,.86), rgba(236,229,248,.5)); }
body.light .composer { background: linear-gradient(0deg, rgba(240,234,251,.98), rgba(240,234,251,.5)); }
body.light .auth-tabs { background: rgba(96,72,168,.08); }
body.light .composer-inner,
body.light .field input,
body.light #input { background: #f6f1fd; }
body.light .us-track,
body.light .cp-bar .bar,
body.light .vc-bar,
body.light .switch { background: var(--field); }
body.light .gen-img { background: var(--field); }
body.light .bubble code:not(pre code) { background: rgba(96,72,168,.11); color: var(--violet-2); }
/* (Los bloques .bubble pre se quedan en editor oscuro VS Code también en claro.) */
/* Tus burbujas (azul): borde azul y texto navy para contraste. */
body.light .msg.user .bubble { border-color: rgba(70,130,205,.5); color: #15314f; }
/* Burbujas de Mady: morado medio (se distingue del azul del usuario); texto
   muy oscuro para que se lea bien dentro. */
body.light .msg.ai .bubble { background: linear-gradient(180deg, #d6c4f0, #c3a9ea); border-color: rgba(120,86,205,.42); color: #271a48; }
body.light .msg.ai .bubble strong { color: #1c1238; }
body.light .msg.ai .bubble code:not(pre code) { background: rgba(40,22,90,.12); color: #34206e; }
body.light .msg.ai .bubble a { color: #15348f; }
body.light .scrim { background: rgba(40,28,78,.30); }
/* Acentos diseñados para fondo NEGRO (verde menta, cian, amarillo, azul claro):
   en claro se oscurecen para que el texto contraste sobre los contenedores lila. */
body.light .engine-badge.on { color: #0a8f63; border-color: rgba(16,150,108,.42); background: rgba(16,150,108,.13); box-shadow: none; }
body.light .engine-badge.off { color: #936400; border-color: rgba(180,130,20,.42); background: rgba(200,150,40,.14); }
body.light .engine-status.ok { color: #2f63d8; }
body.light .engine-status.warn { color: #936400; background: rgba(200,150,40,.10); border-color: rgba(180,130,20,.3); }
body.light .fb-btn.up.on { color: #0a8f63; border-color: rgba(16,150,108,.42); background: rgba(16,150,108,.13); }
body.light .fb-btn.down.on { color: #cf2f4e; border-color: rgba(207,47,78,.42); background: rgba(207,47,78,.11); }
body.light .mode-chip-create.on { color: #8a6400; background: rgba(255,200,40,.22); border-color: rgba(200,150,30,.6); }
body.light .vc-warn { color: #936400; }
body.light .convo-item.is-program { background: rgba(16,150,108,.08); border-color: rgba(16,150,108,.30); }
body.light .convo-item.is-program.on { background: rgba(16,150,108,.16); border-color: rgba(16,150,108,.55); }
body.light .reason-live { color: var(--violet-2); }
body.light .reason-label { background: linear-gradient(90deg,#5a3de0,#2f63d8,#5a3de0); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; }
body.light .pg-live-writing { color: var(--violet-2); }
body.light .pg-live-part { color: var(--violet-2); border-color: rgba(108,80,200,.4); background: rgba(108,80,200,.1); }
/* "Pensando opciones…" del flujo de editar: era verde crema (invisible sobre el
   modal lila claro). Lo hacemos legible. */
body.light .pg-busy { color: #176b4f; }
/* Botones de código (Abrir página / Código): el violeta translúcido se perdía
   sobre la burbuja morada de Mady en claro. Los hacemos sólidos y visibles. */
body.light .code-preview-btn { background: linear-gradient(135deg,#5b86f0,#7d5cf0); color:#fff; border-color: rgba(90,70,200,.55); box-shadow: 0 6px 18px -10px rgba(90,70,200,.7); }
body.light .code-preview-btn .cpl-label { color:#fff; }
body.light .code-preview-btn .cpl-sub { color: rgba(255,255,255,.8); }
body.light .code-preview-btn .cpl-go { color: rgba(255,255,255,.85); }
body.light .code-preview-codebtn { background:#ffffff; color:#4a32c0; border-color: rgba(108,80,200,.55); }
body.light .code-preview-codebtn:hover { background:#f3eefc; border-color: rgba(108,80,200,.75); }
body.light .code-preview-codebtn .cpc-ic { color:#6a4dff; }
/* Barra lateral en claro: lila diferenciada (un punto más saturada que el chat),
   NUNCA oscura. Anula el fondo oscuro que el layout de PC pone por defecto. */
@media (min-width: 880px) {
  body.light .app-screen .drawer,
  body.light .app-screen .drawer[hidden] {
    background: linear-gradient(180deg, #ebe4f8, #e0d6f3);
    border-right: 1px solid rgba(108, 80, 200, 0.20);
  }
}
/* El fondo animado neon se suaviza en claro */
body.light .bg-grid { opacity: .35; }
body.light .bg-glow { opacity: .5; }
body.light .bg-scan { display: none; }
/* La tarjeta Pro se queda oscura a propósito (look premium) en ambos temas. */

/* Toggle de tema en ajustes */
.theme-row { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.theme-seg { display: flex; gap: 6px; background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 5px; }
.theme-seg button { flex: 1; border: 0; background: transparent; color: var(--text-dim); padding: 9px; border-radius: 8px; font-size: 12.5px; font-weight: 700; letter-spacing: .4px; transition: .15s; }
.theme-seg button.on { color: #fff; background: var(--grad); box-shadow: 0 6px 16px rgba(110,80,230,.32); }
/* Registro por invitacion */
.password-rules{display:grid;gap:5px;margin:-2px 0 14px;padding:10px 12px;border:1px solid var(--line);border-radius:10px;background:rgba(74,163,255,.055);font-size:11px;color:var(--text-dim);line-height:1.45}.password-rules[hidden],.turnstile-wrap[hidden],.invite-panel[hidden],.pin-form[hidden]{display:none}.password-rules strong{color:var(--cyan-soft);letter-spacing:.8px}.turnstile-wrap{display:grid;justify-items:center;gap:7px;margin:4px 0 12px;min-height:70px}.turnstile-wrap small{color:var(--text-dim);font-size:10px}.auth-link{display:block;width:100%;margin:12px 0 0;padding:7px;border:0;background:transparent;color:var(--cyan-soft);font-size:12px;text-decoration:underline;text-underline-offset:3px}.auth-link:hover{color:var(--text-bright)}.invite-panel{text-align:center}.invite-status-icon{width:64px;height:64px;margin:0 auto 12px;display:grid;place-items:center;border:1px solid var(--line-strong);border-radius:20px;background:radial-gradient(circle,rgba(74,163,255,.15),rgba(46,125,255,.03));color:var(--cyan);font:700 32px/1 var(--font-display);box-shadow:0 0 30px rgba(74,163,255,.14)}.invite-status-tag{margin:0 0 8px;color:var(--cyan);font-size:10px;letter-spacing:2px}.invite-panel h2,.pin-form h2{margin:0 0 10px;color:var(--text-bright);font:700 20px/1.25 var(--font-display);letter-spacing:.5px}.invite-panel>p:not(.invite-status-tag),.pin-intro{margin:0;color:var(--text-dim);font-size:12px;line-height:1.65}.masked-email{margin:15px 0 8px;padding:11px;border:1px solid var(--line);border-radius:10px;background:rgba(0,0,0,.25);color:var(--text-bright);font-size:13px;overflow-wrap:anywhere}.invite-expiry{min-height:17px;color:var(--cyan-soft)!important;font-size:11px!important}.invite-panel-actions{margin-top:15px}.pin-form{text-align:center}.pin-form .field{text-align:left}.pin-intro{margin-bottom:17px}.pin-code{text-align:center;font:700 27px/1 var(--font-display)!important;letter-spacing:9px}.auth-card:has(.invite-panel:not([hidden])),.auth-card:has(.pin-form:not([hidden])){max-width:430px}@media(max-width:440px){.auth-card{padding:25px 18px 20px}.pin-code{font-size:23px!important;letter-spacing:7px}}

.auth-link[hidden]{display:none}
.reset-notice{margin:2px 0 14px;padding:11px 13px;border:1px solid rgba(74,163,255,.3);border-radius:11px;background:rgba(74,163,255,.08);color:var(--text-dim);font-size:12px;line-height:1.55;text-align:left}
.reset-notice[hidden]{display:none}
.password-field{position:relative;display:block}
.password-field input{padding-right:64px!important}
.password-toggle{position:absolute;top:50%;right:8px;transform:translateY(-50%);border:1px solid var(--line);background:rgba(0,0,0,.3);color:var(--cyan-soft);font-size:11px;letter-spacing:.5px;padding:6px 10px;border-radius:8px;cursor:pointer;transition:.15s}
.password-toggle:hover{color:var(--text-bright);border-color:var(--cyan)}

/* Visualizador de codigo HTML (vista previa renderizada) */
.code-preview{margin:10px 0 4px}
.code-preview-launch{display:flex;gap:8px;flex-wrap:wrap;align-items:stretch}
.code-preview-btn{display:inline-flex;align-items:center;gap:11px;font-size:13px;font-weight:600;color:#eaf4ff;background:linear-gradient(135deg,rgba(77,163,255,.18),rgba(122,92,255,.16));border:1px solid rgba(122,140,255,.4);border-radius:14px;padding:9px 16px 9px 11px;cursor:pointer;transition:.18s;box-shadow:0 6px 18px -10px rgba(77,120,255,.6)}
.code-preview-btn:hover{transform:translateY(-1px);border-color:rgba(140,160,255,.7);box-shadow:0 11px 26px -12px rgba(77,120,255,.85)}
.code-preview-btn .cpl-ic{display:grid;place-items:center;width:34px;height:34px;border-radius:10px;background:var(--grad);color:#fff;font-size:16px;box-shadow:inset 0 0 0 1px rgba(255,255,255,.22)}
.code-preview-btn .cpl-tx{display:flex;flex-direction:column;line-height:1.18;text-align:left}
.code-preview-btn .cpl-label{font-weight:700;color:#f3f7ff}
.code-preview-btn .cpl-sub{font-size:10.5px;font-weight:500;color:rgba(200,210,255,.6)}
.code-preview-btn .cpl-go{margin-left:2px;font-size:14px;color:rgba(200,210,255,.7);transition:transform .18s}
.code-preview-btn:hover .cpl-go{transform:translate(2px,-2px)}
.code-preview-codebtn{display:inline-flex;align-items:center;gap:6px;font-size:12px;font-weight:600;color:#d6cfff;background:rgba(120,90,255,.12);border:1px solid rgba(122,100,255,.38);border-radius:14px;padding:8px 14px;cursor:pointer;transition:.15s}
.code-preview-codebtn:hover{background:rgba(120,90,255,.22);border-color:rgba(140,120,255,.62)}
.code-preview-codebtn .cpc-ic{font-family:var(--font-mono);font-weight:700;color:#b9a8ff}
.code-preview-code{margin-top:8px;border:1px solid #3a3a3a;border-radius:12px;overflow:hidden;background:#1e1e1e}
.code-preview-code .code-preview-bar{background:#252526;border-bottom-color:#3a3a3a}
.code-preview-code[hidden]{display:none}
.code-preview-pre{margin:0;max-height:420px;overflow:auto;padding:14px 16px;background:#1e1e1e}
.code-preview-pre code{font-family:var(--font-mono);font-size:12px;line-height:1.6;color:#d4d4d4;white-space:pre}
/* Resaltado de sintaxis estilo VS Code Dark+ (el visor de codigo es oscuro en
   ambos temas, como un editor de verdad). */
.hl-text{color:#d4d4d4}
.hl-tag{color:#569cd6}
.hl-attr{color:#9cdcfe}
.hl-str{color:#ce9178}
.hl-comment{color:#6a9955}
.hl-punct{color:#808080}
.hl-doctype{color:#569cd6}
.hl-kw{color:#569cd6}
.hl-num{color:#b5cea8}
.hl-fn{color:#dcdcaa}
.hl-prop{color:#9cdcfe}
.hl-sel{color:#d7ba7d}
.code-preview-frame{margin-top:8px;border:1px solid rgba(120,180,255,.28);border-radius:12px;overflow:hidden;background:#fff}
.code-preview-frame[hidden]{display:none}
.code-preview-frame.is-fullscreen-preview{position:fixed;inset:0;z-index:10000;margin:0;border:0;border-radius:0;display:grid;grid-template-rows:auto minmax(0,1fr);width:100vw;height:100dvh;max-width:none;background:#fff;overscroll-behavior:none}
.code-preview-iframe{width:100%;height:380px;border:0;display:block;background:#fff}
.code-preview-frame.is-fullscreen-preview .code-preview-iframe{height:100%;min-height:0}
.code-preview-bar{position:relative;z-index:2;display:flex;align-items:center;justify-content:flex-end;gap:6px;flex-wrap:nowrap;padding:max(8px,env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) 8px max(8px,env(safe-area-inset-left));background:rgba(10,20,35,.98);border-bottom:1px solid rgba(120,180,255,.18)}
.code-preview-title{margin-right:auto;padding-left:4px;font-size:12px;font-weight:700;color:#eaf4ff}
.code-preview-fs{font-size:11px;font-weight:600;color:#cfe6ff;background:rgba(77,163,255,.14);border:1px solid rgba(77,163,255,.4);border-radius:8px;padding:7px 10px;cursor:pointer;transition:.15s}
.code-preview-fs:hover{background:rgba(77,163,255,.26);border-color:rgba(77,163,255,.6)}
.code-preview-close{color:#fff;border-color:rgba(255,110,110,.5);background:rgba(255,80,80,.18)}
@media(max-width:520px){.code-preview-title{display:none}.code-preview-bar{justify-content:stretch;gap:5px;padding-top:max(10px,env(safe-area-inset-top));padding-bottom:max(8px,env(safe-area-inset-bottom))}.code-preview-fs{display:inline-flex;align-items:center;justify-content:center;flex:1 1 0;min-width:0;min-height:42px;padding:8px 4px;white-space:nowrap}}
.mode-chip-create.on{background:rgba(255,211,61,.18);border-color:rgba(255,211,61,.62);color:#fff4bd;box-shadow:0 0 16px rgba(255,190,50,.25);font-weight:700}

/* Chip "Programar" (premium) */
.mode-chip-program { letter-spacing: .3px; }
.mode-chip-program.on { color: #00231b; border-color: transparent; background: linear-gradient(120deg, #34e6b0, #18b9ff); box-shadow: 0 0 18px rgba(52,230,176,.35); font-weight: 700; }

/* Ventana dedicada del asistente Programar */
.program-modal { position: absolute; inset: 0; z-index: 13; display: grid; place-items: center; padding: 20px; background: rgba(0,4,8,.66); backdrop-filter: blur(4px); animation: fade .2s ease; }
.program-modal[hidden] { display: none; }
.program-card { width: min(520px, 100%); max-height: 86%; display: flex; flex-direction: column; background: var(--panel-solid); border: 1px solid var(--line-strong); border-radius: 18px; padding: 18px; box-shadow: 0 24px 70px rgba(0,0,0,.55), 0 0 40px rgba(52,230,176,.12); animation: rise .25s ease; }
.program-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.program-head strong { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-display); letter-spacing: 1px; font-size: 15px; color: var(--text-bright); }
.program-body { overflow-y: auto; }

.pg-busy { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #bfeede; padding: 18px 4px; }
.pg-q { font-size: 15px; color: var(--text-bright); font-weight: 600; line-height: 1.45; margin-bottom: 12px; }
.pg-opts { display: flex; flex-direction: column; gap: 9px; margin-bottom: 12px; }
.pg-opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; padding: 12px 14px; border-radius: 13px; border: 1px solid var(--line); background: rgba(52,230,176,.05); color: var(--text-bright); font-size: 13.5px; transition: .14s; }
.pg-opt:hover { border-color: rgba(52,230,176,.5); background: rgba(52,230,176,.1); }
.pg-opt.sel { border-color: transparent; background: linear-gradient(120deg, rgba(52,230,176,.92), rgba(24,185,255,.92)); color: #00231b; font-weight: 700; }
.pg-opt-label { flex: 1; min-width: 0; }
.pg-opt-copy { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 3px; }
.pg-opt-desc { color: var(--text-dim); font-size: 11.5px; font-weight: 400; line-height: 1.35; }
.pg-opt.sel .pg-opt-desc { color: rgba(0,35,27,.72); }
.pg-rec { flex: none; font-size: 10px; font-weight: 700; letter-spacing: .3px; padding: 2px 8px; border-radius: 999px; background: rgba(52,230,176,.22); color: #34e6b0; }
.pg-opt.sel .pg-rec { background: rgba(0,35,27,.25); color: #00231b; }
/* Preview de imagenes (grid 3/fila) antes de construir */
.pg-imggrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 12px 0 16px; max-height: 56vh; overflow: auto; }
.pg-imgcell { display: flex; flex-direction: column; gap: 7px; border: 1px solid var(--line); border-radius: 12px; padding: 8px; background: rgba(255,255,255,.02); }
.pg-imgwrap { position: relative; aspect-ratio: 1/1; border-radius: 9px; overflow: hidden; background: rgba(255,255,255,.04); }
.pg-imgwrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pg-imgname { font-size: 12px; font-weight: 600; color: var(--text-bright); text-align: center; line-height: 1.25; min-height: 30px; display: flex; align-items: center; justify-content: center; }
.pg-imgswap { font-size: 11px; font-weight: 600; color: #34e6b0; padding: 6px 8px; border-radius: 999px; border: 1px solid rgba(52,230,176,.3); background: rgba(52,230,176,.07); transition: .14s; }
.pg-imgswap:hover { background: rgba(52,230,176,.16); }
.pg-imgswap:disabled { opacity: .55; cursor: default; }
@media (max-width: 560px) { .pg-imggrid { grid-template-columns: repeat(2, 1fr); } }
.pg-custom { margin-bottom: 14px; }
.pg-custom input { width: 100%; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.03); color: var(--text-bright); font-size: 13.5px; }
.pg-custom input:focus { outline: none; border-color: rgba(52,230,176,.6); }
.pg-actions { display: flex; justify-content: flex-end; gap: 10px; }
.pg-next { padding: 10px 18px; border-radius: 12px; border: none; font-weight: 700; font-size: 13.5px; color: #00231b; background: linear-gradient(120deg, #34e6b0, #18b9ff); box-shadow: 0 0 16px rgba(52,230,176,.3); transition: .14s; }
.pg-next:disabled { opacity: .4; box-shadow: none; }
.pg-next:not(:disabled):active { transform: scale(.97); }
.pg-ghost { padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: transparent; color: var(--text-dim); font-size: 13px; }
.pg-plan-title { font-size: 15px; font-weight: 700; color: var(--text-bright); margin-bottom: 8px; }
.pg-plan-body { font-size: 13px; color: var(--text); line-height: 1.55; max-height: 46vh; overflow-y: auto; padding: 12px 14px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.02); margin-bottom: 14px; }
.pg-plan-body h1, .pg-plan-body h2, .pg-plan-body h3 { font-size: 14px; color: var(--text-bright); margin: 10px 0 6px; }

/* Chips cuando el chat ya esta dedicado a un modo */
.mode-chip:disabled, .model-picker-btn:disabled, .model-picker-btn.locked { opacity: .38; cursor: not-allowed; pointer-events: none; }
.mode-chip.mode-locked-on { pointer-events: none; } /* el chip del modo activo: se ve "on" pero no se puede togglear */

/* ════════════════════════════════════════════════
   Ajuste de tracking para titulos serif. La antigua display (Orbitron)
   usaba tracking muy ancho que no le sienta a una serif tipo Tiempos.
   Va al final para ganar la cascada sobre los letter-spacing previos.
   ════════════════════════════════════════════════ */
.brand-title { letter-spacing: .5px; }
.welcome h2,
.tt-text strong,
.drawer-head strong,
.settings-head strong,
.invite-panel h2,
.pin-form h2,
.os-promo-title,
.pro-title { letter-spacing: .2px; }
