/* "ถามพี" member chat. Same calm look as bevel.css: light page, white cards, ink buttons.
   Shown only when coach-chat.js has set html[data-coach-chat="on"] for a signed-in member. */
#coach-chat-open,#coach-chat{--cc-page:#f2f4f8;--cc-card:#fff;--cc-ink:#141922;--cc-muted:#667080;--cc-line:#e3e7ee;--cc-soft:#edf0f5;--cc-teal:#0a8f84;--cc-glow:#9ffcf0;--cc-mint:#dff2ee;--cc-ease:cubic-bezier(.2,.8,.2,1)}

#coach-chat-open{display:none}
html[data-coach-chat="on"] body.focus-client #coach-chat-open:not([hidden]){display:grid}
/* Never over the set-by-set logger: a mis-tap there would open the chat mid-set. */
html[data-coach-chat="on"] body.focus-client:has([data-workout-log]) #coach-chat-open:not([hidden]){display:none}
#coach-chat-open{position:fixed;z-index:30;right:max(16px,calc(50% - 210px));bottom:calc(max(12px,env(safe-area-inset-bottom)) + 82px);width:62px;height:62px;place-items:center;padding:0;border:0;border-radius:50%;background:var(--cc-card);box-shadow:0 10px 24px rgba(20,25,34,.2);cursor:pointer;transition:transform .2s var(--cc-ease)}
#coach-chat-open.cc-away{display:none!important}
#coach-chat-open:active{transform:scale(.94)}
#coach-chat-open img{width:54px;height:54px;display:block;animation:cc-bob 2.8s ease-in-out infinite}
#coach-chat-open::after{content:"";position:absolute;inset:0;border-radius:50%;animation:cc-ring 2.8s ease-out infinite}
#coach-chat-open:focus-visible,#coach-chat :focus-visible{outline:3px solid #5a6bf0;outline-offset:2px}

#coach-chat{box-sizing:border-box;position:fixed;inset:auto 0 0 0;margin:0 auto;width:100%;max-width:440px;height:min(100dvh,780px);max-height:100dvh;padding:0;border:0;border-radius:28px 28px 0 0;background:var(--cc-page);color:var(--cc-ink);overflow:hidden;font-size:15px;line-height:1.5}
#coach-chat[open]{display:flex;flex-direction:column;animation:cc-sheet .42s var(--cc-ease) both}
#coach-chat::backdrop{background:rgba(20,25,34,.45)}
#coach-chat *,#coach-chat *::before,#coach-chat *::after{box-sizing:border-box}
#coach-chat [hidden]{display:none}
#coach-chat button{font:inherit;color:inherit;cursor:pointer;border:0;background:none;padding:0}
#coach-chat p{margin:0}

#coach-chat .cc-who{flex:none;position:relative;z-index:1;padding:12px 16px 14px;border-radius:0 0 28px 28px;background:linear-gradient(180deg,var(--cc-mint) 0,var(--cc-card) 78%);box-shadow:0 1px 2px rgba(20,25,34,.05),0 8px 24px rgba(20,25,34,.05)}
#coach-chat .cc-bar{display:flex;align-items:center;gap:10px;min-height:44px}
#coach-chat .cc-icon{flex:none;width:40px;height:40px;border-radius:50%;background:rgba(255,255,255,.75);display:grid;place-items:center;font-size:20px;line-height:1}
#coach-chat .cc-id{flex:1;min-width:0;display:flex;align-items:center;gap:10px}
#coach-chat .cc-avatar{flex:none;width:44px;height:44px;border-radius:50%;background:var(--cc-card);opacity:0;transform:scale(.6);transition:opacity .3s,transform .35s var(--cc-ease)}
#coach-chat .cc-name{font-weight:700;font-size:16px;line-height:1.25}
#coach-chat .cc-sub{font-size:12px;font-weight:500;color:var(--cc-teal)}
#coach-chat .cc-figure{height:176px;display:grid;place-items:center;overflow:hidden;transition:height .4s var(--cc-ease),opacity .25s}
#coach-chat .cc-figure .cc-stk{height:176px}
#coach-chat .cc-hello{margin:6px 0 2px;text-align:center;font-size:17px;font-weight:600;max-height:80px;overflow:hidden;transition:max-height .4s var(--cc-ease),opacity .25s}
#coach-chat .cc-who.compact .cc-figure{height:0;opacity:0}
#coach-chat .cc-who.compact .cc-hello{max-height:0;opacity:0;margin:0}
#coach-chat .cc-who.compact .cc-avatar{opacity:1;transform:none}

