/* ==========================================================================
   Messenger — stile "aero" morbido ispirato al mockup
   ========================================================================== */
:root {
  --font: "Segoe UI", "Segoe UI Variable", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg: linear-gradient(160deg, #e9f4ff 0%, #d6eafe 45%, #e6f1fd 100%);
  --pane: rgba(255, 255, 255, .72);
  --card: #ffffff;
  --card-soft: #f6faff;
  --border: #cfe2f7;
  --border-strong: #b5d2f2;
  --text: #11243d;
  --muted: #55688a;
  --blue: #2a7be4;
  --blue-2: #4d9bf2;
  --blue-soft: #e3f0ff;
  --sel: #d9eaff;
  --green: #2cbf4a;
  --red: #e5484d;
  --orange: #f08c1a;
  --yellow: #f4b400;
  --shadow: 0 2px 6px rgba(40, 92, 160, .10), 0 10px 30px rgba(40, 92, 160, .08);
  --shadow-btn: 0 1px 0 #fff inset, 0 1px 3px rgba(40, 92, 160, .18);
  --radius: 16px;
  --bubble-in: #f3f6fa;
  --bubble-in-b: #dde5ef;
  --bubble-out: linear-gradient(#e6f2ff, #d5e9ff);
  --bubble-out-b: #b9d6f6;
  color-scheme: light;
}
html.dark {
  --bg: linear-gradient(160deg, #0d1626 0%, #101f36 50%, #0b1526 100%);
  --pane: rgba(20, 32, 54, .78);
  --card: #172843;
  --card-soft: #1b2e4c;
  --border: #253c60;
  --border-strong: #31507d;
  --text: #e5eefb;
  --muted: #94a8c8;
  --blue: #5aa6ff;
  --blue-2: #3d8ef0;
  --blue-soft: #1e3658;
  --sel: #23406a;
  --shadow: 0 2px 6px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .25);
  --shadow-btn: 0 1px 0 rgba(255,255,255,.06) inset, 0 1px 3px rgba(0,0,0,.4);
  --bubble-in: #1c2f4d;
  --bubble-in-b: #29426a;
  --bubble-out: linear-gradient(#24476f, #1f3f66);
  --bubble-out-b: #33608f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); color: var(--text); background: var(--bg); background-attachment: fixed; font-size: 15px; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.inline { display: inline; margin: 0; }

/* ---------- icone ---------- */
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.sm { width: 14px; height: 14px; }
.ic.xl { width: 34px; height: 34px; }
.ic.blue { color: var(--blue); } .ic.green { color: var(--green); } .ic.orange { color: var(--orange); } .ic.yellow { color: #e8a200; }
#i-dots circle { fill: currentColor; }

/* ---------- pulsanti ---------- */
.iconbtn, .softbtn, .toolbtn, .btn {
  border: 1px solid var(--border-strong); background: linear-gradient(var(--card), var(--card-soft));
  border-radius: 12px; box-shadow: var(--shadow-btn); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s, background .15s, border-color .15s;
}
.iconbtn:hover, .softbtn:hover, .toolbtn:hover, .btn:hover { border-color: var(--blue-2); background: var(--blue-soft); }
.iconbtn:active, .softbtn:active, .toolbtn:active, .btn:active { transform: translateY(1px); }
.iconbtn { width: 44px; height: 44px; color: var(--blue); }
.softbtn { width: 54px; height: 46px; }
.toolbtn { height: 44px; min-width: 50px; padding: 0 10px; }
.btn { padding: 10px 16px; font-weight: 500; }
.btn.wide { width: 100%; padding: 12px; }
.btn.primary { background: linear-gradient(#55a6ff, #2a7be4); color: #fff; border-color: #2a73d6; }
.btn.primary:hover { background: linear-gradient(#4d9bf2, #1f6dd4); }
.btn.danger { color: var(--red); }
.btn.big { padding: 13px; font-size: 16px; }
.btn:disabled, .btn:disabled:hover { opacity: .5; cursor: default; background: linear-gradient(var(--card), var(--card-soft)); border-color: var(--border-strong); }
.link { background: none; border: 0; color: var(--blue); padding: 4px 6px; font-weight: 500; }
.link.small { font-size: 13px; margin-left: auto; }
.link.strong { font-weight: 700; }

.toolbtn.nudge { background: linear-gradient(#fff8ec, #ffe8c4); border-color: #f5c27c; color: #c45f00; font-weight: 600; padding: 0 16px; }
html.dark .toolbtn.nudge { background: linear-gradient(#4a3417, #3a2810); border-color: #8a5c20; color: #ffc278; }

/* ---------- layout ---------- */
.shell { height: 100%; display: flex; flex-direction: column; padding: 10px; gap: 10px; max-width: 1680px; margin: 0 auto; }
.glass { background: var(--pane); backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3); border: 1px solid rgba(255,255,255,.7); box-shadow: var(--shadow); }
html.dark .glass { border-color: rgba(255,255,255,.06); }
.topbar { display: flex; align-items: center; gap: 16px; padding: 8px 14px; border-radius: var(--radius); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 27px; font-weight: 700; font-style: italic; color: var(--blue); letter-spacing: -.5px; }
.topsearch { margin-left: auto; position: relative; width: min(340px, 40vw); }
.topsearch .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.topsearch input, .search-field input {
  width: 100%; border: 1px solid var(--border-strong); background: var(--card); border-radius: 12px; padding: 10px 12px 10px 42px; outline: none;
}
.topsearch input:focus, .search-field input:focus, textarea:focus, .modal input:focus, .modal select:focus { border-color: var(--blue-2); box-shadow: 0 0 0 3px rgba(77,155,242,.18); }
.topactions { display: flex; gap: 10px; }

.app { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(300px, 380px) 1fr minmax(300px, 410px); gap: 10px; }
.pane { min-height: 0; border-radius: var(--radius); background: var(--pane); border: 1px solid rgba(255,255,255,.7); box-shadow: var(--shadow); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
html.dark .pane { border-color: rgba(255,255,255,.06); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 1px 2px rgba(40,92,160,.06); }

/* ---------- colonna sinistra ---------- */
.left { display: flex; flex-direction: column; gap: 12px; padding: 10px; }
.me-card { display: flex; gap: 14px; padding: 14px; align-items: center; }
.me-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.me-name, .me-psm { border: 1px solid transparent; background: transparent; border-radius: 8px; padding: 2px 6px; margin-left: -6px; outline: none; width: 100%; text-overflow: ellipsis; }
.me-name { font-size: 20px; font-weight: 700; }
.me-psm { font-style: italic; color: var(--muted); font-size: 14px; }
.me-name:hover, .me-psm:hover { border-color: var(--border); }
.me-name:focus, .me-psm:focus { border-color: var(--blue-2); background: var(--card-soft); }
.status-pick { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; padding: 2px 6px; margin-left: -6px; border-radius: 8px; width: max-content; font-size: 16px; }
.status-pick:hover { background: var(--blue-soft); }
.status-pick .ic { transform: rotate(90deg); }
.dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; background: #9aa6b5; box-shadow: inset 0 -2px 3px rgba(0,0,0,.18), 0 0 0 2px rgba(255,255,255,.7); flex: none; }
.dot.online { background: radial-gradient(circle at 35% 30%, #9cf28a, var(--green) 60%); }
.dot.busy { background: radial-gradient(circle at 35% 30%, #ff9c9c, var(--red) 60%); }
.dot.away { background: radial-gradient(circle at 35% 30%, #ffd08a, var(--orange) 60%); }
.dot.invisible, .dot.offline { background: radial-gradient(circle at 35% 30%, #e1e6ec, #9aa6b5 60%); }

.search-field { position: relative; display: block; }
.search-field .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tab { border: 1px solid var(--border-strong); background: linear-gradient(var(--card), var(--card-soft)); border-radius: 12px; padding: 9px; display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 500; box-shadow: var(--shadow-btn); position: relative; }
.tab .ic { color: var(--blue); }
.tab.on { background: linear-gradient(#fff6ea, #ffe6c6); border-color: #f5b871; color: #d46a00; font-weight: 600; }
.tab.on .ic { color: var(--orange); }
html.dark .tab.on { background: linear-gradient(#4a3417, #3a2810); border-color: #8a5c20; color: #ffc278; }

.contact-list { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; scrollbar-width: thin; }
.group-h { display: flex; align-items: center; gap: 8px; padding: 6px 10px; margin: 6px 0 4px; border-radius: 8px; background: linear-gradient(90deg, var(--blue-soft), transparent); color: var(--text); font-weight: 600; cursor: pointer; user-select: none; }
.group-h::before { content: ""; border: 6px solid transparent; border-top-color: var(--blue); border-bottom: 0; margin-top: 2px; transition: transform .15s; }
.group-h.closed::before { transform: rotate(-90deg); }
.group-h.closed + .group { display: none; }
.contact { display: flex; gap: 12px; align-items: center; padding: 8px 10px; border-radius: 12px; cursor: pointer; position: relative; }
.contact:hover { background: rgba(77,155,242,.08); }
.contact.on { background: var(--sel); box-shadow: inset 0 0 0 1px var(--border-strong); }
.contact .meta { min-width: 0; flex: 1; }
.contact .name { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact .sub { font-style: italic; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact .time { font-size: 12px; color: var(--muted); align-self: flex-start; margin-top: 4px; }
.contact.offline .avatar { filter: saturate(.55); opacity: .85; }
.contact .req-actions { display: flex; gap: 6px; }
.contact .req-actions button { width: 34px; height: 34px; border-radius: 10px; }
.badge { min-width: 20px; height: 20px; border-radius: 10px; background: var(--orange); color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; }
.contact .badge { position: absolute; right: 10px; bottom: 10px; }
.tab .badge { position: absolute; right: 10px; }
.list-empty { color: var(--muted); text-align: center; padding: 30px 12px; font-size: 14px; }

/* ---------- avatar ---------- */
.avatar { position: relative; flex: none; width: 56px; height: 56px; border-radius: 14px; background: linear-gradient(140deg, var(--a1, #5ab8ff), var(--a2, #1f6fe0)); background-size: cover; background-position: center; color: #fff; display: grid; place-items: center; font-weight: 700; letter-spacing: .5px; box-shadow: 0 2px 6px rgba(30,80,150,.25), inset 0 0 0 2px rgba(255,255,255,.55); }
.avatar.img { background-image: var(--img); }
.avatar.sm { width: 36px; height: 36px; border-radius: 10px; font-size: 13px; }
.avatar.md { width: 64px; height: 64px; border-radius: 16px; font-size: 22px; }
.avatar.xl { width: 84px; height: 84px; border-radius: 18px; font-size: 32px; cursor: pointer; box-shadow: 0 4px 10px rgba(30,80,150,.3), inset 0 0 0 3px rgba(255,255,255,.7); }
.avatar.hero { width: 170px; height: 170px; border-radius: 28px; font-size: 60px; box-shadow: 0 8px 24px rgba(30,80,150,.3), inset 0 0 0 4px rgba(255,255,255,.8); }
.avatar[data-status]::after { content: ""; position: absolute; right: -3px; bottom: -3px; width: 30%; height: 30%; max-width: 30px; max-height: 30px; min-width: 12px; min-height: 12px; border-radius: 50%; border: 2px solid #fff; background: #9aa6b5; }
.avatar[data-status=online]::after { background: radial-gradient(circle at 35% 30%, #9cf28a, var(--green) 60%); }
.avatar[data-status=busy]::after { background: radial-gradient(circle at 35% 30%, #ff9c9c, var(--red) 60%); }
.avatar[data-status=away]::after { background: radial-gradient(circle at 35% 30%, #ffd08a, var(--orange) 60%); }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; overflow: hidden; position: relative; }
.empty-chat { margin: auto; text-align: center; color: var(--muted); padding: 30px; max-width: 420px; }
.empty-chat h2 { color: var(--text); margin: 18px 0 6px; }
.chat-wrap { display: flex; flex-direction: column; height: 100%; min-height: 0; position: relative; }
.chat-head { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--border); background: linear-gradient(var(--card), transparent); }
.chat-title { min-width: 0; flex: 1; }
.chat-title h2 { margin: 0; font-size: 26px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 16px; }
.chat-actions { display: flex; gap: 10px; }
.only-mobile { display: none; }

.messages { flex: 1; overflow-y: auto; padding: 14px 18px 8px; display: flex; flex-direction: column; scroll-behavior: auto; transition: background .3s; }
#msgList { display: flex; flex-direction: column; gap: 10px; }
.messages.theme-sky { background: linear-gradient(180deg, rgba(255,255,255,.55), rgba(230,242,255,.55)); }
.messages.theme-rose { background: linear-gradient(180deg, #fff4f8, #ffe1ec); --bubble-out: linear-gradient(#ffe8f1, #ffd6e6); --bubble-out-b: #f5b3cd; }
.messages.theme-lavender { background: linear-gradient(180deg, #f7f3ff, #e8ddff); --bubble-out: linear-gradient(#efe7ff, #e1d3ff); --bubble-out-b: #c5aef3; }
.messages.theme-peach { background: linear-gradient(180deg, #fff8ef, #ffe6c9); --bubble-out: linear-gradient(#fff0db, #ffe1bd); --bubble-out-b: #f3c486; }
.messages.theme-mint { background: linear-gradient(180deg, #f2fcf3, #d9f5dc); --bubble-out: linear-gradient(#e6f9e8, #d0f2d4); --bubble-out-b: #9fdca8; }
html.dark .messages.theme-sky { background: linear-gradient(180deg, rgba(20,36,62,.6), rgba(16,30,52,.6)); }
html.dark .messages.theme-rose { background: linear-gradient(180deg, #2a1a26, #331b2b); --bubble-out: linear-gradient(#5a2a45, #4c2239); --bubble-out-b: #7a3a5e; }
html.dark .messages.theme-lavender { background: linear-gradient(180deg, #211b35, #271f40); --bubble-out: linear-gradient(#45357a, #3a2c69); --bubble-out-b: #5c4aa0; }
html.dark .messages.theme-peach { background: linear-gradient(180deg, #2c2116, #33251a); --bubble-out: linear-gradient(#6a4520, #5a3a1a); --bubble-out-b: #8a5c2a; }
html.dark .messages.theme-mint { background: linear-gradient(180deg, #14281b, #173020); --bubble-out: linear-gradient(#25553a, #1f4831); --bubble-out-b: #2f6e4a; }

.day-sep { align-self: center; display: flex; align-items: center; gap: 12px; width: 100%; color: var(--muted); font-size: 14px; margin: 6px 0; }
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.day-sep span { border: 1px solid var(--border); background: var(--card); border-radius: 20px; padding: 3px 14px; }

.msg { display: flex; gap: 12px; align-items: flex-end; max-width: 78%; animation: pop .18s ease-out; }
.msg.out { align-self: flex-end; flex-direction: row-reverse; }
.msg.cont .avatar { visibility: hidden; }
.bubble { position: relative; padding: 10px 14px 8px; border-radius: 16px; background: var(--bubble-in); border: 1px solid var(--bubble-in-b); box-shadow: 0 1px 2px rgba(30,80,150,.08); font-size: 17px; line-height: 1.4; word-wrap: break-word; overflow-wrap: anywhere; min-width: 0; }
.msg.out .bubble { background: var(--bubble-out); border-color: var(--bubble-out-b); }
.bubble .text { white-space: pre-wrap; }
.bubble .text .emo { font-size: 1.15em; }
.bubble.jumbo { background: transparent !important; border: 0 !important; box-shadow: none; font-size: 42px; padding: 0 4px; }
.bubble a { color: var(--blue); }
.stamp { float: right; margin: 8px 0 -4px 14px; font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.stamp .ic { width: 17px; height: 17px; color: #8aa0bd; }
.stamp .ic.read { color: var(--blue); }
.msg.highlight .bubble { box-shadow: 0 0 0 3px var(--yellow); }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }

.msg-event { align-self: center; display: flex; align-items: center; gap: 12px; padding: 10px 22px; border-radius: 14px; font-weight: 600; font-size: 16px; animation: pop .2s; }
.msg-event.nudge { background: linear-gradient(#fffaf2, #fff0dc); border: 1px solid #f5c27c; color: #d35d00; }
.msg-event.call { background: var(--card); border: 1px solid var(--border); color: var(--text); font-weight: 500; }
.msg-event.call > .ic { color: var(--green); }
.msg-event.call.missed > .ic { color: var(--red); }
.msg-event.system { background: transparent; color: var(--muted); font-weight: 400; font-size: 13px; font-style: italic; padding: 2px; }
.msg-event .stamp { margin: 0 0 0 6px; float: none; font-weight: 400; }
.msg-event .bell { font-size: 26px; display: inline-block; animation: ring 1s ease-in-out 2; }
html.dark .msg-event.nudge { background: linear-gradient(#3e2a12, #33230f); border-color: #8a5c20; color: #ffb35c; }
@keyframes ring { 0%,100% { transform: rotate(0); } 15% { transform: rotate(18deg); } 30% { transform: rotate(-16deg); } 45% { transform: rotate(12deg); } 60% { transform: rotate(-8deg); } 75% { transform: rotate(4deg); } }

.att-img { display: block; max-width: min(320px, 100%); max-height: 300px; border-radius: 10px; cursor: zoom-in; margin-bottom: 2px; }
.att-file { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; min-width: 220px; }
.att-file .fi { width: 44px; height: 52px; border-radius: 8px; background: #fff; border: 1px solid var(--border); display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff; position: relative; overflow: hidden; }
.att-file .fi b { background: var(--red); padding: 2px 5px; border-radius: 4px; }
.att-file small { display: block; color: var(--muted); }
.att-audio { display: flex; align-items: center; gap: 10px; min-width: 230px; }
.att-audio button { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--blue); color: #fff; display: grid; place-items: center; }
.att-audio button .ic { width: 16px; height: 16px; fill: currentColor; stroke: none; }
.att-audio .bar { flex: 1; height: 6px; border-radius: 3px; background: var(--border); position: relative; cursor: pointer; }
.att-audio .bar i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--blue); border-radius: 3px; }
.att-audio small { color: var(--muted); font-size: 13px; min-width: 34px; }
.game-invite { display: flex; align-items: center; gap: 12px; }
.game-invite .gi { font-size: 34px; }

.typing { display: flex; align-items: center; gap: 12px; padding: 10px 0 4px; color: var(--muted); }
.typing-dots { display: inline-flex; gap: 4px; padding: 9px 12px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; }
.typing-dots i { width: 7px; height: 7px; border-radius: 50%; background: #8aa0bd; animation: blink 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: .2s; } .typing-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.loader-more { text-align: center; color: var(--muted); font-size: 13px; padding: 6px; }

.composer { border-top: 1px solid var(--border); padding: 12px 18px 14px; background: linear-gradient(transparent, var(--card-soft)); position: relative; }
.tools { display: flex; gap: 10px; margin-bottom: 10px; align-items: center; flex-wrap: wrap; }
.rec { display: flex; align-items: center; gap: 10px; margin-left: auto; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 6px 10px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: blink 1s infinite; }
.toolbtn.recording { background: #ffe5e5; border-color: var(--red); }
.input-row { display: flex; gap: 12px; align-items: flex-end; }
textarea#input { flex: 1; resize: none; border: 1px solid var(--border-strong); background: var(--card); border-radius: 14px; padding: 13px 18px; outline: none; max-height: 160px; font-size: 17px; line-height: 1.35; }
.sendbtn { width: 60px; height: 52px; border-radius: 50%; border: 0; background: radial-gradient(circle at 35% 30%, #7cc0ff, #2a7be4 70%); color: #fff; display: grid; place-items: center; box-shadow: 0 3px 10px rgba(42,123,228,.45), inset 0 1px 0 rgba(255,255,255,.5); flex: none; }
.sendbtn .ic { fill: #fff; stroke: #fff; width: 26px; height: 26px; }
.sendbtn:hover { filter: brightness(1.07); }
.emoji-pop { position: absolute; bottom: calc(100% - 6px); left: 14px; width: 330px; max-width: calc(100% - 28px); background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 8px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; z-index: 20; }
.emoji-pop button { border: 0; background: none; font-size: 24px; padding: 4px; border-radius: 8px; }
.emoji-pop button:hover { background: var(--blue-soft); }
.emoji-pop .hint { grid-column: 1 / -1; font-size: 12px; color: var(--muted); padding: 4px; }
.drop-hint { position: absolute; inset: 0; background: rgba(42,123,228,.12); border: 3px dashed var(--blue); border-radius: var(--radius); display: grid; place-items: center; font-size: 22px; font-weight: 600; color: var(--blue); z-index: 30; pointer-events: none; }

/* trillo */
.shake { animation: shake .5s linear 2; }
@keyframes shake { 0%,100% { transform: translate(0,0); } 10% { transform: translate(-10px,-4px); } 20% { transform: translate(9px,5px); } 30% { transform: translate(-8px,6px); } 40% { transform: translate(8px,-5px); } 50% { transform: translate(-6px,3px); } 60% { transform: translate(6px,-3px); } 70% { transform: translate(-4px,4px); } 80% { transform: translate(3px,-2px); } 90% { transform: translate(-2px,1px); } }

/* ---------- colonna destra ---------- */
.right { padding: 12px; overflow-y: auto; }
.info-empty { height: 100%; display: grid; place-content: center; justify-items: center; text-align: center; color: var(--muted); gap: 6px; }
.info { display: flex; flex-direction: column; gap: 12px; }
.info-head { text-align: center; padding: 12px 0 2px; }
.info-head .avatar { margin: 0 auto; }
.info-head h3 { font-size: 30px; margin: 14px 0 2px; }
.info-head p { margin: 0; font-style: italic; color: var(--muted); font-size: 17px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.section { padding: 14px; }
.section h4 { margin: 0 0 12px; display: flex; align-items: center; gap: 10px; font-size: 17px; }
.section h4 .ic { color: var(--blue); }
.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.swatches button { height: 52px; border-radius: 10px; border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); }
.swatches button.on { border-color: var(--orange); box-shadow: 0 0 0 2px #fff inset, 0 0 0 1px var(--orange); }
.swatches [data-theme=sky] { background: linear-gradient(135deg, #c8e6ff, #4d9bf2); }
.swatches [data-theme=rose] { background: linear-gradient(135deg, #ffe0ec, #f7a8c8); }
.swatches [data-theme=lavender] { background: linear-gradient(135deg, #e3d6ff, #a78bf0); }
.swatches [data-theme=peach] { background: linear-gradient(135deg, #ffe7c2, #f7a64a); }
.swatches [data-theme=mint] { background: linear-gradient(135deg, #c9f2cf, #4cc265); }
.shared { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.shared .sf { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; height: 116px; background: var(--card-soft); display: flex; flex-direction: column; justify-content: flex-end; padding: 10px; text-decoration: none; color: inherit; background-size: cover; background-position: center; position: relative; }
.shared .sf.doc { justify-content: center; gap: 2px; }
.shared .sf b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shared .sf small { color: var(--muted); }
.shared .sf .tag { position: absolute; top: 10px; left: 10px; background: var(--red); color: #fff; font-size: 11px; font-weight: 800; padding: 2px 6px; border-radius: 4px; }
.shared .empty { grid-column: 1 / -1; color: var(--muted); font-size: 14px; text-align: center; padding: 10px; }
.games-card { display: flex; align-items: center; gap: 14px; text-align: left; width: 100%; color: inherit; }
.games-card div { flex: 1; } .games-card strong { display: block; font-size: 17px; } .games-card small { font-style: italic; color: var(--muted); }
.games-card:hover { border-color: var(--blue-2); }

/* ---------- menu, dropdown, modal, toast ---------- */
.dropdown, .menu { position: absolute; background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); z-index: 50; overflow: hidden; }
.dropdown { top: calc(100% + 6px); left: 0; right: 0; max-height: 420px; overflow-y: auto; }
.dropdown .res { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border); }
.dropdown .res:hover { background: var(--blue-soft); }
.dropdown .res small { color: var(--muted); display: block; }
.dropdown .res mark { background: #ffe58a; color: inherit; border-radius: 3px; }
.dropdown .none { padding: 14px; color: var(--muted); }
.menu { position: fixed; min-width: 220px; padding: 6px; }
.menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 10px 12px; border: 0; background: none; border-radius: 8px; text-align: left; }
.menu button:hover { background: var(--blue-soft); }
.menu button.danger { color: var(--red); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px; }

.modal-back { position: fixed; inset: 0; background: rgba(10,30,60,.35); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .15s; }
.modal { width: min(460px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; border-radius: 20px; padding: 22px; background: var(--card); }
.modal.wide { width: min(640px, 100%); }
.modal h3 { margin: 0 0 14px; font-size: 21px; display: flex; align-items: center; gap: 10px; }
.modal .close { margin-left: auto; }
.modal label { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 4px; }
.modal input[type=text], .modal input[type=email], .modal input[type=password], .modal select, .modal input:not([type]) { width: 100%; border: 1px solid var(--border-strong); background: var(--card-soft); border-radius: 10px; padding: 10px 12px; outline: none; color: var(--text); }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.modal .switch { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); color: var(--text); font-size: 15px; margin: 0; }
.modal .note { font-size: 13px; color: var(--muted); }
.modal .err { color: var(--red); font-size: 14px; margin-top: 8px; }
.modal .ok { color: var(--green); font-size: 14px; margin-top: 8px; }
.prof { text-align: center; }
.prof .avatar { margin: 0 auto 10px; }
.prof dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; text-align: left; margin: 16px 0 0; }
.prof dt { color: var(--muted); } .prof dd { margin: 0; font-weight: 500; }
.lightbox { max-width: 92vw; max-height: 86vh; border-radius: 12px; display: block; margin: auto; }
.modal.bare { background: transparent; box-shadow: none; border: 0; width: auto; padding: 0; }
.files-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
@keyframes fade { from { opacity: 0; } }

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { display: flex; align-items: center; gap: 14px; min-width: 300px; max-width: 380px; padding: 12px 14px; border-radius: 16px; background: linear-gradient(#fffaf2, #fff0dc); border: 1px solid #f5c27c; box-shadow: var(--shadow); animation: slidein .25s ease-out; cursor: pointer; }
html.dark .toast { background: linear-gradient(#3e2a12, #33230f); border-color: #8a5c20; }
.toast.t-info { background: var(--card); border-color: var(--border); }
.toast.t-err { background: #fff0f0; border-color: #f2b3b3; color: #a12a2a; }
.toast .t { flex: 1; font-size: 16px; } .toast .t small { display: block; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.toast .x { border: 0; background: none; color: var(--muted); }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } }

/* ---------- giochi ---------- */
.game-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.game-pick button { border: 1px solid var(--border); background: var(--card-soft); border-radius: 14px; padding: 18px 12px; text-align: center; }
.game-pick button:hover { border-color: var(--blue-2); background: var(--blue-soft); }
.game-pick .gi { font-size: 40px; display: block; }
.game-pick strong { display: block; margin-top: 6px; } .game-pick small { color: var(--muted); }
.board { display: grid; gap: 8px; margin: 10px auto; user-select: none; }
.board.tris { grid-template-columns: repeat(3, 1fr); width: min(300px, 100%); }
.board.tris .cell { aspect-ratio: 1; border-radius: 14px; background: var(--card-soft); border: 2px solid var(--border); font-size: 54px; font-weight: 800; display: grid; place-items: center; cursor: pointer; }
.board.tris .cell.X { color: var(--blue); } .board.tris .cell.O { color: var(--orange); }
.board.forza4 { grid-template-columns: repeat(7, 1fr); width: min(420px, 100%); background: linear-gradient(#3d8ef0, #2a6fd0); padding: 10px; border-radius: 16px; gap: 6px; }
.board.forza4 .cell { aspect-ratio: 1; border-radius: 50%; background: var(--card); box-shadow: inset 0 3px 5px rgba(0,0,0,.25); cursor: pointer; }
.board.forza4 .cell.X { background: radial-gradient(circle at 35% 30%, #ff8f8f, #e03131); }
.board.forza4 .cell.O { background: radial-gradient(circle at 35% 30%, #ffe27a, #f2b100); }
.board .cell.win { box-shadow: 0 0 0 4px #33d06b; animation: pulsewin 1s infinite; }
.board .cell.last { outline: 3px solid rgba(255,255,255,.7); }
@keyframes pulsewin { 50% { transform: scale(.92); } }
.game-status { text-align: center; font-weight: 600; font-size: 17px; margin: 6px 0; }
.game-players { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--muted); }

/* ---------- chiamate ---------- */
.callview { position: fixed; inset: 0; z-index: 300; background: radial-gradient(circle at 50% 30%, #23466f, #0b1628 70%); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.callview #remoteVideo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; opacity: 0; pointer-events: none; }
.callview.has-video #remoteVideo { opacity: 1; }
.callview.has-video .call-audio { display: none; }
.call-audio { display: grid; place-items: center; }
.call-top { position: absolute; top: max(28px, env(safe-area-inset-top)); left: 0; right: 0; text-align: center; text-shadow: 0 1px 6px rgba(0,0,0,.5); }
.call-top h2 { margin: 0; font-size: 30px; } .call-top p { margin: 6px 0 0; opacity: .85; font-size: 17px; }
.callview #localVideo { position: absolute; right: 18px; bottom: 120px; width: min(240px, 32vw); aspect-ratio: 4/3; object-fit: cover; border-radius: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.5); border: 2px solid rgba(255,255,255,.4); background: #111; transform: scaleX(-1); }
.callview #localVideo.screen, .callview #localVideo.rear { transform: none; }
.quality { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; margin-right: 8px; vertical-align: -1px; }
.quality i { width: 4px; border-radius: 1px; background: rgba(255,255,255,.3); }
.quality i:nth-child(1) { height: 5px; } .quality i:nth-child(2) { height: 9px; } .quality i:nth-child(3) { height: 14px; }
.quality[data-level="3"] i { background: #4ade80; }
.quality[data-level="2"] i:nth-child(-n+2) { background: #facc15; }
.quality[data-level="1"] i:nth-child(1) { background: #f87171; }
.quality[data-level="0"] i { background: rgba(255,255,255,.3); }
.callview .quality-text { font-size: 14px !important; color: #fecaca; min-height: 1em; }
.callview:not(.local-video) #localVideo { display: none; }
.call-bar { position: absolute; bottom: max(26px, env(safe-area-inset-bottom)); display: flex; gap: 16px; padding: 12px 18px; border-radius: 40px; background: rgba(10,20,40,.55); backdrop-filter: blur(12px); }
.cbtn { width: 60px; height: 60px; border-radius: 50%; border: 0; background: rgba(255,255,255,.16); color: #fff; display: grid; place-items: center; transition: background .15s, transform .1s; }
.cbtn:hover { background: rgba(255,255,255,.28); }
.cbtn.off { background: #fff; color: #1b2b44; }
.cbtn.red { background: var(--red); } .cbtn.red:hover { background: #ff5b60; }
.cbtn.green { background: var(--green); } .cbtn.green:hover { background: #3ad25a; }
.cbtn .ic { width: 26px; height: 26px; }
.pulse { position: relative; display: grid; place-items: center; }
.pulse::before, .pulse::after { content: ""; position: absolute; inset: -14px; border-radius: 40px; border: 3px solid rgba(90,170,255,.6); animation: ripple 2s infinite; }
.pulse::after { animation-delay: 1s; }
@keyframes ripple { from { transform: scale(.9); opacity: 1; } to { transform: scale(1.35); opacity: 0; } }
.incoming { position: fixed; z-index: 310; right: 20px; top: 20px; width: 320px; max-width: calc(100vw - 40px); padding: 28px 20px 22px; border-radius: 24px; background: linear-gradient(160deg, #23466f, #0f203a); color: #fff; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.45); animation: slidein .3s; }
.incoming .avatar.hero { width: 110px; height: 110px; font-size: 40px; }
.incoming h3 { margin: 22px 0 4px; font-size: 24px; } .incoming p { margin: 0 0 18px; opacity: .8; }
.inc-actions { display: flex; justify-content: center; gap: 16px; }

/* ---------- login ---------- */
.auth-body { display: grid; place-items: center; padding: 20px; min-height: 100%; }
.auth-card { width: min(420px, 100%); border-radius: 24px; padding: 30px; }
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-brand h1 { margin: 8px 0 2px; font-style: italic; color: var(--blue); font-size: 34px; }
.auth-brand p { margin: 0; color: var(--muted); font-style: italic; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--blue-soft); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.seg a { text-align: center; padding: 9px; border-radius: 9px; text-decoration: none; color: var(--muted); font-weight: 600; }
.seg a.on { background: var(--card); color: var(--blue); box-shadow: var(--shadow-btn); }
.auth-form label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.auth-form input, .auth-form select { display: block; width: 100%; margin-top: 4px; padding: 12px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--card); outline: none; color: var(--text); }
.auth-form .btn { width: 100%; margin-top: 8px; }
.auth-error { background: #fff0f0; color: #a12a2a; border: 1px solid #f2b3b3; padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; font-size: 14px; }

.info-close { display: none; align-self: flex-end; width: 38px; height: 38px; }
.chat-title, #chatAvatar { cursor: pointer; }

.auth-ok { background: #edfbef; color: #1d6b2c; border: 1px solid #a8e3b2; padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; font-size: 14px; }
.auth-note { font-size: 14px; color: var(--muted); margin: 0 0 12px; }
.auth-link { text-align: center; margin: 14px 0 0; font-size: 14px; }
.auth-link a { color: var(--blue); text-decoration: none; font-weight: 500; }
html.dark .auth-ok { background: #173523; color: #9fe3b0; border-color: #2c6b40; }
html.dark .auth-error { background: #3a1a1c; color: #ffb0b0; border-color: #7a2c30; }
.danger-zone { border: 1px solid #f2b3b3; border-radius: 12px; padding: 12px; margin-top: 16px; }
.danger-zone h4 { margin: 0 0 6px; color: var(--red); }
.device-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.devices .device { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.devices .device div { flex: 1; min-width: 0; }
.devices .device small { display: block; color: var(--muted); font-size: 13px; }
.devices .device .btn { padding: 6px 12px; font-size: 14px; }
.devices .device.cur b { color: var(--blue); }

/* ---------- responsive ---------- */
@media (max-width: 1250px) {
  .app { grid-template-columns: minmax(280px, 340px) 1fr; }
  .right { position: fixed; right: 10px; top: 84px; bottom: 10px; width: min(380px, calc(100vw - 20px)); z-index: 60; transform: translateX(calc(100% + 20px)); transition: transform .25s; background: var(--card); }
  body.info-open .right { transform: none; }
  .info-close { display: inline-flex; }
}
@media (max-width: 760px) {
  body { font-size: 15px; }
  .shell { padding: 0; gap: 0; }
  .topbar { border-radius: 0; padding: 8px 10px; gap: 8px; }
  .brand span { display: none; }
  .topsearch { width: auto; flex: 1; margin-left: 0; }
  .topactions { gap: 6px; } .iconbtn { width: 40px; height: 40px; }
  .app { grid-template-columns: 1fr; gap: 0; }
  .pane { border-radius: 0; border: 0; }
  .chat { display: none; }
  body.chat-open .left { display: none; }
  body.chat-open .chat { display: flex; }
  body.chat-open .topbar { display: none; }
  .only-mobile { display: inline-flex; }
  .chat-head { padding: 8px 10px; gap: 10px; }
  .chat-head .avatar.md { width: 44px; height: 44px; font-size: 16px; }
  .chat-title h2 { font-size: 19px; } .chat-status { font-size: 14px; }
  .softbtn { width: 42px; height: 40px; } .chat-actions { gap: 6px; }
  .messages { padding: 10px; }
  .msg { max-width: 90%; } .bubble { font-size: 16px; }
  .msg .avatar.sm { display: none; }
  .composer { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .tools { gap: 6px; margin-bottom: 8px; } .toolbtn { height: 38px; min-width: 40px; padding: 0 8px; }
  .toolbtn.nudge span { display: none; }
  .sendbtn { width: 48px; height: 48px; }
  textarea#input { font-size: 16px; padding: 11px 14px; }
  .right { top: 0; right: 0; bottom: 0; width: 100vw; border-radius: 0; }
  .toasts { left: 10px; right: 10px; bottom: 10px; } .toast { min-width: 0; max-width: none; }
  .callview #localVideo { width: 34vw; bottom: 110px; right: 10px; }
  .cbtn { width: 52px; height: 52px; } .call-bar { gap: 10px; }
  .incoming { left: 20px; right: 20px; width: auto; }
}

/* ---- fase 4: sicurezza e privacy ---------------------------------------- */
.verify-bar { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 8px 16px; border-radius: 999px; font-size: 14px; max-width: calc(100vw - 20px); box-shadow: 0 8px 30px rgba(20,60,120,.25);
  background: linear-gradient(#fffbe8, #ffefb8); color: #5b4300; border: 1px solid #f1cf6a; }
html.dark .verify-bar { background: linear-gradient(#4a3c12, #3a2e0b); color: #ffe7a3; border-color: #7a6220; }
.verify-bar span { overflow: hidden; text-overflow: ellipsis; }
.btn.sm { padding: 5px 10px; font-size: 13px; min-height: 0; }
.iconbtn.sm { width: 28px; height: 28px; }
.modal .sec-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.modal .sec-row.col { flex-direction: column; align-items: stretch; gap: 6px; }
.modal .sec-row small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.modal .sec-row .btn { flex-shrink: 0; }
.modal .steps { padding-left: 20px; margin: 4px 0 10px; font-size: 14px; line-height: 1.45; }
.qr-box { display: flex; justify-content: center; margin: 6px auto; }
.qr-box svg { width: 196px; height: 196px; border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,.12); }
.center { text-align: center; }
.secret-key { font-size: 13px; letter-spacing: .5px; background: var(--hover, rgba(0,0,0,.05)); padding: 3px 6px; border-radius: 6px; user-select: all; }
.code-input { font-size: 22px !important; letter-spacing: 4px; text-align: center; font-variant-numeric: tabular-nums; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin: 10px 0; }
.codes code { text-align: center; padding: 7px; border-radius: 8px; background: var(--hover, rgba(0,0,0,.05)); font-size: 15px; letter-spacing: 1px; user-select: all; }
.phrase { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0; }
.phrase span { padding: 8px 6px; border-radius: 8px; background: linear-gradient(#f4f9ff, #e4efff); border: 1px solid #c7dbf7; font-weight: 600; font-size: 14px; color: #17325a; }
html.dark .phrase span { background: linear-gradient(#21324c, #1a2840); border-color: #2f4a70; color: #dbe8ff; }
.phrase i { font-style: normal; font-weight: 400; color: var(--muted); font-size: 11px; margin-right: 5px; }
.menu-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.report-quote { border-left: 3px solid #e2574c; background: rgba(226,87,76,.08); padding: 8px 10px; border-radius: 6px; margin-bottom: 8px; font-size: 14px; white-space: pre-wrap; word-break: break-word; max-height: 120px; overflow: auto; }
.reasons { display: flex; flex-direction: column; gap: 2px; margin: 8px 0; }
.modal .radio { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 15px; margin: 0; color: var(--text); cursor: pointer; }
.modal .radio input { width: 18px; height: 18px; margin: 0; }
.linkbtn { background: none; border: 0; color: var(--accent, #2a7be4); text-decoration: underline; cursor: pointer; font: inherit; padding: 0; font-size: 13px; }
.auth-2fa { background: rgba(42,123,228,.08); border: 1px solid rgba(42,123,228,.25); border-radius: 10px; padding: 10px 12px; font-size: 14px; line-height: 1.45; margin-bottom: 6px; }
.auth-link.small { font-size: 13px; color: var(--muted); }
@media (max-width: 600px) { .verify-bar { top: auto; bottom: 74px; border-radius: 14px; font-size: 13px; } .phrase { grid-template-columns: repeat(2, 1fr); } }

/* ---- chiamate verificate end-to-end ------------------------------------- */
.callview .call-sec { display: inline-flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; margin-top: 10px !important;
  padding: 6px 12px; border-radius: 999px; font-size: 13.5px !important; opacity: 1 !important; background: rgba(0,0,0,.35); backdrop-filter: blur(8px); }
.callview .call-sec.ok { box-shadow: inset 0 0 0 1px rgba(110,231,160,.55); }
.callview .call-sec.warn { box-shadow: inset 0 0 0 1px rgba(253,224,71,.6); }
.callview .call-sec b { font-size: 20px; letter-spacing: 3px; font-weight: 400; }
.gc-sec { position: absolute; right: 8px; top: 8px; background: rgba(0,0,0,.5); color: #fff; padding: 2px 8px; border-radius: 10px; font-size: 13px; letter-spacing: 1px; }
.gc-sec.warn { box-shadow: inset 0 0 0 1px rgba(253,224,71,.7); }
