:root{--red:#e10a17;--red-d:#a8000c;--ink:#111114;--ink2:#1c1c21;--mut:#6c6c74;--bg:#f3f3f5;--line:#e6e6ea;--card:#fff;--me:#fde7e9;--ok:#16a34a}
*{box-sizing:border-box}html,body{height:100%;margin:0}
body{font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif;background:var(--bg);color:var(--ink);-webkit-font-smoothing:antialiased}
button{font:inherit;cursor:pointer}input,textarea,select{font:inherit}
.mut{color:var(--mut)}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;height:40px;padding:0 18px;border:0;border-radius:99px;background:var(--red);color:#fff;font-weight:700}
.btn:hover{background:var(--red-d)}.btn.dark{background:var(--ink)}.btn.ghost{background:#fff;color:var(--ink);border:1.5px solid var(--line)}.btn.sm{height:32px;padding:0 12px;font-size:13px}
.btn.bad{background:#fff;color:var(--red);border:1.5px solid #f3b6ba}.btn:disabled{opacity:.6;cursor:default}
.ib{width:34px;height:34px;border-radius:10px;border:0;background:var(--bg);color:var(--ink);font-size:20px;line-height:1;display:grid;place-items:center}
.ib:hover{background:#e9e9ee}
input:not([type=checkbox]):not([type=radio]):not([type=file]),select,textarea{width:100%;border:1.5px solid var(--line);border-radius:10px;padding:9px 12px;background:#fff;outline:0}
input:focus,select:focus,textarea:focus{border-color:var(--red);box-shadow:0 0 0 3px rgba(225,10,23,.1)}
label{font-size:13px;font-weight:600;display:block}

/* Login */
body.login{display:grid;place-items:center;background:var(--ink)}
.lg{background:#fff;border-radius:20px;padding:28px;width:min(360px,92vw);display:flex;flex-direction:column;gap:12px;box-shadow:0 30px 80px -20px rgba(0,0,0,.6)}
.lg h1{margin:4px 0 0;font-size:24px}.lg p{margin:0 0 6px}.lg label input{margin-top:5px}.lg .btn{margin-top:6px}
.err{background:#fdecee;color:var(--red);border-radius:10px;padding:9px 12px;font-size:13.5px;font-weight:600}

/* Estructura */
.app{display:grid;grid-template-columns:76px 360px 1fr;height:100vh;height:100dvh}
.app>*{min-height:0;min-width:0;overflow:hidden}body:not(.login){overflow:hidden;position:fixed;inset:0}.msgs{min-height:0;overscroll-behavior:contain}.items{min-height:0;overscroll-behavior:contain}
.rail{background:var(--ink);color:#fff;display:flex;flex-direction:column;align-items:center;padding:12px 0;gap:6px;overflow-y:auto}
.rail .logo{margin-bottom:8px}
.rail button.rl{position:relative;width:52px;height:52px;border-radius:16px;border:0;background:var(--ink2);color:#fff;display:grid;place-items:center;font-weight:800;font-size:15px;flex:none}
.rail button.rl:hover{background:#2a2a31}.rail button.rl.on{outline:2.5px solid #fff;outline-offset:2px}
.rail button.rl .dot{position:absolute;right:3px;bottom:3px;width:11px;height:11px;border-radius:50%;border:2px solid var(--ink);background:#777}
.rail button.rl .dot.open{background:#22c55e}.rail button.rl .dot.qr,.rail button.rl .dot.starting{background:#f59e0b}
.rail .bd{position:absolute;top:-5px;right:-6px;min-width:19px;height:19px;padding:0 5px;border-radius:99px;background:var(--red);color:#fff;font-size:11px;font-weight:800;display:grid;place-items:center;border:2px solid var(--ink)}
.rail .sp{flex:1}.rail .tool{width:44px;height:44px;border-radius:12px;border:0;background:transparent;color:#cfcfd6;font-size:20px;display:grid;place-items:center}
.rail .tool:hover{background:var(--ink2);color:#fff}.rail .me{width:38px;height:38px;border-radius:50%;background:var(--red);color:#fff;display:grid;place-items:center;font-weight:800;border:0}
.list{background:#fff;border-right:1px solid var(--line);display:flex;flex-direction:column;min-width:0}
.lh{padding:12px 12px 8px;border-bottom:1px solid var(--line)}
.lt{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px}.lt b{font-size:19px}
.lchips{display:none}.mmenu{display:none!important}
.sr{display:flex;gap:8px;align-items:center}.sr input{height:38px}.uo{display:flex;align-items:center;gap:5px;white-space:nowrap;font-weight:600;color:var(--mut);margin:0}
.items{overflow-y:auto;flex:1}
.it{display:flex;gap:10px;padding:10px 12px;cursor:pointer;border-bottom:1px solid #f1f1f4;align-items:center}
.it:hover{background:#fafafb}.it.on{background:#fff1f2}
.av{width:44px;height:44px;border-radius:50%;flex:none;display:grid;place-items:center;color:#fff;font-weight:800;font-size:16px;position:relative}
.it .bx{flex:1;min-width:0}.it .r1{display:flex;justify-content:space-between;gap:8px}.it .nm{font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.it .tm{font-size:12px;color:var(--mut);flex:none}.it .r2{display:flex;justify-content:space-between;gap:8px;align-items:center;margin-top:2px}
.it .lx{font-size:13.5px;color:var(--mut);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.it.un .lx{color:var(--ink);font-weight:600}.it.un .tm{color:var(--red);font-weight:700}
.it .ub{min-width:20px;height:20px;padding:0 6px;border-radius:99px;background:var(--red);color:#fff;font-size:11.5px;font-weight:800;display:grid;place-items:center;flex:none}
.it .r3{display:flex;gap:8px;align-items:center;margin-top:3px}.it .ph{font-size:12.5px;color:#44444c;font-weight:600}
.tag{display:inline-flex;align-items:center;gap:4px;font-size:11px;font-weight:700;padding:1px 7px;border-radius:99px;background:var(--bg);color:#44444c;white-space:nowrap}
.tag i{width:7px;height:7px;border-radius:50%;display:inline-block}
.more{display:block;margin:10px auto;font-size:13px}
.noitems{padding:30px 16px;text-align:center;color:var(--mut)}

/* Conversación */
.conv{display:flex;flex-direction:column;min-width:0;background:#efeae2;background-image:radial-gradient(rgba(0,0,0,.035) 1px,transparent 1px);background-size:18px 18px}
.empty{margin:auto;text-align:center}.empty h2{margin:10px 0 4px}
.ch{display:flex;align-items:center;gap:10px;padding:10px 14px;background:#fff;border-bottom:1px solid var(--line);min-height:62px}
.ch .bk{display:none}.ch .who{flex:1;min-width:0}.ch .who b{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ch .who small{color:var(--mut)}
.msgs{flex:1;overflow-y:auto;padding:14px 6%;display:flex;flex-direction:column;gap:3px}
.day{align-self:center;background:#fff;color:#55555d;font-size:12px;font-weight:600;padding:4px 10px;border-radius:8px;margin:10px 0 6px;box-shadow:0 1px 1px rgba(0,0,0,.06)}
.m{max-width:min(560px,78%);padding:6px 9px 4px;border-radius:10px;background:#fff;box-shadow:0 1px 1px rgba(0,0,0,.08);align-self:flex-start;position:relative;font-size:14.5px;line-height:1.38;word-wrap:break-word;overflow-wrap:anywhere}
.m.me{align-self:flex-end;background:var(--me)}
.m .tx{white-space:pre-wrap}.m .ft{display:flex;justify-content:flex-end;gap:5px;font-size:11px;color:#77777f;margin-top:2px;align-items:center}
.m .by{font-size:11px;font-weight:700;color:var(--red-d);margin-bottom:2px}
.m img.pic{display:block;max-width:100%;max-height:340px;border-radius:7px;cursor:zoom-in;margin-bottom:3px}.m img.stk{width:140px;height:140px;object-fit:contain;background:transparent}
.m.stkm{background:transparent;box-shadow:none}
.m video{display:block;max-width:100%;max-height:340px;border-radius:7px;margin-bottom:3px}.m audio{width:260px;max-width:100%;display:block}
.doc{display:flex;align-items:center;gap:9px;background:rgba(0,0,0,.05);border-radius:8px;padding:8px 10px;text-decoration:none;color:inherit;margin-bottom:3px}
.doc span{font-size:24px}.doc b{font-size:13.5px;overflow:hidden;text-overflow:ellipsis}
.tick{font-size:12px;letter-spacing:-3px;color:#8a8a92}.tick.r{color:#2196f3}
.m a{color:#0b6bcb}
.cmp{display:flex;align-items:flex-end;gap:8px;padding:10px 12px;background:#f7f7f9;border-top:1px solid var(--line)}
.cmp textarea{resize:none;max-height:140px;min-height:42px;border-radius:21px;padding:10px 15px;line-height:1.35}
.cmp .ib{width:42px;height:42px;border-radius:50%;flex:none;background:#fff;border:1.5px solid var(--line)}
.cmp .send{width:42px;height:42px;border-radius:50%;border:0;background:var(--red);color:#fff;flex:none;display:grid;place-items:center}
.cmp .send svg{width:20px;height:20px}
.off{background:#fff6e0;color:#7a4a00;font-size:13px;padding:8px 14px;border-top:1px solid #f4e2b8;font-weight:600}
.fprev{display:flex;align-items:center;gap:8px;padding:8px 12px;background:#fff;border-top:1px solid var(--line);font-size:13px}
.fprev b{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* Diálogos */
.dlg{border:0;border-radius:18px;padding:0;width:min(640px,95vw);max-height:90vh;box-shadow:0 30px 80px -20px rgba(0,0,0,.5)}
.dlg::backdrop{background:rgba(17,17,20,.55)}
.dlg[open]{display:flex;flex-direction:column}
.dh{display:flex;justify-content:space-between;align-items:center;padding:14px 18px;border-bottom:3px solid var(--red);font-size:17px}
.x{width:34px;height:34px;border-radius:10px;border:0;background:var(--bg);font-size:22px;line-height:1}
.db{padding:16px 18px;overflow-y:auto}
.row{display:flex;gap:10px;align-items:center;flex-wrap:wrap}.grid2{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.fld{margin-bottom:10px}.fld input,.fld select{margin-top:4px}
.ln{border:1px solid var(--line);border-radius:14px;padding:12px;margin-bottom:10px}
.ln .top{display:flex;gap:10px;align-items:center}.ln .top .nm{flex:1;min-width:0}.ln .top .nm b{display:block}.ln .top small{color:var(--mut)}
.st{font-size:12px;font-weight:700;padding:2px 9px;border-radius:99px;background:var(--bg)}.st.open{background:#e5f7ec;color:#13793b}.st.qr,.st.starting{background:#fff4dc;color:#a46200}.st.off{background:#f1f1f4;color:#55555d}
.ag{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px}.ag label{display:flex;align-items:center;gap:5px;background:var(--bg);padding:5px 10px;border-radius:99px;font-weight:600;margin:0;cursor:pointer}
.ag label:has(input:checked){background:#fde7e9;color:var(--red-d)}
.ln .acts{display:flex;gap:6px;flex-wrap:wrap;margin-top:10px}
.qrb{text-align:center}.qrb img{width:264px;height:264px;image-rendering:pixelated;border:1px solid var(--line);border-radius:12px;padding:8px;background:#fff}
.qrb ol{text-align:left;font-size:14px;line-height:1.6;max-width:420px;margin:12px auto 0}
.u{display:flex;gap:10px;align-items:center;padding:10px 0;border-bottom:1px solid var(--line)}.u .nm{flex:1;min-width:0}.u small{color:var(--mut)}
.toast{position:fixed;left:50%;bottom:22px;transform:translateX(-50%);background:var(--ink);color:#fff;padding:10px 16px;border-radius:12px;font-size:14px;font-weight:600;z-index:99;max-width:90vw;box-shadow:0 10px 30px rgba(0,0,0,.3)}
.toast.err{background:var(--red)}
.zoom{position:fixed;inset:0;background:rgba(0,0,0,.88);display:grid;place-items:center;z-index:90;cursor:zoom-out}.zoom img{max-width:94vw;max-height:94vh}
.colors{display:flex;gap:6px}.colors label{width:26px;height:26px;border-radius:50%;cursor:pointer;margin:0;border:3px solid transparent}.colors input{display:none}.colors label:has(input:checked){border-color:var(--ink)}

/* Celular: una columna a la vez */
@media (max-width:820px){
  .app{grid-template-columns:1fr}.rail{display:none}
  .lchips{display:flex;gap:6px;overflow-x:auto;margin-bottom:8px;scrollbar-width:none}.lchips::-webkit-scrollbar{display:none}
  .lchips button{flex:none;display:flex;align-items:center;gap:6px;border:1.5px solid var(--line);background:#fff;border-radius:99px;padding:5px 11px;font-size:13px;font-weight:700}
  .lchips button.on{background:var(--ink);color:#fff;border-color:var(--ink)}.lchips i{width:8px;height:8px;border-radius:50%}
  .lchips em{font-style:normal;background:var(--red);color:#fff;border-radius:99px;font-size:11px;padding:0 6px}
  .app.chat .list{display:none}.app:not(.chat) .conv{display:none}
  .mmenu{display:grid!important}.ch .bk{display:grid}.msgs{padding:10px 10px}.m{max-width:86%}
}
