/* =====================================================================
   💬 แชทรวม
   ===================================================================== */
@keyframes chPop{from{transform:translateY(8px) scale(.96);opacity:0}}
@keyframes chDot{0%,60%,100%{transform:translateY(0);opacity:.45}30%{transform:translateY(-4px);opacity:1}}
@keyframes chFlash{0%,100%{background:transparent}30%{background:#ffd56b33}}
@keyframes chShake{20%,60%{transform:translateX(-4px)}40%,80%{transform:translateX(4px)}}
@keyframes chSpin{to{transform:rotate(360deg)}}

.cht{position:fixed;left:0;right:0;top:60px;bottom:96px;z-index:5;display:flex;flex-direction:column;width:100%;max-width:760px;margin:0 auto;padding:0 10px}
.cht-top{display:flex;align-items:center;gap:8px;padding:8px 4px 6px;flex:none}
.cht-top b{font-size:1.1rem}.cht-top small{color:#7dffb0;font-size:.78rem;flex:1}.cht-top .ic{font-size:.8rem;font-family:Kanit,sans-serif}
.chl{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;padding:4px 2px 30px;border-radius:20px;background:#0c0624aa;border:1px solid #ffffff12;scrollbar-width:thin}
.chl-top{min-height:8px;text-align:center}
.chstart,.chempty{color:#ffffff66;font-size:.78rem;padding:14px 0 6px;line-height:1.5}
.chempty{font-size:1rem;padding-top:60px}.chempty small{font-size:.8rem}
.chspin{display:inline-block;width:20px;height:20px;border:2.5px solid #ffffff33;border-top-color:#ffd56b;border-radius:50%;animation:chSpin .8s linear infinite;margin:8px}
.chday{text-align:center;margin:12px 0 6px}.chday span{font-size:.72rem;color:#ffffffaa;background:#ffffff14;padding:3px 12px;border-radius:12px}
.chdiv{display:flex;align-items:center;gap:8px;margin:10px 6px;color:#ff8fa8;font-size:.75rem;font-weight:800}
.chdiv::before,.chdiv::after{content:"";flex:1;height:1px;background:#ff8fa866}

.chm{display:flex;align-items:flex-end;gap:7px;padding:2px 6px;margin-top:8px;border-radius:12px}
.chm.g{margin-top:2px}.chm.flash{animation:chFlash 1.4s 2}
.chm-av{width:34px;flex:none;align-self:flex-start;padding-top:18px}.chm.g .chm-av{padding-top:0}
.chm-av .av,.chav .av{width:34px;height:34px;font-size:.95rem;cursor:pointer}
.cha-crown{display:inline-flex!important;align-items:center;justify-content:center;width:34px;height:34px;border-radius:50%;background:radial-gradient(circle at 35% 30%,#fff3b0,#ffb02e 60%,#b8560a);font-size:1.05rem;box-shadow:0 0 10px #ffd56b88}
.chm-c{max-width:min(78%,520px);min-width:0;display:flex;flex-direction:column;align-items:flex-start}
.chm.me{justify-content:flex-end}.chm.me .chm-c{align-items:flex-end}
.chn{font-size:.74rem;font-weight:800;color:#c9b8ff;margin:0 0 2px 4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
.chn em{font-style:normal;font-size:.62rem;padding:1px 6px;border-radius:8px;background:linear-gradient(180deg,#ffe27a,#ffb02e);color:#3a1500;margin-left:4px;vertical-align:1px}
.chn.rb{background:linear-gradient(90deg,#ff5f6d,#ffc371,#7dffb0,#4cc8ff,#c86bff);-webkit-background-clip:text;background-clip:text;color:transparent}
.chb{position:relative;padding:8px 12px;border-radius:18px 18px 18px 6px;background:#ffffff14;border:1px solid #ffffff14;color:#fff;max-width:100%;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;cursor:default;animation:chPop .22s ease-out}
.chm.g .chb{border-radius:6px 18px 18px 6px}
.chm.me .chb{border-radius:18px 18px 6px 18px;background:linear-gradient(135deg,#7b4dff,#c04dff);border-color:#ffffff22}
.chm.me.g .chb{border-radius:18px 6px 6px 18px}
.chm.adm .chb{background:linear-gradient(135deg,#3a2a06,#2a1d4a);border:1.5px solid #ffd56b;box-shadow:0 0 12px #ffd56b44}
.chm.me.adm .chb{background:linear-gradient(135deg,#8a5a0a,#b8860b)}
.chm.pend .chb{opacity:.75}
.cht-t{white-space:pre-wrap;word-break:break-word;overflow-wrap:anywhere;font-size:.95rem;line-height:1.45}
.chx{color:#ffffff88;font-size:.85rem}
.chtm{font-size:.62rem;color:#ffffff66;margin:2px 6px 0;display:flex;gap:4px;align-items:center}
.chst{font-style:normal}.chst.ok{color:#7dffb0}.chst.f{color:#ff8fa8;font-weight:800}
.chq{display:flex;flex-direction:column;gap:1px;padding:5px 9px;margin:0 0 6px;border-left:3px solid #ffd56b;border-radius:8px;background:#00000033;cursor:pointer;max-width:260px}
.chq b{font-size:.7rem;color:#ffe27a}.chq span{font-size:.78rem;color:#ffffffcc;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chim{max-width:100%;border-radius:12px;overflow:hidden;background:#ffffff10;display:flex;align-items:center;justify-content:center;margin:0 0 4px;cursor:zoom-in}
.chim img{width:100%;height:100%;object-fit:cover;display:block}
.chie{font-size:.8rem;color:#ffffff88;padding:12px 16px;border-radius:12px;background:#00000033;margin:0 0 4px}

.chnew{position:absolute;right:22px;bottom:84px;z-index:3;display:none;align-items:center;gap:6px;padding:8px 14px;border-radius:20px;font-weight:800;font-size:.82rem;color:#fff;background:#2a1d4af0;border:1px solid #ffffff33;box-shadow:0 6px 18px #000a}
.chnew.on{display:flex;animation:chPop .2s}.chnew.n{background:linear-gradient(135deg,#ff5f8a,#c04dff);border-color:#fff6}
.chty{position:relative;height:0;z-index:2}
.chty span{position:absolute;left:8px;bottom:6px;font-size:.74rem;color:#ffffffcc;background:#1b0d3de6;border:1px solid #ffffff1a;padding:3px 10px;border-radius:12px;white-space:nowrap;max-width:85%;overflow:hidden;text-overflow:ellipsis;animation:chPop .2s}
.chty span i{display:inline-block;width:4px;height:4px;margin-left:3px;border-radius:50%;background:#ffd56b;vertical-align:middle;animation:chDot 1s infinite}
.chty span i:nth-of-type(2){animation-delay:.15s}.chty span i:nth-of-type(3){animation-delay:.3s}
.chrp{display:none;align-items:center;gap:8px;margin:6px 0 0;padding:6px 8px 6px 12px;border-left:3px solid #ffd56b;border-radius:10px;background:#ffffff12}
.chrp.on{display:flex}.chrp div{flex:1;min-width:0;display:flex;flex-direction:column}.chrp b{font-size:.74rem;color:#ffe27a}
.chrp span{font-size:.8rem;color:#ffffffbb;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.chrp button{width:28px;height:28px;border-radius:50%;background:#ffffff1a;color:#fff}
.chin{display:flex;align-items:flex-end;gap:8px;padding:8px 0 4px;flex:none}
.chin.off{opacity:.5;pointer-events:none}
.chimg{flex:none;width:42px;height:42px;border-radius:14px;background:#ffffff16;border:1px solid #ffffff22;font-size:1.2rem}
.chta{flex:1;position:relative;min-width:0}
.chta textarea{width:100%;resize:none;min-height:42px;max-height:110px;padding:10px 14px;border-radius:20px;background:#ffffff12;border:1px solid #ffffff2a;color:#fff;font:inherit;font-size:16px;line-height:1.35;display:block}
.chta textarea:focus{outline:none;border-color:#c04dffaa;background:#ffffff18}
.chta small{position:absolute;right:12px;top:-16px;font-size:.66rem;color:#ffffff88}.chta small.hot{color:#ff8fa8}
.chsend{position:relative;flex:none;width:44px;height:44px;border-radius:50%;background:#ffffff16;color:#ffffff88;display:flex;align-items:center;justify-content:center;transition:background .2s,color .2s}
.chsend.ready{background:linear-gradient(135deg,#ffe27a,#ffb02e);color:#3a1500;box-shadow:0 0 14px #ffb02e88}
.chsend.shake{animation:chShake .35s}
.chsend svg{position:absolute;inset:0;width:100%;height:100%;transform:rotate(-90deg)}
.chsend circle{fill:none;stroke-width:3}.chsend .r0{stroke:transparent}.chsend .r1{stroke:#ffd56b;stroke-dasharray:100.5;stroke-dashoffset:100.5;transition:stroke-dashoffset .5s linear}
.chsend.cd .r0{stroke:#ffffff1a}
.chsend b{position:relative;font-size:1.05rem;font-weight:800}
.chmute{display:none;text-align:center;font-size:.78rem;color:#ffb3c0;padding:2px 0 4px}.chmute.on{display:block}

/* ป๊อปอัปข้อความใหม่ (ตอนอยู่หน้าอื่น) */
.chpop{position:fixed;left:50%;top:calc(env(safe-area-inset-top) + 64px);z-index:60;display:flex;align-items:center;gap:10px;width:min(380px,calc(100% - 24px));padding:10px 12px;border-radius:18px;background:#24124ef2;border:1.5px solid #c04dff88;box-shadow:0 10px 30px #000b;cursor:pointer;touch-action:none;
  opacity:0;visibility:hidden;pointer-events:none;transform:translate(-50%,-24px) scale(.96);transition:transform .3s ease-in,opacity .25s ease-in,visibility 0s linear .3s}
.chpop.on{opacity:1;visibility:visible;pointer-events:auto;transform:translate(-50%,0) scale(1);transition:transform .4s cubic-bezier(.2,1.3,.4,1),opacity .2s,visibility 0s}
.chpop .av{width:38px;height:38px;flex:none}.chpop div{flex:1;min-width:0;display:flex;flex-direction:column}
.chpop b{font-size:.85rem}.chpop small{font-size:.78rem;color:#ffffffbb;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chpop i{font-style:normal;font-size:.72rem;padding:2px 7px;border-radius:10px;background:#ff5f8a;font-weight:800}

/* เมนูกดค้าง / ขออนุญาตรูป / ดูรูป */
.chsheet .chs-who{display:flex;align-items:center;gap:10px;margin:4px 0 8px}.chsheet .chs-who .av{width:44px;height:44px}
.chsheet .chs-who div{display:flex;flex-direction:column}.chsheet .chs-who small{color:#ffffffaa;font-size:.78rem}
.chs-time{font-size:.82rem;color:#ffffffbb;background:#ffffff0d;border-radius:12px;padding:8px 10px;line-height:1.5}.chs-time b{color:#fff}
.chs-adm{margin-top:10px;padding-top:8px;border-top:1px dashed #ffffff33}.chs-adm>b{display:block;font-size:.8rem;color:#ffd56b;margin-bottom:4px}
.chperm-ic{font-size:3.2rem}.chperm ul{text-align:left;list-style:none;padding:0;margin:10px 0 14px;font-size:.88rem;line-height:1.9}
.chpv{display:flex;justify-content:center;max-height:52vh;overflow:hidden;border-radius:14px;background:#00000040}.chpv img{max-width:100%;max-height:52vh;object-fit:contain}
.chview{position:fixed;inset:0;z-index:10050;background:#000e;display:flex;align-items:center;justify-content:center;overflow:auto;animation:chPop .2s}
.chview img{max-width:100%;max-height:100%;object-fit:contain;cursor:zoom-in;transition:transform .25s}
.chview.z{align-items:flex-start;justify-content:flex-start}.chview.z img{max-width:none;max-height:none;width:200%;cursor:zoom-out}
.chview button{position:fixed;top:calc(env(safe-area-inset-top) + 12px);right:12px;width:42px;height:42px;border-radius:50%;background:#ffffff26;color:#fff;font-size:1.1rem}

/* แท็บล่าง: ตัวเลขข้อความใหม่ */
.tbn-chat{position:absolute;top:6px;right:calc(50% - 22px);min-width:18px;height:18px;padding:0 5px;border-radius:9px;background:#ff3d6e;color:#fff;font-style:normal;font-size:.66rem;font-weight:800;line-height:18px;text-align:center;box-shadow:0 0 0 2px #1d0f4a;transform:scale(0);transition:transform .2s}
.tbn-chat.on{transform:scale(1)}

/* หน้ารายงานแชท (แอดมิน) */
.chrep{padding:10px;border-radius:16px;background:#ffffff0a;margin-bottom:8px}
.chrep-h{display:flex;align-items:center;gap:8px}.chrep-h .av{width:36px;height:36px}.chrep-h div{flex:1;min-width:0;display:flex;flex-direction:column}.chrep-h small{font-size:.72rem;color:#ffffff88}
.chrep-h em{font-style:normal;font-size:.8rem;padding:2px 8px;border-radius:10px;background:#ff3d6e;font-weight:800}
.chrep-t{margin:8px 0 4px;padding:8px 10px;border-radius:10px;background:#00000033;white-space:pre-wrap;word-break:break-word;font-size:.9rem}
.chrep-by{display:block;color:#ffffff88;font-size:.74rem}
.chrep-b{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}.chrep-b .btn{width:auto;margin:0;flex:1;min-width:110px}

@media (min-width:700px){.cht{padding:0 16px}.chm-c{max-width:min(70%,520px)}}
.lite .chb,.lite .chnew,.lite .chpop{animation:none}
/* 📌 ปักหมุดข้อความ — กรอบไฟวิ่ง */
@property --pa{syntax:'<angle>';inherits:false;initial-value:0deg}
@keyframes pinRun{to{--pa:360deg}}
@keyframes pinGlow{0%,100%{box-shadow:0 0 10px #ffd34d55,0 0 0 #ff5fa200}50%{box-shadow:0 0 18px #ffd34d99,0 0 26px #ff5fa255}}
.chpinw{flex:none}
.chpinw:empty{display:none}
.chpin{--pa:0deg;position:relative;display:flex;align-items:center;gap:10px;margin:0 2px 8px;padding:8px 10px 8px 12px;border-radius:16px;background:linear-gradient(135deg,#2a1450f2,#3d1a4af2);cursor:pointer;animation:pinGlow 2.4s ease-in-out infinite;isolation:isolate}
.chpin::before,.chm.pin .chb::before{content:'';position:absolute;inset:-2px;border-radius:inherit;padding:2px;pointer-events:none;z-index:1;
  background:conic-gradient(from var(--pa),#ffd34d,#ff5fa2,#a78bfa,#5ec2ff,#7dffb0,#ffd34d);
  -webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);mask-composite:exclude;
  animation:pinRun 2.2s linear infinite}
.chpin::after,.chm.pin .chb::after{content:'';position:absolute;inset:-2px;border-radius:inherit;padding:2px;pointer-events:none;z-index:1;
  background:conic-gradient(from var(--pa),transparent 0deg,transparent 280deg,#ffffffcc 330deg,#fff 350deg,transparent 360deg);
  -webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);mask-composite:exclude;
  animation:pinRun 1.4s linear infinite;filter:drop-shadow(0 0 4px #fff)}
.chpin-ic{font-size:1.3rem;flex:none;filter:drop-shadow(0 2px 4px #0008);animation:pinBob 2.4s ease-in-out infinite}
@keyframes pinBob{0%,100%{transform:rotate(-12deg)}50%{transform:rotate(8deg) translateY(-1px)}}
.chpin-c{flex:1;min-width:0;display:flex;flex-direction:column;line-height:1.25}
.chpin-c b{font-size:.74rem;color:#ffd34d}
.chpin-c span{font-size:.9rem;color:#fff;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;word-break:break-word}
.chpin-c small{font-size:.66rem;color:#ffffff88}
.chpin-x{flex:none;width:30px;height:30px;border:0;border-radius:50%;background:#ffffff1a;color:#fff;font-size:.9rem;cursor:pointer;position:relative;z-index:2}
.chm.pin .chb{isolation:isolate;box-shadow:0 0 14px #ffd34d55}
.chm.pin .chtm::before{content:'📌 ';}
.lite .chpin,.lite .chpin::before,.lite .chpin::after,.lite .chm.pin .chb::before,.lite .chm.pin .chb::after,.lite .chpin-ic{animation:none}
@media (prefers-reduced-motion:reduce){.chpin,.chpin::before,.chpin::after,.chm.pin .chb::before,.chm.pin .chb::after,.chpin-ic{animation:none}}
.cht-t a{color:#9fe8ff;text-decoration:underline;word-break:break-all}.chm.me .cht-t a{color:#fff3b0}