@font-face { font-family: "Exo 2"; font-weight: 600; font-display: swap; src: url("fonts/exo-2-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Exo 2"; font-weight: 800; font-display: swap; src: url("fonts/exo-2-latin-800-normal.woff2") format("woff2"); }
:root {
  --bg: #0e0b16;
  --bg2: #151021;
  --bg3: #1d162d;
  --bg4: #2a2142;
  --line: #30264a;
  --tx: #ece9f4;
  --tx2: #b0a8c6;
  --tx3: #877d9f;
  --acc: #7c00ff;       /* viola ENS: sfondi e bordi */
  --acc2: #913ffc;      /* viola ENS chiaro: hover */
  --acc3: #440f96;      /* viola ENS scuro */
  --acc-tx: #bd94ff;    /* viola leggibile come testo su sfondo scuro */
  --brand-font: "Exo 2", "Segoe UI", system-ui, sans-serif;
  --ok: #3ccf8e;
  --warn: #f2b84b;
  --bad: #f05d6c;
  --r: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--tx);
  font: 14px/1.45 "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif; }
body { overflow: hidden; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--tx); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px; outline: none; width: 100%; }
input:focus, textarea:focus, select:focus { border-color: var(--acc); }
textarea { resize: none; }
a { color: var(--acc-tx); }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.btn { border: 0; border-radius: 8px; padding: 9px 14px; background: var(--bg4); font-family: var(--brand-font); font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background .12s; }
.btn:hover { background: #372b56; }
.btn.primary { background: var(--acc); color: #fff; }
.btn.primary:hover { background: var(--acc2); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid #5a2a33; }
.btn.danger:hover { background: #2a1519; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.big { width: 100%; padding: 12px; font-size: 15px; }
.btn:disabled { opacity: .55; cursor: default; }
.ib { width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--tx2);
  display: inline-grid; place-items: center; transition: background .12s, color .12s; }
.ib:hover { background: var(--bg4); color: var(--tx); }
.ib.on { color: var(--bad); }
.ib.active { color: var(--ok); }

/* ---------- accesso ---------- */
/* Scorre da sé (body non scorre): col margine automatico la scheda resta centrata ma non si taglia in alto sul telefono. */
.join { height: 100%; display: flex; padding: 16px; overflow-y: auto; overscroll-behavior: contain;
  background: url("join-bg.svg") center/cover no-repeat, linear-gradient(115deg, var(--acc2) 0%, var(--acc) 42%, var(--acc3) 80%, #2f0a6b 100%); }
.join-card { margin: auto; width: min(420px, 100%); background: var(--bg2); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px; box-shadow: 0 20px 60px #0008; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; display: flex; align-items: center; gap: 12px; font: 800 24px/1 var(--brand-font); letter-spacing: 3px;
  text-transform: uppercase; color: var(--acc-tx); }
.logo { display: block; height: 30px; width: auto; }
.sub { color: var(--tx2); margin: 6px 0 20px; }
.join label { display: block; margin-bottom: 14px; color: var(--tx2); font-size: 13px; }
.join label input, .join label textarea { margin-top: 6px; }
details { margin-bottom: 14px; }
summary { cursor: pointer; color: var(--tx2); font-size: 13px; margin-bottom: 10px; }
.err { color: var(--bad); background: #2a1519; border-radius: 8px; padding: 9px 11px; margin: 0 0 14px; }
.ver { color: var(--tx3); font-size: 12px; text-align: center; margin: 16px 0 0; }

/* ---------- layout app ---------- */
.app { display: grid; grid-template-columns: 264px 1fr; height: 100%; }
.side { background: var(--bg2); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 12px 16px;
  background: linear-gradient(115deg, var(--acc) 0%, var(--acc3) 100%); }
.side-head .ib { color: #fff; }
.side-head .ib:hover { background: #fff3; color: #fff; }
.side-head h2 { margin: 0; color: #fff; font: 800 16px/1.3 var(--brand-font); letter-spacing: .5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-scroll { flex: 1; overflow: auto; padding: 8px; }
.sec { margin-bottom: 14px; }
.sec-title { display: flex; justify-content: space-between; align-items: center; color: var(--tx3);
  text-transform: uppercase; font-family: var(--brand-font); font-size: 11px; font-weight: 800; letter-spacing: .8px; padding: 6px 8px; }
.pill { background: var(--bg4); color: var(--tx2); border-radius: 99px; padding: 0 7px; font-size: 11px; }
.ulist { list-style: none; margin: 0 0 8px; padding: 0; }
.ulist li { display: flex; align-items: center; gap: 9px; padding: 5px 8px; border-radius: 8px; min-height: 36px; }
.ulist li:hover { background: var(--bg3); }
.ulist li .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ulist li .tags { display: flex; gap: 4px; color: var(--tx3); }
.ulist li .tags svg.i { width: 15px; height: 15px; }
.ulist li .tags .red { color: var(--bad); }
.ulist li.clickable { cursor: pointer; }
.av { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px;
  color: #fff; flex: none; box-shadow: 0 0 0 2px transparent; transition: box-shadow .1s; }
.av.pic { background-size: cover; background-position: center; background-repeat: no-repeat; }
.av.big { width: 72px; height: 72px; font-size: 28px; }
.av.speaking { box-shadow: 0 0 0 2px var(--bg2), 0 0 0 4px var(--ok); }
.live { background: var(--bad); color: #fff; font-size: 10px; font-weight: 800; border-radius: 4px; padding: 1px 5px; letter-spacing: .4px; }
.watch-btn.cam-btn { padding: 2px 5px; display: inline-grid; place-items: center; }
.watch-btn.cam-btn svg.i { width: 14px; height: 14px; }
.watch-btn { border: 0; background: var(--acc); color: #fff; border-radius: 6px; font-size: 11px; font-weight: 700; padding: 3px 8px; }
.watch-btn.on { background: var(--bg4); color: var(--tx2); }
.voice-btn { width: 100%; }
.voice-btn.join { height: auto; display: inline-flex; padding: 9px 14px; background: #1f3b2f; color: var(--ok); }
.voice-btn.join:hover { background: #24493a; }
.voice-btn.leave { background: #3a1d22; color: var(--bad); }
.voice-btn.leave:hover { background: #4a2229; }
.me { border-top: 1px solid var(--line); padding: 10px; display: flex; flex-direction: column; gap: 8px; background: #110d1b; }
.me-info:hover { background: var(--bg3); }
.me-info { cursor: pointer; border-radius: 8px; display: flex; align-items: center; gap: 9px; min-width: 0; }
.me-text { min-width: 0; display: flex; flex-direction: column; }
.me-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text small { color: var(--tx3); font-size: 12px; }
.me-ctrls { display: flex; justify-content: space-between; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.banner { background: #3a2f12; color: var(--warn); padding: 7px 14px; font-size: 13px; text-align: center; }
/* la posizione dei riquadri la calcola layoutStage in base alle proporzioni dei video */
.stage { flex: 0 0 var(--stage, 58%); position: relative; background: #09070f; border-bottom: 1px solid var(--line); min-height: 0; overflow: hidden; }
.tile { position: absolute; background: #000; border-radius: var(--r); overflow: hidden; display: grid; place-items: center; cursor: pointer; }
.tile.focus { box-shadow: 0 0 0 2px var(--acc); }
.tile:fullscreen { border-radius: 0; cursor: default; }
.tile .fsb { position: absolute; right: 6px; bottom: 6px; background: #000a; color: #fff; opacity: 0; transition: opacity .15s; }
.tile:hover .fsb { opacity: 1; }
/* il video non decide l'altezza del riquadro: qualsiasi proporzione (4:3 stretched, ultrawide) si vede intera */
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.tile .cap { position: absolute; left: 8px; bottom: 8px; background: #000a; padding: 3px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.tile .tools { position: absolute; right: 6px; top: 6px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.tile:hover .tools { opacity: 1; }
.tile .tools .ib { background: #000a; color: #fff; }
.tile .wait { color: var(--tx3); }
.tile.self { outline: 2px solid var(--bad); outline-offset: -2px; }
.tile.cam video { object-fit: cover; }
.tile.cam.mine video { transform: scaleX(-1); } /* la propria anteprima si vede a specchio */
.tile.cam.speaking { outline: 2px solid var(--ok); outline-offset: -2px; }

.split { flex: none; height: 6px; cursor: row-resize; background: var(--line); touch-action: none; }
.mention { background: #7c00ff33; color: #c9a4ff; border-radius: 4px; padding: 0 3px; font-weight: 600; cursor: pointer; }
.mention.self { background: #e0a80033; color: var(--warn); }
.msg.mentioned { background: #e0a80014; box-shadow: inset 2px 0 var(--warn); }
.mention-box { flex: 0 1 auto; min-height: 44px; max-height: min(190px, 45%); overflow-y: auto; margin: 0 14px 6px; background: var(--bg3); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.mention-box button { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; color: var(--tx); padding: 7px 10px; text-align: left; font: inherit; cursor: pointer; }
.mention-box button.sel { background: var(--bg4); }
.mention-box .av { width: 22px; height: 22px; font-size: 10px; flex: none; }
.dm-bar { display: flex; align-items: center; gap: 10px; padding: 7px 14px; background: var(--bg2); border-bottom: 1px solid var(--line); min-width: 0; }
.dm-bar .btn { flex: none; padding: 4px 10px; font-size: 12px; min-height: 30px; }
.dm-bar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; min-width: 0; flex: 1; }
.e2e-note { color: var(--tx3); font-style: italic; }
.e2e-alert { color: var(--bad, #e8615a); font-size: 12px; cursor: pointer; }
.e2e-code { font: 600 15px/1.7 ui-monospace, Consolas, monospace; letter-spacing: .5px; user-select: all; margin: 8px 0 12px; word-spacing: 4px; }
.e2e-error { color: var(--bad, #e8615a); font-size: 13px; margin: 0 0 10px; }
.ulist li.active { background: var(--bg4); }
.ulist li.offline .nm { color: var(--tx3); }
.ulist.off li { opacity: .55; }
.ulist.off li:hover { opacity: 1; }
.pill.new { background: var(--acc); color: #fff; }
.compose-preview { margin: 0 14px 6px; padding: 6px 10px; background: var(--bg3); border: 1px solid var(--line); border-radius: 10px; max-height: min(190px, 45%); overflow-y: auto; position: relative; flex: 0 1 auto; min-height: 48px; }
.composer { flex: none; }
.compose-preview small { display: block; color: var(--tx3); font-size: 11px; margin-bottom: 3px; }
.compose-preview .gif { display: block; max-height: min(130px, 22vh); max-width: 100%; border-radius: 8px; }
.compose-preview .ib { position: absolute; top: 2px; right: 2px; }
.tile.fs-on { position: fixed !important; inset: 0 !important; width: auto !important; height: auto !important; z-index: 40; border-radius: 0; outline: 0; }
.tile.fs-on video { object-fit: contain; }
/* a tutto schermo una sola X, che esce: nascondere la webcam resta nel riquadro normale */
.tile.fs-on .tools { display: none; }
.tile.fs-on .fsb { top: 12px; right: 12px; bottom: auto; opacity: 1; width: 40px; height: 40px; }
.tile.narrow:not(.fs-on) .cap { display: none; }
.tile.tiny:not(.fs-on) .tools, .tile.tiny:not(.fs-on) .fsb, .tile.tiny:not(.fs-on) .cap { display: none; }
.split:hover, .split.drag, .side-split.drag { background: var(--acc); }
.side-split { display: none; }
.stage.hidden ~ .split { display: none; }
.main-empty { display: none; flex: 1; place-items: center; align-content: center; gap: 12px; color: var(--tx3); }
body.chat-off .chat, body.chat-off .split { display: none; }
body.chat-off .stage { flex: 1 1 auto; border-bottom: 0; }
body.chat-off .stage.hidden ~ .main-empty { display: grid; }
.ib.dot { position: relative; }
.ib.dot::after { content: ""; position: absolute; top: 5px; right: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--acc2); box-shadow: 0 0 0 2px var(--bg2); }
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 18px 8px; }
.msg { display: flex; gap: 12px; padding: 3px 0; position: relative; border-radius: 6px; }
.msg:hover { background: #ffffff06; }
.msg.flash { background: #7c00ff33; transition: background .3s; }
.msg-tools { position: absolute; right: 4px; top: -12px; display: none; background: var(--bg3); border: 1px solid var(--line); border-radius: 8px; padding: 1px; z-index: 2; }
.msg:hover .msg-tools { display: flex; }
.msg-tools .ib { width: 28px; height: 28px; }
.msg-tools svg.i { width: 15px; height: 15px; }
.reply-quote { display: flex; align-items: center; gap: 6px; color: var(--tx3); font-size: 12px; margin-bottom: 2px; cursor: pointer; min-width: 0; }
.reply-quote svg.i { width: 13px; height: 13px; }
.reply-quote b { flex: none; font-weight: 650; }
.reply-quote span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.reply-quote:hover span { color: var(--tx); }
.reply-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 14px; padding: 2px 4px 2px 12px; background: var(--bg3); border-radius: 8px 8px 0 0; font-size: 12.5px; color: var(--tx2); }
.reply-bar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.reply-bar .ib { width: 26px; height: 26px; flex: none; }
.edit-box textarea { background: var(--bg3); max-height: 240px; }
.edit-actions { display: flex; align-items: center; gap: 6px; margin: 6px 0 4px; }
.edit-actions .btn { padding: 4px 12px; font-size: 12px; }
.edit-actions small { color: var(--tx3); font-size: 11px; }
.edited { display: block; color: var(--tx3); font-size: 10.5px; }
/* testo dei messaggi */
.txt p { margin: 0; white-space: pre-wrap; }
.txt p + p, .txt p + ul, .txt p + ol, .txt ul + p, .txt ol + p, .txt pre + p, .txt blockquote + p, .txt .md-table + p { margin-top: 6px; }
.txt h1, .txt h2, .txt h3, .txt h4, .txt h5, .txt h6 { margin: 8px 0 3px; font-family: var(--brand-font); font-weight: 800; line-height: 1.25; }
.txt h1 { font-size: 21px; } .txt h2 { font-size: 18px; } .txt h3 { font-size: 16px; } .txt h4 { font-size: 14.5px; } .txt h5 { font-size: 13.5px; } .txt h6 { font-size: 12.5px; color: var(--tx2); }
.txt > :first-child { margin-top: 0; }
.txt ul, .txt ol { margin: 2px 0; padding-left: 24px; }
.txt li.task { list-style: none; margin-left: -20px; }
.txt li.task > input { width: auto; margin: 0 6px 0 0; vertical-align: -1px; accent-color: var(--acc); }
.txt li.task > p { display: inline; }
.txt blockquote { margin: 4px 0; padding: 1px 0 1px 10px; border-left: 3px solid var(--acc); color: var(--tx2); }
.txt code { font-family: Consolas, "Cascadia Mono", "DejaVu Sans Mono", monospace; font-size: 12.5px; background: var(--bg4); border-radius: 4px; padding: 1px 4px; }
.txt pre { margin: 5px 0; background: #09070f; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; overflow-x: auto; }
.txt pre code { background: none; padding: 0; white-space: pre; }
.txt hr { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }
.md-table { overflow-x: auto; margin: 5px 0; }
.md-table table { border-collapse: collapse; }
.md-table th, .md-table td { border: 1px solid var(--line); padding: 3px 9px; }
.md-table th { background: var(--bg3); }
img.emoji { width: 22px; height: 22px; object-fit: contain; vertical-align: -5px; }
/* pannelli emoji e GIF */
.picker { position: fixed; z-index: 25; width: min(380px, calc(100vw - 16px)); display: flex; flex-direction: column; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 50px #000b; overflow: hidden; }
.pk-head, .pk-form { display: flex; gap: 6px; padding: 8px; align-items: center; }
.pk-head .ib { flex: none; }
.pk-form { padding-top: 0; }
.pk-form .btn { padding: 8px 12px; flex: none; }
.pk-body { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 8px; }
.pk-title { position: sticky; top: 0; background: var(--bg2); color: var(--tx3); font: 800 11px/1.4 var(--brand-font); text-transform: uppercase; letter-spacing: .8px; padding: 6px 2px; }
.pk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); }
.pk-emoji { aspect-ratio: 1; border: 0; background: none; border-radius: 8px; font-size: 22px; line-height: 1; display: grid; place-items: center; padding: 0;
  font-family: "Segoe UI Emoji", "Noto Color Emoji", "Apple Color Emoji", sans-serif; }
.pk-emoji:hover { background: var(--bg4); }
.pk-emoji img.emoji { width: 26px; height: 26px; }
.pk-gifs { columns: 2; column-gap: 6px; }
.pk-gif { display: block; width: 100%; padding: 0; border: 0; background: var(--bg3); border-radius: 8px; overflow: hidden; margin-bottom: 6px; break-inside: avoid; }
.pk-gif img { display: block; width: 100%; }
.pk-gif:hover { outline: 2px solid var(--acc); outline-offset: -2px; }
.pk-note { color: var(--tx3); text-align: center; padding: 28px 12px; }
.pk-foot { color: var(--tx3); font-size: 11px; text-align: right; padding: 4px 10px 6px; }
/* inquadratura dell'avatar */
.crop { margin-bottom: 14px; }
.crop canvas { display: block; margin: 0 auto 10px; width: min(280px, 100%); aspect-ratio: 1; border-radius: 10px; cursor: grab; touch-action: none; }
.crop canvas:active { cursor: grabbing; }
.crop label { margin-bottom: 4px; }
.msg.first { margin-top: 12px; }
.msg .av { width: 36px; height: 36px; font-size: 14px; margin-top: 2px; }
.msg .gap { width: 36px; flex: none; color: var(--tx3); font-size: 10px; text-align: right; padding-top: 3px; visibility: hidden; }
.msg:hover .gap { visibility: visible; }
.msg .body { min-width: 0; flex: 1; }
.msg .head { display: flex; gap: 8px; align-items: baseline; }
.msg .head b { font-weight: 650; }
.msg .head time { color: var(--tx3); font-size: 11px; }
.msg .txt { word-wrap: break-word; overflow-wrap: anywhere; }
.msg img.att { display: block; max-width: min(420px, 100%); max-height: 320px; border-radius: 8px; margin-top: 6px; cursor: zoom-in; background: var(--bg3); }
.msg video.att { display: block; max-width: min(480px, 100%); max-height: 320px; border-radius: 8px; margin-top: 6px; }
.file { display: inline-flex; align-items: center; gap: 10px; margin-top: 6px; background: var(--bg3); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 12px; text-decoration: none; color: var(--tx); max-width: 100%; }
.file small { color: var(--tx3); }
.sys { text-align: center; color: var(--tx3); font-size: 12px; margin: 10px 0; }
.empty { color: var(--tx3); text-align: center; margin-top: 18vh; }
.composer { display: flex; align-items: flex-end; gap: 6px; margin: 0 14px 14px; padding: 6px; background: var(--bg3);
  border: 1px solid var(--line); border-radius: 12px; }
.composer textarea { border: 0; background: transparent; padding: 7px 4px; max-height: 180px; }
.composer .send { color: var(--acc-tx); }
.uploads { margin: 0 14px; }
.up { font-size: 12px; color: var(--tx2); background: var(--bg3); border-radius: 8px; padding: 6px 10px; margin-bottom: 6px; }
.up .bar { height: 3px; background: var(--bg4); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.up .bar div { height: 100%; background: var(--acc); width: 0; }
.drop-hint { position: absolute; inset: 10px; border: 2px dashed var(--acc); border-radius: 14px; background: #7c00ff33;
  display: grid; place-items: center; font-size: 18px; font-weight: 600; pointer-events: none; z-index: 5; }

/* ---------- profilo ---------- */
.profile-pic { display: flex; align-items: center; gap: 16px; margin: 14px 0; }
.profile-pic .row-btns { margin: 0; }
.color-row { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.color-row input[type=color] { width: 56px; height: 36px; padding: 2px; flex: none; cursor: pointer; }

/* ---------- modali ---------- */
.modal { background: var(--bg2); color: var(--tx); border: 1px solid var(--line); border-radius: 14px; padding: 0;
  width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 40px); box-shadow: 0 30px 80px #000a; }
.modal.wide { width: min(640px, calc(100vw - 32px)); }
.modal::backdrop { background: #0009; }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 14px 14px 10px 20px; border-bottom: 1px solid var(--line); }
.modal h3 { margin: 0; font: 800 17px/1.3 var(--brand-font); }
.modal-body { padding: 6px 20px 20px; overflow: auto; max-height: calc(100vh - 110px); }
.modal h4 { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .8px; font-family: var(--brand-font); font-weight: 800; color: var(--tx3); }
.modal label { display: block; color: var(--tx2); font-size: 13px; margin-bottom: 10px; }
.modal label input:not([type=checkbox]), .modal label select { margin-top: 5px; }
.modal input[type=range] { padding: 0; accent-color: var(--acc); }
.modal label.chk { display: flex; align-items: center; gap: 9px; color: var(--tx); }
.modal label.chk input { width: auto; accent-color: var(--acc); }
.hint { color: var(--tx3); font-size: 12.5px; margin: 0 0 10px; }
.row-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.span2 { grid-column: span 2; }
.meter { height: 6px; background: var(--bg4); border-radius: 3px; overflow: hidden; margin: -4px 0 12px; }
.meter { position: relative; overflow: visible; }
.meter div { height: 100%; width: 0; background: var(--ok); transition: width .08s; border-radius: 3px; }
.meter div.closed { background: var(--tx3); }
.gate-mark { position: absolute; top: -3px; width: 2px; height: 12px; background: var(--tx); }
.val { color: var(--tx); float: right; font-weight: 600; }
.hint.block { display: block; }
.card-top { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.card-who { min-width: 0; }
.card-who b { margin: 0 0 2px; overflow-wrap: anywhere; }
.card-who small { margin: 0; }
.clickable { cursor: pointer; }
.invite { background: var(--bg3); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.invite .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.invite .top b { font-size: 13px; }
.invite .top small { color: var(--tx3); font-family: Consolas, monospace; }
.invite .code { display: flex; gap: 6px; }
.invite .code input { font-family: Consolas, monospace; font-size: 12px; color: var(--tx2); }
.netbox { background: var(--bg3); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.netbox div { margin: 2px 0; }
.netbox .ok { color: var(--ok); } .netbox .warn { color: var(--warn); }
.alist { list-style: none; padding: 0; margin: 0; }
.alist li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.alist li > span:not(.av), .alist li > input { flex: 1; min-width: 0; }
.alist li > input { padding: 4px 8px; }
.alist li small { color: var(--tx3); }
.alist .btn { padding: 5px 10px; font-size: 12px; }
.alist .none { color: var(--tx3); }

.pop { position: fixed; z-index: 30; background: var(--bg3); border: 1px solid var(--line); border-radius: 10px; padding: 12px; width: 240px; max-height: calc(100vh - 12px); overflow: auto;
  box-shadow: 0 12px 40px #000a; }
.pop b { display: block; margin-bottom: 8px; }
.pop input[type=range] { padding: 0; accent-color: var(--acc); }
.pop small { color: var(--tx3); display: block; margin-bottom: 8px; }
.pop-status { color: var(--tx2); font-size: 12px; margin: -4px 0 8px; overflow-wrap: anywhere; }
.pop-btn { width: 100%; padding: 6px 10px; font-size: 12px; margin-bottom: 4px; }
.pop-sep { color: var(--tx3); font: 800 11px/1.4 var(--brand-font); text-transform: uppercase; letter-spacing: .8px; margin: 10px 0 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.pop-rename { display: flex; gap: 4px; margin-top: 6px; }
.pop-rename input { padding: 5px 8px; font-size: 12px; min-width: 0; }
.pop-rename .btn { padding: 5px 10px; font-size: 12px; }

.lightbox { position: fixed; inset: 0; background: #000d; display: grid; place-items: center; z-index: 40; cursor: zoom-out; }
.lightbox img { max-width: 95vw; max-height: 95vh; }
/* sopra la barra di scrittura, e senza prendere i clic: non deve coprire i suoi pulsanti */
.toasts { position: fixed; right: 16px; bottom: 76px; pointer-events: none; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--bg4); border: 1px solid var(--line); border-left: 3px solid var(--acc); padding: 10px 14px; border-radius: 8px;
  max-width: 340px; box-shadow: 0 10px 30px #0008; animation: tin .18s ease-out; }
.toast.bad { border-left-color: var(--bad); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #3a2d5a; border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 720px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, var(--side, auto)) auto minmax(0, 1fr); }
  .side { max-height: var(--side-max, 42vh); border-right: 0; border-bottom: 0; overflow: hidden; }
  .side-scroll { min-height: 0; }
  .side-split { display: block; height: 6px; background: var(--line); touch-action: none; cursor: row-resize; }
  .main { --stage: 40%; }
  /* su una riga sola: al telefono serve lo spazio per la chat */
  .me { flex-direction: row; align-items: center; padding: 5px 8px; gap: 2px; }
  .me-text { display: none; }
  .me-ctrls { flex: 1; min-width: 0; }
  .side-head { padding-top: 8px; padding-bottom: 8px; }
  .grid2 { grid-template-columns: 1fr; } .span2 { grid-column: auto; }
}
/* telefono: la chat va sempre a capo, anche codice e tabelle */
@media (max-width: 720px), (pointer: coarse) {
  .msgs { overflow-x: hidden; }
  .txt pre { overflow-x: visible; }
  .txt pre code { white-space: pre-wrap; overflow-wrap: anywhere; }
  .md-table { overflow-x: visible; }
  .md-table table { width: 100%; table-layout: fixed; }
  .md-table th, .md-table td { overflow-wrap: anywhere; padding: 3px 4px; }
}
/* col dito i divisori si devono poter prendere, e non c'è il passaggio del mouse che mostra i pulsanti */
@media (pointer: coarse) {
  .split, .side-split { height: 14px; }
  /* la pagina segue la parte visibile: su iPhone la tastiera le passa sopra senza rimpicciolirla */
  .app { position: fixed; left: 0; right: 0; top: var(--vtop, 0); height: var(--vh, 100%); }
  .dm-bar .btn { min-height: 34px; }
  .tile .ib { width: 30px; height: 30px; }
  .tile.fs-on .fsb { width: 40px; height: 40px; }
  .msgs { padding: 10px 10px 6px; }
  .msg { gap: 8px; }
  .msg .av { width: 30px; height: 30px; font-size: 12px; }
  .msg .gap { width: 30px; }
  .composer { margin: 0 8px 8px; }
  .composer.has-text #bAttach, .composer.has-text #bGif { display: none; } /* mentre si scrive il testo ha bisogno di spazio */
  .composer textarea { padding: 6px 4px; }
  input, textarea, select { font-size: 16px; } /* sotto i 16px Safari su iPhone ingrandisce la pagina quando si tocca una casella */
}
/* mentre si scrive sul telefono contano solo la chat e la casella */
body.typing .side, body.typing .side-split { display: none; }
body.typing .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
body.typing .stage { flex-basis: 26%; }
@media (max-height: 460px) {
  body.typing .stage, body.typing .split { display: none; }
}
@media (hover: none) {
  .tile .tools, .tile .fsb { opacity: 1; }
  /* niente passaggio del mouse: le azioni sul messaggio si aprono tenendolo premuto */
  .msg-tools { display: none !important; }
  .ib:hover { background: transparent; } /* su un telefono l'evidenziazione resterebbe dopo il tocco */
  .tile .ib:hover { background: #000a; }
  .side-head .ib:hover { background: transparent; }
  .msgs { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  .msgs textarea { -webkit-user-select: text; user-select: text; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---- accesso con account, stanze, permessi, scadenza dei file ---- */
.tabs { display: flex; gap: 4px; background: var(--bg3); border-radius: var(--r); padding: 4px; margin-bottom: 14px; }
.tabs button { flex: 1; border: 0; border-radius: 8px; padding: 8px; background: transparent; color: var(--tx2); font: inherit; cursor: pointer; }
.tabs button.on { background: var(--acc); color: #fff; }
.linkbtn { display: block; margin: 10px auto 0; border: 0; background: none; color: var(--acc-tx); font: inherit; cursor: pointer; text-decoration: underline; }
.err.ok { color: var(--ok); background: #13281f; }
.hint.warn { color: var(--warn); }
.join-card a, .infobar a, .hint a { color: var(--acc-tx); }
.ib.small { width: 26px; height: 26px; }
.ib.small svg.i { width: 15px; height: 15px; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.sec-title .ib.small { margin-left: auto; }
.ulist.rooms li { cursor: pointer; min-height: 32px; }
.ulist.rooms li.on { background: var(--bg4); color: var(--tx); font-weight: 600; }
.ulist.rooms .rhash { color: var(--tx3); width: 16px; text-align: center; }
.ulist.rooms .rname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ulist.rooms li .ib.small { opacity: .5; }
.ulist.rooms li:hover .ib.small { opacity: 1; }
.infobar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 7px 14px; font-size: 13px; background: var(--bg3); color: var(--tx2); border-bottom: 1px solid var(--line); }
.infobar > span { flex: 1; min-width: 200px; }
.infobar.warn { background: #3a2f12; color: var(--warn); }
.locked { opacity: .45; }
.composer.readonly textarea { opacity: .6; }
.att-box { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.expiry { color: var(--tx3); font-size: 12px; }
.file.gone { color: var(--tx3); font-style: italic; padding: 4px 0; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 2px 12px; margin-top: 6px; }
.rpeople li { flex-direction: column; align-items: stretch; }
.rp-head { display: flex; align-items: center; gap: 8px; }
.rp-head > span:not(.av):not(.rp-btns) { flex: 1; min-width: 0; }
.rp-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.rp-perms { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 12px; padding: 8px 0 4px 40px; }
.rp-perms label { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0; font-size: 13px; }

.alist li.report { align-items: flex-start; }
.alist li.report > span { display: flex; flex-direction: column; gap: 2px; }
.alist li.report.closed { opacity: .6; }
.report-text { white-space: pre-wrap; overflow-wrap: anywhere; border-left: 3px solid var(--line); padding-left: 8px; }
