/* =============================================================
   Gcompy AI — stile
   ============================================================= */
:root {
  --sfondo: #f6f5f1;
  --superficie: #ffffff;
  --superficie-2: #efeee8;
  --sidebar: #eceae3;
  --testo: #1d1d1a;
  --testo-2: #5d5d57;
  --testo-3: #8a8a83;
  --bordo: #dedcd3;
  --bordo-forte: #c9c7bd;
  --accento: #2f6f5e;
  --accento-hover: #255a4c;
  --accento-tenue: #dcebe5;
  --accento-testo: #ffffff;
  --oro: #c98a3e;
  --pericolo: #b4423a;
  --ok: #2f7d4f;
  --ombra: 0 1px 2px rgba(30, 30, 20, .05), 0 8px 24px rgba(30, 30, 20, .06);
  --ombra-forte: 0 20px 60px rgba(20, 20, 10, .18);
  --raggio: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Fraunces", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --larghezza-chat: 760px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="chiaro"]) {
    --sfondo: #151614; --superficie: #1e1f1c; --superficie-2: #262723; --sidebar: #1a1b19;
    --testo: #ecebe6; --testo-2: #b1b0a8; --testo-3: #85847d; --bordo: #31322e; --bordo-forte: #44453f;
    --accento: #5fbf9f; --accento-hover: #79d1b3; --accento-tenue: #1f3a32; --accento-testo: #0d1f1a;
    --ombra: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25); --ombra-forte: 0 20px 60px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-tema="scuro"] {
  --sfondo: #151614; --superficie: #1e1f1c; --superficie-2: #262723; --sidebar: #1a1b19;
  --testo: #ecebe6; --testo-2: #b1b0a8; --testo-3: #85847d; --bordo: #31322e; --bordo-forte: #44453f;
  --accento: #5fbf9f; --accento-hover: #79d1b3; --accento-tenue: #1f3a32; --accento-testo: #0d1f1a;
  --ombra: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25); --ombra-forte: 0 20px 60px rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--sfondo); color: var(--testo);
  font: 15px/1.6 var(--font); -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accento); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.serif { font-family: var(--serif); font-weight: 500; letter-spacing: -.01em; }
::selection { background: var(--accento-tenue); }

/* ---------- caricamento ---------- */
.splash { position: fixed; inset: 0; display: grid; place-items: center; background: var(--sfondo); z-index: 100; transition: opacity .4s; }
.splash.via { opacity: 0; pointer-events: none; }
.splash-logo { width: 56px; animation: respiro 1.4s ease-in-out infinite; }
@keyframes respiro { 50% { transform: scale(.9); opacity: .7; } }

/* ---------- pulsanti ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 10px; padding: 10px 16px;
  font-weight: 500; background: var(--superficie-2); text-decoration: none; transition: background .15s, border-color .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn.primario { background: var(--accento); color: var(--accento-testo); }
.btn.primario:hover { background: var(--accento-hover); }
.btn.contorno { background: transparent; border-color: var(--bordo-forte); }
.btn.contorno:hover { background: var(--superficie-2); }
.btn.pericolo { background: var(--pericolo); color: #fff; }
.btn.piccolo { padding: 7px 12px; font-size: 14px; }
.btn.largo { width: 100%; padding: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; }
.icona-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px;
  border: 0; background: transparent; color: var(--testo-2); transition: background .15s, color .15s;
}
.icona-btn:hover { background: var(--superficie-2); color: var(--testo); }

/* ---------- accesso ---------- */
.auth { position: fixed; inset: 0; display: grid; grid-template-columns: 1.1fr 1fr; overflow: auto; }
.auth-art { position: relative; overflow: hidden; background: #0d2b2a; }
.paesaggio { position: absolute; inset: 0; width: 100%; height: 100%; stroke: none; }
.paesaggio .sole { animation: sorgere 14s ease-in-out infinite alternate; transform-origin: center; }
.paesaggio .stelle circle { animation: brilla 3s ease-in-out infinite; }
.paesaggio .stelle circle:nth-child(2n) { animation-delay: 1.2s; }
.paesaggio .stelle circle:nth-child(3n) { animation-delay: 2s; }
.paesaggio .m1 { animation: deriva 22s ease-in-out infinite alternate; }
.paesaggio .m2 { animation: deriva 16s ease-in-out infinite alternate-reverse; }
@keyframes sorgere { from { transform: translateY(40px); } to { transform: translateY(-30px); } }
@keyframes brilla { 50% { opacity: .25; } }
@keyframes deriva { from { transform: translateX(-12px); } to { transform: translateX(12px); } }
.auth-motto { position: absolute; left: 48px; right: 48px; top: 56px; color: #f4efe4; max-width: 460px; animation: entra .8s ease both; }
.auth-motto-logo { width: 44px; margin-bottom: 28px; box-shadow: 0 8px 30px rgba(0,0,0,.3); border-radius: 12px; }
.auth-motto h2 { font-size: clamp(34px, 4vw, 52px); line-height: 1.05; margin: 0 0 16px; }
.auth-motto p { font-size: 17px; opacity: .85; margin: 0; }
.auth-form-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; gap: 20px; }
.auth-card { width: 100%; max-width: 380px; animation: entra .6s .1s ease both; }
@keyframes entra { from { opacity: 0; transform: translateY(14px); } }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 19px; margin-bottom: 28px; color: var(--testo); text-decoration: none; }
.brand img { width: 32px; height: 32px; border-radius: 9px; }
.brand.piccolo { font-size: 16px; margin: 0; }
.brand.piccolo img { width: 28px; height: 28px; border-radius: 8px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--superficie-2); padding: 4px; border-radius: 12px; margin-bottom: 22px; }
.tab { border: 0; background: transparent; padding: 9px; border-radius: 9px; font-weight: 500; color: var(--testo-2); transition: all .2s; }
.tab.attivo { background: var(--superficie); color: var(--testo); box-shadow: var(--ombra); }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; font-weight: 500; color: var(--testo-2); }
.form input, .form textarea, .form select, .dialog input, .dialog select, .dialog textarea {
  width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--bordo-forte);
  background: var(--superficie); color: var(--testo); font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
