.chat-launch {
  position: fixed; z-index: 2; right: max(18px, calc((100vw - 1180px) / 2)); bottom: 18px;
  gap: 9px; padding: 11px 15px; min-height: 48px; border: 1px solid #dfad35; border-radius: 50px;
  background: linear-gradient(#ffd76c, var(--gold)); color: #22301b; box-shadow: 0 9px 24px #183c3050;
}
.chat-symbol {
  width: 17px; height: 14px; position: relative; flex: none; border: 1.6px solid currentColor; border-radius: 5px;
}
.chat-symbol::after {
  content: ""; position: absolute; width: 5px; height: 5px; inset: auto auto -3px 3px;
  transform: skewY(-35deg); border: solid currentColor; border-width: 0 0 1.6px 1.6px; background: var(--gold);
}
#chat {
  position: fixed; inset: auto max(16px, calc((100vw - 1180px) / 2)) 16px auto; margin: 0; padding: 0;
  width: min(440px, calc(100vw - 32px)); height: min(660px, calc(100dvh - 32px)); max-height: none;
  border: 1px solid #c9dbd0; border-radius: 22px; background: #f5f9f5; box-shadow: 0 22px 75px #0c382e50;
  overflow: hidden;
}
#chat::backdrop { background: #122e241f; }
.chat-shell { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; }
.chat-header {
  display: flex; align-items: center; justify-content: space-between; gap: 9px; padding: 15px;
  background: radial-gradient(ellipse at 5% 0, #377351, transparent 75%), #10392d; color: white;
}
.chat-identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-avatar {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 14px;
  color: #214b18; background: #d9f3bf; font-weight: 700; font-size: 21px;
}
.chat-avatar.mini { width: 27px; height: 27px; border-radius: 9px; font-size: 12px; }
.chat-identity h2 { margin: 0; font-size: 17px; letter-spacing: -.03em; }
.chat-identity p { margin: 2px 0 0; color: #d5eadf; font-size: 11px; line-height: 1.35; }
.chat-close {
  width: 37px; min-height: 37px; padding: 0; flex: none; border-radius: 11px;
  border-color: #ffffff45; background: #ffffff13; color: white; font-size: 23px;
}
#messages { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 16px 13px; scrollbar-width: thin; }
.chat-turn { display: flex; align-items: end; gap: 7px; margin-bottom: 11px; }
.chat-turn.customer { justify-content: flex-end; }
.bubble {
  width: fit-content; max-width: 89%; margin: 0; padding: 9px 12px; border-radius: 14px 14px 14px 4px;
  border: 1px solid #e0eade; background: white; color: #173429; font-size: 13px;
  white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 2px 6px #163d2b08;
}
.customer .bubble { border-radius: 14px 14px 4px 14px; border-color: #cde4bb; background: #e5f5d9; }
.bubble.typing { color: #4d685a; }
.chat-error .bubble { background: #fff8e4; border-color: #eddca7; }
.chat-retry { display: block; min-height: 30px; padding: 4px 8px; margin-top: 6px; background: white; border-color: #d9c889; font-size: 11px; }
.chat-controls { padding: 10px 12px; border-top: 1px solid #dce8df; background: #fff; }
.suggestions { display: flex; gap: 6px; overflow: auto; padding: 4px 0 8px; scrollbar-width: thin; }
.suggestions button {
  flex: none; white-space: nowrap; min-height: 30px; padding: 4px 8px; border-radius: 99px;
  border-color: #cfdfd1; background: #f4faf2; color: #2c543e; font-size: 11px;
}
.chat-composer { display: flex; align-items: end; gap: 6px; }
.chat-composer textarea {
  flex: 1; min-width: 0; min-height: 42px; max-height: 100px; margin: 0; padding: 9px; resize: vertical;
  border-color: #c6d8ca; font-size: 13px; background: #fbfdfa;
}
.chat-send { width: 42px; min-height: 42px; padding: 0; border-radius: 12px; font-size: 22px; background: #73bd32; }
.chat-footer { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 5px; }
.chat-footer p { margin: 0; color: #4d6859; font-size: 10px; }
.chat-footer button { min-height: 30px; padding: 4px 0 4px 5px; border: 0; background: none; color: #305f26; font-size: 11px; }
.chat-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-height: 490px) {
  .chat-header { padding-block: 7px; }
  .chat-controls { padding-block: 5px; }
}
#chat.chat-expanded { width:min(720px,calc(100vw - 32px)); height:min(830px,calc(100dvh - 32px)); }
.chat-shell { grid-template-rows:auto minmax(0,1fr) auto auto; }
#chat:has(.chat-checkout:not(:empty)) .chat-shell { grid-template-rows:auto minmax(0,1fr) minmax(0,5fr); }
.chat-checkout:not(:empty) { min-height:0; min-width:0; overflow:auto; padding:0 12px 12px; background:#fff; border-top:1px solid var(--line); overscroll-behavior:contain; }
.chat-checkout .dialog-heading { padding-top:8px; }
.chat-checkout:empty { display:none; }
.chat-product-deck { display:grid; gap:8px; margin:6px 0 12px 30px; }
.chat-product { display:flex; gap:8px; padding:8px; border:1px solid #dce8df; border-radius:12px; background:#fff; }
.chat-product a { flex:none; }
.chat-product img { display:block; width:75px; height:78px; object-fit:cover; border-radius:8px; }
.chat-product p,.chat-product small { display:block; margin:0; }
.chat-product button { margin-top:4px; min-height:34px; }
.payment-indicator { display:none; }
[data-state=paid] .payment-indicator,[data-state=deposit] .payment-indicator,[data-state=pending] .payment-indicator,[data-state=cancelled] .payment-indicator { display:grid; place-items:center; width:44px; height:44px; margin:8px 0; border-radius:50%; font-size:23px; background:#fff2cc; color:#684800; }
[data-state=paid] .payment-indicator { background:#d9f2d3; color:#2b6b22; }
[data-state=deposit] .payment-indicator { background:#d9eaff; color:#175697; }
[data-state=cancelled] .payment-indicator { background:#f9e5d9; color:#8e3d17; }
@media(prefers-reduced-motion:no-preference){ [data-state=paid] .payment-indicator,[data-state=deposit] .payment-indicator { animation:receipt-pop .3s ease-out; } @keyframes receipt-pop{from{transform:scale(.75);opacity:.4}} }
.chat-image-preview { display:flex; gap:8px; align-items:center; margin-bottom:5px; }
.chat-image-preview img,.chat-image-thumb { display:block; width:68px; max-height:68px; object-fit:contain; border-radius:6px; }
.chat-image-thumb { width:auto; max-height:180px; max-width:100%; margin-top:6px; }
#chat-attach { min-width:43px; }

#chat .bubble { font-size:15px; line-height:1.55; user-select:text; -webkit-user-select:text; }
#chat .chat-turn { margin-bottom:14px; }
#chat-header { touch-action:pan-x; }
#chat .chat-close,#chat .chat-send,#chat #chat-attach { min-width:44px; min-height:44px; }
#chat .suggestions { gap:8px; overscroll-behavior-inline:contain; touch-action:pan-x; }
#chat .suggestions button { min-height:44px; font-size:13px; padding-inline:12px; }
#chat .suggestions button:active { background:#d8edc9; transform:scale(.97); }
#chat .chat-composer textarea { font-size:16px; min-height:46px; max-height:124px; resize:none; }
#chat .chat-controls { padding:10px max(12px,env(safe-area-inset-right)) max(10px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left)); }
#chat-latest { position:absolute; z-index:2; right:14px; bottom:calc(136px + env(safe-area-inset-bottom)); min-height:44px; border-radius:24px; }
#chat:has(.chat-checkout:not(:empty)) #chat-latest { display:none; }
#chat .typing { display:flex; gap:6px; align-items:center; min-height:44px; }
.typing-dot { width:7px; height:7px; border-radius:50%; background:#56795a; }
#chat-photo { inset:0; width:100vw; height:100dvh; max-width:none; max-height:none; margin:0; padding:16px; border:0; border-radius:0; color:white; background:#0e2219; touch-action:none; }
#chat-photo[open] { display:grid; place-items:center; }
#chat-photo figure { margin:0; text-align:center; }
#chat-photo img { max-width:100%; max-height:77dvh; object-fit:contain; }
#chat-photo-close { position:absolute; top:max(12px,env(safe-area-inset-top)); right:14px; z-index:1; min-width:44px; font-size:22px; }
@media (prefers-reduced-motion:no-preference){
  #chat .assistant,#chat .chat-product-deck { animation:chat-rise .23s ease-out both; }
  .typing-dot { animation:chat-dot .85s ease-in-out infinite alternate; }
  .typing-dot:nth-child(2) { animation-delay:.13s; }
  .typing-dot:nth-child(3) { animation-delay:.26s; }
  @keyframes chat-rise { from { opacity:0; transform:translateY(7px); } }
  @keyframes chat-dot { to { transform:translateY(-4px); opacity:.5; } }
}
@media(prefers-color-scheme:dark){
  .storefront #chat { background:#14231d; color:#e3f0e7; }
  #chat .chat-controls,#chat .chat-checkout,#chat .bubble,#chat .chat-product { background:#203129; color:#eff8ef; border-color:#43594a; }
  #chat .customer .bubble { background:#31533a; }
  #chat .chat-composer textarea { background:#172820; color:#eff8ef; }
  #chat .chat-footer p,#chat .chat-footer button,#chat .typing { color:#c6dfca; }
}
#chat .chat-product button,#chat .chat-footer button { min-height:44px; }
html:has(#chat[open]) { overflow:hidden; }
@media(prefers-color-scheme:dark){
  #chat .shipping-summary,#chat .pay-data { background:#283e32; color:#eff8ef; border-color:#486052; }
  #chat .bubble.typing .typing-dot { background:#9fcea1; }
  #chat .chat-checkout .checkout-note,#chat .chat-checkout .pay-hint { color:#d0e0d3; }
}
#chat #chat-cart-feedback { font-size:12px; overflow-wrap:anywhere; }

#chat .chat-header-actions { flex:none; flex-wrap:nowrap; gap:5px; }
#chat .chat-identity { flex:1; min-width:0; }
#chat .chat-identity div { min-width:0; }
#chat .chat-identity h2,#chat .chat-identity p { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#chat #chat-order { position:relative; width:44px; padding:0; background:#ffffff13; border-color:#ffffff45; color:white; }
#chat #chat-order:disabled { opacity:.65; cursor:default; }
#chat-cart-count { position:absolute; top:1px; right:1px; min-width:17px; padding:1px 3px; border-radius:10px; background:#fbbb25; color:#1d321e; font-size:10px; line-height:1.2; text-align:center; }
#chat-cart-feedback { position:absolute; bottom:calc(116px + env(safe-area-inset-bottom)); left:12px; right:12px; z-index:3; margin:0; pointer-events:none; }
#chat-cart-feedback:not(:empty) { padding:8px 12px; border-radius:11px; background:#163a2c; color:#fff; box-shadow:0 4px 12px #102f2433; }
#chat-latest { bottom:calc(116px + env(safe-area-inset-bottom)); }
#chat .chat-composer { min-width:0; }
#chat .chat-composer textarea:focus::placeholder { opacity:0; }
#chat .chat-product a { min-width:44px; min-height:44px; }
@media(max-width:650px), (pointer:coarse) and (max-height:500px){
  .storefront #chat,.storefront #chat.chat-expanded {
    --visible: min(100dvh,var(--chat-height,100dvh));
    --sheet-gap: max(8px,env(safe-area-inset-bottom));
    --sheet-height: calc(var(--visible) * .90);
    box-sizing:border-box;
    inset:calc(var(--chat-top,0px) + var(--visible) - var(--sheet-gap) - var(--sheet-height)) 0 auto;
    margin:0 auto;
    width:calc(100% - max(8px,env(safe-area-inset-left)) - max(8px,env(safe-area-inset-right)));
    height:var(--sheet-height);
    border:1px solid #c9dbd0;
    border-radius:18px;
  }
  .storefront #chat.chat-expanded { --sheet-height:calc(var(--visible) * .96 - var(--sheet-gap)); }
  .storefront #chat.chat-keyboard { --sheet-gap:0px; --sheet-height:var(--visible); border-radius:12px 12px 0 0; }
  .storefront #chat::backdrop { background:#102a2190; }
  .storefront .chat-launch { bottom:max(14px,env(safe-area-inset-bottom)); right:max(14px,env(safe-area-inset-right)); }
  #chat .chat-header { gap:6px; padding:6px 9px; }
  #chat .chat-identity { gap:7px; }
  #chat .chat-identity .chat-avatar { width:34px;height:34px;font-size:17px; }
  #chat .chat-identity h2 { font-size:15px; }
  #chat .chat-controls { min-width:0; padding:6px 9px; }
  #chat .suggestions { gap:9px; padding-block:0 6px; }
  #chat .suggestions button { padding-inline:12px; }
  #chat .chat-checkout:not(:empty) { padding-inline:8px; }
}
.chat-review { margin:8px 8px 12px 30px; overflow-wrap:anywhere; } .chat-review p { margin:4px 0; } .chat-draft-action,#cancel-chat-order { min-height:44px; } @media(prefers-color-scheme:dark){ #chat .chat-review { background:#203129; border-color:#43594a; } }

@media(prefers-color-scheme:dark){ #chat .chat-checkout { --checkout-surface:#203129; --checkout-line:#43594a; --checkout-muted:#c6dfca; } }
