/* Convivio — notte indaco, zafferano per le persone, acquamarina→lilla per le IA. */
:root {
  --night: #14182b; --deep: #0e1120; --surface: #1e2440; --raise: #2a3157; --line: #343c68;
  --ink: #eef0ff; --mute: #9aa1c9;
  --saffron: #ffc24b; --aqua: #6ee7d8; --lilac: #b79cff; --coral: #ff7a6b;
  --ai: conic-gradient(from 210deg, var(--aqua), var(--lilac), #ffd9a0, var(--aqua));
  --font: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", "Nunito", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--deep); color: var(--ink); font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
:focus-visible { outline: 2px solid var(--saffron); outline-offset: 2px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

input, textarea {
  width: 100%; padding: .8rem 1rem; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--deep); outline: 0; transition: border-color .15s;
}
input:focus, textarea:focus { border-color: var(--saffron); }
input::placeholder, textarea::placeholder { color: var(--mute); }
textarea { resize: vertical; }
.btn { padding: .8rem 1.2rem; border-radius: 14px; background: var(--raise); font-weight: 600; white-space: nowrap; display: inline-flex; gap: .5rem; align-items: center; justify-content: center; }
.btn:hover { filter: brightness(1.15); }
.btn.primary { background: var(--saffron); color: #2b1d00; }
.err { color: var(--coral); margin: 0; min-height: 1.5em; font-size: .9rem; }

/* ---------- Ingresso ---------- */
#home { height: 100%; display: grid; grid-template-columns: 1.1fr 1fr; align-items: center; gap: 4vw; padding: 5vh 7vw; overflow: auto;
  background: radial-gradient(60vw 60vw at 28% 50%, #232a52 0%, transparent 60%), var(--deep); }
#enter { max-width: 26rem; display: grid; gap: .8rem; }
h1 { font-size: clamp(3rem, 7vw, 5.2rem); line-height: 1; margin: 0; font-weight: 800; letter-spacing: -.035em; }
.lead { font-size: 1.25rem; line-height: 1.4; color: var(--mute); margin: 0 0 1.2rem; max-width: 22ch; }
.invited { margin: 0; padding: .7rem 1rem; border-radius: 14px; background: rgba(255,194,75,.12); color: var(--saffron); }
.code-row { margin-top: 1rem; padding-top: 1.2rem; border-top: 1px solid var(--line); color: var(--mute); font-size: .9rem; display: grid; gap: .5rem; }
.code-row div { display: flex; gap: .6rem; }

/* Il tavolo: l'unico elemento decorativo. Quattro posti umani, uno IA. */
.table { position: relative; width: min(38vw, 68vh); aspect-ratio: 1; justify-self: center; }
.ring { position: absolute; inset: 22%; border-radius: 50%; border: 2px solid var(--line);
  background: radial-gradient(circle at 50% 40%, var(--surface), var(--night)); box-shadow: 0 40px 80px -30px #000; }
.seat { position: absolute; width: 15%; aspect-ratio: 1; border-radius: 50%; left: 50%; top: 50%; background: var(--saffron);
  transform: translate(-50%,-50%) rotate(var(--a)) translateY(-255%); animation: sit .9s cubic-bezier(.2,.9,.3,1.2) backwards; animation-delay: var(--d); }
.s1 { --a: -72deg; --d: .1s; } .s2 { --a: -144deg; --d: .2s; background: #ffd98a; }
.s3 { --a: 144deg; --d: .3s; } .s4 { --a: 72deg; --d: .4s; background: #ffd98a; }
.s5 { --a: 0deg; --d: .8s; width: 19%; transform: translate(-50%,-50%) translateY(-200%); }
@keyframes sit { from { opacity: 0; scale: .2; } }

.orb { background: var(--ai); border-radius: 50%; box-shadow: 0 0 40px -4px var(--aqua), inset 0 0 18px rgba(255,255,255,.45); }
.orb.mini { display: inline-block; width: 1.1em; height: 1.1em; margin-right: .5em; vertical-align: -.15em; box-shadow: none; }
@keyframes turn { to { rotate: 360deg; } }
@keyframes breathe { 50% { scale: 1.12; } }

/* ---------- Stanza ---------- */
#room { height: 100%; display: grid; grid-template: "head head" auto "stage panel" 1fr / 1fr auto; background: var(--night); }
header { grid-area: head; display: flex; align-items: center; justify-content: space-between; padding: .7rem 1.1rem; }
.brand { font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; }
.chip { display: inline-flex; align-items: center; gap: .5rem; padding: .4rem .9rem; border-radius: 99px; background: var(--surface); color: var(--mute); font-size: .9rem; font-variant-numeric: tabular-nums; }
.chip:hover { color: var(--ink); }
.chip svg { width: 16px; height: 16px; }

#stage { grid-area: stage; min-height: 0; padding: 0 1rem 6.2rem; display: grid; gap: .8rem;
  grid-template-columns: repeat(var(--cols, 1), 1fr); grid-auto-rows: 1fr; }
#stage.spot { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); grid-template-rows: 1fr 112px; grid-auto-rows: 0; overflow: hidden; }
.tile { position: relative; min-height: 0; border-radius: 22px; overflow: hidden; background: var(--surface); display: grid; place-items: center; cursor: pointer; }
#stage.spot .tile.feat { grid-column: 1 / -1; grid-row: 1; }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.tile.feat video, .tile.sharing video, .tile.brand-background video { object-fit: contain; }
.tile.mirror video { transform: scaleX(-1); }
.tile.novideo video { visibility: hidden; }
.avatar { width: min(34%, 120px); aspect-ratio: 1; border-radius: 50%; display: none; place-items: center; background: var(--saffron); color: #2b1d00; font-weight: 800; font-size: clamp(1rem, 3vw, 2.4rem); }
.tile.novideo .avatar, .tile.bot .avatar { display: grid; }
.tile.bot { background: radial-gradient(circle at 50% 45%, #2b2f66, var(--surface) 70%); cursor: default; }
.tile.bot .avatar { background: var(--ai); box-shadow: 0 0 60px -8px var(--aqua), inset 0 0 24px rgba(255,255,255,.5); }
.tile.bot.thinking .avatar { animation: turn 1.6s linear infinite; }
.tile.bot.speaking .avatar { animation: breathe .7s ease-in-out infinite; }
.tile.bot.speaking { box-shadow: inset 0 0 0 2px var(--aqua); }
.tag { position: absolute; left: .7rem; bottom: .7rem; max-width: calc(100% - 1.4rem); display: flex; align-items: center; gap: .4rem; padding: .25rem .7rem; border-radius: 99px;
  background: rgba(14,17,32,.72); backdrop-filter: blur(8px); font-size: .85rem; font-weight: 600; }
.tag span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag svg { width: 14px; height: 14px; color: var(--coral); display: none; }
.tile.muted .tag svg { display: block; }
.tag em { font-style: normal; color: var(--aqua); font-size: .75rem; }
.tile .status { position: absolute; top: .7rem; left: .7rem; font-size: .8rem; color: var(--aqua); display: none; }
.tile.thinking .status { display: block; }
.tile .raised { position: absolute; top: .6rem; right: .6rem; width: 2.1rem; height: 2.1rem; border-radius: 50%; background: var(--saffron); color: #2b1d00; display: none; place-items: center; }
.tile.hand .raised { display: grid; }
.raised svg { width: 18px; height: 18px; }

#captions { grid-area: stage; align-self: end; justify-self: center; z-index: 2; margin-bottom: 5.6rem; max-width: min(46rem, 90%); display: grid; gap: .3rem; pointer-events: none; }
#captions p { margin: 0; padding: .35rem .9rem; border-radius: 12px; background: rgba(14,17,32,.85); font-size: 1.02rem; line-height: 1.35; }
#captions b { color: var(--saffron); margin-right: .45em; }
#captions .interim { opacity: .65; }

#dock { grid-area: stage; align-self: end; justify-self: center; z-index: 3; margin-bottom: 1rem; display: flex; align-items: center; gap: .35rem; padding: .45rem;
  border-radius: 99px; background: rgba(30,36,64,.86); backdrop-filter: blur(14px); border: 1px solid var(--line); box-shadow: 0 18px 40px -18px #000; }
#dock button { position: relative; width: 3rem; height: 3rem; border-radius: 50%; display: grid; place-items: center; background: var(--raise); transition: background .15s, color .15s; }
#dock button:hover { background: var(--line); }
#dock button.on { background: var(--saffron); color: #2b1d00; }
#dock button.off { background: transparent; color: var(--coral); box-shadow: inset 0 0 0 1.5px var(--coral); }
#dock button.off::after { content: ""; position: absolute; width: 1.7rem; height: 2px; background: currentColor; rotate: -45deg; border-radius: 2px; }
#dock button.ai { background: var(--ai); color: #1b1640; }
#dock button.danger { background: var(--coral); color: #3a0d07; width: 3.8rem; border-radius: 99px; }
#dock .sep { width: 1px; height: 1.6rem; background: var(--line); margin: 0 .25rem; }
.badge { position: absolute; top: .3rem; right: .3rem; width: .7rem; height: .7rem; border-radius: 50%; background: var(--aqua); }

#panel { grid-area: panel; width: 22rem; min-height: 0; margin: 0 1rem 1rem 0; border-radius: 22px; background: var(--surface); display: flex; flex-direction: column; overflow: hidden; }
#panel nav { display: flex; gap: .2rem; padding: .6rem; }
#panel nav button { padding: .45rem .9rem; border-radius: 99px; color: var(--mute); font-weight: 600; }
#panel nav button.sel { background: var(--raise); color: var(--ink); }
#panel nav .x { margin-left: auto; padding: .45rem; display: grid; }
.return-video { display: none; }
.ai-address-hint { margin: .3rem .8rem; padding: .65rem .8rem; border-radius: 12px; background: var(--raise); color: var(--ink); font-size: .82rem; line-height: 1.4; display: grid; gap: .15rem; }
.ai-address-hint strong { color: var(--aqua); }
.ai-address-example { font-weight: 700; color: var(--saffron); }
.ai-address-mobile { color: #c1c7e4; }
.tab { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#msgs { flex: 1; overflow-y: auto; padding: .4rem 1rem; display: flex; flex-direction: column; gap: .7rem; }
.empty { color: var(--mute); margin: auto; text-align: center; max-width: 16rem; }
.msg { max-width: 92%; }
.msg small { color: var(--mute); display: block; margin: 0 0 .15rem .2rem; font-size: .78rem; }
.msg p { margin: 0; padding: .55rem .85rem; border-radius: 6px 16px 16px 16px; background: var(--raise); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.mine { align-self: flex-end; }
.msg.mine small { text-align: right; margin-right: .2rem; }
.msg.mine p { background: var(--saffron); color: #2b1d00; border-radius: 16px 6px 16px 16px; }
.msg.bot small { color: var(--aqua); }
.msg.bot p { background: linear-gradient(135deg, rgba(110,231,216,.16), rgba(183,156,255,.2)); box-shadow: inset 0 0 0 1px rgba(110,231,216,.35); }
#chatform { padding: .7rem; }
#plist { list-style: none; margin: 0; padding: .2rem .7rem; overflow-y: auto; flex: 1; }
#plist li { display: flex; align-items: center; gap: .7rem; padding: .5rem .4rem; border-radius: 12px; }
#plist .dot { width: 2.1rem; height: 2.1rem; border-radius: 50%; background: var(--saffron); color: #2b1d00; display: grid; place-items: center; font-weight: 800; font-size: .8rem; flex: none; }
#plist .dot.orb { box-shadow: none; }
#plist .who { flex: 1; min-width: 0; line-height: 1.25; }
#plist .who b, #plist .who small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#plist .who small { color: var(--mute); font-size: .78rem; }
#plist button { color: var(--mute); padding: .3rem; display: grid; border-radius: 8px; }
#plist button:hover { color: var(--coral); background: var(--raise); }
#plist button svg { width: 18px; height: 18px; }
.ai-btn { margin: .7rem; background: var(--ai); color: #1b1640; }

dialog { border: 1px solid var(--line); border-radius: 24px; background: var(--surface); color: var(--ink); padding: 1.6rem; width: min(30rem, 92vw); }
dialog::backdrop { background: rgba(8,10,20,.7); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 .5rem; font-size: 1.35rem; letter-spacing: -.01em; }
dialog p { color: var(--mute); margin: 0 0 1rem; }
dialog label { display: block; margin: .9rem 0 .3rem; font-size: .9rem; color: var(--mute); }
dialog .check { display: flex; gap: .6rem; align-items: center; color: var(--ink); font-size: 1rem; cursor: pointer; }
dialog .check input { width: 1.1rem; height: 1.1rem; accent-color: var(--aqua); flex: none; }
dialog .hint { font-size: .85rem; margin: .3rem 0 0 1.7rem; }
.row { display: flex; gap: .6rem; margin-bottom: .7rem; }
.end { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.2rem; }

#toasts { position: fixed; top: 4rem; left: 50%; translate: -50%; z-index: 20; display: grid; gap: .4rem; justify-items: center; pointer-events: none; }
#toasts p { margin: 0; padding: .5rem 1rem; border-radius: 99px; background: var(--ink); color: var(--deep); font-weight: 600; font-size: .9rem; animation: pop .25s ease-out; max-width: 90vw; text-align: center; }
@keyframes pop { from { opacity: 0; translate: 0 -8px; } }

@media (max-width: 820px) {
  #home { grid-template-columns: 1fr; padding: 4vh 6vw; }
  .table { width: min(52vw, 30vh); order: -1; }
  #room { grid-template: "head" auto "stage" 1fr / 1fr; }
  #panel { grid-area: stage; z-index: 5; width: auto; margin: 0 .6rem 5.4rem; }
  #stage { padding: 0 .6rem 5.6rem; gap: .5rem; }
  #dock { gap: .2rem; max-width: 100vw; }
  #dock button { width: 2.6rem; height: 2.6rem; }
  #dock .sep { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
#plist .dot.orb { background: var(--ai); }
input:focus-visible, textarea:focus-visible { outline: 0; }

/* ---------- Scelta del modello (solo host) e stato della connessione ---------- */
dialog { max-height: 94vh; overflow-y: auto; }
dialog .hint.flat { margin: .3rem 0 0; }
:is(#ai-models, #tr-models) { list-style: none; margin: .5rem 0 0; padding: .25rem; height: 10.5rem; overflow-y: auto; border-radius: 14px; background: var(--deep); border: 1.5px solid var(--line); }
:is(#ai-models, #tr-models) .note { color: var(--mute); padding: .6rem .7rem; font-size: .9rem; }
:is(#ai-models, #tr-models) button { width: 100%; text-align: left; padding: .4rem .7rem; border-radius: 10px; display: grid; grid-template-columns: 1fr auto; gap: 0 .8rem; line-height: 1.3; }
:is(#ai-models, #tr-models) button:hover { background: var(--surface); }
:is(#ai-models, #tr-models) button.sel { background: var(--raise); box-shadow: inset 0 0 0 1.5px var(--aqua); }
:is(#ai-models, #tr-models) b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:is(#ai-models, #tr-models) small { color: var(--mute); font-size: .75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:is(#ai-models, #tr-models) .cost { grid-row: 1 / span 2; grid-column: 2; align-self: center; color: var(--aqua); font-variant-numeric: tabular-nums; }
dialog .picked { margin: .4rem 0 0; font-size: .85rem; color: var(--aqua); min-height: 1.3em; overflow-wrap: anywhere; }
#offline { position: fixed; top: .7rem; left: 50%; translate: -50%; z-index: 30; margin: 0; padding: .45rem 1.1rem; border-radius: 99px; background: var(--coral); color: #3a0d07; font-weight: 700; font-size: .9rem; max-width: 92vw; text-align: center; }

/* ---------- Voci, menu «Altro» e telefono ---------- */
select { width: 100%; padding: .8rem 1rem; border-radius: 14px; border: 1.5px solid var(--line); background: var(--deep); font: inherit; color: inherit; }
select:focus { border-color: var(--saffron); outline: 0; }
#ai-natural-box { margin-top: .9rem; }
button, .btn, input, select, textarea { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
#dock #b-more { display: none; }
.sheet { padding: 1rem; }
.sheet > button { width: 100%; display: flex; align-items: center; gap: 1rem; padding: .95rem 1rem; border-radius: 16px; font-size: 1.05rem; font-weight: 600; text-align: left; }
.sheet > button:hover, .sheet > button:active { background: var(--raise); }
.sheet > button.on { color: var(--saffron); }
.sheet > button.ai-row svg { color: var(--aqua); }
.sheet .end { margin-top: .6rem; }
.sheet .end .btn { width: 100%; }

@media (max-width: 820px) {
  html, body { height: var(--vh, 100dvh); }
  body { position: fixed; inset: 0 0 auto 0; }
  #home { align-content: start; gap: 2vh; padding: max(3vh, env(safe-area-inset-top)) 6vw calc(4vh + env(safe-area-inset-bottom)); }
  .table { width: min(46vw, 24vh); }
  .lead { margin-bottom: .6rem; }
  header { padding: max(.6rem, env(safe-area-inset-top)) max(.9rem, env(safe-area-inset-right)) .5rem max(.9rem, env(safe-area-inset-left)); }
  #stage { padding: 0 .5rem calc(5.4rem + env(safe-area-inset-bottom)); }
  #stage.spot { grid-template-rows: 1fr 92px; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  #captions { margin-bottom: calc(5.2rem + env(safe-area-inset-bottom)); }
  #captions p { font-size: .95rem; }
  /* Barra in basso: cinque comandi grandi, il resto nel menu «Altro». */
  #dock { justify-self: stretch; justify-content: space-around; gap: 0; margin: 0 .6rem calc(.6rem + env(safe-area-inset-bottom)); padding: .5rem .6rem; }
  #dock .sec { display: none; }
  #dock #b-more { display: flex; }
  #dock button { width: 3.2rem; height: 3.2rem; }
  #dock button.danger { width: 4rem; }
  /* La chat occupa tutta l'area visibile, anche con la tastiera aperta. */
  #panel { position: fixed; inset: 0; width: 100%; height: var(--vh, 100dvh); margin: 0; z-index: 6; border: 0; border-radius: 0; }
  #panel nav { flex: none; align-items: center; padding: max(.65rem, env(safe-area-inset-top)) max(.75rem, env(safe-area-inset-right)) .65rem max(.75rem, env(safe-area-inset-left)); border-bottom: 1px solid var(--line); }
  #panel nav button { padding: .65rem .8rem; }
  #panel nav .x { display: flex; align-items: center; gap: .25rem; padding: .65rem .45rem; color: var(--ink); }
  #panel nav .x svg { width: 18px; height: 18px; }
  .return-video { display: inline; font-size: .8rem; white-space: nowrap; }
  #msgs { padding: .8rem 1rem; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .ai-address-hint { padding: .55rem .7rem; font-size: .8rem; }
  #download-transcript { align-self: flex-end; margin: .1rem 1rem; padding: .35rem .65rem; font-size: .75rem; }
  #chatform { flex: none; padding: .65rem max(.75rem, env(safe-area-inset-right)) max(.65rem, env(safe-area-inset-bottom)) max(.75rem, env(safe-area-inset-left)); background: var(--surface); }
  #plist button { padding: .6rem; }
  /* Le finestre salgono dal basso, come i fogli di iOS. */
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 24px 24px 0 0; border-width: 1px 0 0; max-height: 88dvh;
    padding: 1.3rem 1.2rem calc(1.2rem + env(safe-area-inset-bottom)); animation: rise .22s ease-out; }
  .row { flex-wrap: wrap; }
  .row .btn { flex: 1; }
  #toasts { top: calc(3.6rem + env(safe-area-inset-top)); }
  #offline { top: max(.5rem, env(safe-area-inset-top)); }
}
@keyframes rise { from { translate: 0 30%; opacity: 0; } }

/* Chat: campo e tasto di invio sulla stessa riga. */
#chatform { display: flex; gap: .5rem; }
#chat-send { flex: none; width: 3.1rem; border-radius: 14px; background: var(--saffron); color: #2b1d00; display: grid; place-items: center; }
#dock .lbl { display: none; }
#b-more svg { stroke-width: 3.4; }
@media (max-width: 820px) {
  /* Ogni tasto della barra ha la sua etichetta: niente icone da indovinare. */
  #dock { border-radius: 26px; padding: .35rem; }
  #dock button, #dock button.danger { flex: 1; width: auto; height: 3.7rem; border-radius: 20px; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem; }
  #dock button:hover { background: transparent; }
  #dock button:active { background: var(--raise); }
  #dock .lbl { display: block; font-size: .68rem; font-weight: 600; line-height: 1; color: var(--mute); }
  #dock button.off { box-shadow: none; }
  #dock button.off .lbl { color: var(--coral); }
  #dock button.off::after { top: 1.05rem; }
  #dock button.on { background: var(--raise); color: var(--saffron); }
  #dock button.danger { background: var(--coral); color: #3a0d07; }
  #dock button.danger .lbl { color: inherit; }
  .badge { top: .45rem; right: calc(50% - 1.1rem); }
}

/* Azione sempre visibile sul riquadro dell'IA per l'amministratore. */
.tile .bot-edit { position: absolute; top: .6rem; right: .6rem; z-index: 2; padding: .45rem .7rem; border-radius: 10px; background: var(--surface); color: var(--ink); font-size: .85rem; font-weight: 600; }
#plist button.edit-ai { display: block; color: var(--aqua); font-size: .85rem; font-weight: 600; white-space: nowrap; }

/* Guida alla prima visita: la schermata di ingresso resta sempre in primo piano. */
.guide { grid-column: 1 / -1; width: min(100%, 72rem); margin: 4rem auto 1rem; padding: clamp(1.4rem, 4vw, 3rem); border: 1px solid var(--line); border-radius: 28px; background: var(--surface); }
.guide-intro { max-width: 38rem; }
.guide-eyebrow { color: var(--aqua); font-size: .8rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.guide h2 { margin: .45rem 0; font-size: clamp(1.7rem, 4vw, 2.6rem); line-height: 1.15; letter-spacing: -.025em; }
.guide-intro > p { margin: 0; color: var(--mute); }
.guide-steps { list-style: none; margin: 2rem 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem; }
.guide-steps li { padding: 1.2rem; border-radius: 18px; background: var(--night); }
.step-icon { display: grid; place-items: center; width: 2.3rem; height: 2.3rem; border-radius: 50%; background: var(--saffron); color: var(--deep); font-weight: 800; }
.step-icon.ai-step { background: var(--ai); }
.guide h3 { margin: 1rem 0 .4rem; font-size: 1.05rem; line-height: 1.3; }
.guide-steps p, .guide-notes p { margin: 0; color: #c1c7e4; font-size: .92rem; line-height: 1.5; }
.guide-steps .guide-example { margin-top: .8rem; color: var(--aqua); font-weight: 600; }
.guide-notes { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; border-top: 1px solid var(--line); padding-top: 1.3rem; }
.guide-notes strong { color: var(--ink); }
@media (max-width: 820px) { .guide { margin: 1.5rem auto 0; padding: 1.3rem; } .guide-steps { grid-template-columns: 1fr 1fr; gap: .6rem; margin: 1.3rem 0; } .guide-steps li { padding: 1rem; } .guide-notes { grid-template-columns: 1fr; gap: .8rem; } }
@media (max-width: 420px) { .guide-steps { grid-template-columns: 1fr; } .guide-steps li { display: flex; align-items: flex-start; gap: .9rem; } .step-icon { flex: none; } .guide h3 { margin: 0 0 .3rem; } }

#guide-link { width: fit-content; color: var(--aqua); font-weight: 600; font-size: .95rem; text-underline-offset: .2em; }

.public-stats { grid-column: 1 / -1; width: min(100%, 72rem); margin: 2rem auto 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.public-stats div { display: grid; gap: .2rem; padding: 1rem 1.3rem; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.public-stats strong { color: var(--aqua); font-size: clamp(1.4rem, 3vw, 2rem); line-height: 1.1; font-variant-numeric: tabular-nums; }
.public-stats span { color: var(--ink); font-size: .9rem; }
@media (max-width: 600px) { .public-stats { gap: .5rem; margin-top: 1rem; } .public-stats div { padding: .8rem .6rem; } .public-stats span { font-size: .75rem; line-height: 1.25; } }

.key-link { display: inline-block; padding: .35rem 0; color: var(--aqua); font-weight: 600; text-underline-offset: .2em; }

#home .home-footer { grid-column: 1 / -1; width: min(100%, 72rem); margin: 0 auto; padding: 1rem 0 .5rem; display: flex; flex-wrap: wrap; justify-content: center; gap: .35rem 1.2rem; color: var(--mute); font-size: .85rem; text-align: center; }
#home .home-footer a { color: inherit; text-underline-offset: .2em; }

.translation-test { padding: .65rem .9rem; background: #293354; font-size: .8rem; line-height: 1.35; }
.translation-test strong { color: var(--aqua); }
.translation-test p { margin: .25rem 0; color: #d0d4ec; }
.translation-test label { display: flex; gap: .5rem; align-items: center; cursor: pointer; }
.translation-test input { width: auto; accent-color: var(--aqua); }

.translation-test input[type="password"], .translation-test input[type="text"] { width: 100%; padding: .45rem .6rem; margin: .15rem 0 .4rem; font-size: .85rem; }


.translated-subtitle { position: absolute; left: 5%; right: 5%; bottom: 3rem; z-index: 3; padding: .45rem .7rem; border-radius: 10px; text-align: center; background: rgba(0,0,0,.85); color: white; font-size: clamp(.85rem, 2vw, 1.05rem); line-height: 1.35; pointer-events: none; overflow-wrap: anywhere; }
.translation-test select { padding: .45rem .6rem; font-size: .85rem; }

.translation-test .caption-test { margin: .35rem 0; padding: .4rem .65rem; font-size: .8rem; }

.tile-captions { position: absolute; top: .6rem; left: .6rem; z-index: 4; width: 2.4rem; height: 2.4rem; display: grid; place-items: center; border-radius: 10px; background: rgba(14,17,32,.82); color: white; }
.tile-captions svg { width: 1.35rem; height: 1.35rem; }
#dlg-subtitles { max-height: 90dvh; overflow-y: auto; }
#dlg-subtitles .translation-test { background: transparent; padding: 0; font-size: .9rem; }
#dlg-subtitles .translation-test input[type="password"], #dlg-subtitles .translation-test input[type="search"] { width: 100%; }

/* Prototipo locale: personaggi illustrati, animati solo durante la voce. */
.tile.bot .avatar { width: min(65%, 260px); background: transparent; box-shadow: none; overflow: visible; }
.tile.bot .ai-character { width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 12px 24px rgba(0,0,0,.25)); }
.tile.bot.thinking .avatar { animation: ai-wait 2.5s ease-in-out infinite; }
.tile.bot.speaking .avatar { animation: ai-wait 1.3s ease-in-out infinite; }
.ai-eyes { transform-box: fill-box; transform-origin: center; animation: ai-blink 6s infinite; }
.ai-mouth { transform-box: fill-box; transform-origin: center; }
.tile.bot.speaking .ai-mouth { animation: ai-talk .34s ease-in-out infinite alternate; }
.tile.bot.speaking .ai-smile { opacity: 0; }
@keyframes ai-talk { 0% { transform: scaleY(1); } 35% { transform: scaleY(3.5); } 70% { transform: scaleY(1.8); } 100% { transform: scaleY(5); } }
@keyframes ai-blink { 0%, 43%, 46%, 100% { transform: scaleY(1); } 44.5% { transform: scaleY(.08); } }
@keyframes ai-wait { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .ai-eyes, .tile.bot .avatar { animation: none !important; } }

.tile.bot.bot-orb .avatar { width: min(38%, 150px); background: radial-gradient(circle at 32% 25%, white -20%, var(--bot-color) 42%, #282444 150%); box-shadow: 0 0 50px -8px var(--bot-color); }
.tile.bot.bot-orb.speaking .avatar { animation: orb-speak .8s ease-in-out infinite alternate; }
@keyframes orb-speak { from { transform: scale(.93); box-shadow: 0 0 22px -8px var(--bot-color); } to { transform: scale(1.12); box-shadow: 0 0 65px 2px var(--bot-color); } }

/* Profilo sempre visibile nel riquadro; il testo completo si apre con un tocco. */
.bot-profile { position: absolute; z-index: 2; left: .7rem; right: .7rem; bottom: .7rem; padding: .55rem .7rem; border-radius: 14px; background: rgba(14,17,32,.88); backdrop-filter: blur(8px); }
.bot-profile .tag { position: static; max-width: 100%; padding: 0; background: none; backdrop-filter: none; font-size: .95rem; }
.bot-role { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; width: 100%; margin-top: .25rem; text-align: left; color: #e0e5f6; font-size: .8rem; line-height: 1.3; overflow-wrap: anywhere; }
.bot-role:focus-visible { outline: 2px solid var(--aqua); outline-offset: 3px; }
.profile-label { color: var(--aqua); font-weight: 600; }
.profile-text { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 45dvh; overflow-y: auto; }
@media (max-width: 820px) { .bot-profile { left: .4rem; right: .4rem; bottom: .4rem; padding: .4rem .55rem; } .bot-profile .tag { font-size: .8rem; } .bot-role { font-size: .72rem; } }
#document-upload { padding: .35rem .8rem; }
#document-upload .hint, #document-upload .err { margin: .3rem 0 0; font-size: .75rem; }
.document-download { display: block; text-align: left; text-decoration: underline; font-weight: 700; overflow-wrap: anywhere; }
.document-message small { margin-top: .35rem; color: inherit; opacity: .85; }
/* Il comando compare solo mentre il partecipante IA sta parlando. */
.tile .bot-stop { position: absolute; top: .6rem; left: .6rem; z-index: 4; display: none; padding: .5rem .7rem; border-radius: 10px; background: #ffe0da; color: #45140b; font-size: .8rem; font-weight: 700; }
.tile.bot.speaking .bot-stop { display: block; }
#clear-chat { margin: .25rem .8rem; }
#document-catalog { margin: .25rem .8rem; padding: .5rem .7rem; border-radius: 12px; background: var(--raise); font-size: .8rem; }
#document-catalog summary { cursor: pointer; font-weight: 600; }
#document-catalog .hint { margin: .4rem 0; }
#document-list { margin: .4rem 0 0; padding-left: 1.2rem; }
.web-used { color: var(--aqua); margin: .3rem .2rem 0; }
.web-sources { margin: .3rem .2rem 0; display: grid; gap: .15rem; font-size: .78rem; overflow-wrap: anywhere; }
.web-sources a { color: var(--aqua); text-decoration: underline; }
