:root{
  --bg:#f0f2f5;--panel:#ffffff;--panel2:#f7f8fa;--fg:#111418;--muted:#5b6270;--rim:rgba(11,27,58,.09);
  --hl:#0165EA;--hl-soft:rgba(1,101,234,.12);--wall:#efeae2;--out:#d9f2ff;--in:#ffffff;--tick:#30b5f5;
  --grad:linear-gradient(90deg,#0133DF,#0165EA 35%,#02A8FE 65%,#0FC9C4);
  --fill:linear-gradient(45deg,#0133DF,#0165EA 45%,#02A8FE 80%,#04D6EE);
}
@media (prefers-color-scheme:dark){:root{
  --bg:#0b1020;--panel:#111827;--panel2:#161f33;--fg:#e8ecf4;--muted:#a9b0be;--rim:rgba(255,255,255,.08);
  --hl:#2AA9FF;--hl-soft:rgba(42,169,255,.16);--wall:#0b141a;--out:#0d4a73;--in:#202c33;
}}
*{box-sizing:border-box;margin:0;padding:0}
html,body,#app{height:100%}
body{font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","Segoe UI",Roboto,Inter,sans-serif;background:var(--bg);color:var(--fg);-webkit-font-smoothing:antialiased;font-size:15px}
button{font:inherit;color:inherit;border:0;background:none;cursor:pointer}
input,textarea{font:inherit;color:inherit}
.gt{background:var(--grad);-webkit-background-clip:text;background-clip:text;color:transparent}
.brandicon{width:40px;height:40px}

/* ---------- pairing ---------- */
.pair{min-height:100%;display:flex;align-items:center;justify-content:center;padding:24px}
.pair .card{background:var(--panel);border:1px solid var(--rim);border-radius:28px;box-shadow:0 30px 80px -40px rgba(1,51,223,.45);display:grid;grid-template-columns:1fr auto;gap:48px;padding:48px;max-width:980px;width:100%}
.pair h1{font-size:30px;letter-spacing:-.8px;margin:18px 0 22px}
.pair ol{padding-left:22px;line-height:2;color:var(--muted);font-size:16px}
.pair ol b{color:var(--fg);font-weight:600}
.qr{width:280px;height:280px;border-radius:20px;background:#fff;padding:14px;display:grid;place-items:center;position:relative}
.qr img,.qr svg{width:100%;height:100%}
.code{margin-top:18px;text-align:center;font-size:30px;font-weight:700;letter-spacing:6px}
.code small{display:block;font-size:13px;letter-spacing:0;color:var(--muted);font-weight:500;margin-bottom:6px}
.hint{margin-top:14px;color:var(--muted);font-size:13px;text-align:center}
@media (max-width:760px){.pair .card{grid-template-columns:1fr;padding:28px}.qr{margin:0 auto}}

/* ---------- main ---------- */
.main{display:grid;grid-template-columns:minmax(300px,420px) 1fr;height:100%;max-width:1600px;margin:0 auto;background:var(--panel);box-shadow:0 0 40px -20px rgba(0,0,0,.3)}
.side{border-right:1px solid var(--rim);display:flex;flex-direction:column;min-width:0}
.side header{display:flex;align-items:center;justify-content:space-between;padding:16px 16px 8px}
.side header h2{font-size:24px;font-weight:800;letter-spacing:-.5px}
.iconbtn{width:38px;height:38px;border-radius:50%;display:grid;place-items:center}
.iconbtn:hover{background:var(--hl-soft)}
.iconbtn svg{width:22px;height:22px;stroke:var(--hl);fill:none;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}
.search{margin:4px 14px 10px;background:var(--panel2);border-radius:12px;display:flex;align-items:center;gap:8px;padding:0 12px;height:40px}
.search input{border:0;background:none;outline:none;flex:1}
.list{overflow-y:auto;flex:1}
.row{display:flex;gap:12px;align-items:center;padding:10px 16px;cursor:pointer}
.row:hover{background:var(--panel2)}
.row.active{background:var(--hl-soft)}
.av{width:48px;height:48px;border-radius:50%;flex:none;display:grid;place-items:center;color:#fff;font-weight:700;background:#c9d1da;overflow:hidden;font-size:18px}
@media (prefers-color-scheme:dark){.av{background:#3a3f46}}
.av img{width:100%;height:100%;object-fit:cover}
.av.group{background:var(--fill)}
.row .mid{flex:1;min-width:0;border-bottom:1px solid var(--rim);padding-bottom:10px}
.row .t{display:flex;justify-content:space-between;gap:8px}
.row .name{font-weight:600;font-size:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.row .time{font-size:12px;color:var(--muted);flex:none}
.row .time.unread{color:var(--hl);font-weight:600}
.row .p{display:flex;justify-content:space-between;gap:8px;margin-top:3px}
.row .prev{color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:14px}
.badge{min-width:20px;height:20px;border-radius:10px;background:var(--fill);color:#fff;font-size:12px;font-weight:700;display:grid;place-items:center;padding:0 6px}

.conv{display:flex;flex-direction:column;min-width:0;background:var(--wall)}
.conv header{display:flex;align-items:center;gap:12px;padding:10px 16px;background:var(--panel);border-bottom:1px solid var(--rim)}
.conv header .av{width:40px;height:40px;font-size:16px}
.conv header .n{font-weight:600}
.conv header .s{font-size:13px;color:var(--muted)}
.conv header .s.hl{color:var(--hl)}
.msgs{flex:1;overflow-y:auto;padding:16px 7%;display:flex;flex-direction:column;gap:3px}
.day{align-self:center;background:var(--panel);color:var(--muted);font-size:12.5px;padding:5px 12px;border-radius:8px;margin:10px 0;box-shadow:0 1px 1px rgba(0,0,0,.06)}
.sys{align-self:center;background:var(--panel);color:var(--muted);font-size:12.5px;padding:5px 12px;border-radius:8px;margin:6px 0;text-align:center;max-width:80%}
.b{max-width:65%;padding:6px 9px 8px;border-radius:10px;background:var(--in);box-shadow:0 1px 1px rgba(0,0,0,.08);position:relative;word-wrap:break-word;white-space:pre-wrap}
.b.me{align-self:flex-end;background:var(--out)}
.b.first{margin-top:8px}
.b .who{font-weight:600;font-size:13px;margin-bottom:2px}
.b .meta{float:right;margin:8px 0 -4px 12px;font-size:11px;color:var(--muted);display:flex;gap:3px;align-items:center}
.b .meta svg{width:16px;height:16px}
.b .fwd{font-size:12px;color:var(--muted);font-style:italic}
.b .quote{background:rgba(0,0,0,.05);border-left:3px solid var(--hl);border-radius:6px;padding:5px 8px;margin-bottom:5px;font-size:13px}
.b .media{margin:-2px -5px 4px;border-radius:8px;overflow:hidden;max-width:330px;cursor:pointer;background:rgba(0,0,0,.08)}
.b .media img,.b .media video{display:block;max-width:100%;max-height:360px}
.b audio{max-width:260px;height:36px}
.doc{display:flex;gap:10px;align-items:center;padding:8px;border-radius:8px;background:rgba(0,0,0,.05);margin-bottom:4px;min-width:220px}
.doc .ic{width:36px;height:36px;border-radius:8px;background:var(--fill);display:grid;place-items:center;color:#fff;font-size:12px;font-weight:700}
.compose{display:flex;align-items:flex-end;gap:10px;padding:10px 16px;background:var(--panel)}
.compose textarea{flex:1;resize:none;border:0;outline:none;background:var(--panel2);border-radius:22px;padding:11px 16px;max-height:140px;line-height:20px}
.send{width:44px;height:44px;border-radius:50%;background:var(--fill);display:grid;place-items:center;flex:none}
.send svg{width:20px;height:20px;fill:#fff}
.empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;color:var(--muted);text-align:center;padding:40px;background:var(--panel2)}
.empty img{width:104px;height:104px}
.empty h3{font-size:30px;font-weight:300;color:var(--fg)}
.banner{background:var(--hl-soft);color:var(--fg);font-size:13px;padding:8px 16px;text-align:center}
.modal{position:fixed;inset:0;background:rgba(0,0,0,.45);display:grid;place-items:center;z-index:10}
.modal .box{background:var(--panel);border-radius:22px;padding:24px;width:min(420px,92vw)}
.modal h3{font-size:19px;margin-bottom:12px}
.modal input{width:100%;height:44px;border-radius:12px;border:1px solid var(--rim);background:var(--panel2);padding:0 12px;outline:none;margin-top:6px}
.modal .acts{display:flex;justify-content:flex-end;gap:8px;margin-top:18px}
.pill{height:40px;padding:0 18px;border-radius:20px;font-weight:600}
.pill.primary{background:var(--fill);color:#fff}
.pill.ghost{color:var(--hl)}
.err{color:#e5484d;font-size:13px;margin-top:8px}
.menu{position:absolute;right:16px;top:54px;background:var(--panel);border:1px solid var(--rim);border-radius:14px;box-shadow:0 12px 30px rgba(0,0,0,.2);z-index:5;overflow:hidden}
.menu button{display:block;width:100%;text-align:left;padding:12px 18px}
.menu button:hover{background:var(--panel2)}
@media (max-width:820px){
  .main{grid-template-columns:1fr}
  .main.open .side{display:none}
  .main:not(.open) .conv{display:none}
  .msgs{padding:12px}
}
