/* =========================================================================
   AgentiCuántico · chat clásico (cabecera con avatar redondo, bandera premium,
   modos Rápido / Pensar / Agente dentro del compositor, tarjeta del plan y
   «Computadora del agente»). Siempre claro.
   ========================================================================= */
.chat.ace {
  --a-lime: #9fff00; --a-lime-soft: rgba(159, 255, 0, .2); --a-ink: #18181b; --a-muted: #52525b; --a-faint: #71717a;
  --a-soft: #F4F5FA; --a-bubble: #E9EBF3; --a-border: rgba(24, 24, 27, .09); --a-border-strong: rgba(24, 24, 27, .16); --a-blue: #2563eb;
  --ink: #18181b; --surface: #fff; --wave: #18181b;
  color-scheme: only light; background: rgba(255, 255, 255, .97); color: var(--a-ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.chat.ace[data-variant="embed"] { width: 100%; max-width: 1140px; margin: 0 auto; height: min(760px, 84vh); height: min(760px, 84svh); min-height: 520px;
  border: 1px solid var(--a-border); border-radius: 28px; box-shadow: 0 30px 100px rgba(18, 22, 33, .10); overflow: hidden; }
.chat.ace svg { width: 20px; height: 20px; }
.chat.ace button { font: inherit; }

/* Cabecera */
.ace-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 12px 16px; border-bottom: 1px solid var(--a-border); background: rgba(255, 255, 255, .92); flex: 0 0 auto; min-width: 0; }
.ace-id { display: flex; align-items: center; gap: 11px; flex: 1 1 auto; min-width: 0; }
.ace-ava { --lvl: 0; position: relative; width: 42px; height: 42px; flex: 0 0 42px; border-radius: 50%; }
.ace-ava img { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; display: block; border: 2px solid rgba(159, 255, 0, .75);
  box-shadow: 0 0 calc(8px + var(--lvl) * 22px) rgba(159, 255, 0, calc(.35 + var(--lvl) * .5)); transform: scale(calc(1 + var(--lvl) * .07)); transition: border-color .25s, transform .1s; }
.ace-ava.thinking img { border-color: #a855f7; box-shadow: 0 0 16px rgba(168, 85, 247, .65); animation: aceBreath 1.6s ease-in-out infinite; }
.ace-ava.speaking img { border-color: #22c55e; }
.ace-ava.listening img { border-color: #ef4444; box-shadow: 0 0 14px rgba(239, 68, 68, .55); }
.ace-dot { position: absolute; right: 0; bottom: 0; width: 11px; height: 11px; border-radius: 50%; background: #22c55e; border: 2px solid #fff; }
.ace-mouth { position: absolute; left: 50%; bottom: -3px; transform: translateX(-50%); display: none; gap: 2px; align-items: flex-end; height: 12px; padding: 1px 4px; background: rgba(15, 23, 42, .82); border-radius: 6px; }
.ace-mouth i { display: block; width: 2px; border-radius: 2px; background: var(--a-lime); height: calc(3px + var(--lvl) * 8px); }
.ace-mouth i:nth-child(2), .ace-mouth i:nth-child(4) { height: calc(2px + var(--lvl) * 6px); }
.ace-mouth i:nth-child(3) { height: calc(4px + var(--lvl) * 7px); }
.ace-ava.speaking .ace-mouth { display: flex; }
.ace-ava.speaking .ace-dot { display: none; }
@keyframes aceBreath { 50% { transform: scale(1.06); } }
.ace-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.ace-txt strong { font-family: Outfit, Inter, sans-serif; font-weight: 700; font-size: 16.5px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--a-ink); }
.ace-txt small { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #475569; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.ace-led { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; flex: 0 0 7px; }
.ace-led.thinking, .ace-led.agentRun { background: #a855f7; animation: aceBlink 1s infinite; }
.ace-led.speaking { background: #22c55e; animation: aceBlink .6s infinite; }
.ace-led.listening { background: #ef4444; animation: aceBlink .8s infinite; }
.ace-demo { color: #4d7c0f; font-weight: 600; }
@keyframes aceBlink { 50% { opacity: .35; } }
.ace-actions { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; margin-left: auto; }
.chat.ace .chat-participants { flex: 0 1 auto; }

/* Selector de idioma premium: botón blanco tipo píldora con bandera en imagen */
.ace-flag { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 9px 0 9px; border-radius: 999px; border: 1px solid var(--a-border-strong); background: #fff; color: var(--a-ink);
  font-weight: 700; font-size: 12px; cursor: pointer; box-shadow: 0 1px 2px rgba(24, 24, 27, .06), 0 4px 12px rgba(24, 24, 27, .05); transition: box-shadow .15s, border-color .15s; }
.ace-flag:hover { border-color: rgba(24, 24, 27, .3); box-shadow: 0 2px 10px rgba(24, 24, 27, .1); }
.ace-flag-img { width: 27px; height: 18px; border-radius: 4px; display: block; flex: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, .06), 0 1px 3px rgba(0, 0, 0, .18); object-fit: cover; }
.ace-flag svg { width: 15px !important; height: 15px !important; color: var(--a-muted); }
.chat.ace .lang-menu .flag, .lang-menu .flag { width: 30px; height: 20px; border-radius: 4px; }
.ace-ib { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 12px; color: #3f3f46; text-decoration: none; flex: 0 0 auto; border: 0; background: none; cursor: pointer; }
.ace-ib:hover { background: var(--a-soft); color: var(--a-ink); }
.ace-ib.round { border-radius: 50%; }
.ace-ib.sm { width: 32px; height: 32px; border-radius: 9px; }
.ace-ib.sm svg { width: 17px; height: 17px; }
.ace-ib[aria-pressed="true"] { background: #1b1a22; color: #fff; }
.ace-call svg { color: #16a34a; }
.chat.ace :focus-visible { outline: 2px solid var(--a-blue); outline-offset: 2px; }

/* Conversación */
.chat.ace .chat-body { background: linear-gradient(#fff, #fafafa); }
.chat.ace .chat-thread { padding: 20px 22px 8px; }
.chat.ace .thread-inner { gap: 16px; max-width: 860px; }
.ace-empty { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; text-align: center; padding: 22px 16px 18px; }
.ace-empty[hidden] { display: none; }
.ace-empty > :first-child { margin-top: auto; } .ace-empty > :last-child { margin-bottom: auto; } /* centrado sin recortar arriba cuando no entra (antes la cara quedaba cortada) */
.ace-hello-face { display: block; width: 84px; height: 84px; border-radius: 50%; padding: 3px; background: var(--a-lime); box-shadow: 0 0 26px rgba(159, 255, 0, .5); flex: none; }
.ace-hello-face img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 2px solid #fff; display: block; }
.ace-greeting { font: 700 clamp(1.3rem, 1.1rem + 1vw, 1.75rem)/1.2 Outfit, Inter, sans-serif; margin: 14px 0 6px; letter-spacing: -.015em; color: var(--a-ink); }
.ace-hello-sub { margin: 0 0 16px; color: var(--a-muted); font-size: 14.5px; line-height: 1.55; max-width: 460px; }
.ace-sugg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: 100%; max-width: 640px; }
.ace-sug { display: flex; align-items: center; gap: 10px; text-align: left; padding: 11px 14px; border: 1px solid var(--a-border); border-radius: 14px; background: #fff; font-size: 14px; line-height: 1.35; color: var(--a-ink); cursor: pointer; transition: border-color .15s, transform .15s; }
.ace-sug:hover { border-color: #9fff00; background: #f7ffe9; transform: translateY(-1px); }
.ace-sug span { display: inline-grid; color: #65a30d; flex: none; }
.ace-sug svg { width: 18px !important; height: 18px !important; }
.chat.ace .msg { flex-direction: row; gap: 10px; align-items: flex-start; }
.chat.ace .msg.user { justify-content: flex-end; flex-wrap: wrap; }
.chat.ace .msg.user .msg-files { flex-basis: 100%; }
.chat.ace .ace-bubble { max-width: min(560px, 86%); background: var(--a-bubble); color: var(--a-ink); padding: 10px 15px; border-radius: 20px 20px 6px 20px; font-size: 15px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.ace-mava { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex: 0 0 30px; margin-top: 2px; border: 1.5px solid rgba(159, 255, 0, .8); }
.ace-mava-badge { width: 30px; height: 30px; flex: 0 0 30px; }
.chat.ace .msg-body { padding-left: 0; flex: 1 1 auto; min-width: 0; }
.chat.ace .md { font-size: 15px; line-height: 1.65; color: var(--a-ink); }
.chat.ace .md h1, .chat.ace .md h2, .chat.ace .md h3, .chat.ace .md h4 { font-family: Outfit, Inter, sans-serif; line-height: 1.3; }
.chat.ace .md h2 { font-size: 19px; } .chat.ace .md h3 { font-size: 17px; } .chat.ace .md h4 { font-size: 15.5px; }
.ace-acts { display: flex; align-items: center; gap: 2px; margin-top: 4px; padding-left: 0 !important; }

/* Tarjeta del plan del agente */
.ace-task { border: 1px solid var(--a-border); border-radius: 16px; background: #fff; margin: 0 0 12px; overflow: hidden; }
.ace-task-h { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; background: none; border: 0; text-align: left; cursor: pointer; color: var(--a-ink); }
.ace-task-h:hover { background: #fafafa; }
.ace-task-t { flex: 1; min-width: 0; }
.ace-task-t strong { display: block; font-size: 15px; font-weight: 700; }
.ace-task-t small { display: block; font-size: 13px; color: var(--a-faint); }
.ace-task-open { color: var(--a-muted); display: inline-grid; }
.ace-task-open svg { width: 18px !important; height: 18px !important; }
.ace-task-h > .ace-st { width: 24px; height: 24px; flex-basis: 24px; }
.ace-prog { height: 4px; background: rgba(24, 24, 27, .06); }
.ace-prog i { display: block; height: 100%; background: var(--a-lime); transition: width .4s; }
.ace-task ul { list-style: none; margin: 0; padding: 10px 14px 12px; display: grid; gap: 8px; }
.ace-task li { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--a-muted); min-width: 0; }
.ace-step-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ace-task li.running, .ace-task li.done { color: var(--a-ink); }
.ace-task em { font-style: normal; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(24, 24, 27, .06); white-space: nowrap; }
.ace-task em.p-thinking, .phase-tag.p-thinking { background: rgba(168, 85, 247, .14); color: #7e22ce; }
.ace-task em.p-searching, .phase-tag.p-searching { background: rgba(37, 99, 235, .12); color: #1d4ed8; }
.ace-task em.p-coding, .phase-tag.p-coding { background: var(--a-lime-soft, rgba(159,255,0,.2)); color: #3f6212; }
.ace-task em.p-verifying, .phase-tag.p-verifying { background: rgba(217, 119, 6, .14); color: #9a3412; }
.ace-st { width: 20px; height: 20px; flex: 0 0 20px; border-radius: 50%; display: grid; place-items: center; border: 1.6px solid rgba(24, 24, 27, .2); color: #18181b; }
.ace-st svg { width: 12px !important; height: 12px !important; stroke-width: 3; }
.ace-st.done { background: #9fff00; border-color: #9fff00; color: #18181b; }
.ace-st.error { background: #d97706; border-color: #d97706; color: #fff; }
.ace-st.running { border-color: #18181b; border-right-color: transparent; animation: aceSpin .8s linear infinite; }
@keyframes aceSpin { to { transform: rotate(360deg); } }
.ace-files { display: grid; gap: 8px; margin: 0 0 12px; }
.ace-file { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; border: 1px solid var(--a-border); border-radius: 14px; background: #fff; min-width: 0; }
.ace-file strong { flex: 1; min-width: 0; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--a-ink); }
.ace-file small { color: var(--a-faint); font-size: 13px; margin-right: 4px; }

/* Compositor: una sola caja; modos dentro de la fila inferior */
.chat.ace .composer { padding: 8px 14px 14px; background: #fff; }
.chat.ace .composer-box { border: 1.5px solid #d4d4d8; border-radius: 24px; background: #fff; padding: 8px 8px 6px 14px; box-shadow: 0 2px 10px rgba(0, 0, 0, .03); max-width: 860px; }
.chat.ace .composer-box:focus-within { border-color: var(--a-blue); box-shadow: 0 0 0 4px rgba(37, 99, 235, .1); }
.chat.ace .composer textarea { padding: 6px 4px 6px 0; min-height: 34px; font-size: 15.5px; line-height: 1.5; color: var(--a-ink); }
.chat.ace .composer textarea::placeholder { color: #71717a; }
.ace-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 0; }
.ace-left { display: flex; align-items: center; gap: 4px; min-width: 0; flex: 1 1 auto; position: relative; }
.ace-modes { display: inline-flex; align-items: center; gap: 2px; padding: 3px; background: var(--a-soft); border-radius: 999px; min-width: 0; overflow: hidden; }
.chat.ace .ace-modes .mode-chip { display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 11px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--a-muted); white-space: nowrap; border: 0; background: transparent; box-shadow: none; }
.chat.ace .ace-modes .mode-chip svg { display: inline-block; width: 15px; height: 15px; color: currentColor; }
.chat.ace .ace-modes .mode-chip[aria-checked="true"] { background: #fff; color: var(--a-ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .1); }
.chat.ace .ace-modes .mode-chip[data-mode="auto"][aria-checked="true"] { background: var(--a-ink); color: #fff; }
.ace-right { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.ace-send { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--a-ink); color: #fff; flex: 0 0 40px; border: 0; cursor: pointer; }
.ace-send.voice { background: var(--a-lime); color: var(--a-ink); }
.ace-send svg { width: 19px !important; height: 19px !important; }
.ace-send[hidden], .chat.ace [hidden] { display: none !important; }
.chat.ace.hands-free [data-act="handsfree"] { background: #22c55e; color: #fff; box-shadow: 0 0 0 4px rgba(34, 197, 94, .2); }
.ace-plus { border: 1px solid var(--a-border-strong) !important; width: 36px !important; height: 36px !important; }

/* Computadora del agente (pantalla completa en teléfonos, panel lateral en escritorio) */
body.ace-lock { overflow: hidden; }
.ace-panel-wrap { position: fixed; inset: 0; z-index: 2000; background: rgba(15, 23, 42, .35); display: flex; justify-content: flex-end; color-scheme: only light; animation: aceFade .15s ease; }
.ace-panel { width: min(100%, 560px); height: 100%; background: #fff; color: #18181b; display: flex; flex-direction: column; box-shadow: -20px 0 60px rgba(0, 0, 0, .18); animation: aceSlide .22s cubic-bezier(.16, 1, .3, 1); }
@keyframes aceFade { from { opacity: 0; } }
@keyframes aceSlide { from { transform: translateX(30px); opacity: .4; } }
.ace-panel-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 14px 14px 20px; border-bottom: 1px solid rgba(24, 24, 27, .09); padding-top: max(14px, env(safe-area-inset-top)); }
.ace-panel-title { display: flex; align-items: center; gap: 10px; }
.ace-panel-title span { display: inline-grid; }
.ace-panel-title svg { width: 22px; height: 22px; }
.ace-panel-title strong { font: 700 18px Outfit, Inter, sans-serif; }
.ace-panel .ace-ib svg { width: 22px; height: 22px; }
.ace-panel-b { flex: 1; overflow-y: auto; padding: 16px 20px 24px; padding-bottom: max(24px, env(safe-area-inset-bottom)); }
.ace-panel .ap-task strong { display: block; font-size: 17px; font-weight: 700; overflow-wrap: anywhere; margin-bottom: 10px; }
.ace-panel .ap-status { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; color: #52525b; margin: 6px 0 8px; }
.ace-panel .progress { height: 5px; border-radius: 5px; background: rgba(24, 24, 27, .07); overflow: hidden; }
.ace-panel .progress i { display: block; height: 100%; background: #9fff00; }
.ace-tabs { display: flex; gap: 4px; margin: 16px 0 14px; background: #f1f1f3; padding: 4px; border-radius: 14px; }
.ace-tab { flex: 1; height: 38px; border-radius: 10px; font-size: 14px; font-weight: 600; color: #52525b; border: 0; background: none; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; }
.ace-tab.on { background: #fff; color: #18181b; box-shadow: 0 2px 8px rgba(24, 24, 27, .08); }
.ace-panel .plan-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.ace-panel .plan-list li { display: grid; grid-template-columns: 20px 1fr; gap: 4px 12px; padding: 9px 4px; border-radius: 10px; align-items: center; }
.ace-panel .plan-list .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 15px; min-width: 0; }
.ace-panel .plan-list .log { grid-column: 2; font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; color: #52525b; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 120px; overflow: hidden; }
.ace-panel .phase-tag { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.ace-panel .computer { border-radius: 14px; overflow: hidden; background: #0f1115; color: #e6e6ea; border: 1px solid #23222b; }
.ace-panel .computer-bar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: #1b1e25; font-size: 12px; color: #a1a1aa; }
.ace-panel .computer-bar i { width: 9px; height: 9px; border-radius: 50%; background: #3f3f46; display: inline-block; }
.ace-panel .computer-bar span { margin-left: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ace-panel .terminal { padding: 12px 14px; font: 12.5px/1.6 ui-monospace, Menlo, Consolas, monospace; max-height: calc(100dvh - 300px); overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.ace-panel .terminal .ln { margin-bottom: 4px; } .ace-panel .terminal .ln.sub { color: #a1a1aa; margin-bottom: 8px; }
.ace-panel .terminal .pr { color: #9fff00; } .ace-panel .terminal .ph { color: #8fb8ff; }
.ace-panel .file-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 10px; }
.ace-panel .file-tab { height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid rgba(24, 24, 27, .12); background: #fff; font-size: 14px; font-weight: 700; cursor: pointer; }
.ace-panel .file-tab.on { background: #18181b; color: #fff; border-color: #18181b; }
.ace-panel .file-acts { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.ace-pill-btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid rgba(24, 24, 27, .16); background: #fff; color: #18181b; font-size: 14px; font-weight: 700; cursor: pointer; }
.ace-pill-btn:hover { border-color: #18181b; }
.ace-pill-btn span { display: inline-grid; } .ace-pill-btn svg { width: 18px; height: 18px; }
.ace-panel .preview-frame { width: 100%; height: 60vh; border: 1px solid rgba(24, 24, 27, .1); border-radius: 12px; background: #fff; }
.ace-panel .ap-empty { color: #71717a; font-size: 14px; }
.ace-panel .md h1 { font: 800 clamp(24px, 6vw, 30px)/1.15 Outfit, Inter, sans-serif; letter-spacing: -.02em; margin: 6px 0 14px; }
.ace-panel .md h2 { font: 700 21px/1.25 Outfit, Inter, sans-serif; margin: 22px 0 8px; }
@media (max-width: 640px) { .ace-panel { width: 100%; box-shadow: none; } .ace-panel-wrap { background: #fff; } }

/* Teléfonos */
@media (max-width: 640px) {
  .chat.ace[data-variant="embed"] { height: min(680px, 82svh); min-height: 500px; border-radius: 22px; }
  .ace-head { padding: 10px 8px 10px 12px; gap: 6px; }
  .ace-id { gap: 9px; }
  .ace-ava, .ace-ava img { width: 38px; height: 38px; flex-basis: 38px; }
  .ace-txt strong { font-size: 15.5px; }
  .ace-txt small { font-size: 11.5px; }
  .ace-actions { gap: 1px; }
  .ace-flag { height: 36px; padding: 0 6px 0 7px; gap: 4px; }
  .ace-flag-code { display: none; }
  .ace-ib { width: 34px; height: 34px; }
  .chat.ace .chat-participants { display: none; }
  .chat.ace .chat-thread { padding: 16px 12px 6px; }
  .ace-sugg { grid-template-columns: 1fr; }
  .ace-sug:nth-child(n+4) { display: none; }
  .chat.ace .composer { padding: 6px 8px 10px; }
  .chat.ace .composer-box { padding: 6px 6px 5px 10px; border-radius: 22px; }
  .chat.ace .ace-modes .mode-chip { padding: 0 8px; font-size: 12.5px; gap: 4px; }
  .ace-task em { display: none; }
  .ace-send { width: 38px; height: 38px; flex-basis: 38px; }
  .ace-right .ace-ib.round { width: 36px; height: 36px; }
}
@media (max-width: 400px) {
  .chat.ace .ace-modes .mode-chip svg { display: none; }
  .chat.ace .ace-modes .mode-chip { padding: 0 8px; }
  .ace-ava, .ace-ava img { width: 34px; height: 34px; flex-basis: 34px; }
  .ace-txt strong { font-size: 14.5px; }
  .chat.ace .ace-plus { width: 32px !important; height: 32px !important; }
  .ace-right { gap: 2px; }
  .ace-right .ace-ib.round { width: 32px; height: 32px; }
  .ace-send { width: 36px; height: 36px; flex-basis: 36px; }
}
@media (max-width: 370px) { .ace-head .ace-call { display: none; } }
@media (prefers-reduced-motion: reduce) { .chat.ace *, .ace-panel-wrap * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; } }

/* Portada: el chat ocupa todo el ancho de su sección */
.chat-section .chat-stage { width: 100%; }
@media (max-width: 420px) { .ace-tab { font-size: 13px; padding: 0 2px; } .ace-tabs { gap: 2px; } }

/* Selector de idioma del chat: mismo estilo que la píldora del encabezado */
.chat.ace .ace-flag, .ace-flag { height: 40px; gap: 8px; padding: 0 11px 0 7px; border-radius: 999px; background: #fff; border: 1px solid rgba(24, 24, 27, .09); box-shadow: 0 1px 2px rgba(24, 24, 27, .05), 0 6px 18px rgba(24, 24, 27, .08); color: #33363d; }
.chat.ace .ace-flag:hover, .ace-flag:hover { border-color: rgba(24, 24, 27, .16); box-shadow: 0 1px 2px rgba(24, 24, 27, .06), 0 8px 22px rgba(24, 24, 27, .12); }
.ace-flag .ace-flag-code { display: none; }
.ace-flag .ace-flag-img { width: 100%; height: 100%; border-radius: 0; box-shadow: none; }
.ace-flag svg.lp-chev { width: 16px !important; height: 16px !important; color: #33363d; }
.chat .lang-menu { background: #fff; }
@media (max-width: 520px) { .chat.ace .ace-flag, .ace-flag { height: 36px; gap: 6px; padding: 0 8px 0 6px; } .ace-flag .lp-flag { width: 27px; height: 18px; border-radius: 5px; } .ace-flag svg.lp-chev { width: 14px !important; height: 14px !important; } }

/* ---- Vista previa de diseños: ajustada al ancho + pantalla completa ---- */
.ace-panel .file-acts .ace-expand { margin-left: auto; background: #18181b; color: #fff; border-color: #18181b; }
.ace-panel .file-acts .ace-expand:hover { background: #000; }
.ace-panel .file-view.has-preview { position: relative; }
.ace-panel .file-view.has-preview .preview-frame { display: block; overflow: hidden; }
.preview-max { position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .25); background: rgba(24, 24, 27, .78); color: #fff; cursor: pointer; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); box-shadow: 0 4px 14px rgba(0, 0, 0, .25); }
.preview-max:hover { background: #18181b; }
.preview-max svg { width: 18px; height: 18px; }
.preview-max:focus-visible, .design-full-btn:focus-visible { outline: 2px solid #9fff00; outline-offset: 2px; }
.design-full { position: fixed; inset: 0; z-index: 2000; background: #0c0c0f; display: flex; flex-direction: column; width: 100vw; height: 100vh; height: 100dvh; }
.design-full-bar { display: flex; align-items: center; gap: 6px; padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left)); color: #f4f4f5; background: #18181b; flex: none; }
.design-full-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 14px/1.2 Inter, system-ui, sans-serif; }
.design-full-btn { width: 40px; height: 40px; display: grid; place-items: center; flex: none; border-radius: 12px; border: 0; background: #27272a; color: #fff; cursor: pointer; }
.design-full-btn:hover { background: #3f3f46; }
.design-full-btn[aria-pressed="true"] { background: #9fff00; color: #18181b; }
.design-full-btn svg { width: 18px; height: 18px; }
.design-full-frame { flex: 1 1 auto; width: 100%; min-height: 0; border: 0; background: #fff; padding-bottom: env(safe-area-inset-bottom); }
body.design-lock { overflow: hidden; }

/* ---------- Búsqueda web en vivo (tarjeta de progreso + fuentes) ---------- */
.chat.ace .ace-web.on { background: var(--a-ink); color: #fff; }
.chat.ace .ace-web.on:hover { background: #27272a; color: #fff; }
.ace-search .ace-task-h { cursor: default; }
.ace-search .ace-task-h:hover { background: none; }
.ace-search-ic { width: 24px; height: 24px; flex: 0 0 24px; border-radius: 50%; display: grid; place-items: center; background: rgba(37, 99, 235, .1); color: #1d4ed8; }
.ace-search-ic svg { width: 15px !important; height: 15px !important; }
.ace-search .ace-task-t small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ace-search.is-done { margin-bottom: 10px; }
.ace-search.is-done .ace-task-h { padding: 9px 14px; }
.ace-search.is-done .ace-task-t strong { font-size: 14px; font-weight: 600; }
.ace-search-note { margin: 0; padding: 0 14px 12px; font-size: 13px; color: #92400e; }
.ace-search-note a { color: inherit; font-weight: 600; }
.ace-sources { margin: 12px 0 2px; width: 100%; max-width: 100%; min-width: 0; overflow: hidden; }
.ace-sources > strong { display: block; font-size: 13px; font-weight: 700; color: var(--a-muted); margin: 0 0 6px; }
.ace-sources ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; min-width: 0; }
.ace-sources li { min-width: 0; }
.ace-sources a { box-sizing: border-box; width: 100%; overflow: hidden; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 12px 6px 6px; border: 1px solid var(--a-border); border-radius: 12px; background: #fff; color: var(--a-ink); text-decoration: none; min-width: 0; }
.ace-sources a:hover { background: #fafafa; }
.ace-sources a:focus-visible { outline: 2px solid #1d4ed8; outline-offset: 2px; }
.ace-src-n { flex: 0 0 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; background: var(--a-soft); font-size: 12px; font-weight: 700; color: #3f3f46; }
.ace-src-t { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ace-sources small { flex: 0 1 auto; max-width: 40%; font-size: 12px; color: var(--a-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 380px) { .chat.ace .ace-web { width: 34px; height: 34px; } }
/* Un solo chat: aviso pequeño solo cuando hay un modo fijo (Ajustes de respuesta); por defecto no se ve. */
.chat.ace .ace-fixed { display: inline-flex; align-items: center; gap: 6px; height: 32px; max-width: 190px; padding: 0 8px 0 12px; border-radius: 999px; border: 1px solid rgba(101, 163, 13, .45); background: #f7ffe9; color: var(--a-ink); font-size: 12.5px; font-weight: 650; white-space: nowrap; cursor: pointer; min-width: 0; }
.chat.ace .ace-fixed[hidden] { display: none; }
.chat.ace .ace-fixed span { overflow: hidden; text-overflow: ellipsis; }
.chat.ace .ace-fixed svg { width: 12px; height: 12px; flex: none; color: var(--a-muted); }
/* Tarjeta del agente v3: en vivo con ✕; plegada en resumen al terminar */
.ace-task { border-radius: 22px; }
.ace-task.is-running { box-shadow: 0 10px 30px rgba(18, 22, 33, .07); }
.ace-task-top { display: flex; align-items: center; }
.ace-task-top .ace-task-h { flex: 1 1 auto; min-width: 0; }
.ace-task.is-running .ace-task-t strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.ace-task-x { flex: none; width: 36px; height: 36px; margin-right: 10px; border-radius: 999px; border: 1px solid var(--a-border-strong); background: #fff; color: var(--a-ink); display: grid; place-items: center; cursor: pointer; }
.ace-task-x:hover { background: var(--a-ink); color: #fff; }
.ace-task-x svg { width: 14px; height: 14px; }
.ace-task.is-folded { background: linear-gradient(180deg, #fff, #f8f9fc); }
.ace-task.is-folded .ace-task-h > .ace-st.done { background: var(--a-lime); }
.ace-task-more { padding: 0 14px 10px; }
.ace-task-more > summary { cursor: pointer; font-size: 13px; font-weight: 650; color: var(--a-ink); padding: 8px 0 2px; }
.ace-task-more ul { padding: 8px 0 2px; }
.ace-mouth, .ace-ava.speaking .ace-mouth { display: none !important; }
.ace-ava picture, .ace-hello-face picture { display: contents; }

/* ===== Pantalla de trabajo (agente en vivo: pasos, acción actual, tiempo, Detener) ===== */
.ws-card { border: 1px solid var(--a-border); border-radius: 22px; background: #fff; margin: 0 0 12px; overflow: hidden; box-shadow: 0 10px 30px -22px rgba(18, 22, 33, .35); }
.ws-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 14px; min-width: 0; }
.ws-dot { flex: none; width: 22px; height: 22px; border-radius: 999px; display: grid; place-items: center; background: var(--a-soft); color: var(--a-ink); }
.ws-dot svg { width: 13px; height: 13px; }
.ws-card.is-running .ws-dot { background: var(--a-lime-soft); box-shadow: 0 0 0 0 rgba(159, 255, 0, .55); animation: wsPulse 1.6s ease-out infinite; }
.ws-card.is-running .ws-dot::after { content: ""; width: 8px; height: 8px; border-radius: 999px; background: #6fbf00; }
.ws-card.is-done .ws-dot { background: var(--a-lime); }
.ws-card.is-stopped .ws-dot, .ws-card.is-error .ws-dot { background: #fde8e8; color: #b42318; }
@keyframes wsPulse { 70% { box-shadow: 0 0 0 9px rgba(159, 255, 0, 0); } 100% { box-shadow: 0 0 0 0 rgba(159, 255, 0, 0); } }
.ws-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ws-title small { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--a-faint); font-weight: 600; }
.ws-title strong { font-size: 14.5px; font-weight: 700; color: var(--a-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-time { flex: none; font: 600 12.5px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--a-muted); background: var(--a-soft); border-radius: 999px; padding: 6px 9px; font-variant-numeric: tabular-nums; }
.ws-ib { flex: none; width: 36px; height: 36px; border-radius: 999px; border: 1px solid var(--a-border-strong); background: #fff; color: var(--a-ink); display: grid; place-items: center; cursor: pointer; }
.ws-ib:hover { background: var(--a-soft); }
.ws-ib svg { width: 16px; height: 16px; transition: transform .2s; }
.ws-card.is-open .ws-fold svg { transform: rotate(180deg); }
.ws-stop { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 999px; border: 0; background: var(--a-ink); color: #fff; font-weight: 700; font-size: 13px; cursor: pointer; }
.ws-stop svg { width: 13px; height: 13px; }
.ws-stop:hover { background: #000; }
.ws-prog { height: 3px; background: var(--a-soft); }
.ws-prog i { display: block; height: 100%; background: linear-gradient(90deg, #6fbf00, var(--a-lime)); transition: width .4s ease; }
.ws-steps { list-style: none; margin: 0; padding: 8px 14px 4px; display: grid; gap: 2px; }
.ws-step { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 14px; color: var(--a-muted); border-bottom: 1px dashed var(--a-border); }
.ws-step:last-child { border-bottom: 0; }
.ws-sdot { flex: none; width: 18px; height: 18px; border-radius: 999px; border: 1.5px solid var(--a-border-strong); display: grid; place-items: center; }
.ws-sdot svg { width: 11px; height: 11px; }
.ws-st { flex: 1; min-width: 0; }
.ws-badge { flex: none; font-style: normal; font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--a-soft); color: var(--a-faint); }
.ws-step.is-running { color: var(--a-ink); font-weight: 600; }
.ws-step.is-running .ws-sdot { border-color: #6fbf00; border-top-color: transparent; animation: wsSpin .9s linear infinite; }
.ws-step.is-running .ws-badge { background: var(--a-lime-soft); color: #2f5200; }
.ws-step.is-done { color: var(--a-ink); }
.ws-step.is-done .ws-sdot { background: var(--a-lime); border-color: var(--a-lime); color: var(--a-ink); }
.ws-step.is-done .ws-badge { background: #eefbe0; color: #2f5200; }
.ws-step.is-error .ws-badge, .ws-step.is-stopped .ws-badge { background: #fde8e8; color: #b42318; }
@keyframes wsSpin { to { transform: rotate(360deg); } }
.ws-sum { margin: 6px 14px 14px; padding: 12px 14px; border-radius: 16px; background: var(--a-soft); font-size: 14px; color: var(--a-ink); }
.ws-sum strong { display: block; margin-bottom: 4px; }
.ws-sum ul { margin: 0; padding-left: 18px; display: grid; gap: 3px; }
.ws-sum p { margin: 8px 0 0; color: var(--a-muted); }
@media (max-width: 480px) {
  .ws-head { gap: 6px; padding: 9px 8px 9px 12px; }
  .ws-stop { padding: 0 10px; }
  .ws-title strong { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) { .ws-card.is-running .ws-dot, .ws-step.is-running .ws-sdot { animation: none; } }
/* Pantalla de trabajo en celular: el título usa todo el ancho y los controles pasan a una segunda fila. */
.ws-head { flex-wrap: wrap; }
.ws-title { flex: 1 1 160px; }
.ws-tools { display: flex; align-items: center; gap: 6px; margin-left: auto; }
@media (max-width: 520px) { .ws-title { flex-basis: calc(100% - 40px); } .ws-tools { width: 100%; justify-content: flex-end; } }

/* ---------- Botón fijo «Ordenador» en la barra del chat + su panel (7.19.0) ---------- */
.chat.ace .ace-pc { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px 0 11px; margin-left: 2px; border-radius: 999px; border: 1px solid var(--a-border-strong); background: #fff; color: var(--a-ink); font: 650 13.5px/1 var(--font, system-ui); cursor: pointer; white-space: nowrap; flex: none; transition: background .15s, border-color .15s; }
.chat.ace .ace-pc svg { width: 18px; height: 18px; flex: none; }
.chat.ace .ace-pc:hover { background: #f7ffe9; border-color: rgba(101, 163, 13, .55); }
.chat.ace .ace-pc:focus-visible { outline: 2px solid #1d4ed8; outline-offset: 2px; }
@media (max-width: 400px) { .chat.ace .ace-pc { height: 36px; padding: 0 11px 0 9px; font-size: 13px; gap: 5px; } .chat.ace .ace-pc svg { width: 16px; height: 16px; } }
@media (max-width: 340px) { .chat.ace .ace-pc-t { display: none; } .chat.ace .ace-pc { width: 36px; padding: 0; justify-content: center; } }
.pc-panel { display: grid; gap: 12px; }
.pc-lead { margin: 0; color: #3f3f46; font-size: 15px; line-height: 1.55; }
.pc-h { margin: 4px 0 0; font-size: 12.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: #52525b; }
.pc-tasks { display: grid; gap: 8px; }
.pc-task { box-sizing: border-box; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 10px 12px; border: 1px solid rgba(24, 24, 27, .12); border-radius: 16px; background: #fff; color: #18181b; font: 500 14.5px/1.4 var(--font, system-ui); text-align: left; cursor: pointer; transition: border-color .15s, background .15s; }
.pc-task:hover { border-color: rgba(101, 163, 13, .6); background: #fbfff3; }
.pc-task:focus-visible { outline: 2px solid #1d4ed8; outline-offset: 2px; }
.pc-task-ic { width: 32px; height: 32px; flex: 0 0 32px; display: grid; place-items: center; border-radius: 10px; background: rgba(159, 255, 0, .22); color: #18181b; }
.pc-task-ic svg { width: 17px; height: 17px; }
.pc-task-t { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.pc-task-go { flex: none; color: #71717a; }
.pc-task-go svg { width: 16px; height: 16px; }
.pc-rules { margin: 2px 0 0; padding-left: 18px; display: grid; gap: 4px; color: #52525b; font-size: 13.5px; line-height: 1.5; }
.pc-login { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 16px; background: #f7ffe9; border: 1px solid rgba(101, 163, 13, .35); }
.pc-login strong { display: block; font-size: 16px; margin-bottom: 2px; color: #18181b; }
.pc-login p { margin: 0; color: #3f3f46; }
.pc-login-ic { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 50%; background: #fff; border: 1px solid rgba(24, 24, 27, .1); }
.pc-login-ic svg { width: 18px; height: 18px; }
