[hidden]{display:none!important}
/* Layout: two-pane messenger shell — chat list left, conversation right; one pane at a time on phones */
:root{
  --bg:#F3F1F6; --panel:#FFFFFF; --line:#E4DEEA; --fg:#1E1726; --muted:#6F657A;
  --accent:#6B2FA0; --accent-ink:#FFFFFF; --accent-soft:#EFE5F8;
  --out:#E7D8F5; --in:#FFFFFF; --chat-bg:#ECE7F1; --dots:#DDD4E6;
  --hover:#F5F1F9; --sel:#EDE3F7; --ok:#2C8A57; --danger:#B83A2E; --shadow:0 1px 2px rgba(40,20,60,.08);
  --display:"Unbounded","Golos Text",system-ui,sans-serif;
  --body:"Golos Text",system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){
  --bg:#141018; --panel:#1C1722; --line:#2F2838; --fg:#EEE8F4; --muted:#9D93A9;
  --accent:#BC8DE8; --accent-ink:#1A0F24; --accent-soft:#2C2238;
  --out:#3C2A52; --in:#251F2D; --chat-bg:#16121B; --dots:#221C29;
  --hover:#231D2A; --sel:#2E2539; --ok:#5CC48A; --danger:#E5776B; --shadow:0 1px 2px rgba(0,0,0,.4);
  color-scheme:dark}}
:root[data-theme="dark"]{
  --bg:#141018; --panel:#1C1722; --line:#2F2838; --fg:#EEE8F4; --muted:#9D93A9;
  --accent:#BC8DE8; --accent-ink:#1A0F24; --accent-soft:#2C2238;
  --out:#3C2A52; --in:#251F2D; --chat-bg:#16121B; --dots:#221C29;
  --hover:#231D2A; --sel:#2E2539; --ok:#5CC48A; --danger:#E5776B; --shadow:0 1px 2px rgba(0,0,0,.4);
  color-scheme:dark}
*{box-sizing:border-box}
html,body{height:100%}
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}

#app{height: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:14px 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:8px 16px;min-height:60px;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{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;inset:0;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;inset:0;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}
