[hidden]{display:none!important}
/* Layout: two-pane messenger shell — chat list left, conversation right; one pane at a time on phones */
:root{
  --bg:#F6F7FB; --panel:#FFFFFF; --line:#DDE1EA; --fg:#0E1424; --muted:#5B6475;
  --accent:#3D5AFE; --accent-ink:#FFFFFF; --accent-soft:#E6EAFF; --mark:#D4401F;
  --out:#3D5AFE; --out-ink:#FFFFFF; --in:#FFFFFF; --chat-bg:#F6F7FB; --dots:transparent;
  --hover:#EEF1F8; --sel:#E6EAFF; --ok:#12805C; --danger:#B8321C; --shadow:0 1px 2px rgba(14,20,36,.06);
  --display:"Unbounded","Manrope",system-ui,sans-serif;
  --body:"Manrope",system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){
  --bg:#0F1420; --panel:#161C2C; --line:#2A3247; --fg:#F2F4F8; --muted:#A3ACBD;
  --accent:#8196FF; --accent-ink:#0E1424; --accent-soft:#1E2742; --mark:#EF6A47;
  --out:#3D5AFE; --out-ink:#FFFFFF; --in:#1E2638; --chat-bg:#0F1420; --dots:transparent;
  --hover:#1B2235; --sel:#222B45; --ok:#4CC79A; --danger:#F08A76; --shadow:0 1px 2px rgba(0,0,0,.4);
  color-scheme:dark}}
:root[data-theme="dark"]{
  --bg:#0F1420; --panel:#161C2C; --line:#2A3247; --fg:#F2F4F8; --muted:#A3ACBD;
  --accent:#8196FF; --accent-ink:#0E1424; --accent-soft:#1E2742; --mark:#EF6A47;
  --out:#3D5AFE; --out-ink:#FFFFFF; --in:#1E2638; --chat-bg:#0F1420; --dots:transparent;
  --hover:#1B2235; --sel:#222B45; --ok:#4CC79A; --danger:#F08A76; --shadow:0 1px 2px rgba(0,0,0,.4);
  color-scheme:dark}
*{box-sizing:border-box}
html,body{height:100%;overscroll-behavior:none}
body{background:var(--bg);color:var(--fg);font:15px/1.42 var(--body);overflow:hidden}
button{font:inherit;color:inherit;background:none;border:0;cursor:pointer;padding:0}
input,textarea{font:inherit;color:var(--fg)}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
svg{display:block}
.ico{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}

