:root{
  --bg:#eef3f2;--card:#ffffff;--fg:#10201e;--mut:#69807c;--line:#e0e8e6;
  --pri:#0d9488;--pri2:#0f766e;--acc:#f59e0b;
  --out:#d7f6ef;--in:#ffffff;--shadow:0 1px 2px #0b1f1c14;
  --wall:linear-gradient(180deg,#eef3f2,#e6efed);
}
.dark{
  --bg:#0b1413;--card:#131f1e;--fg:#e9f1ef;--mut:#8ba29e;--line:#22322f;
  --pri:#2dd4bf;--pri2:#14b8a6;--acc:#fbbf24;
  --out:#0f4a44;--in:#182624;--shadow:0 1px 2px #00000040;
  --wall:linear-gradient(180deg,#0b1413,#0f1b1a);
}
*{box-sizing:border-box;margin:0;padding:0;-webkit-tap-highlight-color:transparent}
html,body{height:100%}
body{
  background:var(--bg);color:var(--fg);font-family:"Noto Sans Arabic","Segoe UI",Tahoma,sans-serif;
  max-width:520px;margin:0 auto;overflow-x:hidden;-webkit-font-smoothing:antialiased;
}
button,input,textarea{font-family:inherit;color:inherit}
img{max-width:100%}
.hidden{display:none!important}
.hdr{
  position:sticky;top:0;z-index:20;background:var(--card);border-bottom:1px solid var(--line);
  display:flex;align-items:center;gap:10px;padding:10px 12px;padding-top:calc(10px + env(safe-area-inset-top));
}
.hdr .brand{font-size:21px;font-weight:800;color:var(--pri);display:flex;align-items:center;gap:8px}
.hdr .brand .mark{width:30px;height:30px;border-radius:9px;background:linear-gradient(140deg,var(--pri),var(--pri2));display:flex;align-items:center;justify-content:center;color:#fff;font-size:14px;font-weight:800}
.hdr .grow{flex:1}
.iconbtn{width:38px;height:38px;border-radius:50%;border:0;background:var(--bg);display:flex;align-items:center;justify-content:center;cursor:pointer;flex:none}
.iconbtn:active{transform:scale(.95)}
.iconbtn svg{width:21px;height:21px}
.screen{display:none;padding-bottom:96px}
.screen.on{display:block}
#s-thread.on{display:flex;flex-direction:column;height:100dvh;padding-bottom:0}
#app.thread-open .bn{display:none}
/* list */
.searchbar{padding:10px 12px;background:var(--card)}
.searchbar input{
  width:100%;border:1px solid var(--line);background:var(--bg);border-radius:14px;
  padding:11px 14px;font-size:15px;outline:0
}
.rows{background:var(--card)}
.row{display:flex;align-items:center;gap:12px;padding:11px 14px;border-bottom:1px solid var(--line);cursor:pointer;background:var(--card)}
.row:active{background:var(--bg)}
.row .info{flex:1;min-width:0}
.row .info b{display:block;font-size:15px;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.row .info small.uname{direction:ltr;unicode-bidi:isolate;text-align:right}
.row .info small{display:block;color:var(--mut);font-size:12.5px;margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.row .side{text-align:left;flex:none;display:flex;flex-direction:column;align-items:flex-end;gap:4px}
.row .side .t{font-size:11px;color:var(--mut)}
.unread{background:var(--pri);color:#fff;border-radius:11px;font-size:11px;font-weight:700;padding:1px 7px;min-width:20px;text-align:center}
.av{width:46px;height:46px;border-radius:50%;flex:none;display:flex;align-items:center;justify-content:center;color:#fff;font-weight:700;font-size:17px;overflow:hidden;background:var(--pri)}
.av img{width:100%;height:100%;object-fit:cover;display:block}
.av.sm{width:34px;height:34px;font-size:14px}
.av.lg{width:92px;height:92px;font-size:34px}
.online-dot{position:relative}
.online-dot:after{content:"";position:absolute;bottom:1px;left:1px;width:11px;height:11px;border-radius:50%;background:#22c55e;border:2px solid var(--card)}
.empty{padding:40px 24px;text-align:center;color:var(--mut);font-size:14px;line-height:1.9}
.empty b{display:block;color:var(--fg);font-size:16px;margin-bottom:6px}
/* fab */
.fab{position:fixed;bottom:86px;left:50%;transform:translateX(calc(-50% + 190px));width:54px;height:54px;border-radius:50%;background:linear-gradient(140deg,var(--pri),var(--pri2));color:#fff;border:0;box-shadow:0 6px 18px #0d94883d;display:flex;align-items:center;justify-content:center;z-index:15}
/* nav */
.bn{position:fixed;bottom:0;left:50%;transform:translateX(-50%);width:100%;max-width:520px;background:var(--card);border-top:1px solid var(--line);display:flex;padding:6px 0 calc(6px + env(safe-area-inset-bottom));z-index:18}
.bn button{flex:1;background:none;border:0;display:flex;flex-direction:column;align-items:center;gap:3px;color:var(--mut);font-size:10.5px;padding:5px 0;position:relative}
.bn button.on{color:var(--pri);font-weight:700}
.bn svg{width:23px;height:23px}
.bn .dot{position:absolute;top:1px;right:calc(50% - 20px);background:#ef4444;color:#fff;font-size:10px;font-weight:700;border-radius:9px;padding:0 5px;line-height:15px}
/* thread */
.thdr{display:flex;align-items:center;gap:10px;padding:8px 10px;background:var(--card);border-bottom:1px solid var(--line);position:sticky;top:0;z-index:12;padding-top:calc(8px + env(safe-area-inset-top))}
.thdr .info{flex:1;min-width:0}
.thdr .info b{display:block;font-size:15.5px;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.thdr .info small{display:block;font-size:11.5px;color:var(--mut);margin-top:1px}
.thdr .info small.typing{color:var(--pri)}
#msgs{flex:1;overflow-y:auto;padding:12px 10px 14px;background:var(--wall);background-attachment:local}
.daysep{text-align:center;margin:10px 0}
.daysep span{background:#00000012;color:var(--mut);font-size:11.5px;border-radius:10px;padding:3px 12px}
.dark .daysep span{background:#ffffff14}
.m{display:flex;margin:3px 0}
.m .bub{max-width:78%;padding:7px 10px 6px;border-radius:14px;font-size:14.5px;line-height:1.6;position:relative;box-shadow:var(--shadow);word-break:break-word}
.m.out{justify-content:flex-end}
.m.in{justify-content:flex-start}
.m.out .bub{background:var(--out);border-bottom-left-radius:5px}
.m.in .bub{background:var(--in);border-bottom-right-radius:5px}
.m .bub .txt{white-space:pre-wrap}
.m .meta{display:flex;align-items:center;gap:4px;justify-content:flex-end;margin-top:3px;font-size:10.5px;color:var(--mut)}
.tk{display:inline-flex;align-items:center;line-height:0;color:var(--mut)}
.tk.read{color:#2f9fd6}
.dark .tk.read{color:#5cc8f5}
.m .bub img.photo{border-radius:10px;display:block;margin:-3px -6px 4px;max-height:280px;object-fit:cover;width:100%}
.vnote{display:flex;align-items:center;gap:8px;min-width:150px;padding:2px 0}
.vnote button{border:0;background:var(--pri);color:#fff;width:30px;height:30px;border-radius:50%;font-size:12px;display:flex;align-items:center;justify-content:center;flex:none}
.vnote .bar{flex:1;height:4px;border-radius:3px;background:#00000022;position:relative}
.vnote .bar i{position:absolute;top:0;right:0;height:100%;width:0;background:var(--pri);border-radius:3px}
.vnote .dur{font-size:11px;color:var(--mut)}
.poll{border-radius:12px;background:#00000008;padding:8px;margin-top:2px;min-width:210px}
.dark .poll{background:#ffffff10}
.poll b{font-size:14px;display:block;margin-bottom:6px}
.poll .opt{display:flex;align-items:center;gap:8px;padding:7px 9px;border-radius:9px;border:1px solid var(--line);margin-bottom:5px;font-size:13.5px;cursor:pointer;position:relative;overflow:hidden}
.poll .opt .fill{position:absolute;inset:0;background:var(--pri);opacity:.14;width:0}
.poll .opt span{position:relative;z-index:1}
.poll .opt .pct{margin-right:auto;font-size:11.5px;color:var(--mut);position:relative;z-index:1}
.poll .opt.mine{border-color:var(--pri);font-weight:700}
.poll small{color:var(--mut);font-size:11px}
.schedbar{display:flex;align-items:center;gap:6px;background:var(--card);border-bottom:1px solid var(--line);padding:7px 12px;font-size:12px;color:var(--mut);overflow-x:auto;white-space:nowrap}
.schedbar b{color:var(--pri)}
.schedbar .x{border:0;background:var(--bg);border-radius:8px;padding:2px 7px;font-size:11px}
/* composer */
.cmp{background:var(--card);border-top:1px solid var(--line);padding:8px 8px calc(8px + env(safe-area-inset-bottom));display:flex;align-items:flex-end;gap:6px;position:sticky;bottom:0;z-index:12}
.cmp textarea{
  flex:1;min-width:0;resize:none;border:1px solid var(--line);background:var(--bg);border-radius:20px;
  padding:10px 14px;font-size:15px;outline:0;max-height:110px;line-height:1.5
}
.cmp .round{width:40px;height:40px;border-radius:50%;border:0;background:var(--bg);display:flex;align-items:center;justify-content:center;flex:none;cursor:pointer}
.cmp .round svg{width:21px;height:21px}
.cmp .send{background:var(--pri);color:#fff}
.cmp .round.rec{background:#ef4444;color:#fff;animation:pulse 1.1s infinite}
@keyframes pulse{50%{opacity:.6}}
/* sheet */
.sheetwrap{position:fixed;inset:0;background:#0007;z-index:60;display:none;align-items:flex-end;justify-content:center}
.sheetwrap.on{display:flex}
.sheet{background:var(--card);width:100%;max-width:520px;border-radius:20px 20px 0 0;padding:16px 16px calc(16px + env(safe-area-inset-bottom));max-height:86vh;overflow-y:auto}
.sheet h3{font-size:17px;margin-bottom:12px}
.sheet .fld{margin-bottom:12px}
.sheet label{display:block;font-size:12.5px;color:var(--mut);margin-bottom:5px}
.sheet input[type=text],.sheet input[type=password],.sheet input[type=number],.sheet textarea,.sheet select{
  width:100%;border:1px solid var(--line);background:var(--bg);border-radius:12px;padding:11px 13px;font-size:15px;outline:0
}
.sheet textarea{min-height:80px;resize:vertical}
.btn{width:100%;border:0;border-radius:12px;padding:13px;background:var(--pri);color:#fff;font-size:15.5px;font-weight:700;cursor:pointer}
.btn.ghost{background:var(--bg);color:var(--fg)}
.btn.danger{background:#ef4444}
.btn:disabled{opacity:.55}
.swrow{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:11px 0;border-bottom:1px solid var(--line)}
.swrow:last-child{border-bottom:0}
.swrow .lbl{font-size:14px}
.swrow .lbl small{display:block;color:var(--mut);font-size:11.5px;margin-top:2px}
.sw{width:46px;height:27px;border-radius:14px;background:var(--line);position:relative;border:0;flex:none;transition:background .15s}
.sw:after{content:"";position:absolute;top:3px;right:3px;width:21px;height:21px;border-radius:50%;background:#fff;transition:transform .15s}
.sw.on{background:var(--pri)}
.sw.on:after{transform:translateX(-19px)}
.chips{display:flex;flex-wrap:wrap;gap:8px}
.chips button{border:1.5px solid var(--line);background:var(--card);border-radius:20px;padding:8px 14px;font-size:13px;cursor:pointer}
.chips button.on{border-color:var(--pri);color:var(--pri);font-weight:700;background:var(--bg)}
.colors{display:flex;gap:10px;flex-wrap:wrap}
.colors button{width:38px;height:38px;border-radius:50%;border:2px solid transparent;cursor:pointer}
.colors button.on{border-color:var(--fg)}
.walls{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
.walls button{height:58px;border-radius:12px;border:2px solid transparent;font-size:12px;color:#fff;font-weight:700;text-shadow:0 1px 3px #0006}
.walls button.on{border-color:var(--pri)}
/* profile */
.pf{background:var(--card);padding:22px 16px 18px;text-align:center}
.pf .av{margin:0 auto 12px}
.pf h2{font-size:20px}
.pf .un{color:var(--mut);font-size:13px;margin-top:3px;direction:ltr;unicode-bidi:isolate}
.pf .bio{margin-top:12px;font-size:14px;line-height:1.7;color:var(--fg);white-space:pre-wrap}
.pf .bio.empty{color:var(--mut)}
.pf .acts{display:flex;gap:8px;margin-top:16px}
.pf .acts .btn{flex:1;padding:11px;font-size:14px}
.card{background:var(--card);margin-top:10px;padding:14px 16px;border-radius:0}
.card h4{font-size:13px;color:var(--mut);margin-bottom:8px;font-weight:600}
.linkbox{display:flex;gap:8px;align-items:center}
.linkbox input{flex:1;min-width:0;border:1px solid var(--line);background:var(--bg);border-radius:10px;padding:10px;font-size:13px;direction:ltr}
/* auth */
#auth{min-height:100dvh;display:flex;flex-direction:column;justify-content:center;padding:24px 18px;background:linear-gradient(165deg,#0f766e,#0d9488 45%,#115e59)}
#auth .acard{background:var(--card);border-radius:22px;padding:22px 18px;box-shadow:0 18px 50px #0006;max-width:420px;width:100%;margin:0 auto}
#auth .logo{display:flex;align-items:center;gap:10px;font-size:26px;font-weight:800;color:var(--pri);margin-bottom:4px}
#auth .logo .mark{width:42px;height:42px;border-radius:12px;background:linear-gradient(140deg,var(--pri),var(--pri2));display:flex;align-items:center;justify-content:center;color:#fff;font-size:19px}
#auth .sub{color:var(--mut);font-size:13px;margin-bottom:16px;line-height:1.7}
#auth input{width:100%;border:1px solid var(--line);background:var(--bg);border-radius:12px;padding:12px 14px;font-size:16px;margin-bottom:10px;outline:0}
#auth .err{background:#fee2e2;color:#b91c1c;border-radius:10px;padding:9px 12px;font-size:13px;margin-bottom:10px;display:none}
#auth .err.on{display:block}
#auth .sw-lnk{text-align:center;font-size:13px;color:var(--mut);margin-top:14px}
#auth .sw-lnk button{background:none;border:0;color:var(--pri);font-weight:700;font-size:13px;cursor:pointer}
#auth .note{font-size:11px;color:var(--mut);text-align:center;margin-top:16px;line-height:1.8}
.toast{position:fixed;bottom:96px;left:50%;transform:translateX(-50%) translateY(20px);background:#10201e;color:#fff;padding:10px 18px;border-radius:14px;font-size:13.5px;z-index:90;opacity:0;transition:.2s;pointer-events:none;max-width:90%}
.toast.on{opacity:1;transform:translateX(-50%) translateY(0)}
.dark .toast{background:#e9f1ef;color:#0b1413}

.tomb{font-style:italic;color:var(--mut);font-size:13px}
.msgmenu .btn{margin-bottom:8px}
.blockbar{background:#fef2f2;color:#b91c1c;border-bottom:1px solid var(--line);padding:9px 12px;font-size:12.5px;display:flex;align-items:center;gap:8px}
.dark .blockbar{background:#3b1d1d;color:#fca5a5}
.blockbar button{border:0;background:#b91c1c;color:#fff;border-radius:9px;padding:5px 10px;font-size:12px;margin-right:auto}
