:root {
  --bg: #ffffff;
  --bg-soft: #f6f5f2;
  --bg-hover: #f1efe9;
  --text: #1d2321;
  --muted: #676d6a;
  --border: #e3e0d8;
  --side-bg: #1f3a38;
  --side-text: #c9d6d3;
  --side-strong: #ffffff;
  --side-hover: #2a4b48;
  --side-active: #d4a24c;
  --side-active-text: #1d2321;
  --top-bg: #18302e;
  --accent: #9b6b27;
  --on-accent: #ffffff;
  --accent-strong: #8c5f1f;
  --accent-soft: #f6ead3;
  --mention-bg: #fbefd5;
  --mention-text: #7a5216;
  --danger: #ae4f3d;
  --on-danger: #ffffff;
  --success: #35844c; --on-success: #ffffff;
  --online: #3f9d5a;
  --badge: #c2412d;
  --badge-text: #c2412d;
  --code-bg: #f1efe9;
  --shadow: 0 8px 28px rgba(20, 30, 28, .16);
  --hl-bg: #f7dc9b;
  --hl-text: #1d2321;
  --skel: #ebe8e1;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1d1c; --bg-soft: #212524; --bg-hover: #262b29; --text: #e4e6e4; --muted: #9aa29f;
    --border: #333836; --side-bg: #132523; --side-hover: #1d3532; --top-bg: #0e1c1b;
    --accent: #d4a24c; --accent-strong: #e2b766; --accent-soft: #3a2f1c; --mention-bg: #3d3120; --mention-text: #f0cf8c;
    --on-accent: #1d2321; --danger: #e07a66; --on-danger: #1d2321; --success: #3f9d5a; --on-success: #1d2321; --badge-text: #e07a66;
    --code-bg: #262b29; --shadow: 0 8px 28px rgba(0, 0, 0, .5); --hl-bg: #6b5223; --hl-text: #fff3d6; --skel: #2c3230; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1d1c; --bg-soft: #212524; --bg-hover: #262b29; --text: #e4e6e4; --muted: #9aa29f;
  --border: #333836; --side-bg: #132523; --side-hover: #1d3532; --top-bg: #0e1c1b;
  --accent: #d4a24c; --accent-strong: #e2b766; --accent-soft: #3a2f1c; --mention-bg: #3d3120; --mention-text: #f0cf8c;
  --on-accent: #1d2321; --danger: #e07a66; --on-danger: #1d2321; --success: #3f9d5a; --on-success: #1d2321; --badge-text: #e07a66;
  --code-bg: #262b29; --shadow: 0 8px 28px rgba(0, 0, 0, .5); --hl-bg: #6b5223; --hl-text: #fff3d6; --skel: #2c3230; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
a { color: var(--accent-strong); }

/* login */
.login { min-height: 100%; display: grid; place-items: center; background: var(--side-bg); padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--bg); border-radius: 14px; padding: 32px 28px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.login-card .logo-scuro { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .login-card .logo-chiaro { display: none; } :root:not([data-theme="light"]) .login-card .logo-scuro { display: block; } }
:root[data-theme="dark"] .login-card .logo-chiaro { display: none; }
:root[data-theme="dark"] .login-card .logo-scuro { display: block; }
.login-card h1 { margin: 4px 0 0; font-size: 26px; }
.login-card p { margin: 0 0 8px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.login-card input { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); font-weight: 400; font-size: 15px; }
.error { color: var(--danger); min-height: 1em; font-size: 13px; margin: 0; }
.info { color: var(--success); font-size: 13px; margin: 0; }
.info:empty { display: none; }
.link.muted { color: var(--muted); font-size: 13px; }
.link { color: var(--accent-strong); font-size: 14px; }

.btn { padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 14px; border: 1px solid var(--border); background: var(--bg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-strong); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.btn.ghost { border-color: transparent; }
.btn.ghost:hover { background: var(--bg-hover); }
.btn.small { padding: 4px 8px; font-size: 13px; }
.icon-btn { width: 30px; height: 30px; border-radius: 6px; display: inline-grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

/* layout */
.app { position: relative; height: 100%; display: grid; grid-template-columns: 68px auto 1fr auto; grid-template-rows: 44px 1fr; grid-template-areas: "top top top top" "rail side main panel"; }
.topbar { grid-area: top; background: var(--top-bg); display: grid; grid-template-columns: 1fr minmax(200px, 640px) 1fr; align-items: center; padding: 0 12px; gap: 12px; }
.search { position: relative; display: flex; align-items: center; gap: 6px; padding: 0 6px 0 10px; height: 30px; border-radius: 6px; border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.1); color: #fff; min-width: 0; }
.search:focus-within, .search.on { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.35); }
.search input { flex: 1; min-width: 0; padding: 4px 0; border: 0; outline: 0; background: transparent; color: #fff; }
.search input::placeholder { color: rgba(255,255,255,.7); }
.search-ic { opacity: .8; font-size: 16px; line-height: 1; }
.search-label { font-weight: 600; font-size: 14px; white-space: nowrap; }
.search-clear { color: #fff; opacity: .8; width: 24px; height: 24px; border-radius: 5px; font-size: 13px; flex: none; }
.search-clear:hover { opacity: 1; background: rgba(255,255,255,.15); }
.topbar-right { justify-self: end; }
.avatar-btn { padding: 0; border-radius: 6px; }

.sidebar { grid-area: side; width: var(--side-w, 260px); background: var(--side-bg); color: var(--side-text); overflow-y: auto; padding-bottom: 16px; }
/* le pagine Attività e Salvati occupano tutta l'area: niente barra laterale */
.app[data-view="activity"] .sidebar, .app[data-view="later"] .sidebar { display: none; }

/* colonna di navigazione */
.rail { grid-area: rail; background: var(--top-bg); display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 0 12px; min-height: 0; overflow-y: auto; }
.rail-item { position: relative; width: 60px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; color: var(--side-text); font-size: 11px; font-weight: 600; border-radius: 8px; }
.rail-ic { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; font-size: 18px; line-height: 1; }
.rail-item:hover .rail-ic { background: var(--side-hover); }
.rail-item.active .rail-ic { background: var(--side-active); color: var(--side-active-text); }
.rail-item.active { color: var(--side-strong); }
.rail-item:focus-visible, .rail-me:focus-visible { outline: 2px solid var(--side-active); outline-offset: 1px; }
.rail-lb { line-height: 1.2; }
.rail-badge { display: none; position: absolute; top: 0; right: 6px; background: var(--badge); color: #fff; font-size: 11px; font-weight: 700; border-radius: 9px; padding: 0 5px; min-width: 18px; line-height: 18px; text-align: center; border: 2px solid var(--top-bg); }
.rail-badge.on { display: block; }
.rail-badge.dot { min-width: 0; width: 12px; height: 12px; padding: 0; right: 12px; top: 2px; background: var(--side-strong); }
.rail-fill { flex: 1; }
.rail-me { border-radius: 8px; }
#me-btn .avatar { width: 40px; height: 40px; font-size: 15px; border-radius: 10px; }
.vp-actions .sr-chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }

/* vista Messaggi diretti: elenco al posto della barra di Home */
.side-title { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px 16px; }
.side-title h2 { flex: 1; margin: 0; color: var(--side-strong); font-size: 17px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-toggle { display: flex; align-items: center; gap: 4px; font-size: 13px; white-space: nowrap; cursor: pointer; }
.side-toggle input { accent-color: var(--side-active); margin: 0; }
.side-title-btn { width: 28px; height: 28px; border-radius: 6px; color: var(--side-text); font-size: 16px; flex: none; }
.side-title-btn:hover { background: var(--side-hover); color: var(--side-strong); }
.side-filter-row { display: flex; align-items: center; gap: 8px; margin: 0 12px 8px; }
.side-filter { display: block; flex: 1; min-width: 0; padding: 5px 10px; border-radius: 6px; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.08); color: var(--side-strong); font-size: 14px; outline: 0; }
.side-filter::placeholder { color: var(--side-text); }
.side-filter:focus { border-color: var(--side-active); }
.side-empty { padding: 16px; font-size: 14px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.dm-row { display: flex; align-items: center; gap: 10px; width: calc(100% - 16px); margin: 0 8px; padding: 8px 10px; border-radius: 8px; text-align: left; color: var(--side-text); }
.dm-row:hover { background: var(--side-hover); }
.dm-row.active { background: var(--side-active); color: var(--side-active-text); }
.dm-row.unread .dm-name, .dm-row.unread .dm-prev { color: var(--side-strong); font-weight: 700; }
.dm-pic { position: relative; flex: none; }
.dm-group { background: var(--side-hover); color: var(--side-strong); }
.dm-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dm-top { display: flex; align-items: baseline; gap: 8px; }
.dm-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-time { font-size: 12px; flex: none; }
.dm-prev { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-row.active .dm-name, .dm-row.active .dm-prev { color: var(--side-active-text); }
.ws-name { color: var(--side-strong); font-weight: 800; font-size: 17px; padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.side-nav { padding: 8px 0; }
.side-section { padding: 6px 0; }
.side-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 16px; font-size: 13px; font-weight: 600; }
.side-actions button { color: var(--side-text); width: 24px; height: 24px; border-radius: 5px; font-size: 16px; }
.side-actions button:hover { background: var(--side-hover); color: #fff; }
.side-item { display: flex; align-items: center; gap: 8px; width: calc(100% - 16px); margin: 0 8px; padding: 4px 10px; border-radius: 6px; text-align: left; color: var(--side-text); font-size: 15px; min-height: 30px; }
.side-item:hover { background: var(--side-hover); }
.side-item.active { background: var(--side-active); color: var(--side-active-text); }
.side-item.unread { color: var(--side-strong); font-weight: 700; }
.side-item .ic { width: 18px; text-align: center; opacity: .85; flex: none; }
.side-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { background: var(--badge); color: #fff; font-size: 12px; font-weight: 700; border-radius: 9px; padding: 0 6px; min-width: 18px; text-align: center; line-height: 18px; }
.dot { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid currentColor; flex: none; margin: 0 4px; }
.dot.on { background: var(--online); border-color: var(--online); }

.main { grid-area: main; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.conv-header { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-bottom: 1px solid var(--border); min-height: 54px; }
.menu-btn { display: none; font-size: 20px; }
.conv-header { flex-wrap: wrap; row-gap: 2px; }  /* con la colonna dei messaggi stretta i pulsanti vanno sotto il titolo */
.conv-title-wrap { flex: 1 1 160px; min-width: 0; }
.conv-title { font-weight: 800; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-topic { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.conv-actions { display: flex; gap: 4px; }

.messages { flex: 1; overflow-y: auto; padding: 12px 0 8px; }
.day-sep { display: flex; align-items: center; gap: 12px; margin: 16px 20px 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.day-sep::before, .day-sep::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.new-sep { display: flex; align-items: center; gap: 8px; margin: 6px 20px; color: var(--badge-text); font-size: 12px; font-weight: 700; }
.new-sep::before { content: ""; flex: 1; border-top: 1px solid var(--badge); }
.empty { padding: 40px 24px; color: var(--muted); }
.empty h2 { color: var(--text); margin: 0 0 6px; font-size: 22px; }

.msg { position: relative; display: grid; grid-template-columns: 40px 1fr; gap: 0 10px; padding: 6px 20px; }
.msg.compact { padding-top: 1px; padding-bottom: 1px; }
.msg:hover, .msg.menu-open { background: var(--bg-soft); }
.msg.highlight { background: var(--accent-soft); transition: background 2s; }
.msg.pinned-msg { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
.msg .time-side { font-size: 11px; color: var(--muted); text-align: right; padding-top: 3px; visibility: hidden; }
.msg.compact:hover .time-side { visibility: visible; }
.avatar { width: 36px; height: 36px; border-radius: 8px; color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px; flex: none; position: relative; }
.avatar.bot { background: var(--bg-soft); border: 1px solid var(--border); font-size: 20px; }
.avatar.bot.sm { font-size: 13px; }
.app-tag { font-size: 10px; font-weight: 700; color: var(--muted); background: var(--bg-hover); border-radius: 3px; padding: 0 4px; letter-spacing: .04em; }
.avatar.sm { width: 22px; height: 22px; border-radius: 5px; font-size: 11px; }
.avatar.xs { width: 20px; height: 20px; border-radius: 4px; font-size: 10px; }
.avatar.avatar-add { background: var(--accent); color: var(--on-accent); }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-author { font-weight: 800; cursor: pointer; }
.msg-author:hover { text-decoration: underline; }
.msg-time { font-size: 12px; color: var(--muted); }
.msg-text { word-wrap: break-word; overflow-wrap: anywhere; }
.msg-text p { margin: 0; }
.msg-text code { background: var(--code-bg); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--danger); }
.msg-text pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; margin: 4px 0; overflow-x: auto; font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; }
.msg-text blockquote { margin: 2px 0; padding-left: 10px; border-left: 4px solid var(--border); color: var(--muted); }
.mention { background: var(--mention-bg); color: var(--mention-text); border-radius: 4px; padding: 0 2px; font-weight: 600; }
.mention.me { background: var(--accent); color: var(--on-accent); }
.edited { color: var(--muted); font-size: 12px; }
.deleted-text { color: var(--muted); font-style: italic; }
.pin-label { font-size: 12px; color: var(--accent-strong); font-weight: 600; grid-column: 2; }

.files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.file-img { max-width: min(360px, 100%); max-height: 260px; border-radius: 8px; border: 1px solid var(--border); display: block; cursor: zoom-in; }
.file-card { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; text-decoration: none; color: var(--text); max-width: 320px; background: var(--bg); }
.file-card .fi { width: 34px; height: 34px; border-radius: 6px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: none; }
.file-card .fn { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card .fs { font-size: 12px; color: var(--muted); }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border); background: var(--bg-soft); border-radius: 12px; padding: 1px 8px; font-size: 13px; }
.reaction:hover { border-color: var(--muted); }
.reaction.mine { background: var(--accent-soft); border-color: var(--accent); }
.reaction .n { font-weight: 600; font-size: 12px; }
.add-react { color: var(--muted); }

.thread-link { display: flex; align-items: center; gap: 6px; margin-top: 4px; padding: 3px 6px; border-radius: 6px; border: 1px solid transparent; width: fit-content; font-size: 13px; }
.thread-link:hover { background: var(--bg); border-color: var(--border); }
.thread-link b { color: var(--accent-strong); }
.thread-link .muted { font-size: 12px; }

.msg-tools { position: absolute; top: -14px; right: 20px; display: none; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.08); padding: 2px; z-index: 2; }
.msg:hover .msg-tools, .msg.menu-open .msg-tools { display: flex; }
.msg-tools button { width: 30px; height: 28px; border-radius: 6px; font-size: 15px; }
.msg-tools button:hover { background: var(--bg-hover); }

.edit-box .edit-wrap { border: 1px solid var(--accent); border-radius: 8px; background: var(--bg); }
.edit-box .rich-editor { min-height: 44px; }
.edit-box .row { display: flex; gap: 6px; justify-content: flex-end; align-items: center; margin-top: 4px; }
.edit-box .row .hint { margin-right: auto; font-size: 12px; }
.sched-edit { border: 1px solid var(--border); border-radius: 8px; background: var(--bg); font-weight: 400; }
.sched-edit .rich-editor { min-height: 70px; }

.typing { height: 20px; padding: 0 20px; font-size: 12px; color: var(--muted); }

.join-bar { margin: 0 20px 16px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--bg-soft); }

/* composer */
.composer { margin: 0 20px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.composer:focus-within { border-color: var(--muted); box-shadow: 0 0 0 1px var(--muted); }
.panel .composer { margin: 0 14px 14px; }
.composer-bottom { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 6px; }
.composer-bottom .left { display: flex; gap: 2px; align-items: center; }
.composer-bottom .left button { width: 30px; height: 28px; border-radius: 6px; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.composer-bottom .left button:hover { background: var(--bg-hover); color: var(--text); }
.composer-bottom .fmt-toggle[aria-pressed="true"] { color: var(--text); }
.composer-bottom .fmt-toggle { margin-right: 4px; position: relative; }
.composer-bottom .fmt-toggle::after { content: ""; position: absolute; right: -4px; top: 6px; bottom: 6px; border-right: 1px solid var(--border); }
.ic-svg { display: inline-block; vertical-align: -0.22em; flex: none; }  /* nei contenitori flex e grid diventa un blocco come prima */

/* editor con la formattazione visibile */
.fmt-bar { display: flex; align-items: center; gap: 1px; padding: 4px 6px 0; flex-wrap: wrap; }
.composer.no-fmt .fmt-bar { display: none; }
.fmt-btn { width: 28px; height: 26px; border-radius: 5px; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.fmt-btn .ic-svg { width: 17px; height: 17px; }
.fmt-btn:hover { background: var(--bg-hover); color: var(--text); }
.fmt-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); }
.fmt-sep { width: 1px; height: 16px; background: var(--border); margin: 0 4px; }
.rich-editor { position: relative; padding: 8px 12px; min-height: 40px; max-height: 240px; overflow-y: auto; outline: 0; word-wrap: break-word; overflow-wrap: anywhere; line-height: 1.45; cursor: text; }
.rich-editor.empty::before { content: attr(data-placeholder); position: absolute; left: 12px; top: 8px; color: var(--muted); pointer-events: none; }
.rich-editor p { margin: 0; }
.rich-editor ul, .rich-editor ol { margin: 2px 0; padding-left: 24px; }
.rich-editor blockquote { margin: 2px 0; padding-left: 10px; border-left: 4px solid var(--border); color: var(--muted); }
.rich-editor code { background: var(--code-bg); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--danger); }
.rich-editor pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; margin: 4px 0; font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; }
.rich-editor a { color: var(--accent-strong); text-decoration: underline; }
.link-pop { position: fixed; z-index: 70; width: 300px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.link-pop .field span { font-size: 13px; }
.link-pop .field input { padding: 7px 9px; }
.link-pop .error { margin: 0; min-height: 0; font-size: 12px; color: var(--danger); }
.link-pop .error:empty { display: none; }
.link-pop .row { display: flex; gap: 6px; justify-content: flex-end; }
.link-pop .link-rm { margin-right: auto; }

/* invio e programmazione: un solo blocco, spento finché non c'è niente da mandare */
.send-group { display: inline-flex; align-items: stretch; border-radius: 6px; overflow: hidden; background: var(--bg-hover); }
.composer.ready .send-group { background: var(--accent); }
.send-btn, .sched-btn { display: inline-flex; align-items: center; justify-content: center; height: 28px; color: var(--on-accent); background: transparent; }
.send-btn { width: 34px; }
.sched-btn { width: 24px; }
.sched-btn .ic-svg { width: 15px; height: 15px; }
.send-sep { width: 1px; margin: 5px 0; background: color-mix(in srgb, var(--on-accent) 45%, transparent); }
.send-btn:not(:disabled):hover, .sched-btn:not(:disabled):hover, .sched-btn[aria-expanded="true"] { background: var(--accent-strong); }
.send-btn:disabled, .sched-btn:disabled { color: var(--muted); cursor: default; }
.send-btn:disabled ~ .send-sep, .composer:not(.ready) .send-sep { background: var(--border); }
.sched-menu { min-width: 240px; }
/* barra dei programmati: attaccata sopra il composer della conversazione o del thread */
.sched-bar { margin: 0 20px; display: flex; align-items: center; gap: 8px; padding: 5px 10px 5px 12px; min-height: 32px; border: 1px solid var(--border); border-bottom: 0; border-radius: 10px 10px 0 0; background: var(--bg-soft); color: var(--muted); font-size: 13px; animation: bl-fade var(--t-med) ease-out; }
.panel .sched-bar { margin: 0 14px; }
.sched-bar .sb-ic { display: inline-grid; place-items: center; flex: none; }
.sched-bar .sb-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sched-bar .sb-open { flex: none; font-size: 13px; font-weight: 600; padding: 2px 6px; border-radius: 6px; }
.sched-bar .sb-open:hover, .sched-bar .sb-open[aria-expanded="true"] { background: var(--bg-hover); text-decoration: underline; }
.has-sched > .composer { border-top-left-radius: 0; border-top-right-radius: 0; }
.sched-pop { padding: 8px 0 4px; max-height: min(420px, 60vh); display: flex; flex-direction: column; }
.sched-pop .sp-head { padding: 2px 14px 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
.sched-pop .sp-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.sched-pop .sp-item { padding: 8px 14px; border-top: 1px solid var(--border); }
.sched-pop .sp-item.err { background: color-mix(in srgb, var(--danger) 8%, transparent); }
.sched-pop .sp-when { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.sched-pop .sp-text { margin: 3px 0 4px; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-height: 2.9em; overflow-wrap: anywhere; }
.sched-pop .sp-text p, .sched-pop .sp-text pre, .sched-pop .sp-text blockquote, .sched-pop .sp-text ul, .sched-pop .sp-text ol { margin: 0; }
.sched-pop .sched-error { padding: 0 0 4px; }
.sched-pop .sp-acts { display: flex; gap: 14px; }
.sched-pop .sp-acts .link, .sched-pop .sp-foot .link { font-size: 13px; font-weight: 600; }
.sched-pop .link.danger { color: var(--danger); }
.sched-pop .link:hover { text-decoration: underline; }
.sched-pop .sp-foot { border-top: 1px solid var(--border); padding: 8px 14px 4px; }
.sched-menu [data-quick] { display: flex; gap: 10px; align-items: center; }
.sched-menu [data-quick] .sub { display: block; font-size: 12px; color: var(--muted); }
.sched-menu [data-quick]:hover .sub, .sched-menu [data-quick]:focus .sub { color: inherit; }
.sched-menu button:focus-visible { background: var(--accent); color: var(--on-accent); outline: 0; }
.sched-ic { color: inherit; }
.pending-files { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 10px 0; }
.pending-file { display: flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; font-size: 13px; background: var(--bg-soft); }
.pending-file img { width: 34px; height: 34px; object-fit: cover; border-radius: 4px; }
.pending-file button { color: var(--muted); }

/* panel */
.panel { grid-area: panel; width: var(--panel-w, 400px); border-left: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 16px; border-bottom: 1px solid var(--border); font-weight: 800; min-height: 54px; }
.panel-head .sub { font-weight: 400; color: var(--muted); font-size: 13px; }
.panel-body { flex: 1; overflow-y: auto; padding: 8px 0; }
.panel .msg { padding-left: 14px; padding-right: 14px; }
.panel .msg-tools { right: 14px; }
.reply-count { display: flex; align-items: center; gap: 8px; margin: 6px 14px; color: var(--muted); font-size: 13px; }
.reply-count::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.result-ctx { padding: 8px 16px 0; font-size: 12px; color: var(--muted); font-weight: 600; }
.result { cursor: pointer; border-bottom: 1px solid var(--border); }
.result:hover { background: var(--bg-soft); }

/* modal & popover */
.modal-back { position: fixed; inset: 0; background: rgba(10, 16, 15, .5); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--bg); border-radius: 12px; width: 100%; max-width: 520px; max-height: 85vh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px 6px; }
.modal-head h2 { margin: 0; font-size: 21px; }
.modal-body { padding: 10px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { padding: 12px 22px 18px; display: flex; justify-content: flex-end; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 14px; }
.field input, .field textarea, .field select { padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); font-weight: 400; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 8px; text-align: left; width: 100%; }
.list-row:hover { background: var(--bg-hover); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; gap: 6px; align-items: center; background: var(--accent-soft); border-radius: 6px; padding: 2px 8px; font-size: 14px; }

.popover { position: fixed; z-index: 60; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 34px); gap: 2px; padding: 8px; }
.emoji-grid button { height: 34px; border-radius: 6px; font-size: 20px; }
.emoji-grid button:hover { background: var(--bg-hover); }
.menu { padding: 6px 0; min-width: 200px; }
.menu button { display: block; width: 100%; text-align: left; padding: 8px 16px; font-size: 14px; }
.menu button:hover { background: var(--accent); color: var(--on-accent); }
.menu button.danger { color: var(--danger); }
.menu button.danger:hover { background: var(--danger); color: var(--on-danger); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.autocomplete { max-height: 240px; overflow-y: auto; min-width: 260px; padding: 4px; }
.ac-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; width: 100%; text-align: left; font-size: 14px; }
.ac-row.sel { background: var(--accent); color: var(--on-accent); }
.ac-row .muted { font-size: 13px; }
.ac-row.sel .muted { color: var(--on-accent); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 70; box-shadow: var(--shadow); }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: grid; place-items: center; z-index: 80; cursor: zoom-out; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }
.offline-bar { background: var(--danger); color: var(--on-danger); text-align: center; font-size: 13px; padding: 4px; }

/* pagine nell'area centrale: Attività, Salvati, Non letti */
.view-page { grid-area: main; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
.vp-wrap { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.vp-head { display: flex; align-items: center; gap: 8px; padding: 8px 16px; min-height: 54px; }
.vp-title { flex: 1; margin: 0; font-size: 17px; font-weight: 800; }
.vp-actions { display: flex; gap: 8px; align-items: center; }
.vp-tabs { display: flex; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; flex: none; }
.vp-tabs::-webkit-scrollbar { display: none; }
.vp-tab { padding: 8px 10px; font-size: 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.vp-tab:hover { color: var(--text); }
.vp-tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.vp-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.app[data-view="unread"] .vp-head { border-bottom: 1px solid var(--border); }
.vp-body { flex: 1; overflow-y: auto; padding: 4px 0 24px; }
.vp-empty { max-width: 380px; margin: 12vh auto 0; padding: 0 24px; text-align: center; color: var(--muted); }
.vp-empty-ic { font-size: 30px; }
.vp-empty h2 { color: var(--text); font-size: 16px; margin: 8px 0 4px; }
.vp-empty p { margin: 0; font-size: 14px; }
.act-ic { display: inline-block; min-width: 16px; text-align: center; }
.act-item.new { box-shadow: inset 3px 0 0 var(--accent); }
.act-new { background: var(--accent-soft); color: var(--text); border-radius: 4px; padding: 0 5px; margin-right: 6px; font-size: 11px; }
.unread-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 4px; }
.unread-head b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread-head .muted { font-size: 13px; }
.view-page .result-ctx, .view-page .unread-head { padding-left: 20px; padding-right: 20px; }
.view-page .sched-actions, .view-page .sched-error { padding-left: 20px; padding-right: 20px; }
.view-page .sched-item .msg-text { padding-left: 20px !important; }
.view-page .rem-item { padding-bottom: 10px; }

@media (max-width: 1100px) {
  .panel { position: fixed; right: 0; top: 44px; bottom: 0; z-index: 30; box-shadow: var(--shadow); max-width: 100%; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: 44px minmax(0, 1fr) 58px; grid-template-areas: "top" "main" "rail"; }
  .topbar { grid-template-columns: 1fr auto; }
  .topbar-left { display: none; }
  .rail { flex-direction: row; justify-content: space-around; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); gap: 0; overflow: visible; }
  .rail-fill { display: none; }
  .rail-item { width: auto; flex: 1; max-width: 80px; }
  .rail-ic { width: 32px; height: 28px; font-size: 17px; }
  .rail-me { flex: none; padding: 0 8px; }
  #me-btn .avatar { width: 30px; height: 30px; font-size: 12px; border-radius: 8px; }
  .sidebar { position: fixed; top: 44px; bottom: 58px; left: 0; width: 280px; max-width: 85vw; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .vp-head { padding: 8px 12px; }
  .vp-actions .btn { white-space: nowrap; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .menu-btn { display: block; }
  .panel { width: 100%; }
  /* intestazione stretta: il titolo tiene sempre una riga sua (con ellissi), i pulsanti vanno a capo sotto */
  .conv-header { padding: 6px 12px; }
  .conv-title-wrap { flex: 1 1 calc(100% - 44px); min-width: 120px; }
  .conv-actions { flex-wrap: wrap; row-gap: 2px; max-width: 100%; }
  .msg { padding-left: 16px; padding-right: 16px; }
  .composer { margin: 0 12px 12px; }
  .sched-bar { margin: 0 12px; }
  .msg-tools { right: 12px; }
}

.google-btn { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px; }
.or-sep { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.or-sep::before, .or-sep::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

.menu-title { padding: 4px 16px 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
.sched-item { border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.sched-item.err { background: color-mix(in srgb, var(--danger) 8%, transparent); }
.sched-error { color: var(--danger); font-size: 13px; padding: 0 14px 6px; }
.sched-actions { display: flex; gap: 6px; padding: 0 14px; }
.goto-msg { display: inline-block; margin-top: 4px; font-weight: 600; text-decoration: none; }

.side-item .count { font-size: 12px; opacity: .8; }
.emoji-search { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); }
.emoji-grid { max-height: 260px; overflow-y: auto; }
.msg-text ul, .msg-text ol { margin: 2px 0; padding-left: 22px; }
.poll { border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-top: 2px; max-width: 460px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); }
.poll-q { font-weight: 700; }
.poll-opt { position: relative; display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; overflow: hidden; text-align: left; }
.poll-opt:hover { border-color: var(--accent); }
.poll-opt.mine { border-color: var(--accent); font-weight: 600; }
.poll-bar { position: absolute; inset: 0 auto 0 0; background: var(--accent-soft); z-index: 0; transition: width .3s; }
.poll-label, .poll-n { position: relative; z-index: 1; }
.poll-n { font-weight: 700; color: var(--muted); }
.lp-card { display: flex; gap: 12px; margin-top: 6px; border-left: 4px solid var(--border); padding: 4px 10px; max-width: 520px; text-decoration: none; color: var(--text); }
.lp-card:hover { border-left-color: var(--accent); }
.lp-text { flex: 1; min-width: 0; }
.lp-site { font-size: 12px; color: var(--muted); font-weight: 600; }
.lp-title { font-weight: 700; color: var(--accent-strong); }
.lp-desc { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lp-img { width: 80px; height: 80px; object-fit: cover; border-radius: 6px; flex: none; }
.fwd-preview { border-left: 4px solid var(--border); max-height: 160px; overflow: hidden; }
.fwd-preview .msg-tools { display: none !important; }
.unread-block { border-bottom: 6px solid var(--bg-soft); }
.join-bar.archived { background: var(--bg-hover); }

/* ricerca: popup sotto la casella */
.search-pop { position: absolute; top: calc(100% + 6px); left: -1px; right: -1px; z-index: 45; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); max-height: min(560px, calc(100vh - 70px)); overflow-y: auto; padding: 6px 0 0; }
.sp-row, .sp-msg { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 8px 16px; font-size: 14px; min-height: 36px; }
.sp-row .grow, .sp-msg .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-row.sel, .sp-msg.sel { background: var(--bg-hover); box-shadow: inset 3px 0 0 var(--accent); }
.sp-ic { width: 22px; height: 22px; display: inline-grid; place-items: center; flex: none; color: var(--muted); font-size: 15px; }
.sp-ic.box { border: 1px solid var(--border); border-radius: 5px; background: var(--bg-soft); font-size: 12px; color: var(--text); }
.sp-act { flex: none; font-size: 12px; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 1px 8px; visibility: hidden; }
.sp-row.sel .sp-act { visibility: visible; }
.sp-act.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.sp-head { padding: 8px 14px 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.sp-sep { border-top: 1px solid var(--border); margin: 6px 0; }
.sp-note { padding: 8px 14px 10px; font-size: 13px; color: var(--muted); }
.sp-msg { align-items: flex-start; margin: 4px 10px; width: calc(100% - 20px); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.sp-msg .avatar { width: 30px; height: 30px; font-size: 12px; }
.sp-msg .grow { white-space: normal; display: flex; flex-direction: column; gap: 2px; }
.sp-msg-top { display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.sp-msg-top .muted { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.sp-date { font-size: 12px; color: var(--muted); flex: none; }
.sp-snip { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-foot { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 8px 14px; margin-top: 6px; border-top: 1px solid var(--border); background: var(--bg-soft); font-size: 12px; color: var(--muted); }
kbd { font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 2px 5px; background: var(--bg); color: var(--text); margin-right: 3px; }
.sp-row kbd { margin-left: auto; color: var(--muted); }
mark.hl { background: var(--hl-bg); color: var(--hl-text); border-radius: 3px; padding: 0 1px; }

/* ricerca: pagina risultati al posto della conversazione */
.search-page { grid-area: main; min-width: 0; min-height: 0; overflow-y: auto; background: var(--bg); }
.sr-wrap { max-width: 1080px; padding: 18px 28px 32px; }
.sr-title { margin: 0 0 12px; font-size: 20px; font-weight: 400; overflow-wrap: anywhere; }
.sr-title b { font-weight: 800; }
.sr-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-bottom: 4px; }
.sr-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-weight: 600; background: var(--bg); white-space: nowrap; min-height: 32px; }
.sr-chip:hover { background: var(--bg-hover); }
.sr-chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.sr-chip .ci { font-size: 13px; opacity: .85; }
.sr-chip .caret { font-size: 10px; color: var(--muted); }
.sr-div { width: 1px; align-self: stretch; background: var(--border); margin: 2px 2px; }
.sr-reset { color: var(--accent-strong); font-size: 14px; font-weight: 600; padding: 4px 6px; white-space: nowrap; }
.sr-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 12px 0 10px; font-size: 14px; color: var(--muted); }
.sr-sort { color: var(--accent-strong); font-weight: 600; }
.sr-count { font-weight: 600; }
.sr-list { display: flex; flex-direction: column; gap: 10px; }
.sr-card { position: relative; display: grid; grid-template-columns: 36px 1fr; gap: 0 12px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); cursor: pointer; }
.sr-card:hover, .sr-card.menu-open, .sr-card:focus-visible { background: var(--bg-soft); }
.sr-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sr-main { min-width: 0; }
.sr-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sr-author { font-weight: 800; }
.sr-where { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.sr-date { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }
.sr-text { max-height: 7.4em; overflow: hidden; margin-top: 2px; }
.sr-card.open .sr-text { max-height: none; }
.sr-more { color: var(--accent-strong); font-size: 13px; font-weight: 600; padding: 2px 0; }
.sr-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.sr-file { font-size: 13px; border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; background: var(--bg-soft); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-counts { display: flex; gap: 6px; margin-top: 8px; }
.sr-cnt { font-size: 12px; font-weight: 600; border: 1px solid var(--border); border-radius: 12px; padding: 1px 9px; color: var(--muted); background: var(--bg); }
.sr-tools { position: absolute; top: -12px; right: 14px; display: none; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.08); padding: 2px; }
.sr-card:hover .sr-tools, .sr-card.menu-open .sr-tools, .sr-card:focus-within .sr-tools { display: flex; }
.sr-tools button { width: 30px; height: 28px; border-radius: 6px; font-size: 15px; }
.sr-tools button:hover { background: var(--bg-hover); }
.sr-state { padding: 28px 4px; color: var(--muted); }
.sr-state h2 { color: var(--text); font-size: 18px; margin: 0 0 8px; }
.sr-state ul { margin: 6px 0; padding-left: 20px; line-height: 1.8; }
.sr-state code { background: var(--code-bg); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; font-size: 13px; }
.sr-state.err h2 { color: var(--danger); }
.sr-loadmore { align-self: center; margin-top: 4px; }
.sr-end { text-align: center; color: var(--muted); font-size: 13px; padding: 8px; }
.sr-skel { cursor: default; }
.sr-skel .avatar { background: var(--skel); }
.sr-skel .sr-main span { display: block; height: 12px; border-radius: 6px; background: var(--skel); margin: 6px 0 10px; animation: srpulse 1.2s ease-in-out infinite; }
.sr-skel .sr-main span.short { width: 40%; }
@keyframes srpulse { 50% { opacity: .5; } }
.sr-pick { width: 300px; padding: 8px; }
.sr-pick .list { max-height: 300px; overflow-y: auto; margin-top: 6px; }
.sr-pick .sp-ic { color: var(--text); }
.menu button[aria-checked="true"] { font-weight: 700; }

@media (max-width: 760px) {
  .search-pop { position: fixed; top: 46px; left: 8px; right: 8px; max-height: calc(100vh - 56px); }
  .search-label { display: none; }
  .sr-wrap { padding: 14px 16px 24px; }
  .sr-filters { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 8px; scrollbar-width: none; }
  .sr-filters::-webkit-scrollbar { display: none; }
  .sr-card { padding: 10px 12px; grid-template-columns: 30px 1fr; gap: 0 10px; }
  .sr-card .avatar { width: 30px; height: 30px; font-size: 12px; }
  .sr-tools { right: 8px; }
  .sp-foot { display: none; }
}
@media (prefers-reduced-motion: reduce) { .sr-skel .sr-main span { animation: none; } }

/* ---------- terzo blocco ---------- */
.draft-ic { font-size: 12px; opacity: .8; flex: none; }
.rail-me { position: relative; }
.me-dnd, .me-away { position: absolute; right: -2px; bottom: -2px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--side-bg); font-size: 9px; line-height: 10px; font-weight: 800; text-align: center; }
.me-dnd { background: var(--side-active); color: var(--side-active-text); }
.me-away { background: var(--side-bg); box-shadow: inset 0 0 0 2px var(--side-text); }
button.edited { padding: 0; background: none; border: 0; cursor: pointer; text-decoration: underline dotted; }
button.edited:hover { color: var(--text); }
.bc-ctx { display: block; font-size: 12px; color: var(--muted); padding: 0; margin-bottom: 2px; text-align: left; }
.bc-ctx span { color: var(--accent-strong); font-weight: 600; }
.bc-ctx:hover span { text-decoration: underline; }
.bc-tag { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.bc-check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); padding: 2px 10px 0; }
.cmd-args { color: var(--muted); font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.cemoji { width: 20px; height: 20px; object-fit: contain; vertical-align: -4px; }
.reaction .cemoji { width: 16px; height: 16px; vertical-align: -3px; }
.emoji-grid .cemoji { width: 22px; height: 22px; }
.bookmarks { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.bm { display: inline-flex; align-items: center; gap: 2px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-soft); }
.bm a { padding: 2px 8px; color: var(--text); text-decoration: none; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm a:hover { text-decoration: underline; }
.bm-x { padding: 0 6px; color: var(--muted); font-size: 11px; }
.bm-x:hover { color: var(--danger); }
.bm-add { padding: 2px 8px; color: var(--muted); border-radius: 6px; }
.bm-add:hover { background: var(--bg-hover); color: var(--text); }
#panel-follow { margin-left: auto; margin-right: 6px; }
#panel-follow[aria-pressed="true"] { background: var(--accent-soft); }
.thread-card { border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.thread-card .unread-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px 0; }
.thread-card .grow { flex: 1; }
.thread-replies { margin-left: 28px; border-left: 2px solid var(--border); }
.thread-more { margin: 2px 0 2px 42px; font-size: 13px; color: var(--accent-strong); font-weight: 600; }
.thread-more:hover { text-decoration: underline; }
.edits { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow: auto; }
.edit-ver { border: 1px solid var(--border); border-radius: 8px; padding-bottom: 8px; }
.edit-ver .msg-text { padding: 4px 14px 0; }
.dnd-on { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 10px; background: var(--accent-soft); border-radius: 8px; }
a.file-link { text-decoration: none; color: inherit; }
.vp-head { flex-wrap: wrap; }
.vp-actions { flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
.app[data-view="threads"] .vp-head { border-bottom: 1px solid var(--border); }
@media (max-width: 760px) {
  .vp-actions [data-page-go] { display: none; }
}
.thread-replies .day-sep { display: none; }

/* chiamate vocali: pulsante nell'intestazione, barra in basso a sinistra, schermo condiviso */
.call-btn.live { color: var(--success); font-weight: 700; }
.call-btn.live .call-n { margin-left: 4px; }
.call-btn.live:hover { color: var(--text); }
.call-btn.in { box-shadow: inset 0 -2px 0 var(--success); }
.side-item .call-ic { flex: none; font-size: 12px; line-height: 1; }
.rail-item.has-call .rail-ic::after { content: ""; position: absolute; left: 14px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--online); border: 2px solid var(--top-bg); }
.call-bar { position: fixed; left: 68px; bottom: 0; width: var(--side-w, 260px); z-index: 35; background: var(--top-bg); color: var(--side-text); border-top: 1px solid var(--side-hover); padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.app.in-call .sidebar { padding-bottom: 150px; }
.call-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.call-live { width: 8px; height: 8px; border-radius: 50%; background: var(--online); flex: none; }
.call-where { flex: 1; min-width: 0; text-align: left; color: var(--side-strong); font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-where:hover { text-decoration: underline; }
.call-time { font-size: 12px; font-variant-numeric: tabular-nums; opacity: .8; }
.call-parts { display: flex; flex-wrap: wrap; gap: 6px; }
.call-part { position: relative; border-radius: 8px; padding: 2px; box-shadow: 0 0 0 2px transparent; transition: box-shadow .15s; }
.call-part .avatar.sm { width: 32px; height: 32px; font-size: 13px; border-radius: 7px; }
.call-part.speaking { box-shadow: 0 0 0 2px var(--online); }
.call-part.wait { opacity: .55; }
.call-flag { position: absolute; right: -4px; bottom: -4px; font-size: 11px; line-height: 1; background: var(--top-bg); border-radius: 6px; padding: 1px; }
.call-note { font-size: 12px; color: var(--side-strong); }
.call-btns { display: flex; gap: 6px; }
.call-b { flex: none; min-width: 40px; height: 34px; border-radius: 8px; background: var(--side-hover); color: var(--side-strong); font-size: 16px; display: grid; place-items: center; padding: 0 10px; }
.call-b:hover { filter: brightness(1.15); }
.call-b.on { background: var(--side-active); color: var(--side-active-text); }
.call-b:disabled { opacity: .45; cursor: not-allowed; }
.call-b.leave { margin-left: auto; background: var(--danger); color: var(--on-danger); font-size: 14px; font-weight: 700; }
.call-b:focus-visible, .call-where:focus-visible { outline: 2px solid var(--side-active); outline-offset: 1px; }
.screen-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.screen-src { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid var(--border); border-radius: 8px; text-align: left; font-size: 13px; }
.screen-src:hover, .screen-src:focus-visible { border-color: var(--accent); background: var(--bg-hover); }
.screen-src img { width: 100%; aspect-ratio: 16 / 10; object-fit: contain; background: var(--bg-soft); border-radius: 4px; }
.screen-src span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) {
  .call-bar { left: 0; right: 0; width: auto; bottom: calc(58px + env(safe-area-inset-bottom)); }
  .app.in-call .main { padding-bottom: 130px; }
}

/* ---------- foto profilo e pallini di presenza (voce 6r) ---------- */
.avatar .av-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.avatar.xl { width: 72px; height: 72px; border-radius: 12px; font-size: 26px; }
/* pallino nell'angolo in basso a destra, con il bordo del colore dello sfondo (--ring) */
.av-pres { position: relative; display: inline-flex; flex: none; --ring: var(--bg); --pres-off: var(--muted); }
.av-pres .dot { position: absolute; right: -3px; bottom: -3px; margin: 0; width: 10px; height: 10px; border: 1.5px solid var(--pres-off); background: var(--ring); box-shadow: 0 0 0 2px var(--ring); }
.av-pres .dot.on { background: var(--online); border-color: var(--online); }
.dot.dnd { border: 0 !important; background: radial-gradient(circle at 78% 24%, var(--ring, var(--bg)) 0 42%, transparent 45%), var(--pres-off, currentColor) !important; }
.avatar.xs + .dot, .av-pres .avatar.xs ~ .dot { width: 9px; height: 9px; right: -3px; bottom: -3px; }
.list-row:hover .av-pres { --ring: var(--bg-hover); }
#sidebar .av-pres, #dms-list .av-pres { --ring: var(--side-bg); --pres-off: var(--side-text); }
.side-item:hover .av-pres, .dm-row:hover .av-pres { --ring: var(--side-hover); }
.side-item.active .av-pres, .dm-row.active .av-pres { --ring: var(--side-active); --pres-off: var(--side-active-text); }
.side-item .ic.ic-av { width: 20px; opacity: 1; display: inline-flex; justify-content: center; }
/* DM di gruppo: due foto sovrapposte */
.av-pair { position: relative; display: inline-block; flex: none; width: 20px; height: 20px; --ring: var(--side-bg); }
.dm-pic .av-pair { width: 22px; height: 22px; }
.av-pair .avatar { position: absolute; width: 70%; height: 70%; font-size: 7px; border-radius: 3px; }
.av-pair .avatar:first-child { left: 0; top: 0; }
.av-pair .avatar:last-child:not(:first-child) { right: 0; bottom: 0; box-shadow: 0 0 0 1.5px var(--ring); }
.side-item:hover .av-pair, .dm-row:hover .av-pair { --ring: var(--side-hover); }
.side-item.active .av-pair, .dm-row.active .av-pair { --ring: var(--side-active); }
/* stato e "tu" subito dopo il nome: il nome si accorcia con i puntini, l'aggiunta resta visibile */
.side-item .label:has(+ .name-status, + .name-you), .dm-name:has(+ .name-status, + .name-you) { flex: 0 1 auto; }
.name-status, .name-you { flex: none; margin-right: auto; font-weight: 400; }
.name-status .cemoji { width: 16px; height: 16px; vertical-align: -3px; }
.name-you { opacity: .7; }
.side-item .name-status, .side-item .name-you { margin-left: -2px; }
/* profilo: foto e ritaglio */
.pf-photo { display: flex; align-items: center; gap: 14px; margin-top: 4px; font-weight: 400; }
.pf-photo-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.acc-list { display: flex; flex-direction: column; gap: 6px; margin: 4px 0; font-weight: 400; }
.acc-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.acc-ic { display: inline-flex; flex: none; }
.acc-link { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; }
.acc-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.acc-txt .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.crop-view { width: 240px; height: 240px; align-self: center; border-radius: 12px; background: var(--bg-soft); cursor: grab; touch-action: none; }
.crop-view:active { cursor: grabbing; }
.crop-view:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.crop-zoom input { width: 100%; }
/* ---------- impostazioni del workspace (#/workspace) ---------- */
.ws-name { display: flex; align-items: center; gap: 10px; }
.ws-name .ws-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-name.ws-admin { cursor: pointer; }
.ws-name.ws-admin:hover, .ws-name.ws-admin:focus-visible { background: var(--side-hover); outline: none; }
.ws-caret { font-size: 11px; opacity: .8; }
.ws-icon { display: inline-grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: var(--on-accent); font-weight: 800; font-size: 15px; }
.ws-icon.big { width: 52px; height: 52px; border-radius: 12px; font-size: 26px; }
.ws-body { max-width: 760px; padding: 4px 16px 0; display: flex; flex-direction: column; gap: 14px; }
.ws-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.ws-card h2 { margin: 0; font-size: 15px; }
.ws-card > .hint { margin: -4px 0 0; color: var(--muted); font-size: 13px; }
.ws-card p.hint { margin: 0; color: var(--muted); font-size: 13px; }
.ws-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.ws-row .grow { flex: 1; min-width: 200px; }
.ws-switch { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.ws-checks { display: flex; flex-wrap: wrap; gap: 6px 16px; font-weight: 400; font-size: 14px; }
.ws-checks label { display: inline-flex; align-items: center; gap: 6px; }
.ws-search input { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.ws-pic { display: inline-grid; place-items: center; width: 28px; height: 28px; flex: none; font-size: 16px; color: var(--muted); font-weight: 700; }
.ws-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 5px; background: var(--accent-soft); vertical-align: 1px; }
.ws-badge.off { background: var(--bg-hover); color: var(--muted); }
.ws-off b { color: var(--muted); }
.list-row select { padding: 5px 8px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg); }
.tok-box { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); cursor: text; }
.tok-box:focus-within { border-color: var(--accent); }
.tok-list { display: contents; }
.tok-input { flex: 1; min-width: 180px; border: 0 !important; padding: 4px !important; outline: none; background: transparent; font-weight: 400; }
.chip.tok.bad { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
@media (max-width: 760px) { .ws-body { padding: 4px 12px 0; } .list-row { flex-wrap: wrap; } }
/* maniglie per allargare o restringere la barra laterale e il pannello destro (sotto 760 px non ci sono) */
.rs-handle { position: absolute; top: 44px; bottom: 0; width: 9px; z-index: 31; cursor: col-resize; touch-action: none; outline: 0; }
.rs-handle::after { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 3px; border-radius: 2px; background: transparent; transition: background-color .12s ease-out; }
.rs-handle:hover::after, .rs-handle.drag::after { background: var(--accent); }
.rs-handle:focus-visible::after { background: var(--accent); box-shadow: 0 0 0 2px var(--bg); }
#rs-side { left: calc(68px + var(--side-w, 260px) - 5px); }
#rs-panel { right: calc(var(--panel-w, 400px) - 4px); }
.app:has(#panel.hidden) #rs-panel, .app[data-view="activity"] #rs-side, .app[data-view="later"] #rs-side { display: none; }
body.resizing, body.resizing * { cursor: col-resize !important; user-select: none !important; }
body.resizing iframe, body.resizing video, body.resizing .messages { pointer-events: none; }
@media (max-width: 760px) { .rs-handle { display: none; } }
@media (prefers-reduced-motion: reduce) { .rs-handle::after { transition: none; } }

/* profilo nel pannello destro, pallino di presenza, scheda al passaggio sulle menzioni */
.prof-pic .avatar.xl { width: 100%; max-width: 240px; height: auto; aspect-ratio: 1; border-radius: 14px; font-size: 76px; }
.prof-pic .av-pres { width: 100%; max-width: 240px; }
.prof-pic .av-pres .dot { width: 20px; height: 20px; right: -5px; bottom: -5px; border-width: 2.5px; box-shadow: 0 0 0 3px var(--ring); }
.pdot-moon { display: inline-block; width: 11px; height: 11px; margin: 0; vertical-align: middle; }
.pdot.deact { border: 1.5px dashed var(--muted); }
.avatar.lg { width: 56px; height: 56px; border-radius: 10px; font-size: 22px; }
.pdot { display: inline-grid; place-items: center; width: 10px; height: 10px; border-radius: 50%; flex: none; box-sizing: border-box; vertical-align: middle; font-size: 8px; line-height: 1; font-weight: 800; }
.pdot.on { background: var(--online); }
.pdot.away, .pdot.off { border: 1.5px solid var(--muted); }
.pdot.dnd { width: 12px; height: 12px; background: var(--side-active); color: var(--side-active-text); }
.prof { padding: 12px 20px 24px; display: flex; flex-direction: column; gap: 8px; }
.prof-pic { display: flex; justify-content: flex-start; }
.prof-name { margin: 6px 0 0; font-size: 22px; font-weight: 800; overflow-wrap: anywhere; }
.prof-name .muted { font-size: 15px; font-weight: 400; }
.prof-title { font-size: 15px; }
.prof-presence { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.prof-status { font-size: 14px; }
.prof-meta { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.prof-mail { color: var(--accent-strong); text-decoration: underline; overflow-wrap: anywhere; }
.prof-actions { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.prof-actions .btn { flex: 1 1 auto; }
.prof-actions [data-prof="more"] { flex: none; width: 40px; padding-left: 0; padding-right: 0; }
.prof-sec { margin: 16px 0 4px; font-size: 14px; font-weight: 700; color: var(--muted); }
.prof .list-row .dm-group { color: var(--side-strong); display: grid; place-items: center; }
.conv-person { font: inherit; color: inherit; padding: 0 4px; margin-left: -4px; border-radius: 6px; display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-person:hover { background: var(--bg-hover); }
.mention[data-user] { cursor: pointer; }
.hover-card { position: fixed; z-index: 70; display: flex; gap: 12px; align-items: flex-start; width: 300px; max-width: calc(100vw - 16px); padding: 12px; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.hover-card::before { content: ""; position: absolute; left: 0; right: 0; top: -8px; bottom: -8px; z-index: -1; }  /* ponte verso la menzione: il mouse ci passa senza chiuderla */
.hc-open { align-self: flex-start; margin-top: 4px; padding: 0; font-size: 13px; font-weight: 600; color: var(--accent-strong); text-decoration: underline; background: none; }
.hc-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.hc-name { display: flex; align-items: center; gap: 6px; }
.hc-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hc-sub { font-size: 13px; }
/* menzioni nel composer: un gettone unico, si cancella intero */
.rich-editor .mention-chip { background: var(--mention-bg); color: var(--mention-text); border-radius: 4px; padding: 0 3px; font-weight: 600; cursor: pointer; white-space: nowrap; user-select: all; }
.rich-editor .mention-chip.group { background: transparent; box-shadow: inset 0 0 0 1.5px var(--mention-text); }
.rich-editor .mention-chip.special { background: var(--accent); color: var(--on-accent); }
/* ---------- nuovo messaggio, menu Crea, concentrazione (6p) ---------- */
.ws-head { display: flex; align-items: center; gap: 6px; padding-right: 8px; border-bottom: 1px solid rgba(255,255,255,.08); }
.ws-head .ws-name { flex: 1; min-width: 0; border-bottom: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.new-msg-btn { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border-radius: 8px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); color: var(--side-strong); transition: background .15s, border-color .15s; }
.new-msg-btn:hover { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.2); }
.new-msg-btn svg { display: block; transform: translate(-0.5px, 0.4px); }
.new-msg-btn:focus-visible { outline: 2px solid var(--side-active); outline-offset: 1px; }
.rail-round { width: 36px; height: 36px; flex: none; border-radius: 50%; display: grid; place-items: center; color: var(--side-strong); background: var(--side-hover); }
.rail-round:hover { filter: brightness(1.2); }
.rail-round:focus-visible { outline: 2px solid var(--side-active); outline-offset: 2px; }
.rail-create .ic-svg { transition: transform .15s; }
.rail-create.menu-open { background: var(--side-strong); color: var(--top-bg); }
.rail-create.menu-open .ic-svg { transform: rotate(45deg); }
.rail-focus { background: transparent; color: var(--side-text); }
.rail-focus:hover { background: var(--side-hover); filter: none; }
.rail-focus.on { background: var(--side-active); color: var(--side-active-text); }
.rail-focus.menu-open:not(.on) { background: var(--side-hover); color: var(--side-strong); }
.rail-menu { min-width: 300px; max-width: min(360px, calc(100vw - 16px)); padding: 8px 0; }
.cr-title { padding: 4px 16px 8px; font-size: 17px; font-weight: 800; }
.menu .cr-item { display: flex; align-items: center; gap: 12px; padding: 8px 16px; }
.cr-ic { width: 36px; height: 36px; flex: none; border-radius: 50%; display: grid; place-items: center; }
.cr-ic.c-accent { color: var(--accent-strong); background: color-mix(in srgb, var(--accent) 18%, transparent); }
.cr-ic.c-success { color: var(--success); background: color-mix(in srgb, var(--success) 18%, transparent); }
.cr-ic.c-online { color: var(--online); background: color-mix(in srgb, var(--online) 18%, transparent); }
.cr-ic.c-mention { color: var(--mention-text); background: var(--mention-bg); }
.cr-ic.c-muted { color: var(--text); background: var(--bg-hover); }
.cr-ic.c-danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 16%, transparent); }
.cr-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cr-txt b { font-size: 15px; }
.cr-txt span { font-size: 13px; color: var(--muted); }
.cr-key { flex: none; font: 12px ui-monospace, Menlo, monospace; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }
.menu .cr-item:hover, .menu .cr-item:focus-visible, .rail-menu button:focus-visible { background: var(--accent); color: var(--on-accent); outline: 0; }
.menu .cr-item:hover .cr-txt span, .menu .cr-item:focus-visible .cr-txt span, .menu .cr-item:hover .cr-key, .menu .cr-item:focus-visible .cr-key { color: inherit; border-color: currentColor; }
.focus-state { display: flex; gap: 10px; align-items: center; padding: 6px 16px 10px; }
.focus-state .ic-svg { color: var(--accent-strong); flex: none; }
.focus-state > span { display: flex; flex-direction: column; font-size: 14px; }
.focus-state > span > span { color: var(--muted); font-size: 13px; }
.new-page .np-to { position: relative; padding: 0 20px; border-bottom: 1px solid var(--border); }
.to-box { position: relative; border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; }
.to-field { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 44px; padding: 6px 0; cursor: text; }
.to-lb { font-weight: 700; color: var(--muted); }
.to-tokens { display: contents; }
.to-tok { display: inline-flex; align-items: center; gap: 5px; background: var(--accent-soft); border-radius: 6px; padding: 2px 4px 2px 4px; font-size: 14px; font-weight: 600; }
.to-tok.chan { padding-left: 8px; }
.to-tok .avatar.xs { width: 20px; height: 20px; font-size: 9px; border-radius: 4px; }
.to-tok button { width: 20px; height: 20px; border-radius: 4px; font-size: 11px; color: var(--muted); }
.to-tok button:hover { background: var(--bg-hover); color: var(--text); }
.to-input { flex: 1; min-width: 160px; border: 0; outline: 0; background: transparent; padding: 4px 0; }
.to-sugg { position: absolute; left: 12px; right: 12px; top: calc(100% - 2px); z-index: 20; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); max-height: 300px; overflow-y: auto; padding: 4px 0; }
.to-row { display: flex; align-items: center; gap: 8px; padding: 6px 12px; cursor: pointer; font-size: 14px; }
.to-row .muted { font-size: 13px; }
.to-row .dot { margin-left: auto; }
.to-row.sel { background: var(--accent); color: var(--on-accent); }
.to-row.sel .muted { color: inherit; }
.to-hash { width: 20px; text-align: center; }
.to-none { padding: 8px 12px; color: var(--muted); font-size: 14px; }
.np-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.np-hint { margin: 0; color: var(--muted); font-size: 14px; max-width: 560px; }
.np-hint .link { font-size: 14px; padding: 0; }
.new-page .np-head { border-bottom: 1px solid var(--border); }
.sched-note { display: flex; align-items: center; gap: 6px; margin: 6px 8px 0; padding: 4px 6px 4px 8px; border-radius: 6px; background: var(--accent-soft); font-size: 13px; }
.sched-note span:nth-child(2) { flex: 1; }
.sched-note button { width: 22px; height: 22px; border-radius: 4px; font-size: 11px; }
.sched-note button:hover { background: var(--bg-hover); }
.sched-note .sched-ic { display: grid; color: var(--accent-strong); }
@media (max-width: 760px) {
  .rail-round { width: 32px; height: 32px; align-self: center; margin: 0 2px; }
  .rail-round .ic-svg { width: 18px; height: 18px; }
  .new-page .np-to, .np-body { padding-left: 12px; padding-right: 12px; }
}
/* thread seguiti: schede con le ultime risposte e un composer per rispondere sul posto */
.app[data-view="threads"] .vp-body { padding: 12px 20px 24px; }
.app[data-view="threads"] .thread-card { border: 1px solid var(--border); border-radius: 10px; margin: 0 auto 14px; max-width: 920px; padding-bottom: 0; background: var(--bg); }
.app[data-view="threads"] .thread-card.new { box-shadow: inset 3px 0 0 var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.tc-title { font-weight: 800; font-size: 15px; padding: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tc-title:hover { text-decoration: underline; }
.tc-title:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.tc-new:empty { display: none; }
.tc-more:empty { display: none; }
.tc-composer .composer { margin: 8px 14px 14px; }
@media (max-width: 760px) {
  .app[data-view="threads"] .vp-body { padding: 8px 8px 24px; }
  .thread-card .unread-head .btn[data-tact="open"] { display: none; }
}

/* ---------- icone disegnate (icons.js): pulsanti solo icona e icone nel testo ---------- */
.hb { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 32px; height: 32px; padding: 0 6px; border-radius: 8px; color: var(--muted); }
.hb:hover { background: var(--bg-hover); color: var(--text); }
.hb[aria-pressed="true"] { color: var(--accent-strong); }
.hb-n { font-size: 13px; font-weight: 600; }
.msg-tools button, .sr-tools button { display: inline-grid; place-items: center; color: var(--muted); }
.msg-tools button:hover, .sr-tools button:hover { color: var(--text); }
.msg-tools button.on, .sr-tools button.on { color: var(--accent-strong); }
.add-react { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; }
.side-item .ic { display: inline-grid; place-items: center; }
.side-actions button { display: inline-grid; place-items: center; }
.menu-btn { color: var(--muted); border-radius: 8px; padding: 4px; }
.menu-btn:hover { background: var(--bg-hover); color: var(--text); }
.ic-inline { display: inline-flex; vertical-align: -0.1em; margin-right: 3px; }
.pin-label { display: flex; align-items: center; gap: 4px; }
.vp-tab { display: inline-flex; align-items: center; gap: 6px; }
.vp-empty-ic { color: var(--muted); display: flex; justify-content: center; }
.btn > .ic-svg:first-child { margin-right: 6px; }
.menu button > .ic-svg:first-child { margin-right: 10px; color: var(--muted); }
.menu button:hover > .ic-svg:first-child { color: inherit; }
.mi-check { display: inline-block; width: 16px; height: 16px; margin-right: 8px; vertical-align: -0.2em; }
#panel-title > .ic-svg:first-child { margin-right: 6px; color: var(--muted); }
.poll-ic { color: var(--muted); margin-right: 6px; }
.poll-mine { display: inline-flex; margin-right: 4px; vertical-align: -0.15em; }
.pending-file .pf-ic { display: grid; place-items: center; width: 34px; height: 34px; color: var(--muted); }
.pending-file button { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 5px; }
.pending-file button:hover { background: var(--bg-hover); color: var(--text); }
.avatar.ic-av-svg { color: var(--muted); }
.chip button, .to-tok button, .bm-x { display: inline-grid; place-items: center; }
.sr-cnt, .sr-file, .sr-sort { display: inline-flex; align-items: center; gap: 4px; }
.call-b .ic-svg { display: block; }
.call-flag { display: grid; place-items: center; }
#join-text { display: inline-flex; align-items: center; gap: 8px; }
.ws-pic .ic-svg { width: 18px; height: 18px; }
.to-hash { display: inline-grid; place-items: center; }

/* ---------- interfaccia morbida: transizioni brevi, comparse, scheletri, stati uniformi ---------- */
:root { --ease-out: cubic-bezier(.2, .7, .3, 1); --t-fast: 120ms; --t-med: 160ms; --t-slow: 180ms; --r-sm: 6px; --r-md: 8px; --r-lg: 10px; --r-xl: 12px; --shadow-sm: 0 2px 8px rgba(20, 30, 28, .08); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --shadow-sm: 0 2px 8px rgba(0, 0, 0, .35); } }
:root[data-theme="dark"] { --shadow-sm: 0 2px 8px rgba(0, 0, 0, .35); }
/* hover, attivo e fuoco uguali dappertutto */
button, a, .side-item, .dm-row, .list-row, .rail-ic, .vp-tab, .sr-chip, .reaction, .msg, .sp-row, .sp-msg, .btn, .hb, .icon-btn, .menu button, .to-row, .lp-card, .file-card {
  transition: background-color var(--t-fast) ease-out, color var(--t-fast) ease-out, border-color var(--t-fast) ease-out, box-shadow var(--t-fast) ease-out, opacity var(--t-fast) ease-out;
}
.hb:active, .icon-btn:active, .msg-tools button:active, .sr-tools button:active, .composer-bottom .left button:active, .fmt-btn:active, .menu-btn:active, .pending-file button:active { background: var(--border); }
.btn:active:not(:disabled) { filter: brightness(.96); }
.side-item:active, .dm-row:active { background: var(--side-hover); filter: brightness(1.08); }
button:focus-visible, a:focus-visible, [role="tab"]:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.side-item:focus-visible, .dm-row:focus-visible, .side-actions button:focus-visible, .side-title-btn:focus-visible { outline: 2px solid var(--side-active); outline-offset: -2px; }
.msg-tools, .sr-tools { border-radius: var(--r-md); box-shadow: var(--shadow-sm); }
.msg-tools { top: -16px; }
.popover, .search-pop, .to-sugg { border-radius: var(--r-lg); }
.modal { border-radius: var(--r-xl); }
/* comparse: leggera dissolvenza e 4 px di spostamento */
@keyframes bl-pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes bl-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes bl-panel { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
@keyframes bl-toast { from { opacity: 0; transform: translate(-50%, 4px); } to { opacity: 1; transform: translate(-50%, 0); } }
.popover, .search-pop:not(.hidden), .hover-card, .to-sugg:not(.hidden) { animation: bl-pop var(--t-med) var(--ease-out); }
.modal-back { animation: bl-fade var(--t-med) ease-out; }
.modal { animation: bl-pop var(--t-slow) var(--ease-out); }
.panel:not(.hidden) { animation: bl-panel var(--t-slow) var(--ease-out); }
.toast:not(.hidden) { animation: bl-toast var(--t-med) var(--ease-out); }
.msg:hover .msg-tools, .sr-card:hover .sr-tools { animation: bl-fade var(--t-fast) ease-out; }
.msg.highlight { transition: background-color 2s ease-out; }
/* niente salti: posto riservato per immagini, anteprime link e reazioni */
.reaction { min-height: 24px; }
.add-react { min-height: 24px; }
.file-img { height: 240px; width: auto; min-width: 120px; max-width: min(360px, 100%); max-height: none; object-fit: scale-down; background: var(--bg-soft); }  /* altezza fissa: l'immagine che arriva non sposta i messaggi; mai ingrandita */
.file-img:not([src]) { width: 240px; background: var(--skel); }
/* video e audio allegati: riquadro di altezza fissa come le immagini, così il lettore che arriva non sposta la lista */
.file-video, .file-audio { margin: 0; width: min(360px, 100%); display: flex; flex-direction: column; gap: 4px; }
.fv-box { position: relative; height: 240px; border-radius: 8px; overflow: hidden; background: #000; border: 1px solid var(--border); }
.fv-box video { width: 100%; height: 100%; display: block; object-fit: contain; background: #000; }
.fv-play { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -40px 0 0 -28px; border-radius: 50%; display: grid; place-items: center; padding-left: 3px;
  background: rgba(0,0,0,.6); color: #fff; border: 2px solid rgba(255,255,255,.85); transition: transform var(--t-fast) ease-out, background-color var(--t-fast) ease-out; }
.fv-play:hover { background: rgba(0,0,0,.75); transform: scale(1.06); }
.file-video.started .fv-play { display: none; }
.fv-full { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; background: rgba(0,0,0,.6); color: #fff; opacity: 0; transition: opacity var(--t-fast) ease-out; }
.fv-box:hover .fv-full, .fv-full:focus-visible, .file-video:not(.started) .fv-full { opacity: 1; }
@media (hover: none) { .fv-full { opacity: 1; } }
.fv-play:focus-visible, .fv-full:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.fv-meta { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; }
.fv-meta .fn { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.fv-meta .fs { color: var(--muted); flex: none; font-size: 12px; }
.fv-dl { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; flex: none; color: var(--accent-strong); font-weight: 600; text-decoration: none; font-size: 12px; }
.fv-dl:hover { text-decoration: underline; }
.file-audio { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--bg); height: 92px; justify-content: center; }
.file-audio .fa-ic { color: var(--muted); display: grid; place-items: center; flex: none; }
.file-audio audio { width: 100%; height: 40px; display: block; }
.fc-note { color: var(--danger); }
.fv-thumb { position: relative; overflow: hidden; padding: 0; width: 52px; height: 52px; flex: none; border-radius: 8px; display: grid; place-items: center; background: #000; cursor: pointer; }
.fv-thumb video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.fv-thumb .ic-svg { position: absolute; color: #fff; filter: drop-shadow(0 0 2px rgba(0,0,0,.8)); }
.fv-thumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pf-vid { position: relative; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 4px; overflow: hidden; background: #000; color: #fff; flex: none; }
.pf-vid video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pf-vid .ic-svg { position: relative; filter: drop-shadow(0 0 2px rgba(0,0,0,.8)); }
.lightbox { animation: bl-fade var(--t-med) ease-out; }
.lightbox:focus { outline: none; }
.files > .file-card, .files > .att { align-self: flex-start; }  /* accanto a un lettore o a un'immagine la scheda non si allunga */
.lb-media { display: flex; flex-direction: column; gap: 8px; width: min(1100px, 100%); max-height: 100%; cursor: default; }
.lb-media video { width: 100%; max-height: calc(100vh - 90px); background: #000; border-radius: 6px; display: block; }
.lb-cap { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 14px; min-width: 0; }
.lb-cap .fn { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.lb-cap .fs { color: rgba(255,255,255,.7); flex: none; }
.lb-cap .fv-dl { color: #fff; font-size: 14px; }
.lb-x { color: #fff; width: 32px; height: 32px; border-radius: 6px; display: grid; place-items: center; flex: none; }
.lb-x:hover { background: rgba(255,255,255,.15); }
.lb-bad { display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; padding: 48px 16px; background: #111; border-radius: 6px; }
/* scheletri di caricamento */
.skel-list { padding: 12px 0; }
.skel-row { display: grid; grid-template-columns: 36px 1fr; gap: 0 12px; padding: 8px 20px; }
.skel-av { width: 36px; height: 36px; border-radius: var(--r-md); background: var(--skel); }
.skel-lines { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.skel-l { display: block; height: 12px; border-radius: 6px; background: var(--skel); animation: srpulse 1.2s ease-in-out infinite; }
.panel .skel-row { padding: 8px 16px; }
/* trascina file: sovrapposizione sull'area giusta */
.drop-overlay { position: fixed; z-index: 55; pointer-events: none; padding: 12px; opacity: 0; transition: opacity var(--t-med) ease-out; }
.drop-overlay.on { opacity: 1; }
.drop-box { width: 100%; height: 100%; border: 2px dashed var(--accent); border-radius: var(--r-xl); background: color-mix(in srgb, var(--bg) 92%, var(--accent-soft)); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 16px; transform: scale(.99); transition: transform var(--t-med) var(--ease-out); }
.drop-overlay.on .drop-box { transform: none; }
.drop-ic { color: var(--accent-strong); display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--accent-soft); }
.drop-text { font-size: 18px; font-weight: 800; color: var(--text); max-width: 100%; overflow-wrap: anywhere; }
.drop-text .ic-inline { vertical-align: -0.15em; }
.drop-sub { font-size: 13px; color: var(--muted); }
/* tutto fermo per chi chiede meno movimento */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .skel-l { animation: none; }
}

/* riquadro dello stato al passaggio */
.st-tip { position: fixed; z-index: 90; max-width: 280px; padding: 8px 12px; border-radius: var(--r-md, 8px); background: var(--bg); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); text-align: center; font-size: 14px; line-height: 1.35; pointer-events: none; animation: st-tip-in .12s ease-out; }
.st-tip-head { display: flex; gap: 6px; align-items: center; justify-content: center; }
.st-tip-until { color: var(--muted); font-size: 13px; margin-top: 2px; }
.st-emoji { cursor: default; }
@keyframes st-tip-in { from { opacity: 0; transform: translateY(2px); } }
@media (prefers-reduced-motion: reduce) { .st-tip { animation: none; } }
.st-tip-me { text-align: left; min-width: 160px; }
.st-tip-me .st-tip-head { justify-content: flex-start; margin-top: 4px; }
.st-tip-name { display: flex; gap: 6px; align-items: center; }
.st-tip-name .pres-dot, .st-tip-name [class*="dot"] { position: static; }
.me-status { position: absolute; left: -4px; top: -6px; font-size: 14px; line-height: 1; filter: drop-shadow(0 0 1px var(--side-bg)); pointer-events: none; }
.me-status img { width: 16px; height: 16px; }
/* Bozze e inviati (#/bozze): schede arrotondate, una per bozza o messaggio inviato */
.vp-count { margin-left: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.vp-count:empty { display: none; }
.vp-tab .ic-svg { vertical-align: -3px; margin-right: 4px; }
.dr-list { display: flex; flex-direction: column; gap: 8px; padding: 12px 20px; }
.dr-card { position: relative; display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); transition: background var(--t-fast, .12s), border-color var(--t-fast, .12s); }
.dr-card:hover { background: var(--bg-soft); }
.dr-card.sel { border-color: var(--accent); background: var(--accent-soft); }
.dr-main { flex: 1; min-width: 0; display: flex; gap: 12px; align-items: flex-start; padding: 10px 14px; text-align: left; border-radius: 10px; }
.dr-main:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.dr-ic { flex: none; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; background: var(--bg-hover); color: var(--muted); }
.dr-av { background: none; }
.dr-av .avatar.sm { width: 32px; height: 32px; font-size: 13px; border-radius: 8px; }
.dr-av .av-pair { width: 32px; height: 32px; --ring: var(--bg); }
.dr-av .av-pair .avatar { font-size: 9px; border-radius: 5px; }
.dr-card:hover .dr-av .av-pair { --ring: var(--bg-soft); }
.dr-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.dr-top { display: flex; align-items: baseline; gap: 10px; }
.dr-title { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dr-time { flex: none; font-size: 12px; color: var(--muted); }
.dr-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dr-root { font-style: italic; }
.dr-text { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dr-text img, .dr-sub img { height: 1.2em; vertical-align: -3px; }
.dr-text code, .dr-sub code { white-space: nowrap; }
.dr-acts { position: absolute; right: 10px; top: 8px; display: flex; gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, .12)); opacity: 0; pointer-events: none; transition: opacity var(--t-fast, .12s); }
.dr-card:hover .dr-acts, .dr-card:focus-within .dr-acts { opacity: 1; pointer-events: auto; }
.dr-check { flex: none; display: grid; place-items: center; padding-left: 14px; cursor: pointer; }
.dr-check input { width: 16px; height: 16px; accent-color: var(--accent); }
.dr-more { display: flex; justify-content: center; padding: 4px 0 12px; }
.dr-acts .icon-btn { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 6px; }
.dr-acts .icon-btn:hover { background: var(--bg-hover); }
.dr-acts .icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.dr-acts [data-ddel]:hover, .dr-acts [data-sact="del"]:hover { color: var(--danger); }
.dr-acts .icon-btn:disabled { opacity: .45; cursor: default; }
.sched-item.dr-row { position: relative; }
.sched-item.dr-row:hover { background: var(--bg-soft); }
.sched-item.dr-row.err:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.sched-item.dr-row:hover .dr-acts, .sched-item.dr-row:focus-within .dr-acts { opacity: 1; pointer-events: auto; }
@media (hover: none) {
  .dr-acts { opacity: 1; pointer-events: auto; position: static; align-self: center; margin-right: 8px; border: 0; box-shadow: none; background: none; }
  .sched-item.dr-row .dr-acts { display: inline-flex; margin: 2px 0 0 10px; }
  .dr-acts .icon-btn { width: 40px; height: 40px; }
}
@media (max-width: 520px) { .dr-card { flex-wrap: wrap; } .dr-card .dr-acts { position: static; opacity: 1; pointer-events: auto; margin: 0 8px 8px auto; }
  .sched-item.dr-row .dr-acts { position: static; display: inline-flex; opacity: 1; pointer-events: auto; margin: 2px 0 0 10px; } }
@media (max-width: 760px) { .rail-drafts { display: none; } .dr-list { padding: 10px 10px; } }
@media (prefers-reduced-motion: reduce) { .dr-card, .dr-acts { transition: none; } }
/* ---------- chiamate: stato, problemi, riquadri video, squillo, scheda nella conversazione (6w) ---------- */
.call-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--side-text); min-height: 16px; }
.call-phase { font-weight: 600; color: var(--side-strong); }
.call-bar[data-phase=connecting] .call-live { background: var(--side-text); animation: call-pulse 1.2s ease-in-out infinite; }
.call-bar[data-phase=connecting] .call-phase::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%; background: currentColor; vertical-align: middle; animation: call-pulse 1.2s ease-in-out infinite; }
.call-bar[data-phase=problem] .call-live { background: var(--danger); }
@keyframes call-pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
.call-issues { margin: 0; padding: 0; list-style: none; font-size: 12px; color: var(--side-strong); display: flex; flex-direction: column; gap: 2px; }
.call-issues li::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); margin-right: 6px; }
.call-part.unreachable { opacity: .55; box-shadow: 0 0 0 2px var(--danger); }
.call-problem { font-size: 13px; color: var(--side-strong); background: var(--side-hover); border-radius: 8px; padding: 8px 10px; }
.call-problem p { margin: 0 0 8px; line-height: 1.35; }
.call-problem-btns { display: flex; gap: 6px; }
.call-problem .btn { color: var(--side-strong); border-color: var(--side-text); background: transparent; }
.call-problem .btn:first-child { background: var(--side-active); color: var(--side-active-text); border-color: transparent; }
.call-problem .btn.ghost:hover { background: var(--top-bg); }
.side-item .call-ic { display: inline-flex; align-items: center; gap: 2px; color: var(--online); }
.call-ic-n { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile.speaking { box-shadow: 0 0 0 2px var(--online); }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.tile.me video { transform: scaleX(-1); }
.tile-name { position: absolute; left: 6px; bottom: 6px; max-width: calc(100% - 12px); font-size: 12px; font-weight: 600; color: #fff; background: rgba(0,0,0,.55); padding: 1px 6px; border-radius: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ring-root { position: fixed; right: 20px; bottom: 20px; z-index: 80; }
.ring { width: 300px; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow), 0 12px 32px rgba(0,0,0,.18); padding: 18px 18px 16px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; animation: ring-in .2s ease-out; }
.ring-av { position: relative; margin-bottom: 4px; }
.ring-av::after { content: ""; position: absolute; inset: -6px; border-radius: 16px; border: 2px solid var(--success); animation: call-pulse 1.4s ease-in-out infinite; }
.ring-who { font-size: 17px; font-weight: 700; }
.ring-status { margin-left: 6px; font-weight: 400; }
.ring-status img { width: 18px; height: 18px; vertical-align: -3px; }
.ring-what { font-size: 14px; color: var(--muted); }
.ring-busy { font-size: 12px; }
.ring-btns { display: flex; gap: 12px; margin-top: 10px; width: 100%; }
.ring-b { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; height: 46px; border-radius: 23px; font-size: 15px; font-weight: 700; transition: filter .15s; }
.ring-b:hover { filter: brightness(1.08); }
.ring-b:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.ring-b.yes { background: var(--success); color: var(--on-success); }
.ring-b.no { background: var(--danger); color: var(--on-danger); }
@keyframes ring-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.callcard .cc-ic { flex: none; width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; background: var(--bg-hover); color: var(--muted); }
.callcard.live .cc-ic { background: var(--success); color: var(--on-success); }
.callcard.missed .cc-ic { background: var(--danger); color: var(--on-danger); }
.cc-main { flex: 1; min-width: 0; }
.cc-title { font-weight: 700; }
.cc-sub { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cc-join { display: inline-flex; align-items: center; gap: 6px; background: var(--success); color: var(--on-success); border-color: transparent; font-weight: 700; }
.cc-join:hover { filter: brightness(1.08); }
@media (max-width: 759px) {
  .ring-root { left: 16px; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); }
  .ring { width: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .call-bar[data-phase=connecting] .call-live, .call-bar[data-phase=connecting] .call-phase::after, .ring-av::after { animation: none; }
  .ring { animation: none; }
}

/* ---------- pagina Chiamate ---------- */
.side-nav .side-item.has-call .ic, .side-nav .side-item.has-call .calls-count { color: var(--online); font-weight: 700; }
.calls-sec { margin: 0 0 24px; }
.calls-h { font-size: 15px; font-weight: 700; margin: 4px 0 8px; }
.calls-none { color: var(--muted); font-size: 14px; margin: 0; }
.calls-list { display: flex; flex-direction: column; gap: 6px; }
.call-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); text-align: left; }
.call-row[role=link] { cursor: pointer; transition: background .15s; }
.call-row[role=link]:hover { background: var(--bg-hover); }
.call-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cl-ic { flex: none; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--bg-hover); color: var(--muted); }
.call-row.live .cl-ic { background: var(--success); color: var(--on-success); }
.call-row.missed .cl-ic, .call-row.declined .cl-ic { background: var(--danger); color: var(--on-danger); }
.cl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cl-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.cl-top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl-out { font-size: 12px; font-weight: 600; color: var(--muted); }
.call-row.missed .cl-out, .call-row.declined .cl-out { color: var(--badge-text); }
.cl-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cl-people { display: flex; flex: none; }
.cl-people .avatar { margin-left: -4px; box-shadow: 0 0 0 2px var(--bg); }
.cl-more { font-size: 12px; color: var(--muted); margin-left: 4px; align-self: center; }
.cl-extra { display: flex; gap: 6px; flex: none; }
.calls-more { align-self: center; margin-top: 6px; }
@media (max-width: 759px) { .cl-people { display: none; } }

/* ---------- selettore dello schermo (app desktop) ---------- */
.modal.screen-picker { width: min(760px, calc(100vw - 32px)); max-width: none; }
.sp-tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.sp-tab { padding: 6px 12px; border-radius: 8px 8px 0 0; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.sp-tab[aria-selected=true] { color: var(--text); border-bottom-color: var(--accent); }
.screen-picker .screen-grid { max-height: 52vh; overflow-y: auto; padding: 2px; }
.screen-src.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.sp-none { color: var(--muted); }
.sp-foot { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.sp-audio { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.sp-audio.off { color: var(--muted); }
.sp-note { font-size: 12px; margin-left: 4px; }
.sp-btns { margin-left: auto; display: flex; gap: 8px; }

/* thread aperto: messaggio iniziale evidenziato nel pannello e nella conversazione */
#panel-body > .msg.thread-root { background: var(--bg-soft); border-bottom: 1px solid var(--border); }
#messages .msg.thread-open { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
@media (prefers-reduced-motion: reduce) { #panel-body > .msg.highlight { transition: none; } }

/* ---------- 7f: popup dei comandi, /me, anteprime comprimibili ---------- */
.cmd-pop { min-width: min(440px, calc(100vw - 32px)); max-width: min(560px, calc(100vw - 32px)); max-height: 340px; }
.cmd-row { gap: 10px; padding: 6px 10px; min-height: 44px; }
.cmd-ic { width: 28px; height: 28px; border-radius: 7px; flex: none; display: grid; place-items: center; overflow: hidden; }
.cmd-ic img { width: 28px; height: 28px; display: block; }
.cmd-ic .logo-scuro { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cmd-ic .logo-chiaro { display: none; } :root:not([data-theme="light"]) .cmd-ic .logo-scuro { display: block; } }
:root[data-theme="dark"] .cmd-ic .logo-chiaro { display: none; }
:root[data-theme="dark"] .cmd-ic .logo-scuro { display: block; }
.cmd-ic-form { background: var(--bg-soft); border: 1px solid var(--border); font-size: 16px; line-height: 1; }
.cmd-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 1px; }
.cmd-line, .cmd-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmd-line b { font-weight: 700; }
.cmd-sub { font-size: 12.5px; color: var(--muted); }
.cmd-alias { font-size: 12px; color: var(--muted); }
.cmd-enter { display: none; flex: none; font: inherit; font-size: 11.5px; padding: 1px 6px; border-radius: 4px; border: 1px solid currentColor; opacity: .85; }
.cmd-row.sel .cmd-enter { display: inline-block; }
.cmd-row.sel .cmd-sub, .cmd-row.sel .cmd-args, .cmd-row.sel .cmd-alias { color: var(--on-accent); }
.cmd-help .list-row { gap: 10px; align-items: center; }
.feed-n { width: 24px; height: 24px; border-radius: 6px; background: var(--bg-soft); border: 1px solid var(--border); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.feed-list .sub { overflow-wrap: anywhere; }
.feed-err { color: var(--danger); }
.msg-me { font-style: italic; }

.att { position: relative; max-width: 100%; min-width: 0; display: flex; flex-direction: column; }
.att-tog { position: absolute; top: 6px; left: 6px; z-index: 2; display: inline-flex; align-items: center; gap: 4px; padding: 2px 5px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--border); color: var(--muted); font-size: 12px; opacity: 0; transition: opacity var(--t-fast, .12s) ease-out; }
.att-tog .att-name { display: none; }
.att:hover > .att-tog, .att-tog:focus-visible { opacity: 1; }
.att-file > .att-tog, .att-lp > .att-tog { left: auto; right: 6px; }
.att-closed > .att-tog { position: static; opacity: 1; background: none; border: 0; padding: 2px 0; font-size: 13px; align-self: flex-start; }
.att-closed > .att-tog .att-name { display: inline; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-closed > .att-tog .ic-svg { transform: rotate(-90deg); }
.att-closed > .att-tog:hover { color: var(--text); }
.att-closed > .att-body { display: none; }
.att-lp:has(> .att-body > .lp:empty) { display: none; }
@media (prefers-reduced-motion: reduce) { .att-tog { transition: none; } }
.emoji-foot { border-top: 1px solid var(--border); padding: 6px 8px; display: flex; justify-content: flex-end; }
/* nome della conversazione nell'intestazione: pulsante per i dettagli, con suggerimento nostro */
.conv-name-btn { font: inherit; color: inherit; padding: 1px 6px; margin-left: -6px; border-radius: 6px; max-width: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; position: relative; text-align: left; }
.conv-name-btn:hover, .conv-name-btn:focus-visible { background: var(--bg-hover); }
.conv-title-wrap { position: relative; }
.conv-title-wrap:has(.conv-name-btn:hover)::after, .conv-title-wrap:has(.conv-name-btn:focus-visible)::after {
  content: attr(data-hint); position: absolute; left: 0; top: 26px; z-index: 30; padding: 4px 8px; border-radius: 6px;
  background: var(--text); color: var(--bg); font-size: 12px; font-weight: 600; white-space: nowrap; pointer-events: none; }
/* inattivo (7f): collegato ma fermo da un po': verde vuoto, ben diverso dal pieno e dal contorno grigio */
.dot.idle { background: transparent; border-color: var(--online); }
.av-pres .dot.idle { background: var(--ring); border: 2px solid var(--online); }
.pdot.idle { border: 2px solid var(--online); background: transparent; }
/* righe di persona nei suggerimenti (A:, @ del composer, filtro Da): alte e leggibili */
.pr-row { min-height: 40px; gap: 10px; }
.pr-txt { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; overflow: hidden; white-space: nowrap; }
.pr-txt b { overflow: hidden; text-overflow: ellipsis; }
.pr-txt .dot { margin: 0 2px; flex: none; }
.pr-txt .muted { overflow: hidden; text-overflow: ellipsis; }
.pr-row.sel .dot.on { border-color: var(--on-accent); }
.pr-row.sel .dot.idle { border-color: var(--on-accent); }
.new-page .np-to .to-sugg { left: 20px; right: 20px; }
@media (max-width: 760px) { .new-page .np-to .to-sugg { left: 12px; right: 12px; } }
.to-row.pr-row { padding: 6px 12px; font-size: 14.5px; }
.to-row:hover:not(.sel) { background: transparent; }
.mention-pop { min-width: 300px; }
.sr-pick .list-row.pr-row.sel { background: var(--accent); color: var(--on-accent); }
.sr-pick .list-row.pr-row.sel .muted { color: var(--on-accent); }
/* suggerimenti (data-tip): riquadro scuro, nome in grassetto, tasti disegnati, consiglio in grigio */
.tip { position: fixed; z-index: 1000; pointer-events: none; max-width: 280px; padding: 6px 9px; border-radius: 8px; background: #1d2321; color: #f3f4f2;
  font-size: 12.5px; line-height: 1.35; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); animation: bl-pop var(--t-fast, .12s) ease-out; }
:root[data-theme="dark"] .tip { background: #f1f2f0; color: #1d2321; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tip { background: #f1f2f0; color: #1d2321; } }
.tip-main { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.tip-keys { display: inline-flex; gap: 3px; }
.tip-keys kbd { font: inherit; font-size: 11.5px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 4px; display: inline-grid; place-items: center;
  background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .28); }
:root[data-theme="dark"] .tip-keys kbd { background: rgba(0, 0, 0, .08); border-color: rgba(0, 0, 0, .22); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tip-keys kbd { background: rgba(0, 0, 0, .08); border-color: rgba(0, 0, 0, .22); } }
.tip-sub { margin-top: 2px; opacity: .72; }
@media (prefers-reduced-motion: reduce) { .tip { animation: none; } }
.msg-text hr { border: 0; border-top: 1px solid var(--border); margin: 8px 0; }
.plus-menu { min-width: 220px; }
.plus-menu button { display: flex; align-items: center; gap: 8px; }
.plus-menu .pm-emoji { width: 16px; text-align: center; }

/* finestra Imposta uno stato (7q) */
.st-dialog { max-width: min(560px, calc(100vw - 32px)); min-width: 0; }
.st-modal { display: flex; flex-direction: column; gap: 12px; }
.st-field { display: flex; align-items: center; gap: 4px; border: 1px solid var(--muted); border-radius: 8px; padding: 3px 4px; background: var(--bg); }
.st-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.st-field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 15px; padding: 7px 4px; }
.st-em-btn { width: 34px; height: 34px; flex: none; display: inline-grid; place-items: center; border-radius: 6px; font-size: 20px; line-height: 1; color: var(--muted); }
.st-em-btn:hover, .st-em-btn:focus-visible { background: var(--bg-hover); color: var(--text); }
.st-em-btn .ic-svg { width: 20px; height: 20px; }
.st-em-btn img, .st-row-em img { width: 20px; height: 20px; }
.st-exp { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.st-exp[hidden], .st-exp input[hidden], .st-field-x[hidden] { display: none; }
.st-exp label { font-weight: 700; }
.st-exp select, .st-exp input { padding: 6px 8px; border: 1px solid var(--muted); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; }
.st-lists { display: flex; flex-direction: column; gap: 12px; max-height: 46vh; overflow-y: auto; margin: 0 -8px; padding: 0 8px; }
.st-sec h3 { margin: 4px 0 4px; font-size: 13px; font-weight: 700; color: var(--muted); }
.st-rows { display: flex; flex-direction: column; }
.st-row { display: flex; align-items: center; border-radius: 6px; }
.st-row:hover, .st-row:focus-within { background: var(--bg-hover); }
.st-pick { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 7px 8px; text-align: left; border-radius: 6px; color: var(--text); }
.st-pick:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.st-row-em { width: 22px; text-align: center; font-size: 18px; flex: none; }
.st-row-tx { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.st-row-x { flex: none; margin-right: 4px; opacity: 0; }
.st-row:hover .st-row-x, .st-row:focus-within .st-row-x { opacity: 1; }
@media (hover: none) { .st-row-x { opacity: 1; } }
.st-dialog .modal-foot { flex-wrap: wrap; }
.st-dialog .modal-foot .st-clear { margin-right: auto; }
.st-dialog .modal-foot .error:empty { display: none; }
.pf-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; font-weight: 400; }
.pf-status-now { flex: 1; min-width: 0; }
.prof-status-me { border-radius: 6px; padding: 4px 8px; color: var(--text); }
.prof-status-me:hover, .prof-status-me:focus-visible { background: var(--bg-hover); }
/* stati del workspace nelle impostazioni */
.ws-st { display: flex; flex-direction: column; gap: 6px; }
.ws-st-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ws-st-row input { flex: 1; min-width: 160px; padding: 7px 9px; border: 1px solid var(--muted); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; }
.ws-st-row select { padding: 7px 8px; border: 1px solid var(--muted); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; }
.ws-st-row .st-em-btn { border: 1px solid var(--muted); }
.ws-st-row [data-ws="st-up"] .ic-svg { transform: rotate(180deg); }
.ws-st-row .icon-btn:disabled { opacity: .35; }
.st-dialog [data-st-save]:disabled { opacity: .45; cursor: default; }

/* ---------- barra della chiamata (7d): più ordinata ---------- */
.call-bar { gap: 8px; padding: 10px 12px 12px; }
.call-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; }
.call-status { display: inline-flex; align-items: baseline; gap: 6px; font-size: 12px; color: var(--side-text); white-space: nowrap; }
.call-phase { font-weight: 600; }
.call-time { font-variant-numeric: tabular-nums; color: var(--side-strong); }
.call-parts { display: flex; flex-wrap: nowrap; gap: 6px; overflow-x: auto; padding: 2px; scrollbar-width: none; }
.call-parts::-webkit-scrollbar { display: none; }
.call-part { flex: none; }
.call-note { font-size: 12px; color: var(--side-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-btns { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.call-b { min-width: 0; width: 100%; padding: 0; height: 36px; }
.call-b.leave { margin-left: 0; }

/* ---------- finestra della chiamata ---------- */
.call-win { position: fixed; z-index: 36; display: flex; flex-direction: column; min-width: 0; color: var(--side-strong);
  background: linear-gradient(160deg, var(--side-bg), var(--top-bg)); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow), 0 16px 40px rgba(0,0,0,.28);
  border: 1px solid var(--side-hover); right: 16px; top: 72px; width: 560px; height: 360px; }
.call-win.dragging { user-select: none; transition: none; }
.cw-head { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; cursor: grab; touch-action: none; font-size: 13px; flex: none; }
.call-win.dragging .cw-head { cursor: grabbing; }
.cw-head:focus-visible { outline: 2px solid var(--side-active); outline-offset: -2px; }
.cw-ic { display: grid; color: var(--online); }
.cw-title { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-time { font-variant-numeric: tabular-nums; color: var(--side-text); font-size: 12px; }
.cw-new { display: none; width: 8px; height: 8px; border-radius: 50%; background: var(--badge); }
.call-win[data-mode=small]:not([data-unread="0"]) .cw-new { display: inline-block; }
.cw-btns { margin-left: auto; display: flex; gap: 2px; }
.cw-b { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; color: var(--side-strong); position: relative; }
.cw-b:hover { background: var(--side-hover); }
.cw-b:focus-visible, .cw-tb:focus-visible, .cw-leave:focus-visible { outline: 2px solid var(--side-active); outline-offset: 1px; }
.cw-main { flex: 1; min-height: 0; display: flex; }
.cw-stage { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; gap: 6px; padding: 0 8px 8px; }
.cw-screen { position: relative; flex: 1; min-height: 0; border-radius: 10px; overflow: hidden; background: #000; }
.cw-screen video { width: 100%; height: 100%; object-fit: contain; display: block; }
.call-tiles { flex: 1; min-height: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); grid-auto-rows: minmax(0, 1fr); align-content: stretch; }
.call-win.with-screen .call-tiles { flex: 0 0 auto; height: 72px; grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 112px; overflow-x: auto; }
.tile { position: relative; min-height: 0; background: var(--side-hover); border-radius: 12px; overflow: hidden; display: grid; place-items: center; box-shadow: 0 0 0 2px transparent; transition: box-shadow .15s; }
.call-win.with-screen .tile .avatar.xl { width: 36px; height: 36px; font-size: 14px; border-radius: 8px; }
.tile.speaking { box-shadow: 0 0 0 3px var(--online); }
.cw-toast { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); max-width: calc(100% - 24px); background: var(--bg); color: var(--text); border-radius: 10px; padding: 6px 12px; font-size: 13px; box-shadow: var(--shadow); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; z-index: 2; }
.cw-chat { flex: none; width: 300px; display: flex; flex-direction: column; background: var(--bg); color: var(--text); border-left: 1px solid var(--border); min-height: 0; }
.cw-chat-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 4px 12px; }
.cw-chat-head .cw-b { color: var(--text); }
.cw-chat-head .cw-b:hover { background: var(--bg-hover); }
.cw-chat-info { margin: 0 12px 6px; font-size: 12px; color: var(--muted); line-height: 1.35; }
.cw-chat-body { flex: 1; min-height: 0; overflow-y: auto; }
.cw-chat-empty { color: var(--muted); font-size: 13px; padding: 8px 12px; margin: 0; }
.cw-chat-composer { flex: none; padding: 0 8px 8px; }
.cw-chat-composer .composer { margin: 0; }
.cw-bar { flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--side-hover); }
.cw-left, .cw-center, .cw-right { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cw-right { justify-content: flex-end; }
.cw-tb { height: 36px; min-width: 36px; border-radius: 9px; display: inline-grid; place-items: center; padding: 0 8px; color: var(--side-strong); background: var(--side-hover); position: relative; }
.cw-tb:hover { filter: brightness(1.15); }
.cw-tb.on, .cw-tb[aria-pressed=true] { background: var(--side-active); color: var(--side-active-text); }
.cw-tb:disabled { opacity: .45; cursor: not-allowed; }
.cw-txt { display: inline-flex; gap: 6px; font-size: 13px; font-weight: 600; }
.cw-split { display: inline-flex; }
.cw-split .cw-tb:first-child { border-radius: 9px 0 0 9px; }
.cw-split .cw-caret { border-radius: 0 9px 9px 0; min-width: 22px; padding: 0 3px; margin-left: 1px; }
.cw-leave { height: 36px; display: inline-flex; align-items: center; gap: 6px; padding: 0 14px; border-radius: 9px; background: var(--danger); color: var(--on-danger); font-weight: 700; }
.cw-leave:hover { filter: brightness(1.08); }
.cw-badge { position: absolute; top: -5px; right: -5px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--badge); color: var(--badge-text-on, #fff); font-size: 10px; font-weight: 700; line-height: 16px; }
.cw-qbars { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.cw-qbars i { width: 3px; border-radius: 1px; background: currentColor; opacity: .35; }
.cw-qbars i:nth-child(1) { height: 25%; } .cw-qbars i:nth-child(2) { height: 50%; } .cw-qbars i:nth-child(3) { height: 75%; } .cw-qbars i:nth-child(4) { height: 100%; }
.cw-q[data-q=good] { color: var(--online); } .cw-q[data-q=good] i { opacity: 1; }
.cw-q[data-q=fair] { color: var(--accent); } .cw-q[data-q=fair] i:nth-child(-n+3) { opacity: 1; }
.cw-q[data-q=poor] { color: var(--danger); } .cw-q[data-q=poor] i:nth-child(-n+1) { opacity: 1; }
.cw-rs { position: absolute; width: 14px; height: 14px; z-index: 3; touch-action: none; }
.cw-rs[data-rs=nw] { left: 0; top: 0; cursor: nwse-resize; } .cw-rs[data-rs=se] { right: 0; bottom: 0; cursor: nwse-resize; }
.cw-rs[data-rs=ne] { right: 0; top: 0; cursor: nesw-resize; } .cw-rs[data-rs=sw] { left: 0; bottom: 0; cursor: nesw-resize; }
.cw-fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 4; }
.cw-fly { position: absolute; font-size: 30px; animation: cw-fly 2.6s ease-out forwards; }
@keyframes cw-fly { from { transform: translateY(0) scale(.6); opacity: 0; } 15% { opacity: 1; transform: translateY(-10px) scale(1); } to { transform: translateY(-140px); opacity: 0; } }
.tile .tile-hand { position: absolute; top: 6px; left: 6px; background: var(--accent); color: var(--on-accent); border-radius: 8px; padding: 2px 6px; font-size: 12px; font-weight: 700; display: inline-flex; gap: 4px; align-items: center; }
/* piccola: solo il video principale (o lo schermo), niente barra né angoli */
.call-win[data-mode=small] .cw-bar, .call-win[data-mode=small] .cw-chat, .call-win[data-mode=small] .cw-rs, .call-win[data-mode=small] .cw-time { display: none; }
.call-win[data-mode=small] .tile:not(.primary) { display: none; }
.call-win[data-mode=small].with-screen .call-tiles { display: none; }
.call-win[data-mode=small] .call-tiles { grid-template-columns: 1fr; }
.call-win[data-mode=small] .cw-head { padding: 4px 4px 4px 10px; }
.call-win[data-mode=small] .cw-stage { padding: 0 4px 4px; }
/* tutta pagina */
.call-win[data-mode=full] { inset: 0 !important; width: auto !important; height: auto !important; border-radius: 0; border: 0; z-index: 70; }
.call-win[data-mode=full] .cw-head { cursor: default; }
.call-win[data-mode=full] .cw-rs { display: none; }
/* telefono: in alto a tutta larghezza; piccola = pillola */
@media (max-width: 759px) {
  .call-win:not([data-mode=full]) { left: 8px !important; right: 8px !important; top: 56px !important; width: auto !important; height: 46vh !important; }
  .call-win[data-mode=small] { height: auto !important; }
  .call-win[data-mode=small] .cw-stage { display: none; }
  .call-win .cw-head { cursor: default; }
  .call-win .cw-rs { display: none; }
  .cw-lbl { display: none; }
  .cw-chat { position: absolute; inset: 0; width: auto; z-index: 5; }
  .cw-bar { grid-template-columns: auto 1fr auto; }
}
@media (prefers-reduced-motion: reduce) { .cw-fly { animation-duration: .01s; } .tile { transition: none; } }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- scheda della chiamata: niente testo tagliato ---------- */
.callcard { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; max-width: 520px; margin: 2px 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-soft); }
.callcard .cc-main { flex: 1 1 180px; }
.callcard .cc-join, .cc-in { flex: none; white-space: nowrap; }
.cc-in { font-size: 13px; color: var(--success); font-weight: 600; }

/* ---------- pagina Chiamate: stesso respiro delle altre pagine, schede compatte (7d) ---------- */
.app[data-view="calls"] .vp-head { border-bottom: 1px solid var(--border); }
.app[data-view="calls"] .vp-body { padding: 12px 20px 24px; }
.calls-wrap { max-width: 760px; }
.calls-h { font-size: 15px; margin: 8px 0 8px; }
.calls-day { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: none; margin: 14px 0 6px; }
.calls-day:first-child { margin-top: 2px; }
.call-row { padding: 8px 12px; gap: 10px; }
.cl-ic { width: 30px; height: 30px; border-radius: 8px; }
.call-row:not(.live):not(.missed):not(.declined) .cl-ic { background: var(--bg-hover); color: var(--muted); }
.cl-main { flex: 0 1 auto; }
.cl-people { margin-left: auto; }
.cl-people .avatar.xs { width: 22px; height: 22px; }
@media (max-width: 759px) { .app[data-view="calls"] .vp-body { padding: 8px 12px 24px; } .call-row { flex-wrap: wrap; } }
/* scheda di una chiamata finita: una riga con l'ora a destra */
.callcard.ended { flex-wrap: nowrap; padding: 6px 10px; gap: 10px; background: transparent; }
.callcard.ended .cc-ic { width: 26px; height: 26px; border-radius: 7px; }
.callcard.ended .cc-line { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; }
.cc-at { flex: none; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* filtri della pagina Chiamate */
.cf-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.cf-chip { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.cf-chip.on { border-color: var(--accent); background: var(--accent-soft); }
.cf-btn { display: inline-flex; align-items: center; gap: 4px; padding: 5px 8px 5px 10px; font-size: 13px; font-weight: 600; border-radius: 8px; }
.cf-x { display: grid; place-items: center; width: 24px; height: 24px; margin-right: 4px; border-radius: 6px; }
.cf-x:hover, .cf-btn:hover { background: var(--bg-hover); }
.cf-pop { width: 300px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.cf-q { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); }
.cf-list { max-height: 300px; overflow-y: auto; }
.cf-list h4 { margin: 8px 4px 4px; font-size: 12px; color: var(--muted); }
.cf-opt { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.cf-opt:hover { background: var(--bg-hover); }
.cf-opt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cf-hash { display: grid; place-items: center; width: 20px; color: var(--muted); }
.cf-none { color: var(--muted); font-size: 13px; margin: 6px; }
.mi-pad { display: inline-block; width: 14px; }
/* finestra: thread compatto, etichette che spariscono se la finestra è stretta, miniatura che riempie */
.call-win { container-type: inline-size; }
@container (max-width: 760px) { .cw-lbl { display: none; } }
.cw-chat .fmt-bar, .cw-chat .bc-check, .cw-chat .sched-bar { display: none; }
.cw-chat .composer .editor-host { max-height: 96px; overflow-y: auto; }
.cw-chat-body { min-height: 80px; }
.call-win[data-mode=small] .call-tiles { display: block; position: relative; }
.call-win[data-mode=small] .tile.primary { position: absolute; inset: 0; }

/* ---------- indicatore di chiamata in corso (barra laterale, colonna, DM) ---------- */
:is(.side-item, .dm-row) .call-pill { flex: none; display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px 1px 5px; border-radius: 10px;
  background: var(--success); color: var(--on-success); font-size: 12px; font-weight: 700; line-height: 18px; cursor: pointer;
  box-shadow: 0 0 0 1px rgba(0,0,0,.18); animation: call-wave 2s ease-in-out infinite; }
:is(.side-item, .dm-row) .call-pill .call-ic-n { font-size: 12px; }
:is(.side-item, .dm-row) .call-pill.in { animation: none; }
:is(.side-item, .dm-row) .call-pill:hover { filter: brightness(1.1); }
@keyframes call-wave { 0%, 100% { box-shadow: 0 0 0 1px rgba(0,0,0,.18), 0 0 0 0 color-mix(in srgb, var(--success) 55%, transparent); } 50% { box-shadow: 0 0 0 1px rgba(0,0,0,.18), 0 0 0 4px color-mix(in srgb, var(--success) 0%, transparent); } }
.rail-item.has-call .rail-ic::after { display: none; }
.rail-call { position: absolute; right: -6px; bottom: -4px; width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; background: var(--success); color: var(--on-success); box-shadow: 0 0 0 2px var(--top-bg); }
.av-pres .call-dot { display: grid; place-items: center; background: var(--success); color: var(--on-success); }
.cl-people { display: flex; align-items: center; }
.cl-av { display: inline-flex; border-radius: 6px; box-shadow: 0 0 0 2px var(--bg); position: relative; }
.cl-av + .cl-av { margin-left: -6px; }
.cl-people .avatar { margin-left: 0; box-shadow: none; }
@media (prefers-reduced-motion: reduce) { :is(.side-item, .dm-row) .call-pill { animation: none; } }
.rail-ic { position: relative; }
.av-pres .dot.call-dot { width: 13px; height: 13px; right: -4px; bottom: -4px; border-color: var(--success); }
/* sulla riga attiva (oro) il verde da solo ha 2:1: un bordo scuro (6,9:1 sull'oro) stacca la pillola */
:is(.side-item, .dm-row).active .call-pill { box-shadow: 0 0 0 2px var(--side-active-text); animation: none; }

/* ---------- anteprima prima di entrare ---------- */
.modal.call-preview { width: min(560px, calc(100vw - 32px)); max-width: none; }
.pv { display: flex; flex-direction: column; gap: 12px; }
.pv-box { --lvl: 0; position: relative; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; display: grid; place-items: center;
  background: linear-gradient(160deg, var(--side-bg), var(--top-bg));
  box-shadow: 0 0 0 calc(1px + var(--lvl) * 3px) color-mix(in srgb, var(--online) calc(var(--lvl) * 100%), transparent), 0 0 calc(var(--lvl) * 28px) color-mix(in srgb, var(--online) calc(var(--lvl) * 80%), transparent);
  transition: box-shadow .08s linear; }
.pv-video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.pv-pic .avatar.xl { width: 96px; height: 96px; font-size: 36px; border-radius: 18px; }
.pv-lvl { position: absolute; left: 10px; bottom: 10px; }
.lv-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 16px; padding: 3px 6px; border-radius: 9px; background: rgba(0,0,0,.55); color: #fff; }
.lv-bars i { width: 3px; height: 30%; border-radius: 2px; background: #fff; opacity: .35; }
.lv-bars i:nth-child(2) { height: 45%; } .lv-bars i:nth-child(3) { height: 60%; } .lv-bars i:nth-child(4) { height: 80%; } .lv-bars i:nth-child(5) { height: 100%; }
.lv-bars i.on { opacity: 1; background: var(--online); }
.lv-bars.off { padding: 2px 6px; }
.pv-warn { margin: -4px 0 0; font-size: 13px; color: var(--muted); }
.pv-toggles { display: flex; justify-content: center; gap: 14px; margin-top: -40px; position: relative; z-index: 1; }
.pv-t { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); color: var(--text); box-shadow: var(--shadow); border: 1px solid var(--border); }
.pv-t.off { background: var(--danger); color: var(--on-danger); border-color: transparent; }
.pv-devs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pv-dev { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; text-align: left; gap: 0 6px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 9px; }
.pv-dev:hover { background: var(--bg-hover); }
.pv-dk { font-size: 11px; color: var(--muted); font-weight: 600; }
.pv-dn { grid-row: 2; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-dev .ic-svg { grid-row: 1 / span 2; grid-column: 2; align-self: center; }
.pv-skip { font-size: 13px; display: inline-flex; gap: 6px; align-items: center; color: var(--muted); }
.pv-foot { display: flex; justify-content: flex-end; gap: 8px; }
@media (max-width: 559px) { .pv-devs { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .pv-box { transition: none; } }
/* menu dei dispositivi */
.dv-menu { min-width: 260px; max-width: 340px; }
.dv-title { font-size: 11px; font-weight: 700; color: var(--muted); padding: 6px 10px 2px; }
.dv-item { display: flex; align-items: center; gap: 6px; width: 100%; text-align: left; }
.dv-item.on { color: var(--accent); font-weight: 600; }
.dv-check { width: 16px; display: grid; place-items: center; flex: none; }
.dv-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dv-lvl .lv-bars { background: transparent; color: inherit; padding: 0; }
.dv-lvl .lv-bars i { background: currentColor; }
.dv-none { margin: 4px 10px; font-size: 13px; color: var(--muted); }

/* menu Altro e sfondi della finestra */
.cm-menu { min-width: 280px; }
.cm-menu button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; }
.cm-more { margin-left: auto; color: var(--muted); font-size: 12px; display: inline-flex; align-items: center; }
.cm-off { opacity: .55; cursor: default; }
.cm-note { margin-left: auto; font-size: 11px; color: var(--muted); }
.cm-sw { width: 18px; height: 18px; border-radius: 5px; flex: none; }
.cc-topic { color: var(--text); }
.call-win[data-bg=bosco], .cm-sw[data-bg=bosco] { background: linear-gradient(160deg, color-mix(in srgb, var(--success) 38%, var(--side-bg)), var(--top-bg)); }
.call-win[data-bg=ambra], .cm-sw[data-bg=ambra] { background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 34%, var(--side-bg)), var(--top-bg)); }
.call-win[data-bg=brace], .cm-sw[data-bg=brace] { background: linear-gradient(160deg, color-mix(in srgb, var(--danger) 30%, var(--side-bg)), var(--top-bg)); }
.cm-sw[data-bg=notte] { background: linear-gradient(160deg, var(--side-bg), var(--top-bg)); }

/* ---------- trascrizione della chiamata (6x) ---------- */
.call-tr { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; max-width: 100%; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; color: var(--side-strong); background: var(--side-hover); border: 1px solid transparent; cursor: pointer; }
.call-tr:hover, .call-tr:focus-visible { border-color: var(--side-text); }
.call-tr .tr-lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-tr .tr-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--badge); animation: tr-pulse 2s ease-in-out infinite; }
.call-tr.problem .tr-dot { background: var(--side-text); animation: none; }
@keyframes tr-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .call-tr .tr-dot { animation: none; } }
.cw-tr { flex: none; padding: 2px 8px; }
.call-win[data-mode=small] .cw-tr .tr-lbl { display: none; }
.tr-open { margin-top: 6px; display: inline-flex; align-items: center; gap: 6px; }
.tr-list { display: flex; flex-direction: column; gap: 10px; max-height: min(60vh, 520px); overflow-y: auto; margin: 0; padding: 0; list-style: none; }
.tr-list li { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; }
.tr-list .tr-at { grid-row: span 2; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 2px; }
.tr-list .tr-who { font-weight: 700; font-size: 13px; }
.tr-list .tr-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.tr-meta { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
