/* Chat di aiuto: bottone e pannello in basso a destra. Colori dai token del sito. */
.as-fab {
  position: fixed; z-index: 70; right: 16px; bottom: 22px;
  width: 56px; height: 56px; padding: 0; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--flame, var(--ink)); color: var(--onflame, var(--paper));
  box-shadow: 0 12px 28px -12px rgba(33,26,42,.55), 0 0 0 1px var(--rule);
  transition: transform .2s;
}
.as-fab:hover { transform: translateY(-2px); }
.as-fab:active { transform: scale(.96); }
.as-fab svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.as-panel {
  position: fixed; z-index: 70; left: 12px; right: 12px; bottom: 90px;
  display: flex; flex-direction: column;
  max-height: 76vh; max-height: min(76dvh, 620px);
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--rule); border-radius: 20px; overflow: hidden;
  box-shadow: 0 24px 60px -20px rgba(33,26,42,.55);
  font-family: var(--font);
  animation: as-in .18s ease-out;
}
.as-panel[hidden] { display: none; }
@keyframes as-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Copertura di banner cookie e menu a tutto schermo */
.as-fab.as-away, .as-panel.as-away { display: none; }
html.menu-open .as-fab, html.menu-open .as-panel { display: none; }

/* Il pulsante "torna su" sale sopra la chat: 12px di distanza */
body.has-assistant .to-top { bottom: 90px; }

.as-head { flex: none; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 12px 12px 18px; border-bottom: 1px solid var(--rule); }
.as-head-text { min-width: 0; }
.as-title { margin: 0; font-family: var(--display); font-weight: 800; font-size: 1.125rem; line-height: 1.2; }
.as-title:focus, .as-title:focus-visible { outline: none; }
.as-sub { margin: 4px 0 0; color: var(--ink-soft); font-size: .875rem; line-height: 1.45; }
.as-x { flex: none; width: 44px; height: 44px; margin: -6px 0 0; border: 0; border-radius: 50%; background: transparent; color: var(--ink); cursor: pointer; display: grid; place-items: center; }
.as-x:hover { background: var(--surface-sunk); }
.as-x svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

.as-msgs {
  position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.as-msg { max-width: 88%; padding: 10px 14px; border-radius: 16px; font-size: .9688rem; line-height: 1.5; overflow-wrap: anywhere; }
.as-bot { align-self: flex-start; background: var(--surface-sunk); color: var(--ink); border-bottom-left-radius: 6px; }
.as-user { align-self: flex-end; background: var(--flame, var(--ink)); color: var(--onflame, var(--paper)); border-bottom-right-radius: 6px; }
.as-bot a { color: var(--brand); text-underline-offset: 3px; }

.as-extra { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.as-pills { display: flex; flex-direction: column; align-items: flex-start; max-width: 100%; }
.as-pill, .as-all {
  min-height: 44px; max-width: 100%; padding: 8px 16px; border-radius: 22px; cursor: pointer;
  font: 600 .9063rem/1.3 var(--font); text-align: left; overflow-wrap: anywhere;
  transition: background-color .2s, color .2s;
}
.as-pill { color: var(--ink); background: var(--surface); border: 1.5px solid var(--rule); }
.as-pill:hover { border-color: var(--brand); background: var(--surface-sunk); }
.as-all { color: var(--brand); background: transparent; border: 0; padding-left: 4px; text-decoration: underline; text-underline-offset: 3px; }
.as-all:hover { color: var(--ink); }
.as-group { margin: 8px 0 0; color: var(--ink-soft); font: 700 .875rem/1.3 var(--display); }

.as-form { flex: none; display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--rule); background: var(--surface); }
.as-input {
  flex: 1 1 auto; min-width: 0; min-height: 44px; padding: 0 14px;
  font: 400 1rem/1.4 var(--font); color: var(--ink);
  background: var(--paper); border: 1.5px solid var(--rule); border-radius: 22px;
}
.as-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--flame) 25%, transparent); }
.as-send {
  flex: none; min-height: 44px; padding: 0 18px; border: 0; border-radius: 22px; cursor: pointer;
  font: 700 .9688rem/1 var(--font); color: var(--onflame, var(--paper)); background: var(--flame, var(--ink));
}
.as-send:active { transform: scale(.97); }
.as-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.as-fab:focus-visible, .as-panel :focus-visible { outline: 2.5px solid var(--brand); outline-offset: 3px; }
.as-fab:focus-visible { outline-color: var(--ink); }

@media (min-width: 560px) {
  .as-panel { left: auto; right: 26px; bottom: 100px; width: 380px; }
}
@media (min-width: 720px) {
  .as-fab { right: 26px; bottom: 32px; }
  body.has-assistant .to-top { bottom: 100px; }
}

@media (prefers-reduced-motion: reduce) {
  .as-panel { animation: none; }
  .as-fab, .as-pill, .as-all { transition: none; }
}