#coach-chat .cc-log{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;display:flex;flex-direction:column;gap:10px;padding:16px 16px 12px}
#coach-chat .cc-msg{display:flex;flex-direction:column;gap:10px;min-width:0;max-width:88%;padding:12px 14px;border-radius:20px;animation:cc-rise .32s var(--cc-ease) both}
#coach-chat .cc-msg.bot{align-self:flex-start;background:var(--cc-card);border-top-left-radius:6px;box-shadow:0 1px 2px rgba(20,25,34,.05)}
#coach-chat .cc-msg.me{align-self:flex-end;background:var(--cc-ink);color:#fff;border-top-right-radius:6px}
#coach-chat .cc-msg.wide{width:100%;max-width:100%;gap:12px;padding:14px}
#coach-chat .cc-msg.wide>*{animation:cc-rise .45s var(--cc-ease) both}
#coach-chat .cc-msg.wide>*:nth-child(2){animation-delay:.08s}
#coach-chat .cc-msg.wide>*:nth-child(3){animation-delay:.16s}
#coach-chat .cc-msg.wide>*:nth-child(4){animation-delay:.24s}
#coach-chat .cc-msg.wide>*:nth-child(n+5){animation-delay:.32s}
#coach-chat .cc-lead{display:flex;align-items:flex-end;gap:10px}
#coach-chat .cc-lead p{flex:1;min-width:0;padding-bottom:8px}
#coach-chat .cc-note,#coach-chat .cc-label{font-size:12px;color:var(--cc-muted)}
#coach-chat .cc-label{font-weight:600}

#coach-chat .cc-stk{display:block;height:88px;width:auto;max-width:none;flex:none;transform-origin:50% 100%;animation:cc-stk-in .55s var(--cc-ease) both,var(--cc-loop,cc-bob) var(--cc-beat,1.6s) ease-in-out .55s infinite}
#coach-chat .cc-stk.small{height:54px}
#coach-chat .cc-stk.think{--cc-loop:cc-rock;--cc-beat:1.4s}
#coach-chat .cc-stk.point{--cc-loop:cc-nudge;--cc-beat:1s}
#coach-chat .cc-stk.thumbs-up{--cc-loop:cc-bob;--cc-beat:.9s}
#coach-chat .cc-stk.cheer{--cc-loop:cc-jump;--cc-beat:.6s}
#coach-chat .cc-stk.care{--cc-loop:cc-sway;--cc-beat:2.6s}
#coach-chat .cc-stk.plan{--cc-loop:cc-sway;--cc-beat:1.8s}
#coach-chat .cc-stk.food{--cc-loop:cc-bob;--cc-beat:1.6s}
#coach-chat .cc-stk.lift{--cc-loop:cc-pump;--cc-beat:.8s}
#coach-chat .cc-stk.greet{animation:cc-hop .7s var(--cc-ease) both,cc-sway 2.4s ease-in-out .7s infinite}

