  :root{
    /* Paleta C.O.R.E. */
    --core-orange: #d74c29;
    --core-black: #000000;
    --core-white: #ffffff;

    /* Neutros permitidos (derivados) */
    --bg: #ffffff;
    --panel: #ffffff;
    --text: #0b0b0b;          /* casi negro para lectura */
    --muted: #5f6368;         /* gris UI */
    --stroke: rgba(0,0,0,.10);
    --stroke-2: rgba(0,0,0,.16);

    --brand: var(--core-orange);
    --shadow: 0 10px 22px rgba(0,0,0,.12);

    --safe-top: env(safe-area-inset-top);
    --safe-bot: env(safe-area-inset-bottom);
    --maxw: 720px;
  }

  *{ box-sizing:border-box; }
  html,body{ height:100%; }

  body{
    margin:0;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  .app{
    height:100%;
    display:flex;
    flex-direction:column;
    max-width: var(--maxw);
    margin:0 auto;
    padding-bottom: calc(14px + var(--safe-bot));
    background: var(--bg);
  }

  /* =========================
     Header
  ========================= */
  .topbar{
    position: sticky;
    top: 0;
    z-index: 10;
    padding: calc(12px + var(--safe-top)) 14px 12px 14px;
    background: var(--core-white);
    border-bottom: 2px solid rgba(215,76,41,.18);
    backdrop-filter: blur(10px);
  }

  .topbar-row{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
  }

  .brand{
    display:flex;
    align-items:center;
    gap:10px;
    min-width: 0;
  }

  .avatar{
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: var(--core-white);
    border: 1px solid rgba(215,76,41,.28);
    display:flex;
    align-items:center;
    justify-content:center;
    box-shadow: 0 6px 14px rgba(0,0,0,.10);
    flex: 0 0 auto;
    overflow: hidden;
  }

  .avatar-img{
    width: 100%;
    height: 110%;
    object-fit: cover;
  }

  .title-wrap{ display:flex; flex-direction:column; min-width:0; }

  .title{
    font-weight: 780;
    font-size: 15px;
    line-height: 1.1;
    white-space: nowrap;
    overflow:hidden;
    text-overflow: ellipsis;
    color: var(--core-black);
  }

  .subtitle{
    font-size: 12px;
    color: var(--muted);
    display:flex;
    align-items:center;
    gap:8px;
  }

  .dot{
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #24c26a;
    box-shadow: 0 0 0 3px rgba(36,194,106,.14);
  }

  .actions{ display:flex; gap:8px; flex:0 0 auto; }

  .icon-btn{
    width: 40px;
    height: 40px;
    border-radius: 14px;
    border: 1px solid var(--stroke);
    background: var(--core-white);
    color: var(--core-black);
    display:flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
    transition: transform .08s ease, background .12s ease, border-color .12s ease, color .12s ease;
    user-select:none;
    -webkit-tap-highlight-color: transparent;
  }
  .icon-btn:hover{
    border-color: rgba(215,76,41,.35);
    color: var(--core-orange);
    background: rgba(215,76,41,.04);
  }
  .icon-btn:active{ transform: scale(.98); }

  /* =========================
     Chips
  ========================= */
  .chips{
    margin-top: 10px;
    display:flex;
    gap:8px;
    overflow:auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .chips::-webkit-scrollbar{ display:none; }

  .chip{
    flex:0 0 auto;
    border: 1px solid var(--stroke);
    background: var(--core-white);
    color: var(--core-black);
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 12px;
    cursor:pointer;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    transition: background .12s ease, border-color .12s ease, color .12s ease;
  }
  .chip:hover{
    border-color: rgba(215,76,41,.35);
    background: rgba(215,76,41,.06);
    color: var(--core-black);
  }

  /* =========================
     Chat
  ========================= */
  .chat{
    flex:1 1 auto;
    padding: 14px 12px;
    overflow:auto;
    display:flex;
    flex-direction:column;
    gap: 10px;
    background: var(--bg);
  }

  .system{
    align-self:center;
    max-width: 92%;
    text-align:center;
    font-size: 12px;
    color: var(--muted);
    background: rgba(0,0,0,.03);
    border: 1px solid var(--stroke);
    padding: 10px 12px;
    border-radius: 14px;
  }

  .msg{
    display:flex;
    gap:8px;
    align-items:flex-end;
  }
  .msg.user{ justify-content:flex-end; }
  .msg.assistant{ justify-content:flex-start; }

  .bubble{
    max-width: 84%;
    padding: 10px 12px;
    border-radius: 16px;
    border: 1px solid var(--stroke);
    background: rgba(0,0,0,.03);
    line-height: 1.35;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: 0 8px 16px rgba(0,0,0,.08);
    color: var(--core-black);
  }

  /* Usuario: burbuja naranja CORE */
  .msg.user .bubble{
    background: var(--core-orange);
    border-color: rgba(215,76,41,.55);
    color: var(--core-white);
  }
  .msg.user .bubble .meta{
    color: rgba(255,255,255,.78);
  }

  .meta{
    margin-top: 6px;
    font-size: 11px;
    color: var(--muted);
    opacity: .95;
  }

  .typing{
    display:flex;
    gap:4px;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid var(--stroke);
    background: rgba(0,0,0,.03);
    width: fit-content;
    max-width: 70%;
  }
  .typing span{
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: rgba(0,0,0,.35);
    animation: blink 1.1s infinite ease-in-out;
  }
  .typing span:nth-child(2){ animation-delay: .15s; }
  .typing span:nth-child(3){ animation-delay: .30s; }
  @keyframes blink{
    0%, 80%, 100% { transform: translateY(0); opacity: .35; }
    40% { transform: translateY(-3px); opacity: 1; }
  }

  /* =========================
     Composer
  ========================= */
  .composer{
    position: sticky;
    bottom: 0;
    z-index: 10;
    padding: 10px 12px calc(10px + var(--safe-bot)) 12px;
    background: var(--core-white);
    border-top: 1px solid var(--stroke);
  }

  .composer-inner{
    display:flex;
    gap: 10px;
    align-items:flex-end;
    padding: 10px;
    border-radius: 18px;
    background: var(--core-white);
    border: 1px solid var(--stroke);
    box-shadow: 0 8px 18px rgba(0,0,0,.10);
  }

  textarea{
    width: 100%;
    resize: none;
    border: none;
    outline: none;
    color: var(--core-black);
    background: transparent;
    font-size: 14px;
    line-height: 1.35;
    min-height: 22px;
    max-height: 120px;
    padding: 0;
  }
  textarea::placeholder{ color: rgba(0,0,0,.45); }

  .send{
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 16px;
    border: 1px solid rgba(215,76,41,.55);
    background: var(--core-orange);
    color: var(--core-white);
    font-weight: 800;
    cursor:pointer;
    display:flex;
    align-items:center;
    justify-content:center;
    -webkit-tap-highlight-color: transparent;
    transition: transform .08s ease, filter .12s ease, background .12s ease;
  }
  .send:hover{ background: #b84224; }
  .send:active{ transform: scale(.98); }
  .send:disabled{ filter: grayscale(.55) brightness(.9); cursor:not-allowed; }

  /* =========================
     Modal
  ========================= */
  .modal-backdrop{
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    display:none;
    align-items:center;
    justify-content:center;
    padding: 18px;
    z-index: 999;
  }

  .modal{
    width: min(520px, 100%);
    background: var(--core-white);
    border: 1px solid var(--stroke);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 16px;
    color: var(--core-black);
  }
  .modal h3{ margin: 0 0 10px 0; font-size: 16px; }
  .modal p{ margin: 0 0 10px 0; color: #3a3a3a; font-size: 13px; line-height:1.45; }
  .modal .row{ display:flex; gap:10px; justify-content:flex-end; }

  .btn{
    border: 1px solid var(--stroke);
    background: var(--core-white);
    color: var(--core-black);
    padding: 10px 12px;
    border-radius: 14px;
    cursor:pointer;
    transition: background .12s ease, border-color .12s ease, color .12s ease;
  }
  .btn:hover{
    border-color: rgba(215,76,41,.35);
    background: rgba(215,76,41,.06);
  }

  .btn.primary{
    border-color: rgba(215,76,41,.55);
    background: var(--core-orange);
    color: var(--core-white);
    font-weight: 800;
  }
  .btn.primary:hover{ background: #b84224; }
  /* =========================
   CORE Tech Upgrade (A)
   Pégalo al FINAL del style.css
========================= */

/* Fondo tech (sin meter colores nuevos: solo negro + naranja muy sutil) */
body{
  background:
    radial-gradient(900px 520px at 15% -10%, rgba(215,76,41,.14), transparent 60%),
    radial-gradient(900px 520px at 85% 0%, rgba(0,0,0,.10), transparent 55%),
    linear-gradient(180deg, #ffffff 0%, #fbfbfb 100%);
}

/* “Marco” premium del chat */
.app{
  border-left: 1px solid rgba(0,0,0,.08);
  border-right: 1px solid rgba(0,0,0,.08);
}

/* Header tipo glass */
.topbar{
  background: rgba(255,255,255,.75);
  border-bottom: 1px solid rgba(215,76,41,.22);
  box-shadow: 0 14px 30px rgba(0,0,0,.10);
}

/* Avatar con glow naranja */
.avatar{
  border-color: rgba(215,76,41,.35);
  box-shadow:
    0 10px 24px rgba(0,0,0,.14),
    0 0 0 6px rgba(215,76,41,.10);
}

/* Chips más “tech”: borde fino + hover con glow */
.chip{
  border-color: rgba(0,0,0,.12);
  box-shadow: 0 10px 20px rgba(0,0,0,.06);
}
.chip:hover{
  box-shadow:
    0 14px 26px rgba(0,0,0,.10),
    0 0 0 6px rgba(215,76,41,.10);
}

/* Mensajes: burbujas con glass */
.bubble{
  border-color: rgba(0,0,0,.10);
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(10px);
  box-shadow: 0 16px 34px rgba(0,0,0,.10);
}

/* Burbuja del usuario con gradiente naranja (mismo color institucional, pero “vivo”) */
.msg.user .bubble{
  background: linear-gradient(135deg, #d74c29 0%, #b84224 100%);
  border-color: rgba(215,76,41,.65);
  box-shadow:
    0 18px 40px rgba(0,0,0,.16),
    0 0 0 6px rgba(215,76,41,.12);
}

/* Burbuja assistant con borde-acento más marcado */
.msg.assistant .bubble{
  border-left: 5px solid rgba(215,76,41,.60);
}

/* Animación sutil de entrada (moderna, no molesta) */
.msg .bubble{
  animation: popIn .14s ease-out;
  transform-origin: bottom;
}
@keyframes popIn{
  from { transform: translateY(6px) scale(.99); opacity: .0; }
  to   { transform: translateY(0)  scale(1);   opacity: 1; }
}

/* Composer más premium (dock) */
.composer{
  background: rgba(255,255,255,.75);
  border-top: 1px solid rgba(0,0,0,.10);
  backdrop-filter: blur(12px);
}
.composer-inner{
  border-color: rgba(0,0,0,.10);
  box-shadow: 0 18px 40px rgba(0,0,0,.12);
}

/* Input focus: aro naranja tipo “UI moderna” */
textarea:focus{
  outline: none;
}
.composer-inner:focus-within{
  border-color: rgba(215,76,41,.55);
  box-shadow:
    0 18px 40px rgba(0,0,0,.12),
    0 0 0 6px rgba(215,76,41,.12);
}

/* Botón enviar: más tech */
.send{
  box-shadow:
    0 18px 36px rgba(0,0,0,.16),
    0 0 0 6px rgba(215,76,41,.12);
}
.send:hover{
  filter: brightness(1.03);
}
