:root {
  --bg: #07061a;
  --panel: rgba(255, 255, 255, 0.045);
  --panel2: rgba(255, 255, 255, 0.075);
  --line: rgba(255, 255, 255, 0.09);
  --text: #f1f0ff;
  --muted: #a9a6c9;
  --violet: #8b5cf6;
  --cyan: #22d3ee;
  --danger: #f87171;
  --grad-btn: linear-gradient(120deg, #8b5cf6 0%, #6366f1 45%, #22d3ee 100%);
  --mine: linear-gradient(135deg, #8b5cf6 0%, #22d3ee 100%);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
.hidden { display: none !important; }
a { color: inherit; }
button { font: inherit; color: inherit; }

.aurora { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.aurora span { position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%; filter: blur(90px); opacity: 0.35; }
.aurora span:nth-child(1) { background: #6d28d9; top: -25vmax; left: -15vmax; }
.aurora span:nth-child(2) { background: #0e7490; bottom: -30vmax; right: -20vmax; opacity: 0.25; }

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 22px; text-decoration: none; letter-spacing: -0.02em; }
.brand b { background: var(--grad-btn); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand img { border-radius: 10px; }
.brand.small { font-size: 18px; }
.tag-pro { display: inline-block; padding: 2px 8px; border-radius: 7px; font-size: 11px; font-weight: 900; letter-spacing: 0.08em; background: linear-gradient(135deg, #f5c451, #f59e0b); color: #1a1205; }
.btn { border: 0; border-radius: 14px; padding: 11px 20px; font-weight: 800; cursor: pointer; background: var(--grad-btn); color: #fff; }
.btn.ghost { background: var(--panel2); border: 1px solid var(--line); }
.icon-btn { border: 0; background: transparent; cursor: pointer; width: 38px; height: 38px; border-radius: 12px; font-size: 20px; display: inline-grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: var(--panel2); color: var(--text); }

/* ---------- collegamento ---------- */
.pair { position: relative; z-index: 1; height: 100%; display: grid; place-items: center; padding: 24px; overflow: auto; }
.pair-card { width: min(980px, 100%); display: grid; grid-template-columns: 1fr auto; gap: 48px; align-items: center; background: rgba(13, 12, 35, 0.85); border: 1px solid var(--line); border-radius: 28px; padding: 48px; box-shadow: 0 40px 90px rgba(0, 0, 0, 0.5), 0 0 90px rgba(139, 92, 246, 0.15); }
.pair h1 { font-size: clamp(28px, 3.6vw, 40px); margin: 26px 0 18px; letter-spacing: -0.03em; line-height: 1.1; }
.steps { padding-left: 22px; margin: 0 0 24px; color: var(--muted); font-size: 17px; line-height: 1.9; }
.steps b { color: var(--text); }
.code-line { color: var(--muted); font-size: 15px; line-height: 1.7; }
.code { display: inline-block; margin-top: 6px; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 26px; letter-spacing: 0.18em; color: var(--text); background: var(--panel2); border: 1px solid var(--line); padding: 6px 14px; border-radius: 12px; }
.pro-note { color: var(--muted); font-size: 14px; margin-top: 22px; }
.qr-box { display: grid; justify-items: center; gap: 14px; }
#qr { background: #fff; border-radius: 22px; padding: 14px; width: 292px; height: 292px; box-shadow: 0 0 0 6px rgba(139, 92, 246, 0.25); }
#qr.dim { opacity: 0.15; }
.qr-state { color: var(--muted); font-size: 14px; text-align: center; max-width: 290px; }
.notice { position: relative; z-index: 1; text-align: center; color: #fecaca; margin-top: 18px; }
@media (max-width: 760px) {
  body { overflow: auto; }
  .pair-card { grid-template-columns: 1fr; padding: 28px 22px; gap: 28px; }
  #qr { width: 240px; height: 240px; }
}

/* ---------- chat ---------- */
.app { position: relative; z-index: 1; height: 100%; display: grid; grid-template-columns: minmax(280px, 380px) 1fr; max-width: 1500px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); background: rgba(7, 6, 26, 0.75); }
.side { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: rgba(255, 255, 255, 0.02); }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 10px; }
.me { padding: 0 18px 10px; color: var(--muted); font-size: 13px; }
.search { padding: 0 14px 10px; }
.search input { width: 100%; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 12px; padding: 10px 14px; font: inherit; outline: none; }
.search input:focus { border-color: rgba(139, 92, 246, 0.6); }
.chat-list { list-style: none; margin: 0; padding: 0 8px; overflow-y: auto; flex: 1; }
.chat-item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 14px; cursor: pointer; }
.chat-item:hover { background: var(--panel); }
.chat-item.on { background: rgba(139, 92, 246, 0.18); }
.chat-item .info { flex: 1; min-width: 0; }
.chat-item .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .sub { color: var(--muted); font-size: 13px; }
.badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--grad-btn); color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center; }
.av { flex: none; width: 44px; height: 44px; border-radius: 15px; display: grid; place-items: center; font-weight: 800; color: #fff; background: var(--grad-btn); }
.av.g { background: linear-gradient(135deg, #f97316, #ec4899); }
.av img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.av:has(img) { overflow: hidden; }
.side-foot { color: var(--muted); font-size: 12px; padding: 10px 18px 16px; margin: 0; }

.conv { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.empty { margin: auto; text-align: center; color: var(--muted); max-width: 380px; padding: 24px; }
.empty img { border-radius: 22px; opacity: 0.9; }
.empty h2 { color: var(--text); margin: 14px 0 6px; }
.conv-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, 0.02); }
.conv-head .back { display: none; }
.conv-title { display: flex; flex-direction: column; min-width: 0; }
.conv-title small { color: var(--muted); font-size: 12.5px; }
.warn { margin: 10px 18px 0; padding: 10px 14px; border-radius: 12px; background: rgba(248, 113, 113, 0.12); border: 1px solid rgba(248, 113, 113, 0.35); color: #fecaca; font-size: 14px; }
.messages { flex: 1; overflow-y: auto; padding: 18px 6% 10px; display: flex; flex-direction: column; gap: 6px; }
.day { align-self: center; color: var(--muted); font-size: 12px; background: var(--panel); padding: 4px 12px; border-radius: 10px; margin: 8px 0; }
.sys { align-self: center; color: var(--muted); font-size: 12.5px; background: var(--panel); padding: 5px 12px; border-radius: 10px; max-width: 80%; text-align: center; }
.msg { max-width: min(560px, 75%); padding: 8px 12px 6px; border-radius: 18px; line-height: 1.45; word-wrap: break-word; white-space: pre-wrap; position: relative; }
.msg.theirs { align-self: flex-start; background: var(--panel2); border-bottom-left-radius: 6px; }
.msg.mine { align-self: flex-end; background: var(--mine); border-bottom-right-radius: 6px; box-shadow: 0 6px 18px rgba(139, 92, 246, 0.25); }
.msg .who { font-size: 12px; font-weight: 800; color: #c4b5fd; margin-bottom: 2px; }
.msg .time { display: block; text-align: right; font-size: 11px; opacity: 0.7; margin-top: 2px; }
.msg.err { opacity: 0.7; font-style: italic; }
.msg .quote { border-left: 3px solid rgba(255, 255, 255, 0.6); background: rgba(0, 0, 0, 0.18); padding: 4px 8px; border-radius: 8px; font-size: 13px; margin-bottom: 4px; opacity: 0.9; white-space: normal; }
.msg img { display: block; max-width: 100%; max-height: 360px; border-radius: 12px; margin: 2px 0; cursor: zoom-in; }
.msg .ph { width: 220px; height: 160px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.msg.pending { opacity: 0.6; }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.composer textarea { flex: 1; resize: none; max-height: 160px; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 16px; padding: 11px 14px; font: inherit; outline: none; line-height: 1.4; }
.composer textarea:focus { border-color: rgba(139, 92, 246, 0.6); }
.send { flex: none; width: 46px; height: 46px; border: 0; border-radius: 15px; background: var(--grad-btn); color: #fff; font-size: 18px; cursor: pointer; }
.attach { flex: none; height: 46px; }
.zoom { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.9); display: grid; place-items: center; cursor: zoom-out; }
.zoom img { max-width: 94vw; max-height: 94vh; border-radius: 10px; }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; transition: 0.25s; z-index: 60; background: #1e1b4b; border: 1px solid var(--line); padding: 10px 18px; border-radius: 14px; font-size: 14px; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; border: 0; }
  .app.open .side { display: none; }
  .app:not(.open) .conv { display: none; }
  .conv-head .back { display: inline-grid; }
  .messages { padding: 14px 10px; }
  .msg { max-width: 85%; }
}

/* Spunte blu (letto) */
.msg .tick-read { color: #5ef0ff; font-weight: 800; text-shadow: 0 0 3px rgba(0,0,0,.7); }