#coach-chat .cc-facts{display:grid;grid-template-columns:1fr 1fr;gap:8px;font-variant-numeric:tabular-nums}
#coach-chat .cc-fact{min-width:0;padding:10px 12px;border-radius:14px;background:var(--cc-soft);animation:cc-pop .42s var(--cc-ease) both}
#coach-chat .cc-fact:nth-child(2){animation-delay:.07s}
#coach-chat .cc-fact:nth-child(3){animation-delay:.14s}
#coach-chat .cc-fact:nth-child(4){animation-delay:.21s}
#coach-chat .cc-fact span{display:block;font-size:12px;color:var(--cc-muted)}
#coach-chat .cc-fact b{font-size:20px;line-height:1.3;font-weight:700}
#coach-chat .cc-fact.now{background:var(--cc-ink);color:#fff}
#coach-chat .cc-fact.now span{color:var(--cc-glow)}
#coach-chat .cc-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}
#coach-chat .cc-ideas{margin:0;padding:0;list-style:none;display:flex;flex-direction:column;gap:6px;font-variant-numeric:tabular-nums}
#coach-chat .cc-ideas li{display:flex;flex-direction:column;padding:10px 12px;border-radius:14px;background:var(--cc-soft)}
#coach-chat .cc-ideas b{font-weight:600}
#coach-chat .cc-ideas span{font-size:12px;color:var(--cc-muted)}
#coach-chat .cc-btn{display:flex;align-items:center;justify-content:center;width:100%;min-height:44px;padding:0 18px;border-radius:14px;background:var(--cc-soft);color:var(--cc-ink);font-weight:600;text-decoration:none}
#coach-chat .cc-btn.ink{background:var(--cc-ink);color:#fff}
#coach-chat .cc-btn:disabled{opacity:.5;cursor:default}
#coach-chat .cc-form{display:flex;flex-direction:column;gap:12px}
#coach-chat .cc-field{display:flex;flex-direction:column;gap:6px}
#coach-chat .cc-seg{display:grid;grid-auto-flow:column;grid-auto-columns:1fr;gap:4px;padding:4px;border-radius:14px;background:var(--cc-soft)}
#coach-chat .cc-seg button{min-height:40px;padding:0 4px;border-radius:11px;font-size:13px;font-weight:600;color:var(--cc-muted);line-height:1.25}
#coach-chat .cc-seg button[aria-pressed="true"]{background:var(--cc-card);color:var(--cc-ink);box-shadow:0 1px 3px rgba(20,25,34,.12)}
#coach-chat .cc-days{display:flex;flex-direction:column;gap:6px}
#coach-chat .cc-day{border-radius:14px;background:var(--cc-soft);padding:0 12px}
#coach-chat .cc-day summary{display:flex;align-items:center;justify-content:space-between;gap:10px;min-height:44px;cursor:pointer;list-style:none}
#coach-chat .cc-day summary::-webkit-details-marker{display:none}
#coach-chat .cc-day summary b{font-weight:600}
#coach-chat .cc-day summary span{flex:none;font-size:12px;color:var(--cc-muted)}
#coach-chat .cc-day ul{margin:0;padding:0 0 10px;list-style:none;display:flex;flex-direction:column;gap:6px;font-variant-numeric:tabular-nums}
#coach-chat .cc-day li{display:flex;justify-content:space-between;gap:10px;font-size:14px}
#coach-chat .cc-day li .cc-sets{flex:none;color:var(--cc-muted)}
#coach-chat .cc-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px}

#coach-chat .cc-dots{display:inline-flex;gap:5px;padding:5px 2px 12px}
#coach-chat .cc-dots i{width:7px;height:7px;border-radius:50%;background:var(--cc-muted);animation:cc-dot 1s infinite}
#coach-chat .cc-dots i:nth-child(2){animation-delay:.15s}
#coach-chat .cc-dots i:nth-child(3){animation-delay:.3s}

#coach-chat .cc-chips{flex:none;display:flex;gap:8px;overflow-x:auto;padding:4px 16px 10px;scrollbar-width:none}
#coach-chat .cc-chips::-webkit-scrollbar{display:none}
#coach-chat .cc-chip{flex:none;white-space:nowrap;padding:9px 14px;border-radius:999px;background:var(--cc-card);font-size:14px;font-weight:600;box-shadow:0 1px 2px rgba(20,25,34,.07)}
#coach-chat .cc-ask{flex:none;display:flex;gap:8px;padding:0 16px calc(14px + env(safe-area-inset-bottom))}
#coach-chat .cc-chips:last-child,#coach-chat .cc-chips:has(+ .cc-ask[hidden]){padding-bottom:calc(14px + env(safe-area-inset-bottom))}
#coach-chat .cc-ask input{flex:1;min-width:0;height:48px;padding:0 14px;border:1px solid var(--cc-line);border-radius:16px;background:var(--cc-card);color:var(--cc-ink);font:inherit;font-size:16px}
#coach-chat .cc-ask input::placeholder{color:var(--cc-muted)}
#coach-chat .cc-ask button{flex:none;width:48px;height:48px;border-radius:16px;background:var(--cc-ink);color:#fff;font-size:20px}
#coach-chat .cc-ask.busy button{opacity:.45}

