/* MahCafe AI helper — right side, light, minimal, responsive */
.mah-ai-launcher{position:fixed;z-index:86;right:max(14px,calc(env(safe-area-inset-right) + 8px));left:auto;bottom:118px;width:50px;height:86px;border:0;padding:0;background:transparent;cursor:pointer;filter:drop-shadow(0 8px 14px rgba(35,24,16,.16));transition:transform .2s ease,opacity .2s ease;touch-action:manipulation}
.mah-ai-launcher:hover{transform:translateY(-2px)}
.mah-ai-launcher:focus-visible{outline:2px solid #c99a62;outline-offset:3px;border-radius:22px}
.mah-ai-launcher::before{content:'کمک می‌خوای؟';position:absolute;top:-14px;right:2px;padding:1px 6px;border-radius:999px;background:rgba(255,253,249,.96);border:1px solid rgba(18,61,44,.08);color:#7b6f61;font:700 9px/1.5 inherit;white-space:nowrap;box-shadow:0 3px 10px rgba(25,35,28,.08)}
.mah-ai-launcher img{display:block;width:100%;height:100%;object-fit:contain;object-position:center bottom;pointer-events:none}
.mah-ai-launcher::after{content:'···';position:absolute;left:-2px;bottom:9px;display:grid;place-items:center;width:24px;height:24px;border:1px solid rgba(18,61,44,.12);border-radius:50%;background:rgba(255,255,255,.96);color:#123d2c;font:800 14px/1 system-ui;box-shadow:0 4px 12px rgba(20,40,31,.12)}
body.mah-ai-open .mah-ai-launcher{opacity:0;pointer-events:none;transform:translateY(6px)}

.mah-ai-panel{pointer-events:none;position:fixed;z-index:130;right:max(12px,calc(env(safe-area-inset-right) + 4px));left:auto;bottom:max(12px,calc(env(safe-area-inset-bottom) + 4px));width:min(380px,calc(100vw - 24px));max-height:min(640px,calc(100dvh - 26px));display:flex;flex-direction:column;overflow:hidden;border:1px solid rgba(18,61,44,.1);border-radius:22px;background:rgba(255,252,248,.98);box-shadow:0 24px 60px rgba(20,30,25,.18);opacity:0;visibility:hidden;transform:translateY(14px) scale(.985);transform-origin:right bottom;transition:opacity .18s ease,transform .18s ease,visibility .18s ease;backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px)}
.mah-ai-panel.is-open{opacity:1;visibility:visible;transform:none;pointer-events:auto}
.mah-ai-head{display:grid;grid-template-columns:40px 1fr 34px;align-items:center;gap:10px;padding:12px 13px 10px;border-bottom:1px solid rgba(18,61,44,.07);background:rgba(255,255,255,.7)}
.mah-ai-head-avatar{width:40px;height:40px;border-radius:14px;overflow:hidden;background:#f4eee8;display:grid;place-items:center}
.mah-ai-head-avatar img{width:36px;height:58px;object-fit:contain;object-position:center 8%;transform:translateY(8px)}
.mah-ai-head-copy{min-width:0;display:flex;flex-direction:column;gap:2px}
.mah-ai-head-copy b{font-size:13px;color:#17372b;font-weight:850}
.mah-ai-head-copy small{font-size:10px;color:#7d847d;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.mah-ai-close{width:32px;height:32px;border:0;border-radius:11px;background:#f3f1ed;color:#5e665f;font:400 22px/1 system-ui;cursor:pointer}

.mah-ai-messages{min-height:220px;overflow:auto;overscroll-behavior:contain;padding:14px 12px 8px;display:flex;flex-direction:column;gap:10px;scrollbar-width:thin;scrollbar-color:#d6d1c9 transparent}
.mah-ai-row{display:flex;max-width:92%}
.mah-ai-row.user{align-self:flex-end;justify-content:flex-end}
.mah-ai-row.assistant{align-self:flex-start;justify-content:flex-start}
.mah-ai-bubble{padding:9px 11px;border-radius:15px;font-size:12.5px;line-height:1.85;white-space:pre-wrap;word-break:break-word}
.mah-ai-row.user .mah-ai-bubble{background:#123d2c;color:#fff;border-bottom-right-radius:5px}
.mah-ai-row.assistant .mah-ai-bubble{background:#f4efe9;color:#3f463f;border-bottom-left-radius:5px}
.mah-ai-thinking{display:inline-flex;align-items:center;gap:4px;min-width:46px}
.mah-ai-thinking i{width:5px;height:5px;border-radius:50%;background:#9b8f80;animation:mahAiDot 1s infinite ease-in-out}
.mah-ai-thinking i:nth-child(2){animation-delay:.14s}.mah-ai-thinking i:nth-child(3){animation-delay:.28s}
@keyframes mahAiDot{0%,65%,100%{opacity:.35;transform:translateY(0)}35%{opacity:1;transform:translateY(-2px)}}

.mah-ai-recs{width:100%;display:flex;flex-direction:column;gap:7px;margin-top:7px}
.mah-ai-rec{display:grid;grid-template-columns:52px minmax(0,1fr) auto;gap:9px;align-items:center;padding:7px;border:1px solid rgba(18,61,44,.08);border-radius:14px;background:#fff}
.mah-ai-rec img{width:52px;height:52px;border-radius:11px;object-fit:cover;background:#eee}
.mah-ai-rec-copy{min-width:0;display:flex;flex-direction:column;gap:2px}
.mah-ai-rec-copy b{font-size:12px;color:#25382f;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.mah-ai-rec-copy small{font-size:10px;color:#8a7560;white-space:nowrap}
.mah-ai-add{border:0;border-radius:10px;background:#edf4f0;color:#123d2c;padding:8px 9px;font:800 10.5px/1 inherit;cursor:pointer;white-space:nowrap}
.mah-ai-add.added{background:#123d2c;color:#fff}
.mah-ai-add-all{align-self:flex-start;border:0;border-radius:10px;background:transparent;color:#816343;font:800 10.5px/1.4 inherit;padding:5px 4px;cursor:pointer}

.mah-ai-quick{display:flex;gap:6px;overflow:auto;padding:0 12px 9px;scrollbar-width:none}
.mah-ai-quick::-webkit-scrollbar{display:none}
.mah-ai-chip{flex:0 0 auto;border:1px solid rgba(18,61,44,.08);border-radius:999px;background:#fff;color:#506057;padding:7px 10px;font:650 10.5px/1.2 inherit;cursor:pointer}

.mah-ai-form{display:grid;grid-template-columns:1fr 42px;gap:7px;padding:9px 10px max(10px,env(safe-area-inset-bottom));border-top:1px solid rgba(18,61,44,.07);background:#fff}
.mah-ai-input{min-width:0;height:42px;border:1px solid rgba(18,61,44,.12);border-radius:14px;background:#faf9f6;padding:0 12px;color:#24372e;font:500 12px/1.4 inherit;outline:none}
.mah-ai-input:focus{border-color:rgba(18,61,44,.3);box-shadow:0 0 0 3px rgba(18,61,44,.05)}
.mah-ai-send{width:42px;height:42px;border:0;border-radius:14px;background:#123d2c;color:#fff;font:700 17px/1 system-ui;cursor:pointer;display:grid;place-items:center}
.mah-ai-send:disabled,.mah-ai-input:disabled{opacity:.55;cursor:not-allowed}
.mah-ai-note{padding:0 12px 8px;color:#9b9e99;font-size:9px;text-align:center}

@media(max-width:480px){
  .mah-ai-launcher{width:48px;height:82px;right:max(12px,calc(env(safe-area-inset-right) + 6px));bottom:108px}
  .mah-ai-launcher::before{top:-12px;right:0;font-size:8.5px;padding:1px 5px}
  .mah-ai-launcher::after{width:22px;height:22px;font-size:12px}
  .mah-ai-panel{right:max(10px,calc(env(safe-area-inset-right) + 2px));bottom:max(10px,calc(env(safe-area-inset-bottom) + 2px));width:calc(100vw - 20px);max-height:calc(100dvh - 20px);border-radius:20px}
  .mah-ai-messages{min-height:180px}
}
@media(min-width:700px){
  .mah-ai-launcher{right:18px;width:52px;height:88px}
  .mah-ai-panel{right:18px;bottom:18px}
}
@media(prefers-reduced-motion:reduce){.mah-ai-launcher,.mah-ai-panel{transition:none}.mah-ai-thinking i{animation:none}}
