:root {
  --bg: #0a0b12; --bg2: #0f1119; --panel: #141726; --panel2: #1b1f33; --line: rgba(255,255,255,.07);
  --text: #eef0ff; --muted: #8b90b0; --accent: #7c6cff; --accent2: #2dd4ff;
  --grad: linear-gradient(135deg, #7c6cff 0%, #4f8bff 55%, #2dd4ff 100%);
  --in: #1b1f33; --out-text: #fff; --danger: #ff5d73; --ok: #34d399; --warn: #fbbf24;
  --shadow: 0 20px 60px rgba(0,0,0,.45); --radius: 18px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f5fb; --bg2: #ffffff; --panel: #ffffff; --panel2: #eef0f9; --line: rgba(20,23,43,.09);
  --text: #14172b; --muted: #6a6f8d; --in: #eceefa; --shadow: 0 20px 60px rgba(40,50,110,.18); color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --bg: #f4f5fb; --bg2: #ffffff; --panel: #ffffff; --panel2: #eef0f9; --line: rgba(20,23,43,.09);
    --text: #14172b; --muted: #6a6f8d; --in: #eceefa; --shadow: 0 20px 60px rgba(40,50,110,.18); color-scheme: light;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); overflow: hidden; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
h1, h2, h3, p { margin: 0; }
small { color: var(--muted); }
.grow { flex: 1; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; word-break: break-all; }

/* ---------- ambient background ---------- */
.aurora { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.aurora::before, .aurora::after { content: ""; position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%; filter: blur(90px); opacity: .28; }
.aurora::before { background: #6a4dff; top: -25vmax; left: -15vmax; animation: drift 24s ease-in-out infinite alternate; }
.aurora::after { background: #00c2ff; bottom: -30vmax; right: -20vmax; animation: drift 30s ease-in-out infinite alternate-reverse; }
:root[data-theme="light"] .aurora::before, :root[data-theme="light"] .aurora::after { opacity: .18; }
@keyframes drift { to { transform: translate(8vmax, 6vmax) scale(1.15); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- logo ---------- */
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; }
.logo.xl { width: 64px; height: 64px; filter: drop-shadow(0 8px 24px rgba(124,108,255,.55)); }
.logo.xxl { width: 96px; height: 96px; filter: drop-shadow(0 12px 36px rgba(124,108,255,.5)); }
.logo svg, [data-icon] svg { width: 100%; height: 100%; display: block; }
.splash { position: fixed; inset: 0; display: grid; place-items: center; z-index: 50; background: var(--bg); transition: opacity .4s; }
.splash.gone { opacity: 0; pointer-events: none; }

/* ---------- screens & cards ---------- */
.screen { position: fixed; inset: 0; z-index: 2; display: grid; place-items: center; padding: 20px; overflow: auto; }
.card { width: min(420px, 100%); background: color-mix(in srgb, var(--panel) 82%, transparent); backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--line); border-radius: 26px; padding: 34px 28px 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; align-items: stretch; animation: rise .5s cubic-bezier(.2,.8,.2,1); }
.card > .logo { align-self: center; margin-bottom: 4px; }
.card h1 { font-size: 24px; letter-spacing: -.02em; text-align: center; }
.card .sub { text-align: center; }
.card #auth-1, .card #auth-2, .card #auth-3 { display: flex; flex-direction: column; gap: 14px; }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.sub { color: var(--muted); font-size: 14px; }
.fine { color: var(--muted); font-size: 12px; text-align: center; }
.error { color: var(--danger); font-size: 13px; min-height: 0; }
.error:empty { display: none; }
.devnote { background: color-mix(in srgb, var(--warn) 14%, transparent); border: 1px dashed var(--warn); color: var(--warn); padding: 10px 12px; border-radius: 12px; font-size: 13px; text-align: center; }
.app-name { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 800; }

/* ---------- form controls ---------- */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
.field input, .field select, input.plain, select, .inline input {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; outline: none; font-size: 15px; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text); transition: border-color .15s, box-shadow .15s; width: 100%; }
select { width: auto; padding: 9px 12px; border-radius: 12px; }
.field input:focus, .field select:focus, .inline input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
input.code { text-align: center; font-size: 26px; letter-spacing: .5em; font-weight: 700; }
.btn { display: inline-flex; gap: 8px; align-items: center; justify-content: center; padding: 12px 18px; border-radius: 14px; background: var(--panel2); border: 1px solid var(--line); font-weight: 600; transition: transform .1s, filter .15s, background .15s; }
.btn:hover { filter: brightness(1.12); } .btn:active { transform: scale(.98); }
.btn.primary { background: var(--grad); border: 0; color: #fff; box-shadow: 0 8px 24px rgba(92,110,255,.4); }
.btn.danger { color: var(--danger); } .btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.block { width: 100%; } .btn:disabled { opacity: .55; pointer-events: none; }
.btn [data-icon], .btn span[data-icon] { width: 18px; height: 18px; }
.seg { display: grid; grid-auto-flow: column; background: var(--panel2); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { padding: 9px; border-radius: 10px; font-weight: 600; color: var(--muted); transition: all .2s; }
.seg button.on { background: var(--bg2); color: var(--text); box-shadow: 0 2px 10px rgba(0,0,0,.25); }
.meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: -4px; } .meter i { height: 4px; border-radius: 4px; background: var(--panel2); transition: background .2s; }
.meter[data-s="1"] i:nth-child(-n+1) { background: var(--danger); } .meter[data-s="2"] i:nth-child(-n+2) { background: var(--warn); }
.meter[data-s="3"] i:nth-child(-n+3) { background: #a3e635; } .meter[data-s="4"] i { background: var(--ok); }
.switch { position: relative; width: 46px; height: 28px; flex: none; } .switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; cursor: pointer; z-index: 1; margin: 0; }
.switch i { position: absolute; inset: 0; background: var(--panel2); border: 1px solid var(--line); border-radius: 20px; transition: .2s; }
.switch i::after { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.switch input:checked + i { background: var(--grad); border: 0; } .switch input:checked + i::after { transform: translateX(18px); }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--muted); transition: background .15s, color .15s; flex: none; padding: 9px; }
.icon-btn:hover { background: var(--panel2); color: var(--text); } .icon-btn.sm { width: 32px; height: 32px; padding: 7px; }
.icon-btn:disabled { opacity: .35; pointer-events: none; }
[data-icon] { display: inline-grid; place-items: center; }

/* ---------- app shell ---------- */
#app { position: fixed; inset: 0; z-index: 1; display: grid; grid-template-columns: 370px 1fr; }
#sidebar { background: color-mix(in srgb, var(--bg2) 88%, transparent); backdrop-filter: blur(20px); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 16px 8px 20px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; letter-spacing: -.02em; }
.row { display: flex; gap: 2px; align-items: center; }
.search { margin: 8px 16px 10px; display: flex; align-items: center; gap: 10px; background: var(--panel2); border-radius: 14px; padding: 0 14px; color: var(--muted); }
.search [data-icon] { width: 18px; height: 18px; } .search input { flex: 1; background: none; border: 0; outline: none; padding: 11px 0; }
.list { flex: 1; overflow-y: auto; padding: 4px 10px; }
.item { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 11px 12px; border-radius: 16px; transition: background .15s; position: relative; }
.item:hover { background: var(--panel2); } .item.on { background: color-mix(in srgb, var(--accent) 18%, var(--panel2)); }
.item .mid { flex: 1; min-width: 0; } .item b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 650; }
.item .pv { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.item .meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 11px; color: var(--muted); }
.badge { background: var(--grad); color: #fff; font-weight: 700; font-size: 11px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center; }
.list-empty { padding: 40px 24px; text-align: center; color: var(--muted); }
.side-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.side-foot [data-icon] { width: 14px; height: 14px; color: var(--ok); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); } .dot.off { background: var(--warn); box-shadow: none; }

.avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 17px; flex: none; position: relative; letter-spacing: .02em; text-shadow: 0 1px 4px rgba(0,0,0,.25); }
.avatar.xl { width: 88px; height: 88px; font-size: 32px; } .avatar.sm { width: 36px; height: 36px; font-size: 14px; }

/* ---------- chat ---------- */
#chat { position: relative; display: flex; min-width: 0; min-height: 0; }
.empty { margin: auto; text-align: center; max-width: 380px; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 20px; }
.empty h2 { font-size: 26px; letter-spacing: -.02em; } .empty p { color: var(--muted); }
#convo { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.chat-head { display: flex; align-items: center; gap: 6px; padding: 10px 14px; background: color-mix(in srgb, var(--bg2) 80%, transparent); backdrop-filter: blur(20px); border-bottom: 1px solid var(--line); z-index: 2; }
.chat-head .who { display: flex; gap: 12px; align-items: center; flex: 1; text-align: left; min-width: 0; padding: 2px 6px; border-radius: 12px; }
.who-text { display: flex; flex-direction: column; min-width: 0; } .who-text b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-text small { display: flex; gap: 5px; align-items: center; } .who-text small.typing { color: var(--accent2); }
.chat-head .avatar { width: 40px; height: 40px; font-size: 15px; } .back { display: none; }
.banner { margin: 10px 14px 0; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--warn) 12%, var(--panel)); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.banner .grow { min-width: 160px; } .banner .btn { padding: 8px 12px; border-radius: 10px; font-size: 13px; }
.msgs { flex: 1; overflow-y: auto; padding: 18px clamp(12px, 4vw, 48px) 8px; display: flex; flex-direction: column; gap: 3px; outline: none; scroll-behavior: smooth; }
.day { align-self: center; margin: 14px 0 8px; font-size: 12px; color: var(--muted); background: var(--panel2); padding: 4px 12px; border-radius: 12px; }
.sysmsg { align-self: center; margin: 8px 0; font-size: 12.5px; color: var(--muted); background: var(--panel2); padding: 6px 14px; border-radius: 14px; text-align: center; max-width: 80%; display: flex; gap: 6px; align-items: center; }
.sysmsg.warn { color: var(--warn); } .sysmsg [data-icon] { width: 14px; height: 14px; }
.e2ee-note { align-self: center; text-align: center; margin: 4px 0 14px; font-size: 12.5px; color: var(--muted); max-width: 340px; }
.msg { max-width: min(560px, 78%); display: flex; flex-direction: column; position: relative; animation: pop .22s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.msg.me { align-self: flex-end; align-items: flex-end; } .msg.them { align-self: flex-start; }
.bubble { padding: 9px 13px 7px; border-radius: 20px; background: var(--in); position: relative; word-wrap: break-word; overflow-wrap: anywhere; }
.me .bubble { background: var(--grad); color: var(--out-text); border-bottom-right-radius: 6px; box-shadow: 0 6px 18px rgba(92,110,255,.22); }
.them .bubble { border-bottom-left-radius: 6px; }
.msg.first-in-group.me .bubble, .msg.mid.me .bubble { border-bottom-right-radius: 20px; } .msg.first-in-group.them .bubble, .msg.mid.them .bubble { border-bottom-left-radius: 20px; }
.bubble.media { padding: 4px; } .bubble.media .txt { padding: 6px 9px 2px; }
.txt { white-space: pre-wrap; } .txt a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.stamp { display: flex; gap: 5px; align-items: center; justify-content: flex-end; font-size: 11px; opacity: .72; margin-top: 2px; padding: 0 3px; }
.stamp [data-icon] { width: 14px; height: 14px; } .stamp .read { color: #bff3ff; } .stamp .exp { display: flex; gap: 2px; align-items: center; }
.stamp .exp [data-icon] { width: 11px; height: 11px; }
.quote { border-left: 3px solid var(--accent2); background: rgba(0,0,0,.18); border-radius: 8px; padding: 5px 9px; margin-bottom: 6px; font-size: 13px; cursor: pointer; }
.quote b { display: block; font-size: 12px; } .quote span { opacity: .85; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.acts { position: absolute; top: -14px; display: none; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 2px; box-shadow: var(--shadow); z-index: 3; }
.me .acts { right: 8px; } .them .acts { left: 8px; } .msg:hover .acts, .msg:focus-within .acts { display: flex; }
.acts .icon-btn { width: 30px; height: 30px; padding: 6px; }
.img-att { display: block; border-radius: 16px; overflow: hidden; cursor: zoom-in; background: rgba(0,0,0,.2); min-width: 120px; min-height: 80px; position: relative; }
.img-att img { display: block; max-width: min(380px, 100%); max-height: 380px; width: auto; height: auto; }
.img-att .loading { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; opacity: .7; }
.file { display: flex; gap: 12px; align-items: center; min-width: 220px; padding: 8px 10px 8px 8px; border-radius: 14px; background: rgba(0,0,0,.16); text-align: left; width: 100%; }
.file .ico { width: 42px; height: 42px; border-radius: 12px; background: rgba(255,255,255,.18); display: grid; place-items: center; padding: 10px; flex: none; }
.file .nm { font-weight: 600; word-break: break-all; display: block; } .file small { color: inherit; opacity: .7; }
.file .dl { margin-left: auto; width: 20px; height: 20px; opacity: .8; flex: none; }
.progress { height: 3px; background: rgba(255,255,255,.25); border-radius: 3px; overflow: hidden; margin-top: 4px; } .progress i { display: block; height: 100%; width: 40%; background: #fff; animation: slide 1s infinite ease-in-out; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
.failed { color: var(--danger); font-size: 12px; }

.replybar { margin: 0 14px; padding: 8px 12px; border-radius: 14px 14px 0 0; background: var(--panel); border: 1px solid var(--line); border-bottom: 0; border-left: 3px solid var(--accent2); display: flex; gap: 10px; align-items: center; }
.replybar > div { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 13px; } .replybar span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chips { display: flex; gap: 8px; padding: 10px 14px 0; overflow-x: auto; }
.chip { display: flex; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 6px 8px 6px 6px; flex: none; max-width: 240px; font-size: 13px; }
.chip img, .chip .ico { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; background: var(--panel2); display: grid; place-items: center; padding: 8px; } .chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.err { border-color: var(--danger); }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 12px 14px calc(14px + env(safe-area-inset-bottom)); }
.composer textarea { flex: 1; resize: none; max-height: 160px; background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 11px 16px; outline: none; line-height: 1.4; }
.composer textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.composer .icon-btn { width: 44px; height: 44px; }
.send { width: 44px; height: 44px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; padding: 11px; box-shadow: 0 6px 18px rgba(92,110,255,.4); transition: transform .12s, opacity .2s; }
.send:active { transform: scale(.92); } .send:disabled { opacity: .35; box-shadow: none; pointer-events: none; }
.dropzone { position: absolute; inset: 64px 0 0 0; z-index: 5; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(8px); border: 2px dashed var(--accent); border-radius: 20px; margin: 12px; text-align: center; }
.dropzone div { display: flex; flex-direction: column; gap: 6px; align-items: center; } .dropzone [data-icon] { width: 40px; height: 40px; color: var(--accent); }

/* ---------- dialogs ---------- */
dialog { background: color-mix(in srgb, var(--panel) 94%, transparent); backdrop-filter: blur(24px); color: var(--text); border: 1px solid var(--line); border-radius: 24px; padding: 22px; width: min(440px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: var(--shadow); overflow: auto; }
dialog[open] { display: flex; flex-direction: column; gap: 14px; animation: rise .3s cubic-bezier(.2,.8,.2,1); }
dialog::backdrop { background: rgba(5,6,12,.62); backdrop-filter: blur(4px); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; } .dlg-head h3 { font-size: 19px; letter-spacing: -.01em; }
.stack { display: flex; flex-direction: column; gap: 8px; } .stack .btn { justify-content: flex-start; }
.actions { display: flex; gap: 8px; justify-content: flex-end; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 14px; } .row-between > div { display: flex; flex-direction: column; min-width: 0; } .row-between small { font-size: 12.5px; }
.section { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.inline { display: flex; gap: 8px; } .inline select { flex: none; } .inline .btn { flex: none; padding: 10px 14px; }
.info-top { display: flex; flex-direction: column; align-items: center; gap: 6px; } .info-top h2 { font-size: 22px; }
.safety { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 10px; background: var(--panel2); padding: 16px; border-radius: 16px; font-family: ui-monospace, Menlo, monospace; font-size: 16px; text-align: center; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.result { display: flex; gap: 12px; align-items: center; background: var(--panel2); border-radius: 16px; padding: 12px; } .result .mid { flex: 1; min-width: 0; } .result b { display: block; }
#dlg-light { background: transparent; border: 0; box-shadow: none; padding: 0; width: auto; max-width: 96vw; align-items: center; backdrop-filter: none; }
#dlg-light img { max-width: 94vw; max-height: 88vh; border-radius: 14px; box-shadow: var(--shadow); } .lx { position: fixed; top: 14px; right: 14px; background: rgba(0,0,0,.5); color: #fff; }
.linkbtn { color: var(--accent2); text-decoration: underline dotted; font-weight: 700; letter-spacing: .1em; }

/* ---------- calls ---------- */
.call { position: fixed; inset: 0; z-index: 40; background: #05060c; color: #fff; display: flex; flex-direction: column; align-items: center; animation: rise .3s; }
#call-remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #05060c; }
#call-local { position: absolute; right: 18px; top: 18px; width: min(26vw, 200px); aspect-ratio: 3/4; object-fit: cover; border-radius: 16px; border: 2px solid rgba(255,255,255,.25); box-shadow: var(--shadow); transform: scaleX(-1); z-index: 3; background: #111; }
.call-scrim { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(5,6,12,.65), transparent 35%, transparent 60%, rgba(5,6,12,.8)); z-index: 1; }
.call.audio .call-scrim { background: radial-gradient(circle at 50% 30%, #2a2270 0%, #0a0b12 70%); }
.call-top { position: relative; z-index: 2; margin-top: 9vh; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.call.live.video .call-top { margin-top: 20px; align-self: flex-start; flex-direction: row; text-align: left; gap: 12px; margin-left: 20px; flex-wrap: wrap; }
.call.live.video .call-top .avatar { width: 44px; height: 44px; font-size: 16px; } .call.live.video .call-top h2 { font-size: 18px; }
.call.live.video .call-top > p { width: 100%; margin: 0; }
.call-top h2 { font-size: 28px; letter-spacing: -.02em; } #call-status { opacity: .8; }
.call-e2ee { display: flex; gap: 6px; align-items: center; font-size: 12.5px; opacity: .85; margin-top: 4px; } .call-e2ee [data-icon] { width: 14px; height: 14px; }
.call.ringing .avatar, .call.calling .avatar { animation: pulse 1.8s infinite; } @keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(124,108,255,.6); } 100% { box-shadow: 0 0 0 36px rgba(124,108,255,0); } }
.call-bar { position: absolute; bottom: calc(6vh + env(safe-area-inset-bottom)); z-index: 4; display: flex; gap: 18px; padding: 14px 20px; background: rgba(20,23,38,.6); backdrop-filter: blur(18px); border-radius: 40px; border: 1px solid rgba(255,255,255,.1); }
.cbtn { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.14); color: #fff; padding: 16px; transition: transform .12s, background .2s; }
.cbtn:hover { background: rgba(255,255,255,.24); } .cbtn:active { transform: scale(.92); } .cbtn.on { background: #fff; color: #111; }
.cbtn.end { background: var(--danger); } .cbtn.ok { background: var(--ok); }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 11px 18px; border-radius: 16px; font-size: 14px; animation: pop .25s; }
.toast.err { border-color: var(--danger); }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; }
  #chat { position: fixed; inset: 0; z-index: 3; background: var(--bg); transform: translateX(100%); transition: transform .28s cubic-bezier(.2,.8,.2,1); }
  #app.chat-open #chat { transform: none; }
  .back { display: grid; } .msg { max-width: 88%; }
  .empty { display: none; }
  #call-local { width: 28vw; }
}
::-webkit-scrollbar { width: 10px; height: 10px; } ::-webkit-scrollbar-thumb { background: var(--panel2); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

/* ---------- groups ---------- */
.pick { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow: auto; }
.pickrow { display: flex; gap: 12px; align-items: center; padding: 8px 10px; border-radius: 14px; cursor: pointer; background: var(--panel2); font-weight: 600; }
.pickrow:hover { filter: brightness(1.1); } .pickrow input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.members { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow: auto; }
.members .result { padding: 8px 12px; } .members small { color: var(--muted); }
.sender { font-size: 12.5px; font-weight: 700; margin-bottom: 2px; }
.muted { color: var(--muted); font-size: 13px; }
#dlg-ginfo .info-top { display: flex; flex-direction: column; align-items: center; gap: 8px; }
#grp-form .stack, #gi-body .stack { align-items: stretch; }
.btn > svg { width: 18px; height: 18px; flex: none; }

/* ---------- shared calendar ---------- */
.cal-nav { display: flex; align-items: center; justify-content: space-between; }
.cal-nav b { font-size: 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-grid .dow { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cd { position: relative; aspect-ratio: 1; border-radius: 12px; display: grid; place-items: center; font-weight: 600; background: var(--panel2); border: 1px solid transparent; }
.cd.dim { opacity: .38; } .cd:hover { filter: brightness(1.12); }
.cd.today { border-color: var(--accent); }
.cd.sel { background: var(--grad); color: #fff; opacity: 1; }
.cd i { position: absolute; bottom: 5px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.cd.sel i { background: #fff; }
.evt .notes { white-space: pre-wrap; margin: 2px 0; } .evt small { display: block; color: var(--muted); }
.btn.sm { padding: 6px 12px; border-radius: 10px; font-size: 13px; }
#cal-body .inline .grow { flex: 1; } #cal-body .inline input { width: 100%; }
#cal-body textarea { resize: vertical; }

/* ---------- media, location, polls ---------- */
.vid-att { border-radius: 16px; overflow: hidden; background: #000; min-width: 220px; max-width: 320px; }
.vid-att video { display: block; width: 100%; max-height: 360px; background: #000; }
.vid-play { width: 100%; aspect-ratio: 16/10; display: grid; place-items: center; gap: 6px; align-content: center; color: #fff; background: linear-gradient(135deg, #1b1e3a, #0a0b12); }
.vid-play .pbtn { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.18); backdrop-filter: blur(6px); }
.vid-play .pbtn svg { width: 24px; height: 24px; } .vid-play .cap { font-size: 12px; opacity: .8; padding: 0 12px; text-align: center; overflow-wrap: anywhere; }
.loc { display: flex; gap: 12px; align-items: center; padding: 8px 4px; color: inherit; text-decoration: none; min-width: 220px; }
.loc .pinbox { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: color-mix(in srgb, currentColor 14%, transparent); flex: none; }
.loc .pinbox svg { width: 22px; height: 22px; } .loc .mid { display: flex; flex-direction: column; } .loc small { opacity: .75; font-size: 12px; }
.poll { display: flex; flex-direction: column; gap: 6px; min-width: 240px; padding: 2px 0; }
.poll .pq { font-size: 15px; } .poll small { opacity: .75; }
.poll .opt { position: relative; display: flex; gap: 10px; align-items: center; justify-content: space-between; text-align: left; padding: 9px 12px; border-radius: 12px; overflow: hidden; background: color-mix(in srgb, currentColor 10%, transparent); border: 1px solid transparent; color: inherit; font-weight: 600; }
.poll .opt.on { border-color: currentColor; } .poll .opt:disabled { opacity: .9; cursor: default; }
.poll .bar { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, currentColor 18%, transparent); transition: width .3s; }
.poll .ot, .poll .ct { position: relative; } .poll .ct { opacity: .8; font-variant-numeric: tabular-nums; }
.poll .pfoot { display: flex; justify-content: space-between; align-items: center; }
.linkbtn { background: none; border: 0; color: inherit; text-decoration: underline; font-size: 12px; padding: 0; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 600; } .check input { width: 18px; height: 18px; accent-color: var(--accent); }
.acts .icon-btn.on, .icon-btn.on { color: var(--warn); }
#btn-rooms.live { color: #3ddc97; position: relative; } #btn-rooms.live::after { content: ''; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: #3ddc97; box-shadow: 0 0 0 3px color-mix(in srgb, #3ddc97 30%, transparent); }
.room-row .rico { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--panel); flex: none; } .room-row .rico svg { width: 18px; height: 18px; }
.room-row small { color: var(--muted); display: block; }
.lib { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow: auto; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.mcell { position: relative; border-radius: 12px; overflow: hidden; background: var(--panel2); min-height: 90px; }
.mcell img { width: 100%; height: 120px; object-fit: cover; display: block; } .mcell .vid-att { min-width: 0; max-width: none; }
.mcell .icon-btn { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.45); color: #fff; }
.frow { display: flex; gap: 6px; align-items: center; } .frow .file { flex: 1; }
.seg button { cursor: pointer; }
/* group room overlay */
.room { position: fixed; inset: 0; z-index: 41; background: #05060c; color: #fff; display: flex; flex-direction: column; animation: rise .3s; }
.room-top { padding: 18px 20px 6px; display: flex; flex-direction: column; gap: 2px; } .room-top b { font-size: 20px; letter-spacing: -.01em; }
.room-top small { opacity: .8; display: flex; gap: 6px; align-items: center; } .room-top [data-icon] { width: 13px; height: 13px; }
.room-grid { flex: 1; min-height: 0; display: grid; gap: 10px; padding: 10px 14px; grid-template-columns: 1fr; align-content: center; }
.room-grid[data-n="2"] { grid-template-columns: repeat(2, 1fr); } .room-grid[data-n="3"], .room-grid[data-n="4"] { grid-template-columns: repeat(2, 1fr); }
.room-grid[data-n="5"], .room-grid[data-n="6"] { grid-template-columns: repeat(3, 1fr); }
.tile { position: relative; aspect-ratio: 16/10; border-radius: 20px; overflow: hidden; background: linear-gradient(135deg, #1b1e3a, #0d0e1c); display: grid; place-items: center; min-height: 0; }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; } .tile.novideo video { opacity: 0; }
.tile .avatar { z-index: 0; } .tile .tname { position: absolute; left: 12px; bottom: 10px; z-index: 2; font-size: 13px; font-weight: 600; background: rgba(0,0,0,.5); padding: 3px 10px; border-radius: 10px; }
.room .call-bar { position: static; align-self: center; margin-bottom: calc(24px + env(safe-area-inset-bottom)); }
@media (max-width: 640px) { .room-grid[data-n="3"], .room-grid[data-n="4"], .room-grid[data-n="5"], .room-grid[data-n="6"] { grid-template-columns: repeat(2, 1fr); } .tile .avatar.xl { width: 56px; height: 56px; font-size: 22px; } }
