/* ปุ่มลอยมุมขวาล่าง (แชท AI + โทร + LINE) และหน้าต่างแชท */
.fab-stack{position:fixed;right:14px;bottom:calc(14px + env(safe-area-inset-bottom));z-index:55;display:flex;flex-direction:column;align-items:flex-end;gap:10px;font-family:'Prompt',system-ui,sans-serif}
.fab{position:relative;width:52px;height:52px;border-radius:50%;border:0;padding:0;display:grid;place-items:center;text-decoration:none;cursor:pointer;color:#0f2447;box-shadow:0 10px 26px rgba(5,13,28,.32),0 2px 6px rgba(5,13,28,.2);transition:transform .25s cubic-bezier(.2,.7,.2,1),box-shadow .25s}
.fab:hover{transform:translateY(-3px) scale(1.05)}.fab:active{transform:scale(.96)}
.fab-call{background:#f2b705}.fab-line{background:#06c755;color:#fff;font-weight:700;font-size:12px;letter-spacing:.2px;text-shadow:0 1px 2px rgba(0,60,20,.45)}
.fab-call svg{width:24px;height:24px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.fab-ai{width:62px;height:62px;background:#fff;border:3px solid #0f2447}
.fab-ai img{width:44px;height:44px;object-fit:contain;display:block}
.fab-ai::before{content:"";position:absolute;inset:-3px;border-radius:50%;border:2px solid rgba(242,183,5,.7);animation:fabRing 2.6s ease-out infinite;pointer-events:none}
@keyframes fabRing{0%{transform:scale(1);opacity:.9}100%{transform:scale(1.5);opacity:0}}
.fab-ai .tag{position:absolute;right:-4px;top:-4px;background:#f2b705;color:#0f2447;font-size:10px;font-weight:700;line-height:1;padding:4px 5px;border-radius:99px;border:2px solid #fff}
.fab-teaser{position:absolute;right:72px;bottom:10px;white-space:nowrap;background:#fff;color:#0f2447;font-size:14px;font-weight:500;padding:9px 14px;border-radius:16px 16px 4px 16px;box-shadow:0 10px 26px rgba(5,13,28,.25);opacity:0;transform:translateY(6px);pointer-events:none;transition:opacity .4s,transform .4s}
.fab-teaser.show{opacity:1;transform:none;pointer-events:auto;cursor:pointer}
body.chat-open .fab-stack{opacity:0;pointer-events:none}

.chat{position:fixed;z-index:70;right:20px;bottom:20px;width:384px;height:min(600px,calc(100dvh - 40px));display:flex;flex-direction:column;background:#f7f9fc;color:#0f2447;border-radius:22px;overflow:hidden;box-shadow:0 24px 70px rgba(5,13,28,.45);font-family:'Prompt',system-ui,sans-serif;opacity:0;transform:translateY(18px) scale(.97);transform-origin:100% 100%;pointer-events:none;visibility:hidden;transition:opacity .3s,transform .35s cubic-bezier(.2,.7,.2,1),visibility 0s .35s}
.chat.open{opacity:1;transform:none;pointer-events:auto;visibility:visible;transition:opacity .3s,transform .35s cubic-bezier(.2,.7,.2,1)}
.chat-head{flex:none;background:#0f2447;color:#fff;padding:12px 14px;display:flex;align-items:center;gap:12px}
.chat-head .av{width:42px;height:42px;border-radius:50%;background:#f2b705;display:grid;place-items:center;overflow:hidden;flex:none}.chat-head .av img{width:84%;height:84%;object-fit:contain}
.chat-head b{display:block;font-weight:600;font-size:16px;line-height:1.3}.chat-head small{display:block;color:#cfdaee;font-size:12px;line-height:1.3}
.chat-head .x{margin-left:auto;width:36px;height:36px;border-radius:50%;border:0;background:rgba(255,255,255,.12);color:#fff;font-size:22px;line-height:1;cursor:pointer}.chat-head .x:hover{background:rgba(255,255,255,.22)}
.chat-log{flex:1;overflow-y:auto;padding:14px;display:flex;flex-direction:column;gap:10px;scroll-behavior:smooth;overscroll-behavior:contain}
.msg{max-width:86%;padding:10px 13px;border-radius:16px;font-size:15px;line-height:1.6;word-wrap:break-word;overflow-wrap:anywhere;animation:msgIn .3s cubic-bezier(.2,.7,.2,1)}
@keyframes msgIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
.msg.bot{align-self:flex-start;background:#fff;box-shadow:0 1px 0 rgba(15,36,71,.08),0 4px 14px rgba(15,36,71,.06);border-bottom-left-radius:4px}
.msg.me{align-self:flex-end;background:#0f2447;color:#fff;border-bottom-right-radius:4px}
.msg a{color:#2f5aa8;font-weight:500}.msg.me a{color:#f2b705}.msg b{font-weight:600}
.msg.err{background:#fff6e0;color:#5c4300}
.typing{display:inline-flex;gap:5px;padding:12px 14px}.typing i{width:7px;height:7px;border-radius:50%;background:#9fb0cd;animation:tdot 1.1s infinite}.typing i:nth-child(2){animation-delay:.18s}.typing i:nth-child(3){animation-delay:.36s}
@keyframes tdot{0%,60%,100%{transform:none;opacity:.4}30%{transform:translateY(-4px);opacity:1}}
.chips{display:flex;flex-wrap:wrap;gap:8px;padding:0 14px 10px}.chips button{font:inherit;font-size:13px;padding:7px 12px;border-radius:99px;border:1.5px solid rgba(15,36,71,.18);background:#fff;color:#0f2447;cursor:pointer;transition:background .2s,border-color .2s}.chips button:hover{background:#fff7d6;border-color:#f2b705}
.chat-acts{flex:none;display:flex;gap:8px;padding:8px 12px;border-top:1px solid rgba(15,36,71,.08);background:#fff}.chat-acts a{flex:1;text-align:center;text-decoration:none;font-size:13px;font-weight:600;padding:8px 6px;border-radius:99px;color:#0f2447;background:#f2b705;white-space:nowrap}.chat-acts a.l{background:#06c755;color:#0f2447}.chat-acts a.t{background:#eef3fb}
.chat-form{flex:none;display:flex;gap:8px;padding:10px 12px;background:#fff;border-top:1px solid rgba(15,36,71,.08)}
.chat-form input{flex:1;min-width:0;font:inherit;font-size:16px;padding:11px 15px;border-radius:99px;border:2px solid #e3e8f1;background:#f7f9fc;color:#0f2447;outline:none;transition:border-color .2s}.chat-form input:focus{border-color:#f2b705;background:#fff}
.chat-form button{flex:none;width:44px;height:44px;border-radius:50%;border:0;background:#f2b705;color:#0f2447;cursor:pointer;display:grid;place-items:center}.chat-form button:disabled{opacity:.5;cursor:default}.chat-form button svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2.2;stroke-linecap:round;stroke-linejoin:round}
.chat-note{flex:none;font-size:11.5px;color:#6b7a94;text-align:center;padding:0 14px 8px;background:#fff;line-height:1.4}

@media (min-width:901px){.fab-call,.fab-line{display:none}}
@media (max-width:900px){.fab-teaser{right:70px}}
@media (max-width:560px){
  .chat{right:0;left:0;bottom:0;width:100%;height:min(86dvh,720px);border-radius:22px 22px 0 0;transform-origin:50% 100%}
  .fab{width:50px;height:50px}.fab-ai{width:60px;height:60px}.fab-ai img{width:42px;height:42px}
}
@media (prefers-reduced-motion:reduce){.fab-ai::before,.typing i{animation:none}.msg{animation:none}.chat,.chat.open{transition:opacity .2s}}
@media print{.fab-stack,.chat{display:none}}
