:root{
  --bg:#d1d7db; --tb:#ffffff; --tbtxt:#111b21; --head:#008069; --headtxt:#fff;
  --wall:#efeae2; --in:#ffffff; --out:#d9fdd3; --txt:#111b21; --muted:#667781;
  --btn:#027eb5; --line:#e9edef; --chip:#ffffff; --accent:#7c5cff; --maya:#8e44ec;
  --panel:#ffffff; --sys:#ffeecd; --systxt:#54656f; --card:#f0f2f5;
  --safe-b:env(safe-area-inset-bottom,0px); --safe-t:env(safe-area-inset-top,0px);
}
html[data-theme=dark]{
  --bg:#0c1317; --tb:#111b21; --tbtxt:#e9edef; --head:#202c33; --headtxt:#e9edef;
  --wall:#0b141a; --in:#202c33; --out:#005c4b; --txt:#e9edef; --muted:#8696a0;
  --btn:#53bdeb; --line:#2a3942; --chip:#202c33; --panel:#111b21; --sys:#182229; --systxt:#8696a0; --card:#111b21;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;height:100%;background:var(--bg);color:var(--txt);
  font:15px/1.38 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;-webkit-text-size-adjust:100%}
button{font:inherit;color:inherit;cursor:pointer}
#app{height:100dvh;display:flex;flex-direction:column;padding-top:var(--safe-t)}
.toolbar{display:flex;align-items:center;gap:8px;padding:6px 10px;background:var(--tb);color:var(--tbtxt);border-bottom:1px solid var(--line);flex:0 0 auto}
.tb-logo{height:22px;width:auto}
html[data-theme=dark] .logo-light, html:not([data-theme=dark]) .logo-dark{display:none}
.profiles{display:flex;background:var(--card);border-radius:999px;padding:3px;gap:2px;margin:0 auto;border:1px solid var(--line)}
.profiles button{border:0;background:none;padding:6px 10px;border-radius:999px;font-size:13px;font-weight:600;white-space:nowrap;color:var(--muted)}
.profiles button.on{background:var(--head);color:#fff}
html[data-theme=dark] .profiles button.on{background:#00a884;color:#111b21}
.tb-actions{display:flex;gap:2px}
.tb-actions button{border:0;background:none;font-size:18px;width:36px;height:36px;border-radius:50%;position:relative}
.tb-actions button:active{background:var(--line)}
.dot{position:absolute;top:6px;right:6px;width:8px;height:8px;border-radius:50%;background:#25d366}
.main{flex:1 1 auto;display:flex;min-height:0;justify-content:center}
.phone{flex:1 1 auto;max-width:720px;display:flex;flex-direction:column;min-height:0;background:var(--wall);position:relative}
.chat-head{display:flex;align-items:center;gap:10px;padding:8px 12px;background:var(--head);color:var(--headtxt);flex:0 0 auto}
.chat-head img{width:40px;height:40px;border-radius:50%;background:#1d2b5c;object-fit:contain;padding:3px}
.chat-head.maya img{background:linear-gradient(135deg,#8e44ec,#5b8cff)}
.ch-txt{flex:1;min-width:0}
#headName{font-weight:600;font-size:16px}
#headStatus{font-size:12.5px;opacity:.85}
.proto-pill{font-size:11px;background:rgba(255,255,255,.16);padding:3px 8px;border-radius:999px;white-space:nowrap}
.chat{flex:1 1 auto;overflow-y:auto;padding:10px 10px 16px;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;
  background-image:radial-gradient(rgba(0,0,0,.035) 1px,transparent 1px);background-size:18px 18px}
html[data-theme=dark] .chat{background-image:radial-gradient(rgba(255,255,255,.03) 1px,transparent 1px)}
.row{display:flex;margin:3px 0}
.row.out{justify-content:flex-end}
.bub{max-width:min(86%,460px);background:var(--in);border-radius:8px;padding:6px 8px 4px;box-shadow:0 1px .5px rgba(11,20,26,.13);position:relative;word-wrap:break-word;overflow-wrap:anywhere}
.row.out .bub{background:var(--out)}
.row.in.first .bub{border-top-left-radius:0}
.row.out.first .bub{border-top-right-radius:0}
.who{font-size:12.5px;font-weight:700;margin-bottom:2px}
.who.bot{color:#1f7aec} .who.maya{color:var(--maya)}
html[data-theme=dark] .who.bot{color:#53bdeb} html[data-theme=dark] .who.maya{color:#c39bff}
.txt{white-space:pre-wrap}
.time{font-size:11px;color:var(--muted);float:right;margin:6px 0 -2px 10px}
.bub img.media{display:block;width:100%;max-width:340px;border-radius:6px;margin:-2px 0 4px;cursor:zoom-in;background:#0b0f1e;aspect-ratio:1/1;object-fit:cover}
.bub img.media.banner{aspect-ratio:1/1}
.bub.has-media{padding:3px 3px 4px}
.bub.has-media .txt,.bub.has-media .time,.bub.has-media .who{padding:0 5px}
.btns{display:flex;flex-direction:column;margin:6px -8px -4px;border-top:1px solid var(--line)}
.btns button{border:0;background:none;color:var(--btn);padding:9px 8px;font-weight:500;font-size:14.5px;border-top:1px solid var(--line)}
.btns button:first-child{border-top:0}
.btns button:disabled{color:var(--muted);opacity:.6;cursor:default}
.btns button.picked{color:var(--muted);font-weight:700}
.listbtn{display:block;width:calc(100% + 16px);margin:6px -8px -4px;border:0;border-top:1px solid var(--line);background:none;color:var(--btn);padding:9px;font-weight:600}
.listbtn:disabled{color:var(--muted)}
.num{margin-top:6px;padding:6px 8px;background:var(--card);border-radius:6px;font-size:13.5px;color:var(--muted);white-space:pre-wrap}
.sys{align-self:center;margin:8px auto;max-width:90%;background:var(--sys);color:var(--systxt);font-size:12.5px;padding:5px 10px;border-radius:8px;text-align:center;box-shadow:0 1px .5px rgba(11,20,26,.1)}
.sys.maya{background:linear-gradient(90deg,#efe4ff,#e3edff);color:#4a2a8a}
html[data-theme=dark] .sys.maya{background:#2a2142;color:#d7c4ff}
.cardx{background:var(--card);border-radius:8px;padding:8px 10px;margin:2px 0 4px;border-left:4px solid #25d366;font-variant-numeric:tabular-nums}
.cardx .k{color:var(--muted);font-size:13px}
.cardx .v{font-weight:700;font-size:16px;letter-spacing:.3px;user-select:all}
.cardx .ln{display:flex;justify-content:space-between;align-items:baseline;gap:10px;padding:3px 0;border-bottom:1px dashed var(--line)}
.cardx .ln:last-child{border-bottom:0}
.cardx .tag{font-size:11px;color:#b45309;font-weight:700}
.fichamsg{background:var(--card);border-radius:8px;padding:6px 8px;font-size:13px;border-left:4px solid var(--maya)}
.fichamsg div{display:flex;gap:6px;padding:1px 0}
.fichamsg span{color:var(--muted);min-width:110px}
.pix{font-family:ui-monospace,Menlo,monospace;font-size:12px;background:var(--card);padding:6px;border-radius:6px;word-break:break-all;margin:4px 0;border:1px dashed #d11}
.typing .bub{padding:10px 14px}
.typing i{display:inline-block;width:7px;height:7px;margin:0 2px;border-radius:50%;background:var(--muted);animation:b 1s infinite}
.typing i:nth-child(2){animation-delay:.15s}.typing i:nth-child(3){animation-delay:.3s}
@keyframes b{0%,60%,100%{transform:translateY(0);opacity:.5}30%{transform:translateY(-4px);opacity:1}}
.composer{flex:0 0 auto;display:flex;gap:8px;padding:6px 8px calc(6px + var(--safe-b));background:var(--tb);border-top:1px solid var(--line)}
.composer input{flex:1;min-width:0;border:0;border-radius:22px;padding:10px 14px;font-size:16px;background:var(--card);color:var(--txt);outline:none}
.composer button{width:44px;height:44px;border-radius:50%;border:0;background:#00a884;color:#fff;font-size:18px;flex:0 0 auto}
/* ficha */
.ficha{width:340px;flex:0 0 340px;background:var(--panel);border-left:1px solid var(--line);display:flex;flex-direction:column;min-height:0}
.f-head{display:flex;justify-content:space-between;align-items:flex-start;padding:12px 14px;border-bottom:1px solid var(--line)}
.f-head small{display:block;color:var(--muted);font-size:12px;font-weight:400}
.f-head button{border:0;background:none;font-size:18px;display:none}
.f-body{flex:1;overflow-y:auto;padding:6px 14px}
.f-row{padding:7px 0;border-bottom:1px solid var(--line);transition:background .6s}
.f-row .l{font-size:12px;color:var(--muted)}
.f-row .v{font-size:14px;font-weight:600}
.f-row .v.empty{color:var(--muted);font-weight:400}
.f-row .src{font-size:10.5px;color:var(--muted);float:right}
.f-row.flash{background:rgba(37,211,102,.18)}
.f-owner{margin:8px 0;padding:8px;border-radius:8px;background:var(--card);font-weight:700;text-align:center}
.f-foot{font-size:12px;color:var(--muted);padding:10px 14px calc(10px + var(--safe-b));margin:0;border-top:1px solid var(--line)}
@media (max-width:1079px){
  .ficha{position:fixed;inset:0 0 0 auto;width:min(92vw,380px);z-index:30;transform:translateX(105%);transition:transform .25s;box-shadow:-8px 0 30px rgba(0,0,0,.25);padding-top:var(--safe-t)}
  .ficha.open{transform:none}
  .f-head button{display:block}
}
@media (min-width:1080px){ #btnFicha{display:none} .main{padding:16px;gap:16px;background:var(--bg)} .phone{border-radius:12px;overflow:hidden;box-shadow:0 6px 30px rgba(0,0,0,.18)} .ficha{border-radius:12px;border:1px solid var(--line)} }
@media (max-width:420px){ .profiles button{padding:6px 7px;font-size:12px} .tb-logo{height:18px} .proto-pill{display:none} }
@media (max-width:350px){ .tb-logo{display:none!important} }
/* sheet */
.sheet{position:fixed;inset:0;z-index:40;display:flex;align-items:flex-end;justify-content:center}
.sheet[hidden]{display:none}
.sheet-bg{position:absolute;inset:0;background:rgba(0,0,0,.45)}
.sheet-card{position:relative;width:100%;max-width:560px;max-height:82dvh;background:var(--panel);border-radius:14px 14px 0 0;display:flex;flex-direction:column;padding-bottom:var(--safe-b);animation:up .2s}
@media (min-width:700px){.sheet{align-items:center}.sheet-card{border-radius:14px}}
@keyframes up{from{transform:translateY(40px);opacity:.4}}
.sheet-top{display:flex;align-items:center;gap:12px;padding:14px 16px;border-bottom:1px solid var(--line)}
.sheet-top button{border:0;background:none;font-size:18px}
.sheet-body{overflow-y:auto;padding:4px 0 10px}
.sec{padding:12px 18px 4px;color:#008069;font-size:13px;font-weight:600}
html[data-theme=dark] .sec{color:#00a884}
.opt{display:flex;width:100%;align-items:center;gap:12px;text-align:left;border:0;background:none;padding:10px 18px}
.opt:active{background:var(--line)}
.opt .ot{font-size:15.5px}
.opt .od{font-size:13px;color:var(--muted)}
.opt .rd{margin-left:auto;width:20px;height:20px;border:2px solid var(--muted);border-radius:50%;flex:0 0 auto}
.viewer{position:fixed;inset:0;z-index:50;background:rgba(0,0,0,.92);display:flex;align-items:center;justify-content:center;padding:calc(20px + var(--safe-t)) 10px calc(20px + var(--safe-b))}
.viewer[hidden]{display:none}
.viewer img{max-width:100%;max-height:100%;object-fit:contain}
.viewer button{position:absolute;top:calc(10px + var(--safe-t));right:12px;border:0;background:rgba(255,255,255,.15);color:#fff;width:40px;height:40px;border-radius:50%;font-size:18px}
.toast{position:fixed;left:50%;bottom:calc(80px + var(--safe-b));transform:translateX(-50%);background:#111b21;color:#fff;padding:8px 14px;border-radius:20px;font-size:13px;z-index:60}
.toast[hidden]{display:none}