.form input:focus, .dialog input:focus, .dialog select:focus, .dialog textarea:focus {
  outline: none; border-color: var(--accento); box-shadow: 0 0 0 3px var(--accento-tenue);
}
.errore-form { color: var(--pericolo); font-size: 14px; min-height: 20px; margin: 12px 0 0; }
.nota { color: var(--testo-3); font-size: 12.5px; }
.nota.centro { text-align: center; }
.firma { color: var(--testo-3); font-size: 13px; margin: 0; }
.firma .autore { color: var(--testo-2); font-weight: 600; }

/* ---------- layout app ---------- */
.app { display: flex; height: 100vh; height: 100dvh; }
.sidebar {
  width: 272px; flex-shrink: 0; background: var(--sidebar); border-right: 1px solid var(--bordo);
  display: flex; flex-direction: column; padding: 14px 10px 10px; gap: 10px;
}
.sb-top { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 4px; }
.nuova-chat { justify-content: flex-start; background: var(--superficie); border: 1px solid var(--bordo); box-shadow: 0 1px 1px rgba(0,0,0,.03); }
.nuova-chat:hover { border-color: var(--bordo-forte); }
.cerca { display: flex; align-items: center; gap: 8px; padding: 0 10px; color: var(--testo-3); border-radius: 9px; }
.cerca:focus-within { background: var(--superficie); }
.cerca svg { width: 16px; height: 16px; }
.cerca input { border: 0; background: transparent; outline: none; padding: 8px 0; width: 100%; font-size: 14px; }
.lista-chat { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; scrollbar-width: thin; }
.gruppo-chat { font-size: 12px; font-weight: 600; color: var(--testo-3); padding: 14px 10px 6px; letter-spacing: .02em; }
.voce-chat {
  position: relative; display: flex; align-items: center; border-radius: 9px; color: var(--testo-2);
  text-decoration: none; font-size: 14px; transition: background .12s;
}
.voce-chat a { flex: 1; padding: 8px 10px; color: inherit; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voce-chat:hover { background: var(--superficie-2); color: var(--testo); }
.voce-chat.attiva { background: var(--superficie); color: var(--testo); box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.voce-chat .azioni-chat { opacity: 0; display: flex; padding-right: 4px; }
.voce-chat:hover .azioni-chat, .voce-chat.attiva .azioni-chat { opacity: 1; }
.azioni-chat button { border: 0; background: transparent; padding: 4px; border-radius: 6px; color: var(--testo-3); display: grid; }
.azioni-chat button:hover { color: var(--testo); background: var(--superficie-2); }
.azioni-chat svg { width: 15px; height: 15px; }
.lista-vuota { color: var(--testo-3); font-size: 13.5px; padding: 16px 10px; }
.sb-bottom { position: relative; border-top: 1px solid var(--bordo); padding-top: 8px; }
.utente-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent;
  padding: 8px; border-radius: 10px; text-align: left;
}
.utente-btn:hover { background: var(--superficie-2); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: var(--accento); color: var(--accento-testo); font-weight: 600; font-size: 14px;
}
.utente-info { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.utente-info > span:first-child { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge-piano { font-size: 12px; color: var(--testo-3); }
.badge-piano.pro { color: var(--accento); font-weight: 600; }
.badge-piano.ultra { color: var(--oro); font-weight: 600; }
.chevron { width: 16px; height: 16px; color: var(--testo-3); }
.menu {
  position: absolute; bottom: calc(100% + 6px); left: 0; right: 0; background: var(--superficie);
  border: 1px solid var(--bordo); border-radius: 12px; box-shadow: var(--ombra-forte); padding: 6px; z-index: 20;
  animation: menu .15s ease;
}
@keyframes menu { from { opacity: 0; transform: translateY(6px); } }
.menu-email { font-size: 12.5px; color: var(--testo-3); padding: 8px 10px 6px; overflow: hidden; text-overflow: ellipsis; }
.menu button, .menu a {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; background: transparent;
  border-radius: 8px; font-size: 14px; color: var(--testo); text-decoration: none; text-align: left;
}
.menu button:hover, .menu a:hover { background: var(--superficie-2); }
.menu svg { width: 17px; height: 17px; color: var(--testo-2); }
.menu hr { border: 0; border-top: 1px solid var(--bordo); margin: 5px 4px; }
.velo { display: none; }

/* ---------- area principale ---------- */
.principale { position: relative; flex: 1; display: flex; flex-direction: column; min-width: 0; }
.barra { display: flex; align-items: center; gap: 10px; padding: 10px 18px; min-height: 56px; }
.titolo-chat { flex: 1; font-size: 15px; font-weight: 500; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--testo-2); }
.solo-mobile { display: none; }
.conversazione { flex: 1; overflow-y: auto; scroll-behavior: smooth; padding: 0 20px; }
.benvenuto {
  max-width: var(--larghezza-chat); margin: 0 auto; min-height: 58%; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end; text-align: center; padding-top: 40px; animation: entra .5s ease both;
}
.benvenuto-logo { width: 52px; height: 52px; border-radius: 14px; margin-bottom: 18px; }
.benvenuto h2 { font-size: clamp(28px, 4vw, 40px); margin: 0 0 26px; }
.suggerimenti { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; width: 100%; }
.suggerimenti button {
  display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden;
  border: 1px solid var(--bordo); background: var(--superficie); border-radius: 16px;
  color: var(--testo); transition: transform .2s, box-shadow .2s, border-color .2s;
}
.suggerimenti button:hover { transform: translateY(-3px); box-shadow: var(--ombra); border-color: var(--bordo-forte); }
.sugg-foto { display: block; height: 78px; background: linear-gradient(135deg, var(--accento-tenue), color-mix(in srgb, var(--oro) 18%, var(--superficie-2))) center/cover no-repeat; transition: transform .5s; }
.suggerimenti button:hover .sugg-foto { transform: scale(1.05); }
.sugg-testo { display: flex; flex-direction: column; padding: 10px 12px 12px; position: relative; background: var(--superficie); }
.sugg-testo strong { font-size: 14px; font-weight: 600; }
.sugg-testo small { font-size: 12.5px; color: var(--testo-3); }

/* ---------- messaggi ---------- */
.messaggi { max-width: var(--larghezza-chat); margin: 0 auto; padding: 8px 0 24px; }
.msg { display: flex; gap: 14px; margin: 22px 0; animation: msg .25s ease both; }
@keyframes msg { from { opacity: 0; transform: translateY(6px); } }
.msg.utente { justify-content: flex-end; }
.msg.utente .bolla {
  background: var(--superficie-2); padding: 11px 16px; border-radius: 18px 18px 4px 18px; max-width: 100%;
  white-space: pre-wrap; word-wrap: break-word;
}
.msg.ia .icona-ia { width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0; margin-top: 2px; }
.msg.ia .corpo { flex: 1; min-width: 0; }
.msg-allegati { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-bottom: 6px; }
.msg-allegati img { max-width: 220px; max-height: 180px; border-radius: 12px; border: 1px solid var(--bordo); object-fit: cover; }
.chip-file {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 11px; border-radius: 10px;
  background: var(--superficie); border: 1px solid var(--bordo); font-size: 13px; max-width: 240px;
}
.chip-file span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-file svg { width: 16px; height: 16px; color: var(--accento); }

.md { word-wrap: break-word; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 14px; }
.md h1, .md h2, .md h3, .md h4 { font-family: var(--serif); font-weight: 600; line-height: 1.3; margin: 24px 0 10px; }
.md h1 { font-size: 1.5em; } .md h2 { font-size: 1.3em; } .md h3 { font-size: 1.12em; }
.md ul, .md ol { padding-left: 1.5em; margin: 0 0 14px; }
.md li { margin: 4px 0; }
.md blockquote { margin: 0 0 14px; padding: 2px 16px; border-left: 3px solid var(--accento); color: var(--testo-2); }
.md code { font-family: var(--mono); font-size: .88em; background: var(--superficie-2); padding: 2px 6px; border-radius: 6px; }
.md pre { margin: 0 0 14px; border-radius: 12px; overflow: hidden; background: #16181a; border: 1px solid #2a2d30; }
.md pre code { display: block; padding: 14px 16px; overflow-x: auto; background: transparent; color: #e6e6e1; font-size: 13.5px; line-height: 1.55; }
.testa-codice { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 6px 14px; background: #1f2225; color: #a3a7ab; font: 12px var(--mono); }
.testa-codice button { border: 0; background: transparent; color: inherit; display: inline-flex; gap: 6px; align-items: center; padding: 4px 8px; border-radius: 6px; font: 12px var(--font); }
.testa-codice button:hover { background: #2c3034; color: #fff; }
.testa-codice svg { width: 14px; height: 14px; }
.md table { border-collapse: collapse; margin: 0 0 14px; display: block; overflow-x: auto; font-size: 14px; }
.md th, .md td { border: 1px solid var(--bordo); padding: 7px 12px; text-align: left; }
.md th { background: var(--superficie-2); font-weight: 600; }
.md hr { border: 0; border-top: 1px solid var(--bordo); margin: 20px 0; }
.md a { text-underline-offset: 2px; }
.md img { max-width: 100%; }

.cursore::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 4px; border-radius: 50%; background: var(--accento); animation: pulsa 1s infinite; vertical-align: middle; }
@keyframes pulsa { 50% { opacity: .2; transform: scale(.7); } }
.pensa { display: flex; gap: 5px; padding: 10px 0; }
.pensa span { width: 7px; height: 7px; border-radius: 50%; background: var(--accento); animation: salta 1.2s infinite ease-in-out; }
.pensa span:nth-child(2) { animation-delay: .15s; } .pensa span:nth-child(3) { animation-delay: .3s; }
@keyframes salta { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-5px); } }
.azioni-msg { display: flex; gap: 2px; margin-top: 8px; opacity: 0; transition: opacity .15s; align-items: center; }
.msg:hover .azioni-msg { opacity: 1; }
.azioni-msg button { border: 0; background: transparent; color: var(--testo-3); padding: 5px; border-radius: 7px; display: grid; }
.azioni-msg button:hover { background: var(--superficie-2); color: var(--testo); }
.azioni-msg svg { width: 16px; height: 16px; }
.azioni-msg .modello-usato { font-size: 12px; color: var(--testo-3); margin-left: 6px; }
.msg-errore { color: var(--pericolo); background: color-mix(in srgb, var(--pericolo) 10%, transparent); padding: 10px 14px; border-radius: 10px; font-size: 14px; }

/* ---------- composer ---------- */
.composer-wrap { padding: 0 20px 14px; }
.avviso-limite {
  max-width: var(--larghezza-chat); margin: 0 auto 10px; padding: 12px 16px; border-radius: 12px;
  background: var(--accento-tenue); color: var(--testo); font-size: 14px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.composer {
  max-width: var(--larghezza-chat); margin: 0 auto; background: var(--superficie); border: 1px solid var(--bordo-forte);
  border-radius: 20px; padding: 12px 12px 10px 16px; box-shadow: var(--ombra); transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: var(--accento); box-shadow: var(--ombra), 0 0 0 3px var(--accento-tenue); }
.composer textarea {
  width: 100%; border: 0; outline: 0; resize: none; background: transparent; max-height: 240px;
  font-size: 15.5px; line-height: 1.5; padding: 2px 0 6px;
}
.composer-azioni { display: flex; align-items: center; gap: 6px; }
.indicatore-crediti {
  margin-left: auto; display: inline-flex; align-items: center; gap: 8px; border: 0; background: transparent;
  color: var(--testo-3); font-size: 12.5px; padding: 6px 8px; border-radius: 8px;
}
.indicatore-crediti:hover { background: var(--superficie-2); color: var(--testo-2); }
.mini-barra { width: 46px; height: 5px; border-radius: 5px; background: var(--superficie-2); overflow: hidden; }
.mini-barra span { display: block; height: 100%; width: 100%; background: var(--accento); border-radius: 5px; transition: width .4s; }
.mini-barra span.basso { background: var(--oro); }
.mini-barra span.finito { background: var(--pericolo); }
.invia {
  width: 36px; height: 36px; border-radius: 11px; border: 0; display: grid; place-items: center;
  background: var(--accento); color: var(--accento-testo); transition: background .15s, transform .1s, opacity .15s;
}
.invia:hover:not(:disabled) { background: var(--accento-hover); }
.invia:disabled { opacity: .35; cursor: default; }
.invia svg { width: 18px; height: 18px; stroke-width: 2.2; }
.invia .ico-stop { display: none; fill: currentColor; stroke: none; }
.invia.stop .ico-invia { display: none; }
.invia.stop .ico-stop { display: block; }
.disclaimer { text-align: center; font-size: 12px; color: var(--testo-3); margin: 10px 0 0; }
.allegati-anteprima { display: flex; flex-wrap: wrap; gap: 8px; }
.allegati-anteprima:not(:empty) { margin-bottom: 10px; }
.anteprima {
  position: relative; display: flex; align-items: center; gap: 8px; padding: 6px 30px 6px 6px; border-radius: 12px;
  background: var(--superficie-2); font-size: 13px; max-width: 230px;
}
.anteprima img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }
.anteprima .icona-file { width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center; background: var(--accento-tenue); color: var(--accento); }
.anteprima .nome { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.anteprima .peso { font-size: 11.5px; color: var(--testo-3); }
.anteprima .togli { position: absolute; top: 4px; right: 4px; border: 0; background: transparent; padding: 3px; border-radius: 6px; color: var(--testo-3); display: grid; }
.anteprima .togli:hover { color: var(--testo); background: var(--superficie); }
.anteprima .togli svg { width: 14px; height: 14px; }
.anteprima.caricamento::after {
  content: ""; position: absolute; inset: 0; border-radius: 12px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--superficie) 60%, transparent), transparent);
  animation: luccica 1.1s infinite;
}
@keyframes luccica { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.drop {
  position: absolute; inset: 10px; border: 2px dashed var(--accento); border-radius: 20px; z-index: 30;
  background: color-mix(in srgb, var(--sfondo) 85%, transparent); display: grid; place-items: center;
  font-family: var(--serif); font-size: 22px; color: var(--accento); pointer-events: none;
}

/* ---------- finestre ---------- */
.dialog {
  border: 1px solid var(--bordo); border-radius: 18px; padding: 24px; background: var(--superficie); color: var(--testo);
  width: min(480px, calc(100vw - 24px)); box-shadow: var(--ombra-forte); max-height: calc(100dvh - 32px);
}
.dialog[open] { animation: apri .2s ease; }
@keyframes apri { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.dialog::backdrop { background: rgba(10, 12, 10, .45); backdrop-filter: blur(3px); }
.dialog.largo { width: min(1000px, calc(100vw - 24px)); }
.dialog.stretto { width: min(400px, calc(100vw - 24px)); }
.dialog h3 { margin: 0 0 4px; font-size: 22px; }
.dlg-testa { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.azioni-dlg { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.sezione { padding: 16px 0; border-top: 1px solid var(--bordo); }
.sezione:first-of-type { border-top: 0; padding-top: 0; }
.sezione h4 { margin: 0 0 12px; font-size: 14px; }
.riga-info { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 14px; }
.riga-info span { color: var(--testo-2); }
.riga-info strong { font-weight: 500; text-align: right; word-break: break-all; }
.segmenti { display: inline-flex; background: var(--superficie-2); padding: 3px; border-radius: 10px; }
.segmenti button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; font-size: 14px; color: var(--testo-2); }
.segmenti button.attivo { background: var(--superficie); color: var(--testo); box-shadow: var(--ombra); }

.piani { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.piano {
  position: relative; border: 1px solid var(--bordo); border-radius: 16px; padding: 22px; display: flex; flex-direction: column; gap: 14px;
  background: var(--sfondo); transition: transform .2s, box-shadow .2s;
}
.piano:hover { transform: translateY(-2px); box-shadow: var(--ombra); }
.piano.evidenza { border-color: var(--accento); box-shadow: 0 0 0 1px var(--accento); }
.piano.ultra { background: linear-gradient(160deg, color-mix(in srgb, var(--oro) 12%, var(--sfondo)), var(--sfondo) 60%); }
.piano .etichetta { position: absolute; top: -11px; left: 20px; background: var(--accento); color: var(--accento-testo); font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.piano h4 { font-family: var(--serif); font-size: 24px; font-weight: 500; margin: 0; }
.piano .prezzo { font-size: 22px; font-weight: 600; }
.piano .descr { color: var(--testo-2); font-size: 14px; margin: -8px 0 0; }
.piano ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 9px; font-size: 14px; flex: 1; }
.piano li { display: flex; gap: 9px; align-items: flex-start; }
.piano li svg { width: 17px; height: 17px; color: var(--accento); margin-top: 2px; stroke-width: 2.4; }
.piano .limiti { font-size: 12.5px; color: var(--testo-3); border-top: 1px solid var(--bordo); padding-top: 12px; }

.uso-blocco { padding: 16px; border: 1px solid var(--bordo); border-radius: 14px; margin-bottom: 12px; }
.uso-testa { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.uso-testa strong { font-weight: 600; }
.uso-testa span { font-size: 13px; color: var(--testo-3); }
.barra-uso { height: 8px; background: var(--superficie-2); border-radius: 8px; overflow: hidden; }
.barra-uso span { display: block; height: 100%; background: var(--accento); border-radius: 8px; transition: width .6s; }
.barra-uso span.basso { background: var(--oro); }
.barra-uso span.finito { background: var(--pericolo); }
.uso-piede { display: flex; justify-content: space-between; font-size: 13px; color: var(--testo-2); margin-top: 8px; }
.illimitato-box { text-align: center; padding: 26px 16px; border-radius: 14px; background: var(--accento-tenue); margin-bottom: 12px; }
.illimitato-box strong { display: block; font-family: var(--serif); font-size: 22px; font-weight: 500; }

/* ---------- statistiche risposta ---------- */
.stat-msg { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: 12.5px; color: var(--testo-3); font-variant-numeric: tabular-nums; }
.stat-msg:empty { display: none; }
.stat-msg span { display: inline-flex; align-items: center; gap: 5px; }
.stat-msg svg { width: 13px; height: 13px; }
.stat-msg.live { color: var(--accento); }

/* ---------- annunci dell'amministratore ---------- */
.annunci { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 150; display: flex; flex-direction: column; gap: 8px; width: min(640px, calc(100vw - 24px)); pointer-events: none; }
.annuncio {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 12px; padding: 12px 12px 12px 16px; border-radius: 14px;
  background: var(--superficie); border: 1px solid var(--bordo); border-left: 4px solid var(--accento);
  box-shadow: var(--ombra-forte); font-size: 14px; animation: scendi .3s ease;
}
.annuncio.avviso { border-left-color: var(--oro); }
.annuncio.manutenzione { border-left-color: var(--pericolo); }
.annuncio .ico { width: 20px; height: 20px; color: var(--accento); margin-top: 1px; }
.annuncio.avviso .ico { color: var(--oro); }
.annuncio.manutenzione .ico { color: var(--pericolo); }
.annuncio .testo { flex: 1; white-space: pre-wrap; word-wrap: break-word; }
.annuncio .testo strong { display: block; margin-bottom: 2px; }
.annuncio button { border: 0; background: transparent; color: var(--testo-3); padding: 3px; border-radius: 6px; display: grid; }
.annuncio button:hover { background: var(--superficie-2); color: var(--testo); }
.annuncio button svg { width: 16px; height: 16px; }
@keyframes scendi { from { opacity: 0; transform: translateY(-12px); } }

/* ---------- foto (Unsplash) ---------- */
.slideshow { position: absolute; inset: 0; }
.slideshow .slide {
  position: absolute; inset: 0; background-size: cover; background-position: center; opacity: 0;
  transition: opacity 1.6s ease; transform: scale(1.08);
}
.slideshow .slide.visibile { opacity: 1; animation: kenburns 9s ease-out forwards; }
@keyframes kenburns { from { transform: scale(1.08); } to { transform: scale(1); } }
.auth-velo { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(8, 24, 20, .62) 0%, rgba(8, 24, 20, .15) 45%, rgba(8, 24, 20, .55) 100%); pointer-events: none; }
.auth-motto { z-index: 2; text-shadow: 0 2px 20px rgba(0,0,0,.35); }
.auth-luogo { position: absolute; left: 48px; bottom: 28px; z-index: 2; color: rgba(255,255,255,.8); font-size: 12.5px; display: flex; align-items: center; gap: 8px; transition: opacity .6s; }
.auth-luogo::before { content: ""; width: 18px; height: 1px; background: currentColor; }
.punti-slide { position: absolute; right: 32px; bottom: 30px; z-index: 2; display: flex; gap: 6px; }
.punti-slide span { width: 6px; height: 6px; border-radius: 6px; background: rgba(255,255,255,.45); transition: all .4s; }
.punti-slide span.attivo { width: 20px; background: #fff; }

.hero { position: relative; width: 100%; height: 210px; border-radius: 22px; overflow: hidden; margin-bottom: 18px; background: linear-gradient(135deg, #2f6f5e, #0f2f29); box-shadow: var(--ombra); }
.hero-foto { position: absolute; inset: 0; background-size: cover; background-position: center 60%; opacity: 0; transition: opacity 1s ease; transform: scale(1.04); }
.hero-foto.caricata { opacity: 1; animation: kenburns 12s ease-out forwards; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(5, 18, 15, .7) 0%, rgba(5, 18, 15, .25) 60%, transparent 100%); }
.hero-testo { position: absolute; z-index: 1; left: 30px; bottom: 26px; right: 30px; color: #fff; text-align: left; }
.hero-testo h2 { font-size: clamp(26px, 3.6vw, 38px); margin: 2px 0 2px; color: #fff; text-shadow: 0 2px 16px rgba(0,0,0,.3); }
.hero-testo p { margin: 0; opacity: .85; }
.hero-data { font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; opacity: .8; }

/* ---------- selettore del modello ---------- */
.sel-modello { position: relative; }
.btn-modello {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--bordo); background: transparent;
  border-radius: 999px; padding: 5px 10px 5px 8px; font-size: 13.5px; font-weight: 500; color: var(--testo-2); transition: all .15s;
}
.btn-modello:hover { background: var(--superficie-2); color: var(--testo); border-color: var(--bordo-forte); }
.btn-modello .chevron { width: 14px; height: 14px; }
.ico-liv { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: var(--accento-tenue); color: var(--accento); }
.ico-liv svg { width: 13px; height: 13px; stroke-width: 2.2; }
.ico-liv.potente { background: color-mix(in srgb, var(--oro) 22%, transparent); color: var(--oro); }
.menu-modelli { left: 0; right: auto; width: 320px; bottom: calc(100% + 10px); padding: 6px; }
.menu-modelli .titolo-menu { font-size: 12px; font-weight: 600; color: var(--testo-3); padding: 8px 10px 4px; }
.voce-liv { display: flex !important; align-items: flex-start !important; gap: 12px !important; padding: 10px !important; }
.voce-liv .ico-liv { width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0; }
.voce-liv .ico-liv svg { width: 16px; height: 16px; }
.voce-liv .info-liv { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.voce-liv strong { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.voce-liv small { color: var(--testo-3); font-size: 12.5px; line-height: 1.35; }
.voce-liv .badge-liv { font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: var(--accento); color: var(--accento-testo); letter-spacing: .02em; }
.voce-liv .badge-liv.ultra { background: var(--oro); color: #fff; }
.voce-liv .costo-liv { color: var(--oro); }
.voce-liv .spunta { color: var(--accento); margin-top: 6px; }
.voce-liv.bloccato .ico-liv, .voce-liv.bloccato .info-liv strong { opacity: .6; }
.voce-liv.bloccato .lucchetto { color: var(--testo-3); margin-top: 6px; }
.menu-modelli .upsell { margin: 6px 4px 4px; width: calc(100% - 8px) !important; justify-content: center; background: var(--accento) !important; color: var(--accento-testo) !important; font-weight: 600; }
.menu-modelli .upsell svg { color: inherit !important; }

/* ---------- intestazione delle risposte ---------- */
.testa-ia { display: flex; align-items: center; gap: 8px; min-height: 30px; margin: 0 0 4px; font-size: 13px; }
.testa-ia .liv { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--testo); }
.testa-ia .liv .ico-liv { width: 20px; height: 20px; border-radius: 6px; }
.testa-ia .reale { color: var(--testo-3); font-family: var(--mono); font-size: 11.5px; }

/* ---------- voce: pulsanti nel riquadro di scrittura ---------- */
#btn-detta.registra { color: #fff; background: var(--pericolo); animation: pulsa-rec 1.2s infinite; }
@keyframes pulsa-rec { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--pericolo) 25%, transparent); } }
#btn-detta.attesa { color: var(--accento); }
.btn-voce {
  width: 36px; height: 36px; border-radius: 11px; border: 1px solid var(--bordo-forte); display: grid; place-items: center;
  background: var(--superficie); color: var(--accento); transition: all .15s;
}
.btn-voce:hover { background: var(--accento-tenue); border-color: var(--accento); }
.btn-voce svg { width: 19px; height: 19px; stroke-width: 2.2; }
.azioni-msg button.legge { color: var(--accento); background: var(--accento-tenue); }
.campo-voce { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; font-weight: 500; color: var(--testo-2); margin-bottom: 12px; }
.campo-voce input[type=range] { accent-color: var(--accento); padding: 0; border: 0; }

/* ---------- voce: modalità conversazione ---------- */
.voce-overlay {
  position: fixed; inset: 0; z-index: 120; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 18px 20px 26px; color: #f4efe4; overflow: hidden;
  background: radial-gradient(120% 90% at 50% 40%, #173f36 0%, #0b1f1b 55%, #060f0d 100%);
  animation: apri-voce .35s ease;
}
@keyframes apri-voce { from { opacity: 0; transform: scale(1.02); } }
.voce-sfondo { position: absolute; inset: -40px; background-size: cover; background-position: center; filter: blur(28px) saturate(1.2); opacity: .32; transform: scale(1.1); pointer-events: none; }
.voce-testa, .voce-centro, .voce-comandi, .voce-suggerimento { position: relative; z-index: 1; }
.voce-testa { width: 100%; display: flex; justify-content: space-between; align-items: center; }
.voce-modello { font-size: 13px; padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); display: inline-flex; align-items: center; gap: 7px; }
.voce-modello .ico-liv { background: rgba(255,255,255,.12); color: #fff; }
.voce-x { width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.08); color: #fff; display: grid; place-items: center; }
.voce-x:hover { background: rgba(255,255,255,.16); }
.voce-centro { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; width: 100%; max-width: 680px; text-align: center; }

.orb { --livello: 0; position: relative; width: 200px; height: 200px; border: 0; background: transparent; padding: 0; border-radius: 50%; cursor: pointer; }
.orb span { position: absolute; border-radius: 50%; pointer-events: none; }
.orb-alone {
  inset: -30px; background: radial-gradient(circle, rgba(95, 191, 159, .55), rgba(95, 191, 159, 0) 65%);
  transform: scale(calc(.9 + var(--livello) * .5)); opacity: calc(.45 + var(--livello) * .55); transition: transform .08s linear, opacity .08s linear;
}
.orb-nucleo {
  inset: 0; background: radial-gradient(circle at 35% 30%, #b7f0dc 0%, #5fbf9f 28%, #2f6f5e 62%, #173f36 100%);
  box-shadow: inset 0 -18px 40px rgba(0,0,0,.35), 0 20px 60px rgba(0,0,0,.4);
  transform: scale(calc(1 + var(--livello) * .18)); transition: transform .08s linear, background .6s, filter .6s;
}
.orb-riflesso { inset: 14% 22% auto auto; width: 34%; height: 22%; background: radial-gradient(ellipse, rgba(255,255,255,.55), transparent 70%); transform: rotate(-25deg); }
.voce-overlay[data-stato="pensa"] .orb-nucleo { animation: pensa-orb 1.6s ease-in-out infinite; background: conic-gradient(from 0deg, #5fbf9f, #c98a3e, #2f6f5e, #5fbf9f); }
.voce-overlay[data-stato="pensa"] .orb-alone { animation: respiro 1.6s ease-in-out infinite; }
@keyframes pensa-orb { 0% { transform: rotate(0) scale(.94); } 50% { transform: rotate(180deg) scale(1.02); } 100% { transform: rotate(360deg) scale(.94); } }
.voce-overlay[data-stato="parla"] .orb-nucleo { background: radial-gradient(circle at 35% 30%, #ffe9c4 0%, #f0b871 30%, #c98a3e 62%, #6b4519 100%); }
.voce-overlay[data-stato="parla"] .orb-alone { background: radial-gradient(circle, rgba(240, 184, 113, .55), rgba(240, 184, 113, 0) 65%); }
.voce-overlay[data-stato="pausa"] .orb-nucleo, .voce-overlay[data-stato="errore"] .orb-nucleo { filter: grayscale(.85) brightness(.7); }
.voce-overlay[data-stato="pausa"] .orb-alone, .voce-overlay[data-stato="errore"] .orb-alone { opacity: .15; }
.voce-stato { font-size: clamp(24px, 4vw, 34px); margin: 0; min-height: 1.3em; }
.voce-trascrizione { margin: 0; font-size: 17px; line-height: 1.55; opacity: .85; min-height: 3.1em; max-height: 9.3em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; }
.voce-trascrizione .tu { opacity: .65; }
.voce-comandi { display: flex; align-items: center; gap: 22px; }
.voce-btn { width: 58px; height: 58px; border-radius: 50%; border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.08); color: #fff; display: grid; place-items: center; transition: background .15s, transform .1s; }
.voce-btn:hover { background: rgba(255,255,255,.16); }
.voce-btn:active { transform: scale(.95); }
.voce-btn svg { width: 24px; height: 24px; }
.voce-btn.grande { width: 72px; height: 72px; background: #f4efe4; color: #0b1f1b; border: 0; }
.voce-btn.grande:hover { background: #fff; }
.voce-btn.grande svg { fill: currentColor; stroke: none; }
.voce-btn.rosso { background: rgba(180, 66, 58, .85); border: 0; }
.voce-btn.rosso:hover { background: #b4423a; }
.voce-btn .ico-off { display: none; }
.voce-btn.spento { background: #f4efe4; color: #0b1f1b; }
.voce-btn.spento .ico-on { display: none; }
.voce-btn.spento .ico-off { display: block; }
.voce-suggerimento { font-size: 13px; opacity: .6; margin: 14px 0 0; text-align: center; max-width: 420px; }

/* ---------- notifiche ---------- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; align-items: center; }
.toast {
  background: var(--testo); color: var(--sfondo); padding: 10px 18px; border-radius: 12px; font-size: 14px;
  box-shadow: var(--ombra-forte); animation: toast .25s ease; max-width: calc(100vw - 32px);
}
.toast.errore { background: var(--pericolo); color: #fff; }
@keyframes toast { from { opacity: 0; transform: translateY(10px); } }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { min-height: 260px; }
  .auth-motto { top: auto; bottom: 28px; left: 24px; right: 24px; }
  .auth-motto h2 { font-size: 32px; }
  .auth-motto p, .auth-motto-logo { display: none; }
  .piani { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .solo-mobile { display: inline-grid; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 50; transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--ombra-forte); }
  .app.menu-aperto .sidebar { transform: none; }
  .app.menu-aperto .velo { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
  .barra { padding: 8px 10px; }
  .conversazione { padding: 0 14px; }
  .composer-wrap { padding: 0 10px 10px; }
  #btn-upgrade span { display: none; }
  .msg.utente .bolla { max-width: 92%; }
  .msg.ia .icona-ia { display: none; }
  .azioni-msg { opacity: 1; }
  .voce-chat .azioni-chat { opacity: 1; }
  #testo-crediti { display: none; }
  .suggerimenti { grid-template-columns: 1fr 1fr; }
  .sugg-foto { height: 54px; }
  .hero { height: 170px; }
  .hero-testo { left: 20px; bottom: 18px; }
  .auth-luogo, .punti-slide { display: none; }
  #nome-livello { max-width: 80px; overflow: hidden; text-overflow: ellipsis; }
  .menu-modelli { width: min(320px, calc(100vw - 40px)); }
}
@media (max-width: 430px) {
  .indicatore-crediti { display: none; }
  #btn-detta { margin-left: auto; }
  .orb { width: 160px; height: 160px; }
  .voce-comandi { gap: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* =============================================================
   Rifiniture (ottobre 2026): ragionamento, risposte a voce, dettagli
   ============================================================= */

/* ---------- ragionamento dell'IA ---------- */
.pensiero { margin: 2px 0 12px; }
.pensiero summary {
  list-style: none; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none;
  font-size: 13.5px; color: var(--testo-2); padding: 4px 10px 4px 8px; margin-left: -8px; border-radius: 8px; transition: background .15s, color .15s;
}
.pensiero summary::-webkit-details-marker { display: none; }
.pensiero summary:hover { background: var(--superficie-2); color: var(--testo); }
.pensiero summary .chevron { width: 14px; height: 14px; transition: transform .2s; }
.pensiero[open] summary .chevron { transform: rotate(90deg); }
.pensiero.attivo .pensiero-titolo, .pensa-testo {
  background: linear-gradient(90deg, var(--testo-3) 0%, var(--testo) 45%, var(--testo-3) 90%);
  background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: scintilla 1.8s linear infinite; font-weight: 500;
}
@keyframes scintilla { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.pensiero-testo {
  margin: 6px 0 2px 2px; padding: 2px 0 2px 16px; border-left: 2px solid var(--bordo-forte);
  color: var(--testo-2); font-size: 14px; line-height: 1.6; max-height: 260px; overflow-y: auto; scrollbar-width: thin;
}
.pensiero.attivo .pensiero-testo { border-left-color: var(--accento); max-height: 180px; mask-image: linear-gradient(transparent 0, #000 28px); -webkit-mask-image: linear-gradient(transparent 0, #000 28px); }
.pensiero-testo p { margin: 0 0 8px; }
.pensiero-testo strong { color: var(--testo); font-weight: 600; }
.pensiero-testo > :last-child { margin-bottom: 0; }
.pensa-testo { display: inline-block; padding: 6px 0; font-size: 14.5px; }

/* ---------- interruttore (Impostazioni → Voce) ---------- */
.interruttore { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; margin-bottom: 16px; }
.interruttore input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.interruttore .levetta {
  position: relative; flex-shrink: 0; width: 40px; height: 24px; border-radius: 999px; margin-top: 1px;
  background: var(--bordo-forte); transition: background .2s;
}
.interruttore .levetta::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s;
}
.interruttore input:checked + .levetta { background: var(--accento); }
.interruttore input:checked + .levetta::after { transform: translateX(16px); }
.interruttore input:focus-visible + .levetta { box-shadow: 0 0 0 3px var(--accento-tenue); }
.interruttore input:disabled + .levetta { opacity: .5; }
.interruttore strong { display: block; font-size: 14px; font-weight: 600; }
.interruttore small { display: block; font-size: 12.5px; color: var(--testo-3); line-height: 1.4; }

/* il microfono ha un puntino quando le risposte a voce sono attive */
#btn-detta { position: relative; }
#btn-detta.con-voce::after {
  content: ""; position: absolute; right: 6px; bottom: 6px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accento); box-shadow: 0 0 0 2px var(--superficie);
}
#btn-detta.registra::after { display: none; }

/* ---------- messaggi più curati ---------- */
.msg.utente .bolla { box-shadow: 0 1px 0 rgba(0,0,0,.03); border: 1px solid color-mix(in srgb, var(--bordo) 60%, transparent); }
.msg.ia .icona-ia { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.messaggi .msg.ia:last-child .azioni-msg { opacity: 1; }
.azioni-msg button.legge { animation: onda-legge 1.4s ease-in-out infinite; }
@keyframes onda-legge { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accento) 18%, transparent); } }
.md pre { box-shadow: 0 4px 18px rgba(0,0,0,.12); }
.md blockquote { background: color-mix(in srgb, var(--accento-tenue) 45%, transparent); border-radius: 0 10px 10px 0; padding: 8px 16px; }
.md li::marker { color: var(--testo-3); }

/* ---------- barra laterale ---------- */
.voce-chat.attiva { position: relative; }
.voce-chat.attiva::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--accento); }
.nuova-chat svg { color: var(--accento); }

/* ---------- riquadro di scrittura ---------- */
.composer { transition: border-color .15s, box-shadow .2s, transform .2s; }
.composer:focus-within { transform: translateY(-1px); }
.invia:not(:disabled):not(.stop) { box-shadow: 0 4px 12px color-mix(in srgb, var(--accento) 35%, transparent); }
.invia.stop { background: var(--testo); color: var(--sfondo); }

/* ---------- torna in fondo ---------- */
.giu {
  position: absolute; left: 50%; bottom: 100%; transform: translate(-50%, -10px); z-index: 5;
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--bordo-forte); display: grid; place-items: center;
  background: var(--superficie); color: var(--testo-2); box-shadow: var(--ombra); transition: opacity .2s, transform .2s;
}
.giu:hover { color: var(--testo); }
.giu.nascosto { opacity: 0; pointer-events: none; transform: translate(-50%, 0); }
.giu svg { width: 18px; height: 18px; }
.composer-wrap { position: relative; }

/* ---------- accessibilità ---------- */
:focus-visible { outline: 2px solid var(--accento); outline-offset: 2px; }
.composer textarea:focus-visible, .cerca input:focus-visible { outline: none; }
@media (hover: none) { .azioni-msg { opacity: 1; } }
@media (max-width: 760px) { .msg.utente .bolla { max-width: 100%; } }

/* ragionamento in stile "chat moderna": una riga che cambia mentre pensa, si apre con un clic */
.pensiero-tempo { color: var(--testo-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.pensiero:not(.attivo) .pensiero-tempo { display: none; }
.pensiero.vuoto summary { cursor: default; }
.pensiero.vuoto summary .chevron { display: none; }
.pensiero.vuoto summary:hover { background: transparent; }
.pensiero.attivo summary::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--accento-tenue); border-top-color: var(--accento); animation: gira .8s linear infinite;
}
@keyframes gira { to { transform: rotate(360deg); } }
/* mentre pensa basta il contatore accanto al pensiero */
.msg.ia:has(.pensiero.attivo) .stat-msg.live, .msg.ia:has(.pensiero.attivo) .azioni-msg { display: none; }

/* accesso: codice a 6 cifre, recupero password */
.link-piccolo { border: 0; background: transparent; color: var(--accento); font-size: 13.5px; padding: 4px; align-self: center; text-decoration: underline; text-underline-offset: 3px; }
.link-piccolo:hover { color: var(--accento-hover); }
.nota-auth { margin: 0; color: var(--testo-2); font-size: 14.5px; }
.input-codice { font-size: 22px !important; letter-spacing: .35em; text-align: center; }
.avviso-email { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 8px;
  padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--oro) 14%, transparent); font-size: 13.5px; }
