 :root {
  --bg: #1e1e24;
  --bg-sidebar: #17171c;
  --bg-bubble-user: #3a5bd9;
  --bg-bubble-ai: #2b2b34;
  --text: #eaeaef;
  --text-dim: #9a9aa5;
  --border: #2f2f38;
  --accent: #3a5bd9;
}
* { box-sizing: border-box; }
body { margin:0; font-family:-apple-system,"Segoe UI",Roboto,sans-serif; background:var(--bg); color:var(--text); height:100vh; }
.app { display:flex; height:100vh; }
.sidebar { width:260px; background:var(--bg-sidebar); border-right:1px solid var(--border); padding:16px; display:flex; flex-direction:column; gap:10px; }
.btn-nuova-chat { background:var(--accent); color:white; border:none; border-radius:8px; padding:10px 14px; font-size:14px; cursor:pointer; }
.btn-nuova-chat:hover { opacity:.9; }
.recenti-titolo { color:var(--text-dim); font-size:12px; font-weight:600; margin:8px 4px 0; text-transform:uppercase; letter-spacing:.5px; }
.lista-chat { overflow-y:auto; display:flex; flex-direction:column; gap:4px; min-height:0; flex:1; }
.voce-chat { padding:10px 12px; border-radius:8px; cursor:pointer; font-size:13px; color:var(--text-dim); display:flex; justify-content:space-between; align-items:center; gap:8px; }
.voce-chat:hover { background:#24242c; }
.voce-chat.attiva { background:#262f4d; color:var(--text); }
.voce-chat .elimina { opacity:0; color:#d97070; font-size:12px; }
.voce-chat:hover .elimina { opacity:1; }
.upgrade-container { position:relative; margin-top:auto; padding-top:10px; border-top:1px solid var(--border); }
.upgrade-btn { width:100%; display:flex; justify-content:space-between; align-items:center; background:#24242c; color:var(--text); border:1px solid var(--border); border-radius:9px; padding:11px 12px; cursor:pointer; font-size:13px; }
.upgrade-btn:hover { background:#2d2d37; }
.upgrade-freccia { font-size:17px; transition:transform .2s; }
.upgrade-btn.aperto .upgrade-freccia { transform:rotate(180deg); }
.upgrade-menu { display:none; margin-top:8px; padding:14px; background:#22222a; border:1px solid #3a3a45; border-radius:10px; box-shadow:0 8px 25px rgba(0,0,0,.35); }
.upgrade-menu.aperto { display:block; }
.upgrade-header { font-size:15px; font-weight:700; }
.upgrade-price { font-size:25px; font-weight:800; margin:7px 0; }
.upgrade-price span { font-size:12px; color:var(--text-dim); font-weight:400; }
.upgrade-menu ul { list-style:none; padding:0; margin:10px 0 14px; color:var(--text-dim); font-size:12px; line-height:1.8; }
.paypal-btn { display:block; text-align:center; text-decoration:none; background:#ffc439; color:#111; font-weight:700; border-radius:7px; padding:9px 8px; font-size:13px; }
.paypal-btn:hover { filter:brightness(.95); }
#paypal-button-container { margin-top: 4px; min-height: 45px; }
.paypal-error { color: #e86c6c; font-size: 12px; margin: 8px 0 0; line-height: 1.4; }
.paypal-setup-hint { color: var(--text-dim); font-size: 11px; line-height: 1.45; margin: 0; }
.paypal-setup-hint code { background: #2a2a34; padding: 1px 4px; border-radius: 3px; font-size: 10px; }
.premium-badge {
  width: 100%;
  text-align: center;
  background: linear-gradient(135deg, #2a3a5c, #1e2a44);
  color: #8ab4ff;
  border: 1px solid #3a5a8a;
  border-radius: 9px;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* --- Auth / Google --- */
.area-auth {
  margin-bottom: 4px;
}
.google-btn-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 40px;
}
.auth-hint, .auth-hint-lista {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.4;
  margin: 8px 4px;
  text-align: center;
}
.auth-hint code {
  background: #2a2a34;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 10px;
}
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.user-avatar-placeholder {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}
.user-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.user-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-logout {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  text-align: left;
}
.btn-logout:hover {
  color: #e86c6c;
}
.btn-nuova-chat:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.main { flex:1; display:flex; flex-direction:column; min-width:0; }
.messaggi { flex:1; overflow-y:auto; padding:24px; display:flex; flex-direction:column; gap:14px; }
.benvenuto { margin:auto; text-align:center; color:var(--text-dim); }
.msg { max-width:70%; padding:10px 14px; border-radius:12px; line-height:1.45; white-space:pre-wrap; display:flex; flex-direction:column; gap:8px; }
.msg.user { align-self:flex-end; background:var(--bg-bubble-user); color:white; }
.msg.assistant { align-self:flex-start; background:var(--bg-bubble-ai); }
.msg.caricamento { align-self:flex-start; color:var(--text-dim); font-style:italic; }
.form-invio { display:flex; gap:10px; padding:16px; border-top:1px solid var(--border); align-items:flex-end; }
.input-wrapper { position:relative; flex:1; display:flex; align-items:flex-end; background:var(--bg-bubble-ai); border:1px solid var(--border); border-radius:10px; min-width:0; }
.form-invio textarea { flex:1; resize:none; background:transparent; border:none; outline:none; color:var(--text); padding:11px 12px 11px 4px; font-size:14px; font-family:inherit; min-width:0; }
.plus-btn { flex:0 0 38px; width:38px; height:38px; margin:3px; border:none; border-radius:8px; background:transparent; color:var(--text); font-size:25px; line-height:1; cursor:pointer; }
.plus-btn:hover { background:#363640; }
.allega-menu { display:none; position:absolute; left:4px; bottom:48px; background:#292931; border:1px solid #3a3a45; border-radius:9px; padding:5px; box-shadow:0 8px 25px rgba(0,0,0,.35); z-index:10; }
.allega-menu.aperto { display:block; }
.allega-opzione { display:block; white-space:nowrap; padding:9px 12px; border-radius:6px; cursor:pointer; font-size:13px; }
.allega-opzione:hover { background:#383842; }
.file-selezionato { max-width:180px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--text-dim); font-size:12px; padding:0 8px 11px 0; }
.form-invio > button[type="submit"] { background:var(--accent); color:white; border:none; border-radius:8px; padding:0 20px; height:40px; cursor:pointer; font-size:14px; }
.form-invio button:disabled { opacity:.5; cursor:default; }
/* mobile rules moved to end */

/* --- Promo code --- */
.promo-box {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #3a3a45;
}
.promo-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.promo-row {
  display: flex;
  gap: 6px;
}
.promo-input {
  flex: 1;
  min-width: 0;
  background: #1a1a22;
  border: 1px solid #3a3a45;
  border-radius: 6px;
  color: var(--text);
  padding: 7px 9px;
  font-size: 12px;
  font-family: inherit;
}
.promo-input:focus {
  outline: none;
  border-color: var(--accent);
}
.promo-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.promo-btn:hover { opacity: 0.9; }
.promo-btn:disabled { opacity: 0.5; cursor: default; }
.promo-msg {
  font-size: 11px;
  margin: 6px 0 0;
  line-height: 1.3;
}
.promo-msg.ok { color: #6dce8a; }
.promo-msg.err { color: #e86c6c; }

/* --- Model selector bar (Premium) --- */
.model-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: #1a1a22;
  flex-shrink: 0;
}
.model-bar-label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
}
.model-options {
  display: flex;
  gap: 6px;
}
.model-opt {
  background: #24242c;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.model-opt:hover {
  background: #2d2d37;
  color: var(--text);
}
.model-opt.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 600;
}
.model-hint {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-dim);
}

/* --- Immagini generate --- */
.msg-immagine-wrap {
  margin-top: 8px;
}
.msg-immagine {
  display: block;
  max-width: min(100%, 360px);
  max-height: 360px;
  border-radius: 10px;
  cursor: pointer;
  background: #1a1a22;
  object-fit: contain;
}
.msg-immagine:hover {
  opacity: 0.92;
}
.msg-immagine-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}
.msg-testo {
  white-space: pre-wrap;
}

.msg-immagine-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 80px;
  padding: 16px 18px;
  background: #1a1a22;
  border: 1px dashed #3a3a45;
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
}
.msg-immagine-loading.errore {
  color: #e86c6c;
  font-style: normal;
  border-color: #5a3030;
}

.contatore-msg {
  text-align: right;
  font-size: 11px;
  color: var(--text-dim);
  padding: 0 20px 4px;
}

/* --- Popup / modal --- */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: none; /* nascosto di default - evita di bloccare i click */
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  backdrop-filter: blur(3px);
  pointer-events: none;
}
.popup-overlay.aperto {
  display: flex;
  pointer-events: auto;
}
.popup-box {
  position: relative;
  background: #22222a;
  border: 1px solid #3a3a45;
  border-radius: 14px;
  padding: 28px 24px 22px;
  max-width: min(400px, calc(100vw - 32px));
  width: 100%;
  max-height: min(90dvh, calc(100vh - 32px));
  overflow-x: hidden;
  overflow-y: auto;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5);
  text-align: center;
  -webkit-overflow-scrolling: touch;
}
.popup-box-upgrade {
  max-width: min(440px, calc(100vw - 32px));
  text-align: left;
}

/* Impostazioni: si adatta allo spazio disponibile */
#panel-impostazioni.popup-overlay {
  padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}
#panel-impostazioni .popup-box {
  display: flex;
  flex-direction: column;
  width: min(440px, calc(100vw - 24px));
  max-width: min(440px, calc(100vw - 24px));
  max-height: min(92dvh, calc(100vh - 24px));
  padding: 20px 18px 16px;
  text-align: left;
  overflow: hidden; /* scroll solo sul corpo */
}
#panel-impostazioni .popup-titolo {
  flex-shrink: 0;
  margin: 0 28px 8px 0;
  font-size: clamp(17px, 2.5vw, 20px);
}
#panel-impostazioni .imp-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
  margin-right: -2px;
}
#panel-impostazioni .imp-footer {
  flex-shrink: 0;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  background: #22222a;
}
#panel-impostazioni .imp-riga {
  padding: clamp(8px, 1.5vh, 12px) 0;
  gap: clamp(8px, 2vw, 14px);
}
#panel-impostazioni .imp-label {
  font-size: clamp(13px, 2.2vw, 14px);
}
#panel-impostazioni .imp-desc {
  font-size: clamp(11px, 1.9vw, 12px);
  line-height: 1.4;
}
#panel-impostazioni .promo-box {
  margin-top: clamp(10px, 2vh, 18px);
}
#panel-impostazioni .popup-btn-primario {
  margin-top: 0;
}
@media (max-height: 560px) {
  #panel-impostazioni .popup-box {
    max-height: calc(100dvh - 16px);
    padding: 14px 14px 12px;
  }
  #panel-impostazioni .imp-desc {
    font-size: 11px;
  }
  #panel-impostazioni .imp-riga {
    padding: 8px 0;
  }
}
@media (max-width: 420px) {
  #panel-impostazioni .popup-box {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    border-radius: 12px;
  }
  #panel-impostazioni.popup-overlay {
    align-items: flex-end;
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  }
}
@media (min-width: 900px) and (min-height: 700px) {
  #panel-impostazioni .popup-box {
    width: min(480px, 42vw);
    max-width: min(480px, 42vw);
    max-height: min(85vh, 720px);
  }
}
.popup-chiudi {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
}
.popup-chiudi:hover { color: var(--text); }
.popup-icona {
  font-size: 36px;
  margin-bottom: 8px;
}
.popup-titolo {
  margin: 0 0 10px;
  font-size: 20px;
  font-weight: 700;
}
.popup-testo {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.45;
  margin: 0 0 8px;
}
.popup-orario {
  font-size: 15px;
  margin: 12px 0 20px;
  color: var(--text);
}
.popup-orario strong {
  color: #8ab4ff;
  font-size: 18px;
}
.popup-countdown {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}
.popup-azioni {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.popup-btn-primario {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 9px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.popup-btn-primario:hover { opacity: 0.92; }
.popup-btn-secondario {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 16px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.popup-btn-secondario:hover {
  background: #2a2a34;
  color: var(--text);
}
.popup-price {
  font-size: 28px;
  font-weight: 800;
  margin: 4px 0 12px;
}
.popup-price span {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 400;
}
.popup-lista {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.85;
}




/* --- Timer Premium dentro la barra messaggio (lato destro) --- */
.premium-timer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-shrink: 0;
  align-self: center;
  margin: 0 8px 0 4px;
  background: linear-gradient(135deg, #2a3a5c, #1e2a44);
  border: 1px solid #3a5a8a;
  color: #8ab4ff;
  border-radius: 8px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  height: 28px;
}
.premium-timer-icon {
  font-size: 11px;
}
.premium-timer.scadendo {
  border-color: #a67c00;
  color: #ffd27a;
  background: linear-gradient(135deg, #3a3220, #2a2418);
}
.premium-timer.scaduto {
  border-color: #5a3030;
  color: #e86c6c;
  background: #2a1a1a;
}

/* --- Impostazioni --- */
.btn-impostazioni {
  width: 100%;
  background: #24242c;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.btn-impostazioni:hover {
  background: #2d2d37;
  color: var(--text);
}
.imp-riga {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.imp-testo { flex: 1; min-width: 0; }
.imp-label {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}
.imp-desc {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
}
.imp-stato {
  font-size: 12px;
  margin: 8px 0 0;
  color: #6dce8a;
}

/* Toggle switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  margin-top: 2px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #3a3a45;
  border-radius: 24px;
  transition: 0.2s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.2s;
}
.switch input:checked + .slider {
  background: var(--accent);
}
.switch input:checked + .slider:before {
  transform: translateX(20px);
}

.imp-badge-pro {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: #ffd27a;
  background: #3a3220;
  border: 1px solid #a67c00;
  border-radius: 4px;
  padding: 1px 5px;
  vertical-align: middle;
  margin-left: 4px;
}
.imp-lock-msg {
  font-size: 12px;
  color: #e8c86a;
  margin-top: 6px;
  line-height: 1.35;
}
.switch.disabilitato {
  opacity: 0.45;
  pointer-events: none;
}
.switch.disabilitato .slider {
  cursor: not-allowed;
}

.model-opt.disabilitato,
.model-opt:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  text-decoration: line-through;
}

/* --- Banner upgrade (risposta debole) --- */
.banner-upgrade {
  position: relative;
  margin: 0 16px 8px;
  background: linear-gradient(90deg, #1e2a44 0%, #2a3a5c 50%, #243048 100%);
  border: 1px solid #3a5a8a;
  border-radius: 12px;
  padding: 12px 36px 12px 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,.25);
  animation: bannerSlide 0.25s ease-out;
}
@keyframes bannerSlide {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.banner-upgrade-x {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
}
.banner-upgrade-x:hover { color: var(--text); }
.banner-upgrade-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}
.banner-upgrade-testo {
  flex: 1;
  min-width: 200px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
}
.banner-upgrade-testo strong { color: #8ab4ff; }
.banner-upgrade-offerta {
  display: block;
  margin-top: 4px;
  color: #ffd27a;
  font-size: 12px;
}
.banner-upgrade-azioni {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.banner-btn-prova {
  background: #2d6a4f;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.banner-btn-prova:hover { background: #1b4332; }
.banner-btn-upgrade {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.banner-btn-upgrade:hover { opacity: 0.92; }

/* --- Login QR --- */
.btn-login-qr {
  width: 100%;
  margin-top: 10px;
  background: #24242c;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.btn-login-qr:hover {
  background: #2d2d37;
}
.qr-login-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 999;
}
.qr-login-panel {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  margin-top: 0;
  padding: 20px;
  background: #1a1a22;
  border: 1px solid var(--border);
  border-radius: 14px;
  text-align: center;
  width: 260px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.qr-login-titolo {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.qr-login-canvas {
  display: flex;
  justify-content: center;
  background: #fff;
  border-radius: 8px;
  padding: 10px;
  margin: 0 auto 8px;
  width: fit-content;
  max-width: 100%;
}
.qr-login-canvas img,
.qr-login-canvas canvas {
  display: block;
  max-width: 180px;
  height: auto;
}
.qr-login-stato {
  font-size: 12px;
  color: var(--text-dim);
  margin: 6px 0;
}
.qr-login-stato.ok { color: #6dce8a; }
.qr-login-stato.err { color: #e86c6c; }
.btn-qr-chiudi {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.btn-qr-chiudi:hover {
  color: var(--text);
  background: #2a2a34;
}


/* --- Azioni sotto messaggio assistente --- */
.msg-azioni {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.msg-azione {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.3;
}
.msg-azione:hover {
  color: var(--text);
  background: #2a2a34;
  border-color: #4a4a55;
}
/* azioni user gestite da .msg-azioni-user */

/* La barra modelli viene nascosta via JS nelle modalità PRO speciali */

/* Link nei messaggi */
.msg-link {
  color: #8ab4ff;
  text-decoration: underline;
  word-break: break-all;
}
.msg-link:hover {
  color: #b3d0ff;
}
.msg.user .msg-link {
  color: #e8f0ff;
}

/* Azioni anche sui messaggi utente */
.msg.user .msg-azioni-user {
  display: flex;
  justify-content: flex-end;
  opacity: 0.55;
}
.msg.user:hover .msg-azioni-user {
  opacity: 1;
}

/* Editor modifica messaggio */
.msg-edit-area {
  width: 100%;
  min-height: 60px;
  resize: vertical;
  background: #1a1a22;
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  box-sizing: border-box;
}
.msg-edit-bar {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-end;
}
.msg-edit-salva {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: transparent !important;
}

/* Miscuglio model button */
#mod-miscuglio.active {
  background: linear-gradient(135deg, #5c4dff, #7c5cff);
  border-color: transparent;
  color: #fff;
}


/* Badge "Novità" su Miscuglio (stabile, no layout shift) */
.model-opt-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.novita-bubble {
  position: absolute;
  top: -9px;
  right: -8px;
  background: linear-gradient(135deg, #7c5cff, #5c4dff);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(92, 77, 255, 0.35);
  z-index: 6;
  pointer-events: auto;
  cursor: pointer;
  line-height: 1.2;
}
.novita-bubble::before { display: none; }
.novita-bubble.nascosta {
  display: none !important;
}
.model-bar:has(.novita-bubble:not(.nascosta)) {
  margin-bottom: 0;
  overflow: visible;
}

/* ===== Pannello Admin ===== */
.btn-admin-panel {
  background: linear-gradient(135deg, #2a2a3a, #3d2a5c);
  color: #e8e0ff;
  border: 1px solid #6b55ff;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-admin-panel:hover { filter: brightness(1.12); }
.admin-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 9990;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.admin-overlay.aperto {
  display: flex !important;
  pointer-events: auto !important;
}
.admin-panel {
  background: #16161e;
  border: 1px solid #333;
  border-radius: 14px;
  width: min(720px, 100%);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #2a2a35;
}
.admin-header h3 { margin: 0; font-size: 16px; }
.admin-chiudi {
  background: transparent;
  border: none;
  color: #aaa;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}
.admin-toolbar {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
}
.admin-cerca {
  flex: 1;
  background: #1a1a22;
  border: 1px solid #333;
  color: #eee;
  border-radius: 8px;
  padding: 8px 10px;
}
.admin-lista {
  overflow-y: auto;
  padding: 8px 12px 16px;
  flex: 1;
}
.admin-user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
}
.admin-user-row:hover { background: #1e1e28; border-color: #333; }
.admin-user-av {
  width: 36px; height: 36px; border-radius: 50%;
  background: #333; object-fit: cover;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: #ccc; flex-shrink: 0;
}
.admin-user-meta { flex: 1; min-width: 0; }
.admin-user-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-user-email { font-size: 12px; color: #888; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.admin-dot.on { background: #3ddc84; box-shadow: 0 0 8px #3ddc84aa; }
.admin-dot.off { background: #555; }
.admin-badge {
  font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 6px;
  text-transform: uppercase;
}
.admin-badge.ban { background: #5c1a1a; color: #ff8a8a; }
.admin-badge.sosp { background: #5c4a1a; color: #ffd48a; }
.admin-badge.adm { background: #2a1a5c; color: #c9b6ff; }
.admin-msg-popup {
  background: #16161e;
  border: 1px solid #444;
  border-radius: 14px;
  width: min(440px, 100%);
  padding: 0 0 16px;
  max-height: 90vh;
  overflow-y: auto;
}
.admin-msg-body {
  padding: 12px 16px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.admin-msg-item {
  background: #1e1e28;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-left: 3px solid #6b55ff;
}
.admin-msg-item .meta { font-size: 11px; color: #888; margin-bottom: 4px; }
.admin-textarea {
  width: 100%;
  box-sizing: border-box;
  margin-top: 8px;
  background: #1a1a22;
  border: 1px solid #333;
  color: #eee;
  border-radius: 8px;
  padding: 10px;
  font-family: inherit;
  resize: vertical;
}
.admin-azione-info {
  padding: 8px 16px 0;
  font-size: 13px;
  color: #bbb;
}
.admin-azioni-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px 0;
  align-items: center;
}
.admin-hr {
  border: none;
  border-top: 1px solid #2a2a35;
  margin: 14px 16px;
}
.admin-btn-sec, .admin-btn-warn, .admin-btn-danger {
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.admin-btn-sec { background: #2a2a35; color: #ddd; }
.admin-btn-warn { background: #6b4e12; color: #ffe6a8; }
.admin-btn-danger { background: #6b1a1a; color: #ffb0b0; }
.admin-chat-view {
  margin: 12px 16px 0;
  max-height: 240px;
  overflow-y: auto;
  background: #121218;
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
}
.admin-chat-view .c-msg { margin: 6px 0; padding: 6px 8px; border-radius: 6px; }
.admin-chat-view .c-user { background: #1a2740; }
.admin-chat-view .c-ai { background: #1e1e28; }

/* close buttons force */
.popup-chiudi,
.admin-chiudi {
  position: relative;
  z-index: 5;
  pointer-events: auto !important;
  cursor: pointer;
  min-width: 36px;
  min-height: 36px;
}
.popup-overlay.aperto {
  display: flex !important;
  pointer-events: auto !important;
}

/* Blocco ban / sospensione */
.blocco-overlay {
  position: fixed;
  inset: 0;
  z-index: 20000;
  background: rgba(8, 8, 12, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.blocco-logout {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 20001;
  background: transparent;
  border: 1px solid #555;
  color: #ccc;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.blocco-logout:hover {
  background: #2a2a35;
  color: #fff;
}
.blocco-box {
  max-width: 420px;
  text-align: center;
  background: #16161e;
  border: 1px solid #333;
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}
.blocco-icon { font-size: 42px; margin-bottom: 10px; }
.blocco-titolo { margin: 0 0 12px; font-size: 22px; }
.blocco-msg { color: #ddd; line-height: 1.5; margin: 0 0 12px; font-size: 15px; }
.blocco-hint { color: #888; font-size: 13px; margin: 0; }

.blocco-logout {
  pointer-events: auto !important;
  z-index: 20002 !important;
}
.blocco-logout-main {
  margin-top: 18px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  background: #3b82f6;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  pointer-events: auto !important;
}
.blocco-logout-main:hover { filter: brightness(1.1); }
.blocco-overlay { pointer-events: auto !important; }

.model-pro-badge {
  position: absolute;
  top: -8px;
  right: -6px;
  background: #7c3aed;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 6px;
  letter-spacing: 0.04em;
}
.model-opt.disabilitato {
  opacity: 0.45;
  cursor: not-allowed;
}




/* ===== Annuncio app Android ===== */
.android-app-banner {
  display: none;
}

/* ===== MOBILE DESIGN ===== */
.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
  position: sticky;
  top: 0;
  z-index: 50;
}
.mobile-topbar-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.2px;
}
.mobile-menu-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #22222a;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.mobile-menu-btn:active { transform: scale(0.96); }
.mobile-menu-ghost { background: transparent; }
.mobile-topbar-spacer { width: 40px; height: 40px; flex-shrink: 0; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 90;
}

@media (max-width: 768px) {
  html, body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
  }
  .app {
    height: 100%;
    height: 100dvh;
    position: relative;
  }

  .mobile-topbar { display: flex; }

  /* Annuncio app Android */
  .android-app-banner {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 7px 10px 0;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--bg-sidebar);
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    flex-shrink: 0;
  }
  .android-app-banner-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #22222a;
    font-size: 18px;
    flex-shrink: 0;
  }
  .android-app-banner-content {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .android-app-banner-content strong {
    font-size: 12px;
    line-height: 1.2;
  }
  .android-app-banner-content span {
    font-size: 10px;
    opacity: .72;
    line-height: 1.25;
  }
  .android-app-banner-btn {
    text-decoration: none;
    white-space: nowrap;
    padding: 8px 10px;
    border-radius: 9px;
    background: #3ddc84;
    color: #071b10;
    font-size: 11px;
    font-weight: 800;
    flex-shrink: 0;
  }
  .android-app-banner-btn:active {
    transform: scale(.97);
  }
  .android-app-banner-close {
    border: 0;
    background: transparent;
    color: var(--text);
    opacity: .6;
    font-size: 19px;
    line-height: 1;
    padding: 2px;
    cursor: pointer;
    flex-shrink: 0;
  }
  .android-app-banner-close:hover {
    opacity: 1;
  }


  /* Sidebar come drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(86vw, 320px);
    max-width: 320px;
    z-index: 100;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    box-shadow: 8px 0 30px rgba(0,0,0,0.35);
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }
  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .main {
    width: 100%;
    min-width: 0;
    height: 100%;
    height: 100dvh;
  }

  .messaggi {
    padding: 12px 12px 8px;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .msg {
    max-width: 92%;
    font-size: 14px;
  }
  .msg img, .msg video {
    max-width: 100%;
    height: auto;
  }

  /* Barra modelli scrollabile */
  .model-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    padding: 8px 10px;
    -webkit-overflow-scrolling: touch;
  }
  .model-bar-label { display: none; }
  .model-options {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
  }
  .model-opt {
    white-space: nowrap;
    font-size: 12px;
    padding: 7px 10px;
  }
  .model-hint {
    display: none;
  }
  /* novità mobile */
  .novita-bubble {
    top: -7px;
    right: -6px;
    font-size: 8px;
    padding: 2px 5px;
  }
  .model-opt-wrap {
    margin-right: 4px;
  }
  .model-bar {
    overflow-x: auto;
    overflow-y: visible;
    padding-top: 12px;
  }


  /* Composer fisso in basso */
  .form-invio {
    padding: 10px 10px max(10px, env(safe-area-inset-bottom));
    gap: 8px;
    background: var(--bg);
  }
  .input-wrapper {
    min-height: 44px;
  }
  .form-invio textarea {
    font-size: 16px; /* evita zoom iOS */
    padding: 10px 8px;
  }
  .form-invio > button[type="submit"] {
    height: 44px;
    padding: 0 14px;
    border-radius: 10px;
    flex-shrink: 0;
  }
  .plus-btn {
    width: 36px;
    height: 36px;
  }

  /* Auth / Google */
  .g_id_signin, .auth-box {
    max-width: 100%;
  }

  /* Popup full-ish width */
  .popup-box,
  .popup-box-upgrade,
  .admin-panel,
  .admin-msg-popup {
    width: calc(100vw - 24px) !important;
    max-width: 100% !important;
    max-height: min(88dvh, 640px);
    margin: 0 12px;
  }
  .popup-overlay,
  .admin-overlay {
    padding: 12px;
    align-items: flex-end;
  }
  @media (min-height: 600px) {
    .popup-overlay,
    .admin-overlay {
      align-items: center;
    }
  }

  .banner-upgrade {
    left: 8px;
    right: 8px;
    bottom: max(72px, env(safe-area-inset-bottom));
  }

  .contatore-msg {
    font-size: 12px;
    padding: 4px 10px;
  }

  .premium-timer {
    font-size: 11px;
  }

  /* Nascondi elementi poco utili su mobile stretti */
  .btn-impostazioni {
    font-size: 13px;
  }
  .voce-chat .elimina {
    opacity: 1;
  }

  .blocco-logout {
    top: max(12px, env(safe-area-inset-top));
    right: 12px;
  }
}

/* telefoni molto stretti */
@media (max-width: 380px) {
  .model-opt { padding: 6px 8px; font-size: 11px; }
  .form-invio > button[type="submit"] { padding: 0 12px; font-size: 13px; }
}


/* Video generato in chat */
.msg-video-wrap {
  margin-top: 8px;
  max-width: min(100%, 420px);
}
.msg-video {
  width: 100%;
  border-radius: 12px;
  background: #000;
  display: block;
}

/* QR: solo computer, nascosto su telefono */
@media (max-width: 768px) {
  .desktop-only-qr,
  #btn-login-qr,
  #qr-login-panel,
  #qr-login-backdrop {
    display: none !important;
  }
}

/* Home: scegli modello (Flash Base rimosso) */
.scegli-modello-box {
  margin-top: 18px;
  padding: 18px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #1a1a22;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}
.scegli-modello-titolo {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 8px;
}
.scegli-modello-sub {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0 0 14px;
  line-height: 1.45;
}
.scegli-modello-azioni {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.scegli-mod-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.scegli-mod-btn:hover { filter: brightness(1.08); }
.msg.caricamento .msg-testo {
  color: var(--text-dim);
  font-style: italic;
  min-height: 1.2em;
}
#mod-base { display: none !important; }

.msg-tempo-lavoro {
  margin-top: 6px;
  font-size: 12px;
  color: #8b8b9a;
  font-weight: 500;
  letter-spacing: 0.01em;
  user-select: none;
}
.msg.assistant .msg-tempo-lavoro {
  opacity: 0.85;
}

.model-hint-badge {
  position: absolute;
  top: -8px;
  right: -10px;
  background: #0d9488;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  pointer-events: none;
}
#wrap-approssimato {
  position: relative;
  display: inline-flex;
  align-items: center;
}
@media (max-width: 768px) {
  .model-hint-badge {
    top: -6px;
    right: -6px;
    font-size: 8px;
    padding: 1px 4px;
  }
  /* Operator solo desktop: su mobile nascondi selettore e badge */
  #wrap-operator,
  #mod-operator,
  #operator-badge,
  .scegli-mod-btn[data-pick="operator"] {
    display: none !important;
  }
}


/* ========== T-Operator workspace ========== */
.t-op-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: #0b0b12;
  display: flex;
  flex-direction: column;
}
.t-op-overlay[hidden] { display: none !important; }

.t-op-intro {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #1a1440 0%, #0b0b12 70%);
  z-index: 2;
  transition: opacity 0.6s ease, visibility 0.6s;
}
.t-op-intro.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.t-op-intro-inner { text-align: center; padding: 24px; max-width: 480px; }
.t-op-logo-pulse {
  width: 72px; height: 72px; margin: 0 auto 20px;
  border-radius: 20px;
  background: linear-gradient(135deg, #6366f1, #22d3ee);
  color: #fff; font-size: 36px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  animation: t-op-pulse 1.2s ease-in-out infinite;
  box-shadow: 0 0 40px rgba(99,102,241,0.5);
}
@keyframes t-op-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 30px rgba(99,102,241,0.4); }
  50% { transform: scale(1.06); box-shadow: 0 0 50px rgba(34,211,238,0.55); }
}
.t-op-intro-title {
  color: #f1f1f5; font-size: 28px; font-weight: 700; margin: 0 0 10px;
}
.t-op-intro-title span {
  background: linear-gradient(90deg, #818cf8, #22d3ee);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.t-op-intro-sub { color: #9ca3af; font-size: 15px; line-height: 1.5; margin: 0 0 28px; }
.t-op-intro-bar {
  height: 4px; background: #1f2937; border-radius: 4px; overflow: hidden;
}
.t-op-intro-bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #6366f1, #22d3ee);
  animation: t-op-load 3s linear forwards;
}
@keyframes t-op-load { to { width: 100%; } }

.t-op-workspace {
  flex: 1; display: flex; flex-direction: column; min-height: 0;
}
.t-op-workspace[hidden] { display: none !important; }

.t-op-topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; background: #12121a; border-bottom: 1px solid #2a2a36;
}
.t-op-brand {
  font-weight: 700; color: #a5b4fc; font-size: 14px; white-space: nowrap;
}
.t-op-address {
  flex: 1; display: flex; align-items: center; gap: 6px;
  background: #1a1a24; border: 1px solid #2f2f3c; border-radius: 10px;
  padding: 4px 10px;
}
.t-op-url {
  flex: 1; background: transparent; border: none; color: #d1d5db;
  font-size: 13px; outline: none; min-width: 0;
}
.t-op-top-actions { display: flex; gap: 8px; align-items: center; }
.t-op-btn-takeover {
  background: #22c55e; color: #052e16; border: none; border-radius: 10px;
  padding: 8px 14px; font-weight: 700; font-size: 13px; cursor: pointer;
}
.t-op-btn-takeover:disabled {
  background: #374151; color: #9ca3af; cursor: not-allowed;
}
.t-op-btn-takeover.ready {
  animation: t-op-pulse 1.5s ease-in-out infinite;
}
.t-op-btn-close {
  background: transparent; border: none; color: #9ca3af;
  font-size: 24px; line-height: 1; cursor: pointer; padding: 0 6px;
}
.t-op-btn-close:hover { color: #fff; }

.t-op-body {
  flex: 1; display: grid; grid-template-columns: minmax(280px, 340px) 1fr;
  min-height: 0;
}
@media (max-width: 800px) {
  .t-op-body { grid-template-columns: 1fr; grid-template-rows: 40% 60%; }
}

.t-op-chat {
  display: flex; flex-direction: column; border-right: 1px solid #2a2a36;
  background: #0f0f16; min-height: 0;
}
.t-op-chat-title {
  padding: 12px 14px; font-size: 13px; font-weight: 600; color: #a5b4fc;
  border-bottom: 1px solid #2a2a36;
}
.t-op-messages {
  flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px;
}
.t-op-msg {
  padding: 10px 12px; border-radius: 12px; font-size: 13px; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
}
.t-op-msg.user {
  background: #3730a3; color: #e0e7ff; align-self: flex-end; max-width: 92%;
}
.t-op-msg.bot {
  background: #1a1a24; color: #e5e7eb; align-self: flex-start; max-width: 95%;
  border: 1px solid #2a2a36;
}
.t-op-msg.bot a { color: #67e8f9; }
.t-op-form {
  display: flex; gap: 8px; padding: 10px; border-top: 1px solid #2a2a36;
}
.t-op-form input {
  flex: 1; background: #1a1a24; border: 1px solid #2f2f3c; border-radius: 10px;
  color: #fff; padding: 10px 12px; font-size: 13px; outline: none;
}
.t-op-form button {
  background: #6366f1; color: #fff; border: none; border-radius: 10px;
  padding: 0 16px; font-weight: 600; cursor: pointer;
}

.t-op-browser {
  display: flex; flex-direction: column; min-height: 0; background: #111;
}
.t-op-steps {
  max-height: 120px; overflow-y: auto; padding: 8px 12px;
  background: #12121a; border-bottom: 1px solid #2a2a36;
  font-size: 12px; color: #9ca3af;
}
.t-op-steps li { margin: 2px 0; }
.t-op-steps .done { color: #86efac; }
.t-op-steps .running {
  color: #fde68a;
  font-weight: 600;
  position: relative;
  padding-left: 2px;
}
.t-op-steps .running::before {
  content: "▶ ";
  color: #22d3ee;
  animation: t-op-step-pulse 0.75s ease-in-out infinite;
}
@keyframes t-op-step-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}
.t-op-steps li {
  transition: color 0.2s ease;
}
.t-op-frame-wrap {
  flex: 1; position: relative; min-height: 0; background: #fff;
}
.t-op-frame {
  width: 100%; height: 100%; border: none; background: #fff;
  pointer-events: none; /* bloccato finché non prendi il controllo / youtube */
  position: relative;
  z-index: 1;
}
.t-op-frame.controllabile {
  pointer-events: auto !important;
  z-index: 6;
}
.t-op-frame-wrap.interattivo .t-op-frame {
  pointer-events: auto !important;
  z-index: 6;
}
.t-op-frame-wrap.interattivo .t-op-shield,
.t-op-frame-wrap.interattivo .t-op-cursor {
  display: none !important;
}
.t-op-frame-wrap.interattivo .t-op-shot {
  z-index: 6;
  pointer-events: auto !important;
  object-fit: fill !important;
  cursor: crosshair;
}
.t-op-shield {
  position: absolute; inset: 0;
  background: rgba(11,11,18,0.25);
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 20px; pointer-events: none;
  transition: opacity 0.3s;
}
.t-op-shield span {
  background: rgba(15,15,22,0.85); color: #e5e7eb;
  padding: 8px 14px; border-radius: 999px; font-size: 12px;
}
.t-op-shield.nascondi { opacity: 0; visibility: hidden; }
.t-op-cursor {
  position: absolute; width: 18px; height: 18px;
  border-radius: 50% 50% 50% 0; background: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.35);
  transform: rotate(-15deg);
  top: 40%; left: 45%;
  transition: top 0.8s ease, left 0.8s ease;
  pointer-events: none; z-index: 5;
  opacity: 0.9;
}
.t-op-cursor.off { display: none; }

.t-op-shot {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: top center;
  z-index: 4;
  pointer-events: auto;
  background: #fff;
  z-index: 1;
}

/* T-Operator: browser a schermo intero dopo Prendi il controllo */
.t-op-overlay.t-op-fullscreen .t-op-chat {
  display: none !important;
}
.t-op-overlay.t-op-fullscreen .t-op-body {
  grid-template-columns: 1fr !important;
}
.t-op-overlay.t-op-fullscreen .t-op-steps {
  display: none;
}
.t-op-overlay.t-op-fullscreen .t-op-frame-wrap {
  min-height: calc(100vh - 52px);
}
.t-op-exit-fs {
  position: fixed;
  top: 12px;
  right: 14px;
  z-index: 10050;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(15,15,22,0.85);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.t-op-exit-fs:hover { background: #ef4444; }
.t-op-cursor.off { display: none !important; opacity: 0 !important; }

.t-op-overlay.t-op-fullscreen .t-op-browser {
  min-height: calc(100vh - 52px);
  height: calc(100vh - 52px);
}
.t-op-overlay.t-op-fullscreen .t-op-frame-wrap {
  flex: 1;
  height: 100%;
  min-height: calc(100vh - 52px);
}
.t-op-overlay.t-op-fullscreen .t-op-frame.controllabile {
  pointer-events: auto !important;
  z-index: 6;
}


/* ===== T-Operator cinematic intro ===== */
.t-op-intro.t-op-cinema {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.t-op-stars {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}
.t-op-cine-scene {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  padding: 24px;
  transition: opacity 0.7s ease, transform 0.7s ease;
  transform: scale(0.96);
}
.t-op-cine-scene.active {
  opacity: 1;
  transform: scale(1);
}
.t-op-cine-logo {
  max-width: min(520px, 78vw);
  width: 100%;
  height: auto;
  filter: drop-shadow(0 0 40px rgba(99,102,241,0.55)) saturate(1.15) contrast(1.05);
  animation: t-op-cine-float 3s ease-in-out infinite;
}
@keyframes t-op-cine-float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-10px) scale(1.02); }
}
.t-op-cine-badge {
  width: 88px; height: 88px;
  border-radius: 22px;
  background: linear-gradient(135deg, #6366f1, #22d3ee);
  color: #fff;
  font-size: 44px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 60px rgba(99,102,241,0.65), 0 0 120px rgba(34,211,238,0.35);
  margin-bottom: 22px;
  animation: t-op-pulse 2s ease-in-out infinite;
}
.t-op-cine-title {
  margin: 0;
  font-size: clamp(36px, 8vw, 72px);
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow: 0 0 24px rgba(129,140,248,0.8), 0 0 60px rgba(34,211,238,0.4);
  background: linear-gradient(90deg, #e0e7ff, #67e8f9, #a5b4fc, #e0e7ff);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: t-op-shine 3s linear infinite;
}
@keyframes t-op-shine {
  to { background-position: 200% center; }
}
.t-op-cine-tag {
  margin: 14px 0 0;
  color: #94a3b8;
  font-size: clamp(14px, 2.5vw, 18px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.t-op-cine-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: center;
  max-width: 900px;
}
.t-op-cine-card {
  width: 200px;
  background: rgba(15,15,25,0.85);
  border: 1px solid rgba(99,102,241,0.35);
  border-radius: 18px;
  padding: 22px 16px;
  text-align: center;
  color: #e5e7eb;
  box-shadow: 0 10px 40px rgba(0,0,0,0.45), inset 0 0 30px rgba(99,102,241,0.08);
  transform: translateY(20px);
  opacity: 0;
}
.t-op-cine-scene.active .t-op-cine-card {
  animation: t-op-card-in 0.6s ease forwards;
}
.t-op-cine-scene.active .t-op-cine-card:nth-child(2) { animation-delay: 0.15s; }
.t-op-cine-scene.active .t-op-cine-card:nth-child(3) { animation-delay: 0.3s; }
@keyframes t-op-card-in {
  to { transform: translateY(0); opacity: 1; }
}
.t-op-cine-card-ico { font-size: 28px; display: block; margin-bottom: 8px; }
.t-op-cine-card strong { display: block; font-size: 16px; margin-bottom: 6px; color: #a5b4fc; }
.t-op-cine-card p { margin: 0; font-size: 13px; color: #9ca3af; }
.t-op-cine-ui-wrap {
  position: relative;
  max-width: min(860px, 90vw);
}
.t-op-cine-ui {
  width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 20px 80px rgba(0,0,0,0.6);
  filter: contrast(1.08) saturate(1.1) brightness(1.05);
}
.t-op-cine-ui-glow {
  position: absolute;
  inset: -20%;
  background: radial-gradient(circle, rgba(99,102,241,0.35), transparent 60%);
  z-index: -1;
  pointer-events: none;
}
.t-op-cine-caption {
  margin-top: 18px;
  color: #cbd5e1;
  font-size: 15px;
  letter-spacing: 0.04em;
}
.t-op-cine-studios {
  max-width: min(640px, 88vw);
  filter: drop-shadow(0 0 50px rgba(56,189,248,0.45)) contrast(1.1) saturate(1.15);
}
.t-op-cine-presenta {
  margin: 18px 0 6px;
  color: #64748b;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  font-size: 12px;
}
.t-op-cine-final {
  margin: 0;
  font-size: clamp(28px, 6vw, 48px);
  font-weight: 900;
  letter-spacing: 0.12em;
  color: #e0e7ff;
  text-shadow: 0 0 30px rgba(99,102,241,0.7);
}
.t-op-skip-intro {
  position: absolute;
  bottom: 28px;
  right: 24px;
  z-index: 5;
  background: rgba(15,15,22,0.7);
  border: 1px solid rgba(148,163,184,0.35);
  color: #e2e8f0;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  backdrop-filter: blur(8px);
}
.t-op-skip-intro:hover { background: rgba(99,102,241,0.35); }
.t-op-cine-progress {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: #111;
  z-index: 5;
}
#t-op-cine-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6366f1, #22d3ee);
  transition: width 0.2s linear;
}
.t-op-intro.fade-out {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transition: opacity 0.5s ease, visibility 0.5s;
}
.t-op-intro[hidden],
.t-op-intro.fade-out.done {
  display: none !important;
}

/* Modulo viaggio T-Operator */
.t-op-travel-form {
  margin: 8px 10px 10px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(15,15,28,0.95);
  border: 1px solid rgba(99,102,241,0.35);
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 55%;
  overflow: auto;
}
.t-op-travel-form[hidden] { display: none !important; }
.t-op-tf-title {
  font-weight: 700;
  color: #a5b4fc;
  font-size: 14px;
  margin-bottom: 2px;
}
.t-op-travel-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #94a3b8;
}
.t-op-travel-form input {
  background: #0f0f18;
  border: 1px solid #333;
  border-radius: 8px;
  color: #e5e7eb;
  padding: 8px 10px;
  font-size: 13px;
}
.t-op-tf-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.t-op-tf-row:has(#tf-rooms) {
  grid-template-columns: 1fr 1fr 1fr;
}
.t-op-tf-start {
  margin-top: 4px;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #6366f1, #22d3ee);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.t-op-tf-start:hover { filter: brightness(1.08); }

/* ========== Giochi T-Operator ========== */
.t-op-games {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: radial-gradient(ellipse at top, #1a1a2e 0%, #0d0d14 70%);
  display: flex;
  align-items: stretch;
  justify-content: center;
  overflow: auto;
}
.t-op-games[hidden] { display: none !important; }
.t-op-games-inner {
  position: relative;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 20px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.t-op-games-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  color: #e5e7eb;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  z-index: 2;
}
.t-op-games-close:hover { background: rgba(239,68,68,0.35); }
.t-op-games-title {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(135deg, #a5b4fc, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-align: center;
}
.t-op-games-sub {
  margin: 0 0 22px;
  color: #94a3b8;
  font-size: 14px;
  text-align: center;
}
.t-op-games-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
  max-width: 480px;
}
.t-op-game-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 14px;
  border-radius: 16px;
  border: 1px solid rgba(99,102,241,0.35);
  background: rgba(15,15,28,0.9);
  color: #e5e7eb;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.t-op-game-card:hover {
  transform: translateY(-3px);
  border-color: #6366f1;
  box-shadow: 0 8px 24px rgba(99,102,241,0.25);
}
.t-op-game-ico { font-size: 28px; line-height: 1.2; }
.t-op-game-card strong { font-size: 16px; }
.t-op-game-card span:last-child { font-size: 12px; color: #94a3b8; }

.t-op-games-board {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.t-op-games-board[hidden] { display: none !important; }
.t-op-g-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 420px;
  gap: 10px;
}
.t-op-g-header h3 {
  margin: 0;
  font-size: 18px;
  color: #e5e7eb;
}
.t-op-g-back {
  border: none;
  border-radius: 10px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.08);
  color: #cbd5e1;
  cursor: pointer;
  font-size: 13px;
}
.t-op-g-back:hover { background: rgba(255,255,255,0.14); }
.t-op-g-status {
  font-size: 14px;
  color: #a5b4fc;
  min-height: 22px;
  text-align: center;
}
.t-op-g-status.win { color: #4ade80; }
.t-op-g-status.lose { color: #f87171; }
.t-op-g-status.draw { color: #fbbf24; }

/* Tris */
.tris-board {
  display: grid;
  grid-template-columns: repeat(3, 88px);
  grid-template-rows: repeat(3, 88px);
  gap: 8px;
}
.tris-cell {
  width: 88px;
  height: 88px;
  border: none;
  border-radius: 12px;
  background: rgba(30,30,50,0.95);
  color: #e5e7eb;
  font-size: 36px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.12s;
}
.tris-cell:hover:not(:disabled) { background: rgba(99,102,241,0.25); }
.tris-cell:disabled { cursor: default; opacity: 0.95; }
.tris-cell.x { color: #22d3ee; }
.tris-cell.o { color: #f472b6; }
.tris-cell.win-cell { background: rgba(74,222,128,0.25); box-shadow: 0 0 0 2px #4ade80; }

/* Forza 4 */
.f4-board {
  display: grid;
  grid-template-columns: repeat(7, 48px);
  grid-template-rows: repeat(6, 48px);
  gap: 6px;
  padding: 12px;
  border-radius: 14px;
  background: #1e3a5f;
}
.f4-cell {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #0f172a;
  border: none;
  cursor: pointer;
  padding: 0;
}
.f4-cell.r { background: #ef4444; box-shadow: inset 0 -4px 0 rgba(0,0,0,0.25); }
.f4-cell.y { background: #eab308; box-shadow: inset 0 -4px 0 rgba(0,0,0,0.25); }
.f4-cell:disabled { cursor: default; }

/* Morra */
.morra-choices {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}
.morra-btn {
  width: 100px;
  height: 100px;
  border-radius: 18px;
  border: 1px solid rgba(99,102,241,0.4);
  background: rgba(15,15,28,0.95);
  font-size: 40px;
  cursor: pointer;
  transition: transform 0.12s;
}
.morra-btn:hover { transform: scale(1.06); border-color: #6366f1; }
.morra-result {
  display: flex;
  gap: 28px;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  margin-top: 8px;
}
.morra-score {
  color: #94a3b8;
  font-size: 14px;
}

/* Memory */
.mem-grid {
  display: grid;
  grid-template-columns: repeat(4, 72px);
  gap: 10px;
}
.mem-card {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  border: 1px solid rgba(99,102,241,0.35);
  background: linear-gradient(145deg, #312e81, #1e1b4b);
  color: transparent;
  font-size: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.15s;
}
.mem-card.flipped, .mem-card.matched {
  background: rgba(15,15,28,0.95);
  color: #e5e7eb;
  cursor: default;
}
.mem-card.matched { border-color: #4ade80; opacity: 0.85; }
.mem-card:not(.flipped):not(.matched):hover { transform: scale(1.04); }

.t-op-g-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}
.t-op-g-actions button {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #6366f1, #22d3ee);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
}
.t-op-g-actions button.secondary {
  background: rgba(255,255,255,0.1);
  color: #e5e7eb;
  font-weight: 500;
}

/* Scacchi */
.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 44px);
  grid-template-rows: repeat(8, 44px);
  border: 2px solid #334155;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(0,0,0,0.35);
}
.chess-sq {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  border: none;
  padding: 0;
  position: relative;
}
.chess-sq.light { background: #e8e4d4; }
.chess-sq.dark { background: #6b8f71; }
.chess-sq.selected { box-shadow: inset 0 0 0 3px #fbbf24; }
.chess-sq.legal::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(34, 211, 238, 0.55);
}
.chess-sq.legal.has-piece::after {
  width: 38px;
  height: 38px;
  background: transparent;
  border: 3px solid rgba(239, 68, 68, 0.55);
  border-radius: 50%;
}
.chess-sq.last-from, .chess-sq.last-to {
  background: rgba(250, 204, 21, 0.45) !important;
}
.chess-sq.check {
  box-shadow: inset 0 0 0 3px #ef4444;
  background: rgba(239, 68, 68, 0.35) !important;
}
.chess-meta {
  font-size: 12px;
  color: #94a3b8;
  text-align: center;
}
@media (max-width: 520px) {
  .chess-board {
    grid-template-columns: repeat(8, 36px);
    grid-template-rows: repeat(8, 36px);
  }
  .chess-sq { width: 36px; height: 36px; font-size: 24px; }
}

/* Lettura automatica — evidenziazione parole */
.msg-testo.tts-active {
  line-height: 1.55;
}
.msg-testo .tts-word {
  transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
  border-radius: 3px;
  padding: 0 1px;
}
.msg-testo .tts-word.tts-spoken {
  color: #94a3b8;
}
.msg-testo .tts-word.tts-current {
  background: linear-gradient(135deg, rgba(99,102,241,0.45), rgba(34,211,238,0.35));
  color: #f8fafc;
  box-shadow: 0 0 0 1px rgba(99,102,241,0.5);
  font-weight: 600;
}
.msg.user .msg-testo .tts-word.tts-current {
  background: linear-gradient(135deg, rgba(34,211,238,0.4), rgba(99,102,241,0.35));
}
.tts-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #a5b4fc;
  margin-top: 4px;
  opacity: 0.9;
}
.tts-indicator .tts-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22d3ee;
  animation: tts-pulse 1s ease-in-out infinite;
}
@keyframes tts-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}


/* Markdown leggero nei messaggi */
.msg-testo strong {
  font-weight: 700;
  color: #e2e8f0;
}
.msg.user .msg-testo strong {
  color: #f8fafc;
}
.msg-testo em {
  font-style: italic;
  color: #cbd5e1;
}
.msg-testo {
  white-space: normal; /* usiamo <br> da formattaTestoMessaggio */
  word-break: break-word;
  overflow-wrap: anywhere;
}
.msg-testo a.msg-link {
  color: #7dd3fc;
  text-decoration: underline;
  word-break: break-all;
}

/* Vendita progetto sotto Premium — piccolo testo cliccabile */
.btn-vendita-progetto {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: auto;
  max-width: 100%;
  margin-top: 6px;
  margin-left: 2px;
  padding: 2px 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
  text-align: left;
  transition: color 0.15s;
}
.btn-vendita-progetto:hover {
  color: #fbbf24;
  background: transparent;
  transform: none;
  text-decoration: underline;
}
.btn-vendita-label {
  text-align: left;
  line-height: 1.3;
}
.btn-vendita-prezzo {
  flex-shrink: 0;
  background: transparent;
  color: #a8a29e;
  padding: 0;
  border-radius: 0;
  font-size: 11px;
  font-weight: 600;
}
.btn-vendita-progetto:hover .btn-vendita-prezzo {
  color: #fbbf24;
}
.vendita-lista {
  margin: 10px 0 14px;
  padding-left: 4px;
  list-style: none;
  font-size: 13px;
  color: #cbd5e1;
  line-height: 1.55;
}
.vendita-lista li {
  margin: 4px 0;
}
.vendita-paypal-wrap {
  min-height: 45px;
  margin-top: 6px;
}

/* Operator: riga browser + menu video embed */
.t-op-browser-row {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 0;
  position: relative;
}
.t-op-browser-row .t-op-frame-wrap {
  flex: 1;
  min-width: 0;
}
.t-op-video-menu {
  width: 240px;
  flex-shrink: 0;
  background: #1e293b;
  border-left: 1px solid rgba(148, 163, 184, 0.2);
  padding: 12px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  z-index: 8;
}
.t-op-video-menu[hidden] {
  display: none !important;
}
.t-op-vm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #e2e8f0;
  font-size: 13px;
}
.t-op-vm-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.t-op-vm-close:hover { color: #f8fafc; }
.t-op-vm-hint {
  margin: 0;
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.4;
}
.t-op-vm-label {
  font-size: 11px;
  color: #cbd5e1;
  font-weight: 600;
}
.t-op-vm-embed {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 90px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  line-height: 1.35;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 8px;
  padding: 8px;
}
.t-op-vm-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.t-op-vm-btn {
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: #334155;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.t-op-vm-btn:hover { background: #475569; }
.t-op-vm-btn.primary {
  background: #4f46e5;
  border-color: transparent;
  color: #fff;
}
.t-op-vm-btn.primary:hover { background: #6366f1; }
.t-op-vm-link {
  font-size: 11px;
  color: #7dd3fc;
  text-decoration: none;
  word-break: break-all;
}
.t-op-vm-link:hover { text-decoration: underline; }
.t-op-vm-status {
  margin: 0;
  font-size: 11px;
  color: #4ade80;
}
.allega-opzione-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: inherit;
  font: inherit;
}
@media (max-width: 900px) {
  .t-op-browser-row {
    flex-direction: column;
  }
  .t-op-video-menu {
    width: 100%;
    border-left: none;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    max-height: 200px;
  }
}

.msg-video-embed-wrap {
  margin-top: 6px;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  max-width: 100%;
}
.msg-video-embed {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  max-height: 280px;
}

.t-op-shield-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 420px;
  padding: 8px 12px;
  text-align: center;
}
.t-op-shield-msg {
  line-height: 1.45;
  font-size: 14px;
}
.t-op-shield-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
}
.t-op-shield-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  color: #0f172a;
  background: linear-gradient(180deg, #fde68a, #f59e0b);
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.35);
}
.t-op-shield-btn:hover {
  filter: brightness(1.05);
}
.t-op-shield-link {
  color: #7dd3fc;
  font-size: 13px;
  text-decoration: underline;
}

/* ---- Bottone Voce accanto a Invia ---- */
.form-invio {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.btn-voce {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(56, 189, 248, 0.35);
  background: linear-gradient(180deg, rgba(56,189,248,0.18), rgba(2,136,209,0.12));
  color: #38bdf8;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
}
.btn-voce:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(56,189,248,0.28), rgba(2,136,209,0.2));
  box-shadow: 0 0 16px rgba(56,189,248,0.35);
  transform: translateY(-1px);
}
.btn-voce:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-voce-icon { display: block; }

/* ---- Overlay chiamata vocale ---- */
.tchat-voice {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  flex-direction: column;
  background: #0a0a0c;
  color: #e2e8f0;
  overflow: hidden;
  font-family: Inter, system-ui, sans-serif;
}
.tchat-voice[hidden] { display: none !important; }
.tchat-voice.light {
  background: #f8fafc;
  color: #0f172a;
}
.tv-ambient {
  position: absolute;
  bottom: -8%;
  left: 50%;
  transform: translateX(-50%);
  width: 130%;
  height: 48%;
  background: radial-gradient(ellipse at bottom, rgba(56,189,248,0.45) 0%, rgba(99,102,241,0.25) 45%, rgba(168,85,247,0.12) 70%, transparent 85%);
  filter: blur(65px);
  border-radius: 50% 50% 0 0;
  pointer-events: none;
  transition: all 0.7s ease;
}
.tv-ambient.active {
  height: 58%;
  animation: tvAura 2s ease-in-out infinite alternate;
}
@keyframes tvAura {
  0% { transform: translateX(-50%) scale(0.98); opacity: 0.8; }
  100% { transform: translateX(-50%) scale(1.06); opacity: 1; }
}
.tv-header {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
}
.tv-brand { display: flex; align-items: center; gap: 10px; }
.tv-logo {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(14,165,233,0.2); border: 1px solid rgba(56,189,248,0.35);
  display: flex; align-items: center; justify-content: center; color: #38bdf8; font-size: 14px;
}
.tv-title { font-weight: 600; font-size: 1.15rem; letter-spacing: -0.02em; }
.tv-live {
  font-size: 11px; font-weight: 500; padding: 3px 10px; border-radius: 999px;
  background: #1e1e24; color: #38bdf8; border: 1px solid #2a2a34;
  display: inline-flex; align-items: center; gap: 6px;
}
.tchat-voice.light .tv-live { background: #e2e8f0; color: #0369a1; border-color: #cbd5e1; }
.tv-dot {
  width: 6px; height: 6px; border-radius: 50%; background: #0ea5e9;
  animation: tvPulse 1.2s ease-in-out infinite;
}
@keyframes tvPulse { 50% { opacity: 0.35; } }
.tv-icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid #2a2a34;
  background: #1a1a22; color: #e2e8f0; cursor: pointer; font-size: 16px;
}
.tchat-voice.light .tv-icon-btn { background: #fff; color: #0f172a; border-color: #e2e8f0; }
.tv-main {
  position: relative; z-index: 2; flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 12px 16px; text-align: center;
}
.tv-orb-wrap {
  width: min(280px, 62vw); height: min(280px, 62vw);
  display: flex; align-items: center; justify-content: center;
}
.tv-orb {
  width: 100%; height: 100%; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e0f2fe 0%, #38bdf8 35%, #0288d1 70%, #0f172a 100%);
  box-shadow: 0 0 70px rgba(56,189,248,0.5), inset -12px -12px 28px rgba(2,136,209,0.8), inset 12px 12px 28px rgba(224,242,254,0.7);
  animation: tvMorph 9s ease-in-out infinite alternate, tvGlow 3s ease-in-out infinite alternate;
  filter: blur(0.5px);
}
.tv-orb.active {
  animation: tvMorph 4.5s ease-in-out infinite alternate, tvActive 1.2s ease-in-out infinite alternate;
}
@keyframes tvMorph {
  0% { border-radius: 42% 58% 70% 30% / 45% 45% 55% 55%; transform: rotate(0deg) scale(1); }
  50% { border-radius: 50% 50% 34% 66% / 56% 34% 66% 44%; transform: rotate(180deg) scale(1.04); }
  100% { border-radius: 58% 42% 38% 62% / 42% 58% 42% 58%; transform: rotate(360deg) scale(1); }
}
@keyframes tvGlow {
  0% { box-shadow: 0 0 35px rgba(14,165,233,0.35), inset -10px -10px 20px rgba(3,105,161,0.5); }
  100% { box-shadow: 0 0 65px rgba(14,165,233,0.65), inset -15px -15px 25px rgba(3,105,161,0.8); }
}
@keyframes tvActive {
  0% { transform: scale(0.98); box-shadow: 0 0 50px rgba(56,189,248,0.6); }
  100% { transform: scale(1.12); box-shadow: 0 0 90px rgba(14,165,233,0.9); }
}
.tv-wave {
  display: flex; align-items: center; gap: 6px; height: 40px; margin-top: 20px; opacity: 0.4;
  transition: opacity 0.3s;
}
.tv-wave.active { opacity: 1; }
.tv-wave span {
  width: 4px; border-radius: 999px;
  background: linear-gradient(180deg, #38bdf8, #818cf8);
  animation: tvWave 1.1s ease-in-out infinite alternate;
  height: 10px;
}
.tv-wave span:nth-child(1) { animation-delay: 0.1s; }
.tv-wave span:nth-child(2) { animation-delay: 0.35s; }
.tv-wave span:nth-child(3) { animation-delay: 0.2s; height: 16px; }
.tv-wave span:nth-child(4) { animation-delay: 0.45s; }
.tv-wave span:nth-child(5) { animation-delay: 0.15s; }
@keyframes tvWave {
  0% { height: 8px; opacity: 0.4; }
  100% { height: 36px; opacity: 1; }
}
.tv-status {
  margin-top: 12px; font-size: 14px; color: #94a3b8; font-weight: 500;
}
.tchat-voice.light .tv-status { color: #64748b; }
.tv-transcript {
  margin-top: 16px; max-width: 520px; width: 100%;
  padding: 12px 16px; border-radius: 14px;
  background: rgba(30,41,59,0.75); border: 1px solid rgba(148,163,184,0.2);
  font-size: 14px; line-height: 1.45; text-align: left; color: #e2e8f0;
  max-height: 140px; overflow-y: auto;
}
.tchat-voice.light .tv-transcript {
  background: rgba(255,255,255,0.9); color: #0f172a; border-color: #e2e8f0;
}
.tv-footer {
  position: relative; z-index: 2; padding: 16px 16px 28px;
  display: flex; justify-content: center;
}
.tv-controls {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; border-radius: 999px;
  background: rgba(23,23,28,0.9); border: 1px solid #2a2a34;
  backdrop-filter: blur(16px); box-shadow: 0 12px 40px rgba(0,0,0,0.45);
}
.tchat-voice.light .tv-controls {
  background: rgba(255,255,255,0.95); border-color: #e2e8f0;
}
.tv-ctrl {
  width: 44px; height: 44px; border-radius: 50%; border: none;
  background: #26262e; color: #e2e8f0; cursor: pointer; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.12s, background 0.2s;
}
.tchat-voice.light .tv-ctrl { background: #f1f5f9; color: #0f172a; }
.tv-ctrl:hover { transform: scale(1.05); }
.tv-ctrl.on { background: rgba(14,165,233,0.25); color: #38bdf8; }
.tv-mic {
  width: 56px; height: 56px; background: #0ea5e9; color: #fff;
  box-shadow: 0 8px 24px rgba(14,165,233,0.4); font-size: 22px;
}
.tv-mic.listening { background: #0284c7; }
.tv-end { background: rgba(239,68,68,0.2); color: #f87171; }
@media (max-width: 480px) {
  .tv-ctrl { width: 40px; height: 40px; }
  .tv-mic { width: 52px; height: 52px; }
  .tv-controls { gap: 8px; padding: 10px 14px; }
}


/* Pannello codice con tendina linguaggio */
.code-panel {
  margin: 10px 0;
  border-radius: 12px;
  overflow: hidden;
  background: #0f172a;
  border: 1px solid #334155;
  text-align: left;
}
.code-panel-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
}
.code-lang-label {
  font-size: 11px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.code-lang-select {
  appearance: none;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #475569;
  border-radius: 999px;
  padding: 3px 28px 3px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%94a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.code-copy-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid #475569;
  color: #cbd5e1;
  border-radius: 8px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
}
.code-copy-btn:hover {
  background: #334155;
  color: #fff;
}
.code-pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  color: #e2e8f0;
  white-space: pre;
}
.code-pre code {
  background: transparent;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}
.msg-inline-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: #1e293b;
  color: #7dd3fc;
  padding: 1px 6px;
  border-radius: 6px;
}
.msg.user .msg-inline-code {
  background: rgba(15, 23, 42, 0.35);
  color: #e0f2fe;
}


/* Embed / iframe */
body.embed-mode .sidebar {
  /* opzionale: più compatto in iframe */
}
.btn-login-popup {
  display: block;
  width: 100%;
  max-width: 228px;
  margin-top: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #3b82f6;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.btn-login-popup:hover {
  background: #1d4ed8;
}
