.nevera-ai-chat {
  --nevera-ai-accent: #72041d;
  --nevera-ai-accent-dark: #560316;
  --nevera-ai-bg: #ffffff;
  --nevera-ai-soft: #f8f4f5;
  --nevera-ai-border: #e9d9dd;
  --nevera-ai-text: #231f20;
  --nevera-ai-muted: #756d70;
  width: 100%;
  max-width: 760px;
  margin: 28px auto;
  background: var(--nevera-ai-bg);
  border: 1px solid var(--nevera-ai-border);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 18px 55px rgba(50, 11, 21, .09);
  font-family: inherit;
  color: var(--nevera-ai-text);
}
.nevera-ai-chat * { box-sizing: border-box; }
.nevera-ai-chat__header { display:flex; align-items:center; gap:12px; padding:18px 20px; background:var(--nevera-ai-accent); color:#fff; }
.nevera-ai-chat__avatar { width:42px; height:42px; flex:0 0 42px; border-radius:50%; display:grid; place-items:center; background:#fff; color:var(--nevera-ai-accent); font-weight:900; font-size:18px; }
.nevera-ai-chat__identity { min-width:0; }
.nevera-ai-chat__header h2 { margin:0; font-size:17px; line-height:1.2; color:#fff; }
.nevera-ai-chat__header p { margin:3px 0 0; opacity:.8; font-size:12px; }
.nevera-ai-chat__status { margin-left:auto; font-size:12px; display:flex; align-items:center; gap:6px; opacity:.95; white-space:nowrap; }
.nevera-ai-chat__status i { width:7px; height:7px; border-radius:50%; background:#7ee787; display:block; box-shadow:0 0 0 3px rgba(126,231,135,.15); }
.nevera-ai-chat__reset,.nevera-ai-chat__close { appearance:none; width:34px; height:34px; flex:0 0 34px; display:grid; place-items:center; padding:0; border:0; border-radius:50%; background:rgba(255,255,255,.12); color:#fff; cursor:pointer; transition:.18s ease; }
.nevera-ai-chat__close { width:38px; height:38px; flex-basis:38px; background:#fff; color:var(--nevera-ai-accent); box-shadow:0 2px 10px rgba(0,0,0,.14); }
.nevera-ai-chat__reset:hover { background:rgba(255,255,255,.22); transform:rotate(-8deg); }
.nevera-ai-chat__close:hover { background:#fff; transform:scale(1.06); }
.nevera-ai-chat__reset svg,.nevera-ai-chat__close svg { width:17px; height:17px; fill:currentColor; }

.nevera-ai-chat__messages { min-height:360px; max-height:600px; overflow:auto; padding:22px; background:linear-gradient(180deg,#fff 0%,#fdfbfc 100%); scroll-behavior:smooth; }
.nevera-ai-message { display:flex; margin:0 0 14px; }
.nevera-ai-message--user { justify-content:flex-end; }
.nevera-ai-message__bubble { max-width:min(82%, 620px); padding:12px 14px; border-radius:16px; overflow-wrap:anywhere; line-height:1.5; font-size:15px; }
.nevera-ai-message--assistant .nevera-ai-message__bubble { background:var(--nevera-ai-soft); border:1px solid var(--nevera-ai-border); border-bottom-left-radius:5px; }
.nevera-ai-message--user .nevera-ai-message__bubble { background:var(--nevera-ai-accent); color:#fff; border-bottom-right-radius:5px; font-weight:700; }
.nevera-ai-message--assistant .nevera-ai-message__bubble p { margin:0 0 10px; }
.nevera-ai-message--assistant .nevera-ai-message__bubble p:last-child { margin-bottom:0; }
.nevera-ai-message--assistant .nevera-ai-message__bubble a { color:var(--nevera-ai-accent); font-weight:800; text-decoration:underline; text-underline-offset:2px; }
.nevera-ai-message__list { margin:0; padding-left:20px; }

.nevera-ai-quick-actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:9px; margin:6px 0 20px; opacity:1; transition:opacity .18s ease, transform .18s ease; }
.nevera-ai-quick-actions.is-hidden { opacity:0; transform:translateY(-4px); }
.nevera-ai-quick-action { appearance:none; width:100%; min-height:58px; display:grid; grid-template-columns:34px 1fr 18px; align-items:center; gap:8px; border:1px solid #e2c7ce; background:#fff; color:var(--nevera-ai-text); border-radius:14px; padding:9px 10px; font:inherit; text-align:left; cursor:pointer; box-shadow:0 5px 16px rgba(65,10,23,.04); transition:.18s ease; }
.nevera-ai-quick-action:hover { border-color:var(--nevera-ai-accent); box-shadow:0 8px 20px rgba(65,10,23,.09); transform:translateY(-1px); }
.nevera-ai-quick-action:disabled { opacity:.5; cursor:wait; transform:none; }
.nevera-ai-quick-action__icon { width:34px; height:34px; border-radius:10px; display:grid; place-items:center; background:#f7eef0; font-size:17px; }
.nevera-ai-quick-action__label { font-size:13px; line-height:1.25; font-weight:850; }
.nevera-ai-quick-action__arrow { color:var(--nevera-ai-accent); font-size:24px; line-height:1; font-weight:400; }

.nevera-ai-tracking { margin-top:12px; padding:15px; border:1px solid var(--nevera-ai-border); border-radius:14px; background:#fff; display:flex; flex-direction:column; gap:9px; box-shadow:0 7px 18px rgba(50,11,21,.04); }
.nevera-ai-tracking__title { font-size:14px; font-weight:900; color:var(--nevera-ai-accent); margin-bottom:2px; }
.nevera-ai-tracking__row { display:grid; grid-template-columns:minmax(115px,auto) 1fr; gap:10px; align-items:baseline; font-size:13px; }
.nevera-ai-tracking__label { color:var(--nevera-ai-muted); }
.nevera-ai-tracking__row strong { overflow-wrap:anywhere; }
.nevera-ai-tracking__button { display:inline-flex; align-items:center; justify-content:center; min-height:42px; margin-top:5px; padding:10px 15px; border-radius:10px; background:var(--nevera-ai-accent); color:#fff!important; text-decoration:none!important; font-size:13px; font-weight:900; transition:.2s ease; }
.nevera-ai-tracking__button:hover { background:var(--nevera-ai-accent-dark); transform:translateY(-1px); }

.nevera-ai-chat__typing { padding:0 22px 10px; color:var(--nevera-ai-muted); font-size:12px; display:flex; align-items:center; gap:4px; }
.nevera-ai-chat__typing[hidden] { display:none; }
.nevera-ai-chat__typing span { width:5px; height:5px; background:var(--nevera-ai-accent); border-radius:50%; animation:nevera-ai-dot 1s infinite ease-in-out; }
.nevera-ai-chat__typing span:nth-child(2){ animation-delay:.12s; }.nevera-ai-chat__typing span:nth-child(3){ animation-delay:.24s; }
.nevera-ai-chat__typing em { margin-left:5px; font-style:normal; }
@keyframes nevera-ai-dot { 0%,60%,100%{transform:translateY(0);opacity:.35}30%{transform:translateY(-4px);opacity:1} }

.nevera-ai-products-wrap { margin:4px 0 20px; }
.nevera-ai-products-title { margin:0 0 9px; font-size:13px; font-weight:900; color:var(--nevera-ai-text); }
.nevera-ai-products { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.nevera-ai-product { display:flex; flex-direction:column; min-width:0; background:#fff; border:1px solid #dcbfc6; border-radius:11px; overflow:hidden; box-shadow:0 4px 12px rgba(50,11,21,.035); transition:.18s ease; }
.nevera-ai-product:hover { transform:translateY(-2px); box-shadow:0 9px 24px rgba(50,11,21,.09); }
.nevera-ai-product__media { aspect-ratio:1/1; width:100%; overflow:hidden; background:#f8f5f3; display:grid; place-items:center; text-decoration:none; }
.nevera-ai-product__media img { width:100%; height:100%; display:block; object-fit:cover; }
.nevera-ai-product__placeholder { padding:20px; color:var(--nevera-ai-muted); font-size:12px; text-align:center; }
.nevera-ai-product__body { padding:12px; display:flex; flex:1; flex-direction:column; gap:9px; min-width:0; }
.nevera-ai-product__name { color:#080808; font-size:13px; line-height:1.25; font-weight:900; text-transform:uppercase; overflow-wrap:anywhere; }
.nevera-ai-product__prices { display:flex; align-items:baseline; flex-wrap:wrap; gap:7px; margin-top:auto; }
.nevera-ai-product__prices del { color:#7a7375; font-size:12px; }
.nevera-ai-product__price { font-size:22px; line-height:1; font-weight:900; color:var(--nevera-ai-accent); }
.nevera-ai-product__button { display:flex; width:100%; min-height:42px; align-items:center; justify-content:center; margin-top:2px; padding:10px 12px; border-radius:9px; background:var(--nevera-ai-accent); color:#fff!important; text-decoration:none!important; text-align:center; font-size:13px; font-weight:900; transition:.18s ease; }
.nevera-ai-product__button:hover { background:var(--nevera-ai-accent-dark); transform:translateY(-1px); }

.nevera-ai-chat__form { display:flex; align-items:flex-end; gap:10px; padding:14px; border-top:1px solid var(--nevera-ai-border); background:#fff; }
.nevera-ai-chat__form textarea { flex:1; min-height:48px; max-height:120px; resize:none; border:1px solid var(--nevera-ai-border); border-radius:14px; padding:13px 14px; outline:none; font:inherit; line-height:1.4; background:#fff; color:var(--nevera-ai-text); box-shadow:none; }
.nevera-ai-chat__form textarea:focus { border-color:var(--nevera-ai-accent); box-shadow:0 0 0 3px rgba(114,4,29,.09); }
.nevera-ai-chat__form button { min-height:48px; border:0; border-radius:14px; background:var(--nevera-ai-accent); color:#fff; padding:0 18px; font-weight:800; display:flex; align-items:center; gap:8px; cursor:pointer; transition:.2s ease; }
.nevera-ai-chat__form button:hover { background:var(--nevera-ai-accent-dark); transform:translateY(-1px); }
.nevera-ai-chat__form button:disabled { opacity:.55; cursor:wait; transform:none; }
.nevera-ai-chat__form svg { width:17px; height:17px; fill:currentColor; }
.nevera-ai-chat__footer { padding:0 18px 14px; font-size:11px; text-align:center; color:var(--nevera-ai-muted); }
.screen-reader-text { position:absolute!important; width:1px!important; height:1px!important; padding:0!important; margin:-1px!important; overflow:hidden!important; clip:rect(0,0,0,0)!important; white-space:nowrap!important; border:0!important; }

/* Floating global assistant */
.nevera-ai-floating { --nevera-ai-accent:#72041d; position:fixed; right:22px; bottom:max(18px, env(safe-area-inset-bottom)); z-index:999999; font-family:inherit; }
.nevera-ai-floating__launcher { position:relative; display:flex; align-items:center; gap:10px; min-height:58px; border:0; border-radius:999px; padding:8px 17px 8px 8px; background:#72041d; color:#fff; box-shadow:0 14px 34px rgba(55,4,16,.32); cursor:pointer; font:inherit; font-weight:900; transition:transform .2s ease, box-shadow .2s ease, background .2s ease; }
.nevera-ai-floating__launcher:hover { transform:translateY(-3px) scale(1.02); background:#5b0317; box-shadow:0 18px 40px rgba(55,4,16,.38); }
.nevera-ai-floating__launcher-icon { position:relative; z-index:2; width:42px; height:42px; border-radius:50%; display:grid; place-items:center; background:#fff; color:#72041d; }
.nevera-ai-floating__launcher-icon svg { width:23px; height:23px; fill:currentColor; }
.nevera-ai-floating__launcher-text { position:relative; z-index:2; font-size:14px; white-space:nowrap; }
.nevera-ai-floating__pulse { position:absolute; left:8px; top:8px; width:42px; height:42px; border-radius:50%; background:#72041d; animation:nevera-ai-pulse 2.2s infinite; }
@keyframes nevera-ai-pulse { 0%{box-shadow:0 0 0 0 rgba(114,4,29,.45)}70%{box-shadow:0 0 0 18px rgba(114,4,29,0)}100%{box-shadow:0 0 0 0 rgba(114,4,29,0)} }
.nevera-ai-floating__panel { position:absolute; right:0; bottom:72px; width:min(420px,calc(100vw - 28px)); max-height:calc(100dvh - 108px); opacity:0; transform:translateY(12px) scale(.97); transform-origin:bottom right; transition:opacity .18s ease, transform .18s ease; pointer-events:none; }
.nevera-ai-floating__panel[hidden] { display:block!important; visibility:hidden; }
.nevera-ai-floating.is-open .nevera-ai-floating__panel { opacity:1; transform:translateY(0) scale(1); pointer-events:auto; visibility:visible; }
.nevera-ai-floating.is-open .nevera-ai-floating__launcher { box-shadow:0 10px 26px rgba(55,4,16,.22); }
.nevera-ai-chat--floating { width:100%; max-width:none; max-height:calc(100dvh - 108px); margin:0; border-radius:20px; box-shadow:0 24px 70px rgba(27,3,9,.23); display:flex; flex-direction:column; overflow:hidden; }
.nevera-ai-chat--floating .nevera-ai-chat__header { padding:15px 16px; position:relative; z-index:6; flex:0 0 auto; }
.nevera-ai-chat--floating .nevera-ai-chat__messages { min-height:0; height:min(52vh,480px); max-height:none; flex:1 1 auto; padding:16px; }
.nevera-ai-chat--floating .nevera-ai-chat__form { padding:11px; flex:0 0 auto; }
.nevera-ai-chat--floating .nevera-ai-chat__footer { padding-bottom:11px; flex:0 0 auto; }
.nevera-ai-chat--floating .nevera-ai-quick-actions { grid-template-columns:1fr; gap:7px; }
.nevera-ai-chat--floating .nevera-ai-quick-action { min-height:52px; }
.nevera-ai-chat--floating .nevera-ai-products { grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
.nevera-ai-chat--floating .nevera-ai-product__name { font-size:11px; }
.nevera-ai-chat--floating .nevera-ai-product__price { font-size:18px; }
.nevera-ai-chat--floating .nevera-ai-product__button { font-size:11px; min-height:38px; }

@media (min-width: 700px) {
  .nevera-ai-chat:not(.nevera-ai-chat--floating) .nevera-ai-products { grid-template-columns:repeat(3,minmax(0,1fr)); }
}

@media (max-width: 640px) {
  .nevera-ai-chat { border-radius:16px; margin:18px auto; }
  .nevera-ai-chat__messages { min-height:330px; padding:16px; }
  .nevera-ai-message__bubble { max-width:92%; }
  .nevera-ai-chat__form { padding:10px; }
  .nevera-ai-chat__form button span { display:none; }
  .nevera-ai-chat__form button { width:48px; padding:0; justify-content:center; }
  .nevera-ai-products { grid-template-columns:repeat(2,minmax(0,1fr)); gap:9px; }
  .nevera-ai-product__body { padding:10px; }
  .nevera-ai-product__name { font-size:11px; }
  .nevera-ai-product__price { font-size:18px; }
  .nevera-ai-product__button { font-size:12px; }
  .nevera-ai-quick-actions { grid-template-columns:1fr; gap:7px; }

  /* Móvil: launcher abajo del todo y panel anclado al viewport. */
  .nevera-ai-floating {
    right:10px;
    bottom:max(8px, env(safe-area-inset-bottom));
  }

  .nevera-ai-floating__launcher {
    width:58px;
    min-height:58px;
    padding:8px;
    justify-content:center;
  }

  .nevera-ai-floating__launcher-text {
    position:absolute!important;
    width:1px!important;
    height:1px!important;
    overflow:hidden!important;
    clip:rect(0,0,0,0)!important;
  }

  /* Importante: fixed respecto al viewport, no absolute respecto al launcher. */
  .nevera-ai-floating__panel {
    position:fixed;
    top:max(8px, env(safe-area-inset-top));
    right:8px;
    bottom:calc(max(8px, env(safe-area-inset-bottom)) + 68px);
    left:8px;
    width:auto;
    max-height:none;
    transform:translateY(10px) scale(.985);
    transform-origin:bottom center;
  }

  .nevera-ai-floating.is-open .nevera-ai-floating__panel {
    transform:translateY(0) scale(1);
  }

  .nevera-ai-chat--floating {
    width:100%;
    height:100%;
    max-height:none;
    margin:0;
    border-radius:18px;
  }

  .nevera-ai-chat--floating .nevera-ai-chat__header {
    position:relative;
    z-index:20;
    flex:0 0 auto;
    padding:12px;
  }

  .nevera-ai-chat--floating .nevera-ai-chat__messages {
    height:auto;
    min-height:0;
    max-height:none;
    flex:1 1 auto;
    overflow-y:auto;
    overscroll-behavior:contain;
  }

  .nevera-ai-chat--floating .nevera-ai-chat__form,
  .nevera-ai-chat--floating .nevera-ai-chat__footer {
    flex:0 0 auto;
  }

  .nevera-ai-chat--floating .nevera-ai-chat__close {
    width:40px;
    height:40px;
    flex-basis:40px;
  }
}

@media (max-width: 420px) {
  .nevera-ai-products,.nevera-ai-chat--floating .nevera-ai-products { grid-template-columns:1fr; }
  .nevera-ai-chat__status { display:none; }
}