@keyframes cc-sheet{from{transform:translateY(40px);opacity:0}to{transform:none;opacity:1}}
@keyframes cc-rise{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
@keyframes cc-pop{from{opacity:0;transform:scale(.9)}to{opacity:1;transform:none}}
@keyframes cc-dot{0%,60%,100%{opacity:.25;transform:none}30%{opacity:1;transform:translateY(-3px)}}
@keyframes cc-ring{0%{box-shadow:0 0 0 0 rgba(19,165,150,.45)}70%,100%{box-shadow:0 0 0 16px rgba(19,165,150,0)}}
@keyframes cc-stk-in{0%{opacity:0;transform:translateY(14px) scale(.6)}65%{opacity:1;transform:translateY(-4px) scale(1.06)}100%{opacity:1;transform:none}}
@keyframes cc-hop{0%{opacity:0;transform:translateY(40px) scale(.8)}60%{opacity:1;transform:translateY(-12px) scale(1.04)}100%{opacity:1;transform:none}}
@keyframes cc-bob{50%{transform:translateY(-4px)}}
@keyframes cc-rock{0%,100%{transform:rotate(-4deg)}50%{transform:rotate(4deg)}}
@keyframes cc-nudge{50%{transform:translateX(6px)}}
@keyframes cc-jump{0%,100%{transform:none}40%{transform:translateY(-18px) scaleY(1.04)}}
@keyframes cc-sway{0%,100%{transform:rotate(-2deg)}50%{transform:rotate(2deg)}}
@keyframes cc-pump{50%{transform:translateY(-5px) scaleY(1.025)}}

@media (prefers-reduced-motion:reduce){
 #coach-chat-open img,#coach-chat-open::after,#coach-chat,#coach-chat *,#coach-chat *::before,#coach-chat *::after{animation:none!important;transition:none!important}
}

#coach-chat .cc-quota{flex:none;display:flex;flex-direction:column;gap:6px;padding:8px 16px 0;font-size:12.5px;line-height:1.4;color:var(--cc-muted)}
#coach-chat .cc-quota[hidden]{display:none}
#coach-chat .cc-quota progress{appearance:none;-webkit-appearance:none;width:100%;height:6px;border:0;border-radius:6px;overflow:hidden;background:rgba(0,0,0,.08)}
#coach-chat .cc-quota progress::-webkit-progress-bar{background:rgba(0,0,0,.08)}
#coach-chat .cc-quota progress::-webkit-progress-value{background:var(--cc-teal);border-radius:6px;transition:width .5s ease}
#coach-chat .cc-quota progress::-moz-progress-bar{background:var(--cc-teal);border-radius:6px}
#coach-chat .cc-quota.low progress::-webkit-progress-value{background:#d98a2b}
#coach-chat .cc-quota.low progress::-moz-progress-bar{background:#d98a2b}
@media (prefers-reduced-motion:reduce){#coach-chat .cc-quota progress::-webkit-progress-value{transition:none}}

/* ฝึกวันนี้ in the chat (2026-11-16) */
#coach-chat .cc-seg.wrap{grid-auto-flow:row;grid-template-columns:repeat(3,1fr)}
#coach-chat .cc-today{padding:4px 12px 8px}
#coach-chat .cc-today .cc-sum{margin:8px 0 2px;font-size:13px;color:var(--cc-muted)}

/* "ให้ตั้งชื่อโปรแกรมว่าอะไร" under the ฝึกวันนี้ preview (2026-11-17). 16px text so iPhone does not zoom on focus. */
#coach-chat .cc-rname{display:flex;flex-direction:column;gap:4px;margin:12px 0 2px}
#coach-chat .cc-rname label{font-size:14px;font-weight:600;color:var(--cc-ink)}
#coach-chat .cc-rname input{width:100%;box-sizing:border-box;min-height:48px;padding:0 14px;border:1px solid var(--cc-line);border-radius:14px;background:var(--cc-card);color:var(--cc-ink);font:inherit;font-size:16px}
#coach-chat .cc-rname input:focus-visible{outline:2px solid var(--cc-ink);outline-offset:1px}
#coach-chat .cc-rname .cc-hint{margin:0;font-size:12px;line-height:1.5;color:var(--cc-muted)}