/* Fixed to the visible area (--vv-* come from app.js): on phones the header stays put and the composer rides on top of the keyboard. */
#app{position:fixed;left:0;right:0;top:var(--vv-top,0px);height:var(--vv-h,100%);display:grid;grid-template-columns:minmax(300px,370px) minmax(0,1fr);padding-left:env(safe-area-inset-left,0px);padding-right:env(safe-area-inset-right,0px)}
@media (max-width:760px){#app{grid-template-columns:minmax(0,1fr)} #app.in-chat #side{display:none} #app:not(.in-chat) #main{display:none}}

/* ---------- sidebar ---------- */
#side{display:flex;flex-direction:column;min-height:0;background:var(--panel);border-right:1px solid var(--line)}
.side-head{display:flex;align-items:center;gap:10px;padding:calc(14px + env(safe-area-inset-top,0px)) 16px 10px}
.logo{font-family:var(--display);font-weight:600;font-size:18px;letter-spacing:-.01em;flex:1;display:flex;align-items:center;gap:8px}
.logo-mark{width:26px;height:26px;border-radius:8px 8px 8px 2px;background:var(--accent);display:grid;place-items:center;color:var(--accent-ink)}
.logo-mark svg{width:16px;height:16px}
.icon-btn{width:38px;height:38px;border-radius:50%;display:grid;place-items:center;color:var(--muted);flex:none}
.icon-btn:hover{background:var(--hover);color:var(--fg)}
.icon-btn:disabled{opacity:.4;cursor:default;background:none}
.me-btn{border-radius:50%}
.search-wrap{padding:0 16px 10px}
.field{width:100%;border:1px solid var(--line);background:var(--bg);border-radius:12px;padding:9px 12px;outline:none}
.field:focus{border-color:var(--accent)}
#list{flex:1;overflow-y:auto;min-height:0;padding-bottom:8px}
.item{display:grid;grid-template-columns:50px minmax(0,1fr) auto;gap:12px;padding:8px 16px;align-items:center;cursor:pointer;width:100%;text-align:left}
.item:hover{background:var(--hover)}
.item.active{background:var(--sel)}
.item .t{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.item .p{color:var(--muted);font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.item .p b{color:var(--fg);font-weight:500}
.item .p.typing{color:var(--accent)}
.item .meta{display:flex;flex-direction:column;align-items:flex-end;gap:5px;font-size:12px;color:var(--muted);font-variant-numeric:tabular-nums}
.badge{min-width:21px;height:21px;padding:0 6px;border-radius:11px;background:var(--accent);color:var(--accent-ink);font-size:12px;font-weight:600;display:grid;place-items:center}
.sec-label{padding:12px 16px 4px;font-size:12px;font-weight:600;text-transform:uppercase;letter-spacing:.06em;color:var(--muted)}
.list-empty{padding:28px 20px;color:var(--muted);font-size:14px;line-height:1.5}
.list-empty h3{color:var(--fg);font-size:15px;margin:0 0 6px}
.list-empty .btn{margin-top:14px}

/* ---------- avatars ---------- */
.av{position:relative;flex:none;border-radius:50%;display:grid;place-items:center;color:#fff;font-weight:600;overflow:visible}
.av .face{width:100%;height:100%;border-radius:50%;display:grid;place-items:center;overflow:hidden;background-size:cover;background-position:center}
.av img{width:100%;height:100%;object-fit:cover}
.av .dot{position:absolute;right:1px;bottom:1px;width:13px;height:13px;border-radius:50%;background:var(--ok);border:2.5px solid var(--panel)}

/* ---------- main / chat ---------- */
#main{display:flex;flex-direction:column;min-height:0;min-width:0;background:var(--chat-bg);background-image:radial-gradient(var(--dots) 1.2px,transparent 1.3px);background-size:22px 22px}
.chat-head{display:flex;align-items:center;gap:12px;padding:calc(8px + env(safe-area-inset-top,0px)) 16px 8px;min-height:calc(60px + env(safe-area-inset-top,0px));flex:none;background:var(--panel);border-bottom:1px solid var(--line)}
.chat-head .who{flex:1;min-width:0;text-align:left;display:flex;align-items:center;gap:12px;border-radius:10px;padding:2px 4px}
.chat-head .who:hover{background:var(--hover)}
.chat-head .name{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-head .status{font-size:13px;color:var(--muted)}
.chat-head .status.on{color:var(--accent)}
.back{display:none}
@media (max-width:760px){.back{display:grid}}
#msgs{flex:1;overflow-y:auto;min-height:0;padding:14px max(16px,4%) 10px;display:flex;flex-direction:column;gap:3px}
.day{align-self:center;margin:12px 0 8px;padding:4px 12px;border-radius:12px;background:var(--panel);color:var(--muted);font-size:12.5px;font-weight:500;box-shadow:var(--shadow)}
.msg{max-width:min(560px,80%);align-self:flex-start;background:var(--in);border-radius:16px 16px 16px 6px;padding:7px 11px 6px;box-shadow:var(--shadow);position:relative;min-width:0}
.msg.out{align-self:flex-end;background:var(--out);border-radius:16px 16px 6px 16px}
.msg.cont{border-top-left-radius:16px}
.msg.out.cont{border-top-right-radius:16px}
.msg.gap{margin-top:8px}
.msg .from{font-size:13px;font-weight:600;margin-bottom:2px}
.msg .txt{white-space:pre-wrap;overflow-wrap:anywhere}
.msg .txt a{color:var(--accent)}
.msg .txt.deleted{color:var(--muted);font-style:italic}
.msg .foot{float:right;margin:6px 0 -2px 10px;display:flex;align-items:center;gap:3px;font-size:11.5px;color:var(--muted);font-variant-numeric:tabular-nums;user-select:none}
.msg .foot svg{width:17px;height:12px}
.msg .foot .read{color:var(--accent)}
.msg .del{position:absolute;top:4px;left:-34px;width:28px;height:28px;border-radius:50%;display:none;place-items:center;color:var(--muted);background:var(--panel);box-shadow:var(--shadow)}
.msg .del svg{width:15px;height:15px}
.msg.out:hover .del,.msg.out:focus-within .del{display:grid}
.att-img{display:block;margin:-3px -7px 6px;border-radius:12px;overflow:hidden;cursor:zoom-in;background:var(--line);max-width:calc(100% + 14px)}
.att-img img{display:block;width:100%;height:auto;max-height:360px;object-fit:cover}
.att-video{display:block;margin:-3px -7px 6px;border-radius:12px;max-width:calc(100% + 14px);max-height:360px;background:#000}
.att-file{display:flex;align-items:center;gap:10px;margin:2px 0 6px;padding:8px 10px;border-radius:12px;background:var(--accent-soft);text-decoration:none;color:var(--fg);min-width:0}
.att-file .fi{width:38px;height:38px;border-radius:10px;background:var(--accent);color:var(--accent-ink);display:grid;place-items:center;flex:none;font-size:11px;font-weight:700;letter-spacing:.04em}
.att-file .fn{font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.att-file .fs{font-size:12.5px;color:var(--muted)}
.att-missing{margin:2px 0 6px;padding:14px;border-radius:12px;background:var(--accent-soft);color:var(--muted);font-size:13px}

.composer{flex:none;display:flex;gap:6px;align-items:flex-end;padding:8px 12px calc(8px + env(safe-area-inset-bottom,0px));background:var(--panel);border-top:1px solid var(--line)}
.composer textarea{flex:1;min-width:0;resize:none;border:1px solid var(--line);background:var(--bg);border-radius:20px;padding:9px 14px;max-height:160px;outline:none;line-height:1.4}
.composer textarea:focus{border-color:var(--accent)}
.send{width:40px;height:40px;border-radius:50%;background:var(--accent);color:var(--accent-ink);display:grid;place-items:center;flex:none}
.send:disabled{opacity:.35;cursor:default}
.send svg{width:20px;height:20px}
.upload-note{padding:6px 16px;font-size:13px;color:var(--muted);background:var(--panel);border-top:1px solid var(--line)}
.drop-hint{position:absolute;inset:0;display:grid;place-items:center;background:color-mix(in srgb,var(--accent) 14%,transparent);border:2px dashed var(--accent);border-radius:16px;font-weight:600;color:var(--accent);pointer-events:none}
.chat-wrap{position:relative;flex:1;display:flex;flex-direction:column;min-height:0}

.blank{flex:1;display:grid;place-items:center;padding:24px}
.blank-card{max-width:400px;text-align:center;background:var(--panel);border-radius:20px;padding:28px 26px;box-shadow:var(--shadow)}
.blank-card h2{font-family:var(--display);font-weight:600;font-size:20px;margin:0 0 10px;text-wrap:balance;letter-spacing:-.01em}
.blank-card p{margin:0 0 8px;color:var(--muted);font-size:14.5px;line-height:1.5}
.banner{padding:8px 16px;background:var(--accent-soft);color:var(--fg);font-size:13.5px;border-bottom:1px solid var(--line)}

/* ---------- buttons ---------- */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;height:40px;padding:0 18px;border-radius:20px;background:var(--accent);color:var(--accent-ink);font-weight:600}
.btn:disabled{opacity:.45;cursor:default}
.btn.ghost{background:var(--accent-soft);color:var(--fg)}
.btn.danger{background:none;color:var(--danger);padding:0 6px}

/* ---------- modal ---------- */
#modal{position:fixed;left:0;right:0;top:var(--vv-top,0px);height:var(--vv-h,100%);z-index:20;background:rgba(15,8,22,.45);display:grid;place-items:center;padding:16px}
.sheet{width:min(440px,100%);max-height:min(640px,100%);display:flex;flex-direction:column;background:var(--panel);border-radius:20px;box-shadow:0 20px 60px rgba(0,0,0,.3);overflow:hidden}
.sheet-head{display:flex;align-items:center;gap:8px;padding:14px 12px 10px 20px}
.sheet-head h2{flex:1;margin:0;font-family:var(--display);font-weight:600;font-size:17px;letter-spacing:-.01em}
.sheet-body{padding:4px 20px 16px;overflow-y:auto;display:flex;flex-direction:column;gap:12px;min-height:0}
.sheet-foot{padding:12px 20px 18px;display:flex;gap:10px;justify-content:flex-end;border-top:1px solid var(--line)}
.lbl{font-size:12px;font-weight:600;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);margin-bottom:5px;display:block}
.hint{font-size:13px;color:var(--muted);line-height:1.45}
.err{font-size:13px;color:var(--danger)}
.tabs{display:flex;gap:4px;background:var(--bg);padding:4px;border-radius:12px}
.tabs button{flex:1;height:34px;border-radius:9px;font-weight:500;color:var(--muted)}
.tabs button[aria-selected="true"]{background:var(--panel);color:var(--fg);box-shadow:var(--shadow)}
.people{display:flex;flex-direction:column;margin:0 -20px}
.person{display:flex;align-items:center;gap:12px;padding:8px 20px;text-align:left;width:100%}
.person:hover{background:var(--hover)}
.person .pn{font-weight:500}
.person .ph{font-size:13px;color:var(--muted)}
.person .grow{flex:1;min-width:0}
.check{width:22px;height:22px;border-radius:50%;border:2px solid var(--line);display:grid;place-items:center;flex:none}
.person[aria-checked="true"] .check{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}
.check svg{width:13px;height:13px}
.photo-row{display:flex;align-items:center;gap:14px}

#lightbox{position:fixed;inset:0;z-index:30;background:rgba(8,4,12,.88);display:grid;place-items:center;padding:20px;cursor:zoom-out}
#lightbox img{max-width:100%;max-height:100%;border-radius:8px}
#toast{position:fixed;left:50%;bottom:calc(84px + env(safe-area-inset-bottom,0px));transform:translateX(-50%);z-index:40;background:var(--fg);color:var(--bg);padding:10px 16px;border-radius:12px;font-size:14px;max-width:calc(100% - 32px);box-shadow:0 8px 24px rgba(0,0,0,.25)}
.loading{color:var(--muted);font-size:14px;padding:24px;text-align:center}
@media (prefers-reduced-motion:no-preference){.msg.new{animation:pop .18s ease-out}@keyframes pop{from{transform:translateY(6px);opacity:.4}}}

/* ---------- auth screen ---------- */
#auth{position:fixed;left:0;right:0;top:var(--vv-top,0px);height:var(--vv-h,100%);z-index:15;overflow-y:auto;background:var(--chat-bg);background-image:radial-gradient(var(--dots) 1.2px,transparent 1.3px);background-size:22px 22px;display:grid;place-items:center;padding:24px 16px}
.auth-card{width:min(400px,100%);background:var(--panel);border-radius:22px;padding:28px 24px 24px;box-shadow:0 10px 40px rgba(40,20,60,.12);display:flex;flex-direction:column;gap:14px}
.auth-card .logo{font-size:22px;justify-content:center;flex:none;margin-bottom:2px}
.auth-card .logo-mark{width:32px;height:32px}
.auth-card .logo-mark svg{width:19px;height:19px}
.auth-card .sub{text-align:center;color:var(--muted);font-size:14px;margin:-6px 0 4px}
.auth-card form{display:flex;flex-direction:column;gap:12px}
.auth-card .btn{width:100%;height:44px}
.load-more{align-self:center;margin:6px 0;font-size:13px;color:var(--muted)}
.btn.small{height:32px;padding:0 12px;font-size:13.5px}
.auth-card .link{align-self:center;color:var(--accent);font-size:14px;font-weight:500;padding:4px 8px}
.auth-card .btn:disabled{opacity:.6;cursor:default}
.push-banner{display:flex;align-items:flex-start;gap:6px;margin:0 12px 8px;padding:10px 6px 10px 12px;border-radius:14px;background:var(--accent-soft)}
.push-banner .pb-text{flex:1;display:flex;flex-direction:column;align-items:flex-start;gap:8px;font-size:13.5px;line-height:1.4}
.push-banner .icon-btn{flex:none;width:28px;height:28px}
.contacts-block{display:flex;flex-direction:column;gap:8px;padding-bottom:10px;border-bottom:1px solid var(--line)}
.contacts-block .cb-actions{display:flex}
.contacts-block .link{color:var(--accent);font-size:inherit;font-weight:500;padding:0;text-align:left}
/* Keyboard open: it already covers the home indicator, so drop the safe-area gap under the composer. */
.kb-open .composer{padding-bottom:8px}
/* iPhone zooms into any field with text under 16px and the page jumps; keep fields at 16px on touch screens. */
@media (pointer:coarse){.field,.composer textarea{font-size:16px}}
/* ---------- round video messages ---------- */
.msg.round{background:none;box-shadow:none;padding:0}
.msg.round .txt{display:flex;justify-content:flex-end}
.msg.round .foot{float:none;margin:4px 4px 0;padding:1px 7px;border-radius:9px;background:var(--panel);box-shadow:var(--shadow)}
.att-round{position:relative;display:block;width:min(240px,62vw);aspect-ratio:1;border-radius:50%;overflow:hidden;background:#000;padding:0;box-shadow:var(--shadow)}
.att-round video{display:block;width:100%;height:100%;object-fit:cover}
.att-round.playing{box-shadow:0 0 0 3px var(--accent)}
.round-dur{position:absolute;left:50%;bottom:10px;transform:translateX(-50%);padding:1px 8px;border-radius:9px;background:rgba(0,0,0,.5);color:#fff;font-size:12px;font-variant-numeric:tabular-nums}
.round-sound{position:absolute;right:16%;top:16%;width:24px;height:24px;border-radius:50%;background:rgba(0,0,0,.5);color:#fff;display:grid;place-items:center}
.round-sound svg{width:15px;height:15px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.att-round.playing .round-sound{display:none}
.rec-overlay{position:fixed;left:0;right:0;top:var(--vv-top,0px);height:var(--vv-h,100%);z-index:25;background:rgba(15,8,22,.88);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:20px;padding:24px 16px calc(24px + env(safe-area-inset-bottom,0px))}
.rec-circle{position:relative;width:min(300px,76vw);aspect-ratio:1}
.rec-preview{width:100%;height:100%;border-radius:50%;object-fit:cover;background:#000;transform:scaleX(-1)}
.rec-ring{position:absolute;inset:-9px;width:calc(100% + 18px);height:calc(100% + 18px);transform:rotate(-90deg);pointer-events:none}
.rec-ring circle{fill:none;stroke:var(--accent);stroke-width:2.6;stroke-linecap:round;stroke-dasharray:301.6;stroke-dashoffset:301.6;transition:stroke-dashoffset .2s linear}
.rec-time{display:flex;align-items:center;gap:8px;color:#fff;font-size:18px;font-variant-numeric:tabular-nums}
.rec-dot{width:10px;height:10px;border-radius:50%;background:#E5484D;animation:recblink 1s steps(2,start) infinite}
@keyframes recblink{to{visibility:hidden}}
.rec-actions{display:flex;gap:12px}
.rec-actions .btn{min-width:130px;height:44px}
.rec-actions .btn.ghost{background:rgba(255,255,255,.14);color:#fff}
/* ---------- calls ---------- */
.call{position:fixed;left:0;right:0;top:var(--vv-top,0px);height:var(--vv-h,100%);z-index:30;background:#1B1222;color:#fff;display:flex;flex-direction:column;align-items:center;overflow:hidden;padding:calc(48px + env(safe-area-inset-top,0px)) 16px calc(28px + env(safe-area-inset-bottom,0px))}
.call-remote{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;background:#000;opacity:0;pointer-events:none}
.call.has-video .call-remote{opacity:1}
.call-top{position:relative;display:flex;flex-direction:column;align-items:center;gap:8px;text-align:center}
.call-av{margin-bottom:12px}
.call.has-video .call-av{display:none}
.call-name{font-family:var(--display);font-weight:600;font-size:22px;text-shadow:0 1px 3px rgba(0,0,0,.5)}
.call-status{font-size:15px;opacity:.8;font-variant-numeric:tabular-nums;text-shadow:0 1px 3px rgba(0,0,0,.5)}
.call-local{position:absolute;right:16px;top:calc(16px + env(safe-area-inset-top,0px));width:min(110px,28vw);aspect-ratio:3/4;object-fit:cover;border-radius:14px;background:#000;transform:scaleX(-1);box-shadow:0 4px 16px rgba(0,0,0,.4)}
.call-btns{position:relative;margin-top:auto;display:flex;gap:22px;justify-content:center;flex-wrap:wrap}
.call-btn{display:flex;flex-direction:column;align-items:center;gap:6px;font-size:12.5px;color:#fff;width:72px}
.call-btn svg{width:60px;height:60px;padding:17px;border-radius:50%;background:rgba(255,255,255,.18);fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.call-btn.on svg{background:#fff;color:#1B1222}
.call-btn.green svg{background:#2EB05E}
.call-btn.red svg{background:#E5484D;transform:rotate(135deg)}
/* ---------- stories ---------- */
.stories{display:flex;gap:12px;overflow-x:auto;padding:2px 14px 10px;scrollbar-width:none;flex:none}
.stories::-webkit-scrollbar{display:none}
.story-bubble{display:flex;flex-direction:column;align-items:center;gap:4px;width:64px;flex:none}
.story-ring{position:relative;padding:2.5px;border-radius:50%;border:2.5px solid transparent}
.story-ring.unseen{border-color:var(--accent)}
.story-ring.seen{border-color:var(--line)}
.story-plus{position:absolute;right:-2px;bottom:-2px;width:22px;height:22px;border-radius:50%;background:var(--accent);color:var(--accent-ink);border:2px solid var(--panel);display:grid;place-items:center;font-size:16px;font-weight:600;line-height:1}
.story-name{font-size:12px;color:var(--muted);max-width:64px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.story-prev{width:100%;max-height:50vh;object-fit:contain;border-radius:14px;background:#000}
.story-view{position:fixed;left:0;right:0;top:var(--vv-top,0px);height:var(--vv-h,100%);z-index:26;background:#000;display:grid;place-items:center}
.sv-frame{position:relative;width:min(100%,calc(var(--vv-h,100vh) * 9 / 16));height:100%;overflow:hidden;color:#fff}
.sv-stage{position:absolute;inset:0;display:grid;place-items:center;user-select:none;-webkit-user-select:none;touch-action:manipulation}
.sv-stage img,.sv-stage video{width:100%;height:100%;object-fit:contain;pointer-events:none}
.sv-top{position:absolute;left:0;right:0;top:0;padding:calc(10px + env(safe-area-inset-top,0px)) 10px 24px;background:linear-gradient(rgba(0,0,0,.55),transparent);pointer-events:none}
.sv-bars{display:flex;gap:4px}
.sv-bars span{flex:1;height:2.5px;border-radius:2px;background:rgba(255,255,255,.35);overflow:hidden}
.sv-bars i{display:block;height:100%;width:0;background:#fff}
.sv-head{display:flex;align-items:center;gap:10px;margin-top:10px}
.sv-who{flex:1;display:flex;align-items:center;gap:10px;min-width:0}
.sv-name{font-weight:600;font-size:14.5px}
.sv-time{font-size:12.5px;opacity:.8}
.sv-close{color:#fff;pointer-events:auto}
.sv-close:hover{background:rgba(255,255,255,.15);color:#fff}
.sv-caption{position:absolute;left:0;right:0;bottom:calc(72px + env(safe-area-inset-bottom,0px));padding:10px 16px;text-align:center;font-size:15px;background:linear-gradient(transparent,rgba(0,0,0,.5));pointer-events:none}
.sv-foot{position:absolute;left:0;right:0;bottom:0;display:flex;gap:8px;align-items:center;padding:10px 12px calc(12px + env(safe-area-inset-bottom,0px))}
.sv-btn{height:38px;padding:0 16px;border-radius:19px;background:rgba(255,255,255,.16);color:#fff;font-weight:500}
.sv-reply{flex:1;min-width:0;height:42px;border-radius:21px;border:1px solid rgba(255,255,255,.4);background:rgba(0,0,0,.3);color:#fff;padding:0 16px;outline:none}
.sv-reply::placeholder{color:rgba(255,255,255,.7)}
.sv-send{width:42px;height:42px;border-radius:50%;background:var(--accent);color:var(--accent-ink);display:grid;place-items:center;flex:none}
.sv-send svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.sv-panel{position:absolute;left:0;right:0;bottom:0;max-height:60%;overflow-y:auto;background:var(--panel);color:var(--fg);border-radius:18px 18px 0 0;padding:6px 8px calc(12px + env(safe-area-inset-bottom,0px))}
.sv-panel-head{display:flex;align-items:center;justify-content:space-between;padding:6px 8px 6px 12px}
@media (pointer:coarse){.sv-reply{font-size:16px}}
/* ---------- message menu, forward, edit ---------- */
.msg .fwd{font-size:12.5px;font-weight:500;color:var(--accent);margin-bottom:3px}
.msg.round .fwd{padding:2px 8px;border-radius:9px;background:var(--panel);display:inline-block;margin-bottom:6px}
.msg{cursor:default}
.msg img,.msg video{-webkit-touch-callout:none}
.menu{display:flex;flex-direction:column;margin:-4px -8px 0}
.menu-item{text-align:left;padding:13px 12px;border-radius:12px;font-size:15.5px}
.menu-item:hover{background:var(--hover)}
.menu-item.danger{color:var(--danger)}
.edit-bar{display:flex;align-items:center;gap:10px;padding:6px 8px 6px 16px;background:var(--panel);border-top:1px solid var(--line);color:var(--accent)}
.edit-bar>svg{width:20px;height:20px;flex:none;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.eb-text{flex:1;min-width:0;font-size:13.5px;color:var(--fg)}
.eb-text b{color:var(--accent);font-weight:600}
.eb-text div{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--muted)}
/* swipe a message left to forward it */
#msgs{overflow-x:hidden}
.msg{touch-action:pan-y;transition:transform .2s ease-out}
.msg.swiping{transition:none}
.swipe-ico{position:absolute;right:-46px;top:50%;margin-top:-17px;width:34px;height:34px;border-radius:50%;background:var(--panel);color:var(--muted);box-shadow:var(--shadow);display:grid;place-items:center;opacity:0;transition:opacity .15s,color .15s,transform .15s;pointer-events:none}
.swipe-ico svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.swipe-ico.armed{color:var(--accent);transform:scale(1.12)}
/* ---------- reels ---------- */
.reels{position:fixed;left:0;right:0;top:var(--vv-top,0px);height:var(--vv-h,100%);z-index:18;background:#000;color:#fff}
.reels-scroll{height:100%;overflow-y:auto;scroll-snap-type:y mandatory;overscroll-behavior:contain;scrollbar-width:none}
.reels-scroll::-webkit-scrollbar{display:none}
.reel{position:relative;height:100%;scroll-snap-align:start;scroll-snap-stop:always;display:grid;place-items:center;overflow:hidden}
.reel-stage{position:absolute;inset:0;margin:0 auto;width:min(100%,calc(var(--vv-h,100vh) * 9 / 16));display:grid;place-items:center;cursor:pointer;-webkit-tap-highlight-color:transparent}
.reel-video{width:100%;height:100%;object-fit:cover;background:#000;-webkit-touch-callout:none}
@media (min-aspect-ratio:3/4){.reel-video{object-fit:contain}}
.reels-top{position:absolute;left:0;right:0;top:0;display:flex;align-items:center;gap:8px;padding:calc(8px + env(safe-area-inset-top,0px)) 10px 20px;background:linear-gradient(rgba(0,0,0,.5),transparent);pointer-events:none}
.reels-title{flex:1;font-family:var(--display);font-weight:600;font-size:18px}
.reels-tbtn{width:40px;height:40px;border-radius:50%;display:grid;place-items:center;color:#fff;pointer-events:auto}
.reels-tbtn svg,.reel-act svg,.reel-sound svg,.reel-burst svg{fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}
.reels-tbtn svg{width:24px;height:24px}
.reel-actions{position:absolute;right:max(8px,calc(50% - var(--vv-h,100vh) * 9 / 32 + 8px));bottom:calc(96px + env(safe-area-inset-bottom,0px));display:flex;flex-direction:column;gap:16px;align-items:center}
.reel-act{display:flex;flex-direction:column;align-items:center;gap:3px;color:#fff;font-size:12.5px;font-weight:600;text-shadow:0 1px 3px rgba(0,0,0,.6);min-width:52px}
.reel-act svg{width:30px;height:30px;filter:drop-shadow(0 1px 2px rgba(0,0,0,.5))}
.reel-act.liked{color:#FF3B5C}
.reel-act.liked svg{fill:currentColor}
.reel-info{position:absolute;left:max(0px,calc(50% - var(--vv-h,100vh) * 9 / 32));right:max(72px,calc(50% - var(--vv-h,100vh) * 9 / 32 + 72px));bottom:0;padding:40px 14px calc(18px + env(safe-area-inset-bottom,0px));background:linear-gradient(transparent,rgba(0,0,0,.55));display:flex;flex-direction:column;gap:6px;pointer-events:none}
.reel-author{display:flex;align-items:center;gap:8px;color:#fff;font-size:14.5px;pointer-events:auto;align-self:flex-start;text-shadow:0 1px 3px rgba(0,0,0,.6)}
.reel-when{opacity:.8;font-size:13px}
.reel-caption{font-size:14.5px;line-height:1.4;white-space:pre-wrap;overflow-wrap:anywhere;max-height:6.2em;overflow:hidden;text-shadow:0 1px 3px rgba(0,0,0,.6)}
.reel-views{font-size:12.5px;opacity:.75}
.reel-sound{position:absolute;top:calc(64px + env(safe-area-inset-top,0px));right:14px;width:32px;height:32px;border-radius:50%;background:rgba(0,0,0,.45);display:grid;place-items:center;pointer-events:none}
.reel-sound svg{width:18px;height:18px}
.reel-sound.flash{animation:reelflash .6s ease-out}
@keyframes reelflash{0%{transform:scale(1.5)}100%{transform:scale(1)}}
.reel-burst{position:absolute;left:50%;top:50%;width:110px;height:110px;margin:-55px 0 0 -55px;color:#fff;opacity:0;pointer-events:none}
.reel-burst svg{width:100%;height:100%;fill:#fff;stroke:none;filter:drop-shadow(0 4px 12px rgba(0,0,0,.4))}
.reel-burst.go{animation:reelburst .8s ease-out}
@keyframes reelburst{0%{opacity:0;transform:scale(.4)}15%{opacity:1;transform:scale(1.1)}30%{transform:scale(.95)}70%{opacity:1}100%{opacity:0;transform:scale(1)}}
.reels-empty{height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:24px;text-align:center}
.reels-empty h3{margin:0;font-size:18px}
.reels-empty p{margin:0 0 6px;opacity:.75}
.reel-comments{display:flex;flex-direction:column;gap:12px;max-height:50vh;overflow-y:auto}
.rc{display:flex;gap:10px;align-items:flex-start}
.rc-body{flex:1;min-width:0;font-size:14px}
.rc-when{color:var(--muted);font-size:12.5px}
.rc-text{white-space:pre-wrap;overflow-wrap:anywhere;margin-top:1px}
.rc .icon-btn{width:30px;height:30px}
.rc .icon-btn svg{width:16px;height:16px}
.sheet-foot .field{flex:1;min-width:0}
/* ---------- bottom tab bar: floating glass capsule ---------- */
:root{--side-w:350px;--glass:rgba(255,255,255,.72);--glass-line:rgba(30,23,38,.08);--glass-pill:rgba(30,23,38,.08)}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){--glass:rgba(34,28,42,.72);--glass-line:rgba(255,255,255,.1);--glass-pill:rgba(255,255,255,.12)}}
:root[data-theme="dark"]{--glass:rgba(34,28,42,.72);--glass-line:rgba(255,255,255,.1);--glass-pill:rgba(255,255,255,.12)}
@media (min-width:761px){#app{grid-template-columns:var(--side-w) minmax(0,1fr)}}
#reelsBtn,#meBtn{display:none}
.tabbar{position:fixed;z-index:19;left:calc(14px + env(safe-area-inset-left,0px));right:calc(14px + env(safe-area-inset-right,0px));bottom:calc(10px + env(safe-area-inset-bottom,0px));
  height:62px;padding:6px;display:flex;gap:4px;border-radius:31px;background:var(--glass);border:1px solid var(--glass-line);
  -webkit-backdrop-filter:blur(24px) saturate(1.8);backdrop-filter:blur(24px) saturate(1.8);box-shadow:0 10px 32px rgba(20,10,30,.18),0 1px 2px rgba(20,10,30,.08)}
@media (min-width:761px){.tabbar{right:auto;width:calc(var(--side-w) - 28px)}}
.tab{flex:1;height:100%;border-radius:25px;display:grid;place-items:center;color:var(--fg);transition:background .2s;-webkit-tap-highlight-color:transparent}
.tab[aria-current="page"]{background:var(--glass-pill)}
.tab:active{transform:scale(.94)}
.tab-ico{position:relative;display:grid;place-items:center}
.tab-ico svg{width:27px;height:27px;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}
.tab[aria-current="page"] .tab-ico svg{stroke-width:2.4}
.tab .av{box-shadow:0 0 0 1.5px var(--glass-line)}
.tab[aria-current="page"] .av{box-shadow:0 0 0 2px var(--fg)}
.tab-dot{position:absolute;right:-4px;bottom:-2px;width:10px;height:10px;border-radius:50%;background:#FF3040;border:2px solid var(--panel)}
.kb-open .tabbar{display:none}
@media (max-width:760px){.in-chat .tabbar{display:none}}
/* Room for the capsule under the last chat and over reel captions */
#list{padding-bottom:calc(92px + env(safe-area-inset-bottom,0px))}
.reel-info{padding-bottom:calc(92px + env(safe-area-inset-bottom,0px))}
.reel-actions{bottom:calc(170px + env(safe-area-inset-bottom,0px))}
.tab-pad{padding:4px 16px 8px}
.profile-tab{padding:18px 16px 24px;display:flex;flex-direction:column;gap:18px}
.pt-card{display:flex;flex-direction:column;align-items:center;gap:6px;text-align:center}
.pt-name{font-family:var(--display);font-weight:600;font-size:20px;margin-top:6px}
.pt-group{display:flex;flex-direction:column;background:var(--bg);border-radius:16px;overflow:hidden}
.pt-row{display:flex;align-items:center;justify-content:space-between;padding:14px 16px;text-align:left;font-size:15px;border-bottom:1px solid var(--line)}
.pt-row:last-child{border-bottom:0}
.pt-row:hover{background:var(--hover)}
.pt-row svg{width:18px;height:18px;fill:none;stroke:var(--muted);stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.pt-row.danger{color:var(--danger)}
/* ---------- METOCH brand ---------- */
.logo{font-weight:800;letter-spacing:-.02em}
.logo-mark{width:30px;height:30px;background:none;border-radius:0;display:block}
.auth-card .logo-mark{width:40px;height:40px}
.logo-mark .logo-svg{width:100%;height:100%;display:block}
.logo-svg .lb{fill:#3D5AFE}
.logo-svg .lm{fill:none;stroke:#fff;stroke-width:6;stroke-linecap:round;stroke-linejoin:round}
.logo-svg .ld{fill:var(--mark);stroke:var(--panel);stroke-width:4}
#main{background-image:none}
/* round avatars everywhere */
.av,.av .face{border-radius:50%}
.story-ring{border-radius:50%}
.badge{background:var(--mark);color:#fff}
.tab-dot{background:var(--mark)}
/* incoming: white with a hairline; own: brand blue with white text */
.msg{border:1px solid var(--line);box-shadow:none;border-radius:20px 20px 20px 6px;padding:8px 12px 6px}
.msg.out{color:var(--out-ink);border-color:transparent;border-radius:20px 20px 6px 20px}
.msg.out .foot,.msg.out .txt.deleted{color:rgba(255,255,255,.78)}
.msg.out .foot .read{color:#fff}
.msg.out .txt a{color:#fff;text-decoration:underline}
.msg.out .fwd{color:#DCE3FF}
.msg.out .att-file{background:rgba(255,255,255,.16);color:#fff}
.msg.out .att-file .fs{color:rgba(255,255,255,.78)}
.msg.out .att-file .fi{background:#fff;color:#3D5AFE}
.msg.round,.msg.round.out{border-color:transparent;color:var(--fg)}
.msg.round.out .foot{color:var(--muted)}
.msg.round.out .foot .read{color:var(--accent)}
.msg.round.out .fwd{color:var(--accent)}
.send{background:#3D5AFE;color:#fff}
.btn{border-radius:14px}
.btn.small{border-radius:12px}
.field{border-radius:14px}
:root{--glass:rgba(255,255,255,.74)}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){--glass:rgba(22,28,44,.74)}}
:root[data-theme="dark"]{--glass:rgba(22,28,44,.74)}
/* ---------- avatar photo editor ---------- */
.photo-btns{display:flex;flex-direction:column;align-items:flex-start;gap:6px}
.photo-sub{display:flex;gap:6px;flex-wrap:wrap}
.ae{position:fixed;left:0;right:0;top:var(--vv-top,0px);height:var(--vv-h,100%);z-index:22;background:#0B0F19;color:#fff;display:flex;flex-direction:column;padding:env(safe-area-inset-top,0px) 0 calc(14px + env(safe-area-inset-bottom,0px))}
.ae-head{display:flex;align-items:center;justify-content:space-between;padding:10px 8px;font-size:16px}
.ae-link{min-width:72px;height:44px;padding:0 12px;color:#fff;font-size:16px}
.ae-link.strong{color:#8FA2FF;font-weight:700}
.ae-stage{position:relative;flex:1;min-height:0;display:grid;place-items:center;margin:0 auto;width:min(100%,560px);overflow:hidden}
.ae-canvas{display:block;touch-action:none;cursor:grab;border-radius:6px}
.ae-canvas:active{cursor:grabbing}
.ae-frame{position:absolute;pointer-events:none;border-radius:50%;box-shadow:0 0 0 2px rgba(255,255,255,.9),0 0 0 9999px rgba(11,15,25,.62)}
.ae-holder{position:relative;overflow:hidden;border-radius:6px}
.ae-zoomrow{display:flex;align-items:center;gap:12px;width:min(100% - 48px,420px);margin:14px auto 4px;color:rgba(255,255,255,.7)}
.ae-zoomrow svg{width:22px;height:22px;flex:none;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.ae-zoom{flex:1;accent-color:#3D5AFE;height:44px}
.ae-tools{display:flex;justify-content:center;gap:28px;padding-top:6px}
.ae-tool{display:flex;flex-direction:column;align-items:center;gap:4px;color:#fff;font-size:12.5px;min-width:64px}
.ae-tool svg{width:44px;height:44px;padding:11px;border-radius:50%;background:rgba(255,255,255,.12);fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
/* touch screens: the hover-only delete button would stick after a tap; the message menu covers deleting */
@media (hover:none){.msg .del{display:none!important}}
/* swipe right in a chat to go back: the chat slides away, the list comes in from under it */
@media (max-width:760px){
  #app.swipe-back #side{display:flex;position:absolute;inset:0;z-index:1;transform:translateX(calc((var(--sb,0px) - 100vw) * .3))}
  #app.swipe-back #main{position:absolute;inset:0;z-index:2;transform:translateX(var(--sb,0px));box-shadow:-12px 0 32px rgba(14,20,36,.18)}
  #app.swipe-anim #side,#app.swipe-anim #main{transition:transform .22s ease-out}
}
