:root { --bg:#1f2a44; --card:#2b3a5e; --card2:#22304f; --fg:#f5f7fb; --muted:#aab4cc; --green:#2ecc71; --red:#e74c3c; --blue:#3d85c6; --accent:#f2cc8f; }
* { box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html,body { margin:0; height:100%; background:var(--bg); color:var(--fg); font-family:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif; }
.hidden { display:none !important; }
.muted { color:var(--muted); } .small { font-size:13px; } .center { text-align:center; padding:24px; }
.err { color:#ff8a80; min-height:1.2em; }
.screen { min-height:100%; }
#main { padding-bottom:84px; }
input { width:100%; font-size:18px; padding:13px; border-radius:12px; border:2px solid #44557e; background:#16203a; color:var(--fg); margin:8px 0; }
#join-code { text-align:center; letter-spacing:4px; font-size:28px; text-transform:uppercase; }
input[type=checkbox] { width:26px; height:26px; margin:0; accent-color:var(--green); flex:none; }
.btn { display:inline-block; border:0; border-radius:14px; padding:13px 18px; font-size:17px; font-weight:600; color:#fff; background:#44557e; margin-top:8px; cursor:pointer; text-align:center; }
.btn.primary { background:var(--green); } .btn.danger { background:var(--red); } .btn.blue { background:var(--blue); }
.btn.big { width:100%; font-size:21px; padding:17px; } .btn.wide { display:block; width:calc(100% - 32px); margin:0 16px 16px; }
.btn.small { font-size:14px; padding:8px 12px; margin:0; }
.join-card { max-width:420px; margin:0 auto; padding:48px 24px; text-align:center; }
.logo { width:96px; height:96px; } h1 { margin:8px 0; }
.top { display:flex; align-items:center; justify-content:space-between; padding:14px 18px; padding-top:calc(14px + env(safe-area-inset-top)); }
.family-name { font-size:24px; font-weight:700; }
.icon-btn { background:none; border:0; font-size:26px; color:var(--fg); cursor:pointer; padding:6px; }
.conn { width:12px; height:12px; border-radius:50%; background:#777; } .conn.on { background:var(--green); } .conn.off { background:var(--red); }
.grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:14px; padding:0 16px 16px; }
.tile { background:var(--card); border-radius:20px; padding:16px 10px 12px; text-align:center; position:relative; }
.tile.offline { opacity:.55; }
.avatar { width:84px; height:84px; border-radius:50%; margin:0 auto 8px; display:flex; align-items:center; justify-content:center; font-size:34px; font-weight:700; color:#fff; position:relative; background-size:cover; background-position:center; flex:none; }
.avatar.sm { width:48px; height:48px; font-size:20px; margin:0; }
.avatar.xs { width:28px; height:28px; font-size:12px; margin:0; }
.avatar.huge { width:120px; height:120px; font-size:50px; }
.dot { position:absolute; right:3px; bottom:3px; width:18px; height:18px; border-radius:50%; border:3px solid var(--card); background:#777; } .dot.on { background:var(--green); }
.tile .name { font-size:19px; font-weight:600; margin-bottom:10px; }
.tile .tag { font-size:12px; color:var(--accent); margin:-6px 0 8px; }
.tile .acts { display:flex; gap:6px; justify-content:center; }
.tile .acts button { flex:1; border:0; border-radius:12px; padding:11px 0; font-size:21px; background:var(--green); color:#fff; cursor:pointer; }
.tile .acts button.video { background:var(--blue); } .tile .acts button.msg { background:#5b6b91; }
.tile .acts button:disabled { background:#555; }
.list { padding:0 8px; }
.item { display:flex; align-items:center; gap:12px; padding:12px 10px; border-radius:14px; cursor:pointer; }
.item:active { background:var(--card); }
.item .mid { flex:1; min-width:0; }
.item .t { font-size:17px; font-weight:600; } .item .s { color:var(--muted); font-size:14px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.item .r { text-align:right; color:var(--muted); font-size:12px; }
.item .missed { color:#ff8a80; }
.badge { background:var(--red); color:#fff; border-radius:10px; font-size:12px; padding:1px 6px; min-width:20px; display:inline-block; text-align:center; font-style:normal; }
.tabs { position:fixed; left:0; right:0; bottom:0; display:flex; background:#16203a; border-top:1px solid #2b3a5e; padding-bottom:env(safe-area-inset-bottom); z-index:5; }
.tabs button { flex:1; background:none; border:0; color:var(--muted); font-size:22px; padding:8px 0 10px; position:relative; cursor:pointer; }
.tabs button span { display:block; font-size:12px; margin-top:2px; } .tabs button.on { color:var(--fg); }
.tabs .badge { position:absolute; top:4px; left:calc(50% + 8px); }
.panel { background:var(--card); margin:0 16px 16px; padding:16px; border-radius:16px; }
.panel h2 { margin:0 0 8px; font-size:18px; }
.me-row { display:flex; align-items:center; gap:14px; }
.row { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:10px 0; font-size:16px; }
.invite-box { margin-top:12px; padding:14px; background:#16203a; border-radius:12px; text-align:center; }
.invite-box .code { font-size:34px; letter-spacing:4px; font-weight:800; color:var(--accent); margin:6px 0; user-select:all; }
.amember { border-top:1px solid #44557e; padding:10px 0; }
.amember .head { display:flex; align-items:center; gap:10px; font-size:17px; font-weight:600; }
.amember .devs { font-size:13px; color:var(--muted); margin-top:4px; }
.amember .devs div { display:flex; justify-content:space-between; align-items:center; padding:3px 0; gap:8px; }
.amember .btns { margin-top:6px; display:flex; flex-wrap:wrap; gap:6px; }
/* chat */
.chat { position:fixed; inset:0; background:var(--bg); z-index:8; display:flex; flex-direction:column; }
.chat-top { background:#16203a; gap:8px; }
.chat-title { flex:1; display:flex; align-items:center; gap:10px; font-size:19px; font-weight:700; }
.msgs { flex:1; overflow-y:auto; padding:12px; display:flex; flex-direction:column; gap:4px; }
.msg { max-width:78%; padding:8px 12px; border-radius:16px; background:var(--card); align-self:flex-start; word-wrap:break-word; white-space:pre-wrap; }
.msg.mine { background:#2f7d55; align-self:flex-end; }
.msg .who { font-size:12px; font-weight:700; margin-bottom:2px; }
.msg .time { font-size:11px; color:#ffffffaa; text-align:right; margin-top:2px; }
.msg img { max-width:240px; max-height:300px; border-radius:10px; display:block; cursor:zoom-in; }
.msg audio { width:220px; height:36px; }
.msg.deleted { font-style:italic; color:var(--muted); }
.msg.pending { opacity:.6; }
.day { align-self:center; font-size:12px; color:var(--muted); margin:10px 0 4px; }
.typing { min-height:18px; padding:0 16px; }
.composer { display:flex; align-items:center; gap:6px; padding:8px; padding-bottom:calc(8px + env(safe-area-inset-bottom)); background:#16203a; }
.composer input { margin:0; border-radius:22px; }
.send { width:46px; height:46px; border-radius:50%; border:0; background:var(--green); color:#fff; font-size:20px; flex:none; cursor:pointer; }
#rec-btn.rec { color:var(--red); animation:pulse 1s infinite; }
.lightbox { position:fixed; inset:0; background:#000e; z-index:30; display:flex; align-items:center; justify-content:center; }
.lightbox img { max-width:100%; max-height:100%; }
/* picker */
.sheet { position:fixed; inset:0; background:#0009; z-index:9; display:flex; align-items:flex-end; justify-content:center; }
.sheet-card { background:var(--card); width:100%; max-width:520px; border-radius:20px 20px 0 0; padding:18px; padding-bottom:calc(18px + env(safe-area-inset-bottom)); max-height:80vh; overflow:auto; }
.sheet-card h2 { margin:0 0 8px; }
.pick { display:flex; align-items:center; gap:12px; padding:8px 0; font-size:18px; }
.pick .grow { flex:1; }
.sheet-btns { display:flex; gap:8px; } .sheet-btns .btn { flex:1; }
/* call */
.call { position:fixed; inset:0; background:#0e1424; z-index:10; display:flex; flex-direction:column; justify-content:space-between; }
.tiles { position:absolute; inset:0; display:grid; gap:4px; grid-template-columns:1fr; }
.tiles.n2 { grid-template-columns:1fr; grid-template-rows:1fr 1fr; }
.tiles.n3, .tiles.n4 { grid-template-columns:1fr 1fr; }
.tiles.n5, .tiles.n6 { grid-template-columns:1fr 1fr; grid-template-rows:repeat(3,1fr); }
@media (orientation:landscape) { .tiles.n2 { grid-template-columns:1fr 1fr; grid-template-rows:1fr; } .tiles.n5, .tiles.n6 { grid-template-columns:repeat(3,1fr); grid-template-rows:1fr 1fr; } }
.ptile { position:relative; background:#16203a; display:flex; align-items:center; justify-content:center; overflow:hidden; }
.ptile video { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; }
.ptile .label { position:absolute; left:10px; bottom:10px; background:#0008; padding:3px 9px; border-radius:8px; font-size:14px; }
.ptile.novideo video { display:none; }
.ptile.waiting { opacity:.6; }
#local-video { position:absolute; right:12px; top:calc(12px + env(safe-area-inset-top)); width:96px; height:132px; object-fit:cover; border-radius:12px; border:2px solid #fff3; z-index:3; transform:scaleX(-1); background:#000; }
.call-info { position:relative; z-index:2; text-align:center; padding-top:calc(16px + env(safe-area-inset-top)); pointer-events:none; }
.call-name { font-size:26px; font-weight:700; text-shadow:0 2px 6px #000a; }
.call-status { font-size:16px; color:#dde; margin-top:4px; text-shadow:0 2px 6px #000a; }
.call-controls { position:relative; z-index:2; display:flex; justify-content:center; gap:14px; padding:20px 12px calc(30px + env(safe-area-inset-bottom)); flex-wrap:wrap; }
.round { width:60px; height:60px; border-radius:50%; border:0; font-size:24px; background:#0008; color:#fff; cursor:pointer; backdrop-filter:blur(6px); }
.round.off { background:#fff; filter:grayscale(1); }
.round.red { background:var(--red); } .round.green { background:var(--green); }
.round.big { width:84px; height:84px; font-size:34px; margin:0 28px; }
#btn-hangup, #btn-decline { transform:rotate(135deg); }
.ringing #btn-answer { animation:pulse 1s infinite; }
@keyframes pulse { 50% { transform:scale(1.1); } }
.toast { position:fixed; left:50%; bottom:100px; transform:translateX(-50%); background:#000d; padding:12px 18px; border-radius:12px; z-index:40; font-size:16px; }

/* v3: replies, reactions, location, SOS */
.msg { cursor:pointer; }
.msg .quote { border-left:3px solid var(--accent); background:#0003; border-radius:8px; padding:4px 8px; margin-bottom:4px; font-size:13px; }
.msg .quote div { color:var(--muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:240px; }
.msg .reacts { display:flex; gap:4px; flex-wrap:wrap; margin-top:4px; }
.msg .reacts span { background:#0004; border-radius:10px; padding:1px 7px; font-size:14px; } .msg .reacts span.on { outline:1px solid var(--accent); }
.msg a.map { color:var(--accent); font-weight:600; }
.msg.sos { background:#b3261e !important; } .msg.sos .sos-title { font-weight:800; font-size:17px; }
.msg-menu { align-self:center; background:var(--card2); border-radius:14px; padding:8px; display:flex; flex-direction:column; gap:6px; box-shadow:0 4px 18px #0007; }
.msg-menu .emojis { display:flex; gap:4px; } .msg-menu .emojis button { font-size:24px; background:none; border:0; border-radius:10px; padding:4px 6px; cursor:pointer; }
.msg-menu .emojis button.on { background:#fff2; }
.msg-menu .acts { display:flex; gap:6px; } .msg-menu .acts button { flex:1; border:0; border-radius:10px; padding:8px; background:#44557e; color:#fff; font-size:15px; cursor:pointer; }
.msg-menu .acts button.danger { background:var(--red); }
.reply-bar { display:flex; align-items:center; gap:8px; padding:6px 12px; background:#16203a; border-left:4px solid var(--accent); }
.reply-bar .grow { flex:1; min-width:0; } .reply-bar .grow div { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.btn.sos { background:var(--red); }
