@font-face{font-family:Vazirmatn;src:url(../fonts/Vazirmatn.woff2) format('woff2');font-weight:100 900;font-display:swap}
:root{
  --blue:#2563eb;--blue-600:#1d4ed8;--blue-800:#1e3a8a;--sky:#38bdf8;
  --bg:#ffffff;--panel:#f6f9ff;--soft:#f4f8ff;--soft-2:#eaf2ff;--line:#e3ebf8;
  --text:#0f1b3d;--muted:#5b6b8c;--ok:#10b981;--no:#ef4444;--warn:#f59e0b;
  --bubble-bot:#f2f6fd;--bubble-user:#2563eb;--code:#0b1736;
  --grad:linear-gradient(135deg,#1d4ed8 0%,#2563eb 45%,#38bdf8 100%);
  --shadow:0 10px 30px -12px rgba(30,64,175,.25);--shadow-lg:0 30px 60px -20px rgba(30,64,175,.35);
  --side-w:300px;
}
:root[data-theme=dark]{
  --bg:#0b1220;--panel:#0f182b;--soft:#121c31;--soft-2:#172542;--line:#1e2b47;--text:#e7edf9;--muted:#93a3c4;
  --bubble-bot:#131e35;--bubble-user:#2563eb;--code:#050a16;--shadow:0 10px 30px -12px rgba(0,0,0,.6);--shadow-lg:0 30px 60px -20px rgba(0,0,0,.7)
}
*{box-sizing:border-box;margin:0;padding:0;-webkit-tap-highlight-color:transparent}
html,body{height:100%}
body{font-family:Vazirmatn,Tahoma,sans-serif;background:var(--bg);color:var(--text);line-height:1.8;-webkit-font-smoothing:antialiased;overflow:hidden}
button{font-family:inherit;cursor:pointer;color:inherit}
input,textarea,select{font-family:inherit;color:inherit}
a{color:inherit;text-decoration:none}
[hidden]{display:none!important}
svg{width:20px;height:20px;flex-shrink:0}
.grow{flex:1}

/* دکمه‌ها */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:.5rem;padding:.75rem 1.3rem;border-radius:14px;font-weight:700;border:0;font-size:.98rem;transition:.2s}
.btn-primary{background:var(--grad);color:#fff;box-shadow:0 10px 22px -10px rgba(37,99,235,.7)}
.btn-primary:hover{transform:translateY(-1px)}
.btn-ghost{background:var(--bg);border:1.5px solid var(--line);color:var(--blue)}
.btn-ghost:hover{border-color:var(--blue);background:var(--soft)}
.btn[disabled]{opacity:.6;cursor:not-allowed;transform:none}
.icon-btn{width:40px;height:40px;border-radius:12px;border:0;background:transparent;display:grid;place-items:center;color:var(--muted);transition:.2s}
.icon-btn:hover{background:var(--soft-2);color:var(--blue)}
.linkbtn{background:none;border:0;color:var(--blue);font-weight:700;font-size:.9rem}
.only-m{display:none}

/* چیدمان */
.app{display:flex;height:100dvh;overflow:hidden}
.side{width:var(--side-w);background:var(--panel);border-inline-end:1px solid var(--line);display:flex;flex-direction:column;padding:14px 12px;gap:10px;flex-shrink:0;z-index:40;transition:transform .3s}
.side-top{display:flex;align-items:center;justify-content:space-between;padding:2px 4px}
.brand{display:flex;align-items:center;gap:.5rem;font-weight:900;font-size:1.25rem}
.brand svg{width:34px;height:34px}
.new-chat{width:100%}
.search input{width:100%;padding:.6rem .9rem;border-radius:12px;border:1.5px solid var(--line);background:var(--bg);outline:none;font-size:.92rem}
.search input:focus{border-color:var(--blue)}
.convs{flex:1;overflow-y:auto;margin:0 -4px;padding:0 4px;scrollbar-width:thin}
.grp{font-size:.75rem;color:var(--muted);font-weight:700;padding:10px 8px 4px}
.conv{display:flex;align-items:center;gap:4px;padding:.55rem .7rem;border-radius:12px;cursor:pointer;font-size:.93rem;position:relative;transition:.15s}
.conv:hover{background:var(--soft-2)}
.conv.active{background:var(--soft-2);color:var(--blue-600);font-weight:700}
:root[data-theme=dark] .conv.active{color:var(--sky)}
.conv .t{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.conv .acts{display:none;gap:2px}
.conv:hover .acts,.conv.active .acts{display:flex}
.conv .acts button{width:28px;height:28px;border:0;background:transparent;border-radius:8px;display:grid;place-items:center;color:var(--muted)}
.conv .acts button:hover{background:var(--bg);color:var(--blue)}
.conv .acts button.del:hover{color:var(--no)}
.conv .acts svg{width:16px;height:16px}
.nores{color:var(--muted);text-align:center;padding:24px 8px;font-size:.9rem}
.side-foot{border-top:1px solid var(--line);padding-top:10px;display:grid;gap:8px}
.usage{background:var(--bg);border:1px solid var(--line);border-radius:14px;padding:10px 12px}
.usage-row{display:flex;align-items:center;justify-content:space-between}
.plan-badge{font-weight:800;font-size:.85rem;background:var(--soft-2);color:var(--blue-600);padding:.1rem .7rem;border-radius:99px}
:root[data-theme=dark] .plan-badge{color:var(--sky)}
.bar{height:6px;background:var(--soft-2);border-radius:99px;overflow:hidden;margin:8px 0 4px}
.bar i{display:block;height:100%;background:var(--grad);border-radius:99px;transition:width .5s}
.bar.low i{background:linear-gradient(90deg,#f59e0b,#ef4444)}
.usage-sub{font-size:.78rem;color:var(--muted)}
.foot-actions{display:flex;justify-content:space-between}
.who{font-size:.78rem;color:var(--muted);text-align:center}

.main{flex:1;display:flex;flex-direction:column;min-width:0;position:relative;background:var(--bg)}
.top{display:flex;align-items:center;gap:8px;padding:10px 16px;border-bottom:1px solid var(--line);background:var(--bg);position:relative;z-index:5}
.model-pick{position:relative}
.model-btn{display:flex;align-items:center;gap:.4rem;border:1.5px solid var(--line);background:var(--bg);padding:.45rem .9rem;border-radius:12px;font-weight:700;font-size:.95rem}
.model-btn:hover{border-color:var(--blue)}
.model-btn svg{width:16px;height:16px;color:var(--muted)}
.model-menu{position:absolute;top:calc(100% + 8px);inset-inline-start:0;width:min(380px,92vw);background:var(--bg);border:1px solid var(--line);border-radius:16px;box-shadow:var(--shadow-lg);padding:6px;z-index:30;max-height:min(72vh,600px);overflow-y:auto;overscroll-behavior:contain}
.mopt{display:flex;gap:10px;align-items:center;width:100%;text-align:start;border:0;background:transparent;padding:.6rem .8rem;border-radius:12px}
.mopt:hover{background:var(--soft-2)}
.mopt.sel{background:var(--soft-2)}
.mopt b{display:block;font-size:.95rem}.mopt small{color:var(--muted);font-size:.8rem;line-height:1.5;display:block}
.mopt .lk{margin-inline-start:auto;color:var(--muted);display:flex;align-items:center;gap:.25rem;font-size:.75rem;white-space:nowrap}
.mopt .lk svg{width:15px;height:15px}
.mopt.locked{opacity:.7}
.chip{display:flex;align-items:center;gap:.4rem;border:1px solid var(--line);background:var(--soft);border-radius:99px;padding:.3rem .9rem;font-size:.85rem;font-weight:700;color:var(--blue-600)}
:root[data-theme=dark] .chip{color:var(--sky)}
.chip svg{width:16px;height:16px;color:var(--warn)}
.chip.low{border-color:#fca5a5;background:#fef2f2;color:#b91c1c}

.stage{flex:1;overflow-y:auto;position:relative;scroll-behavior:smooth;overscroll-behavior:contain}
.msgs{max-width:820px;margin:0 auto;padding:24px 16px 12px;display:flex;flex-direction:column;gap:18px}
.row{display:flex;gap:12px;align-items:flex-start;animation:rise .35s ease}
@keyframes rise{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}}
.row.user{flex-direction:row-reverse}
.av{width:34px;height:34px;border-radius:50%;display:grid;place-items:center;flex-shrink:0;background:var(--soft-2)}
.av svg{width:34px;height:34px}
.row.user .av{display:none}
.bub{max-width:min(100%,680px);min-width:0}
.row.user .bub{background:var(--bubble-user);color:#fff;padding:.7rem 1.1rem;border-radius:20px;border-end-end-radius:6px;white-space:pre-wrap;word-break:break-word}
.row.bot .bub{flex:1;padding-top:2px}
.md{word-break:break-word;font-size:1rem}
.md>*+*{margin-top:.75em}
.md h1,.md h2,.md h3,.md h4{line-height:1.5;font-weight:800;margin-top:1.1em}
.md h1{font-size:1.35rem}.md h2{font-size:1.2rem}.md h3{font-size:1.08rem}
.md ul,.md ol{padding-inline-start:1.5rem}.md li+li{margin-top:.25em}
.md blockquote{border-inline-start:3px solid var(--blue);padding:.2rem 1rem;color:var(--muted);background:var(--soft);border-radius:8px}
.md a{color:var(--blue);text-decoration:underline;text-underline-offset:3px}
.md code{font-family:ui-monospace,Menlo,Consolas,monospace;font-size:.88em;background:var(--soft-2);padding:.1em .4em;border-radius:6px;direction:ltr;unicode-bidi:embed}
.md hr{border:0;border-top:1px solid var(--line)}
.md table{border-collapse:collapse;width:100%;display:block;overflow-x:auto;font-size:.93rem}
.md th,.md td{border:1px solid var(--line);padding:.45rem .8rem;text-align:start}
.md th{background:var(--soft-2)}
.codebox{direction:ltr;text-align:left;background:var(--code);border-radius:14px;overflow:hidden;border:1px solid #1b2a4d}
.codebox .ch{display:flex;justify-content:space-between;align-items:center;padding:.35rem .8rem;background:#101c3a;color:#9fb3dd;font-size:.78rem}
.codebox .ch button{background:none;border:0;color:#9fb3dd;display:flex;align-items:center;gap:.3rem;font-size:.78rem;padding:.15rem .4rem;border-radius:6px}
.codebox .ch button:hover{background:#1b2a4d;color:#fff}
.codebox .ch svg{width:14px;height:14px}
.codebox code{background:none!important;padding:0!important;color:inherit!important;font-size:inherit!important;border-radius:0}
.codebox pre{padding:.9rem 1rem;overflow-x:auto;font-family:ui-monospace,Menlo,Consolas,monospace;font-size:.86rem;line-height:1.7;color:#e6edf7}
.msg-actions{display:flex;gap:2px;margin-top:6px;opacity:.0;transition:.2s}
.row:hover .msg-actions,.row.last .msg-actions,.msg-actions.show{opacity:1}
.msg-actions button{border:0;background:transparent;color:var(--muted);width:30px;height:30px;border-radius:8px;display:grid;place-items:center}
.msg-actions button:hover{background:var(--soft-2);color:var(--blue)}
.msg-actions svg{width:16px;height:16px}
.typing{display:inline-flex;gap:5px;padding:.6rem 0}
.typing i{width:8px;height:8px;border-radius:50%;background:var(--blue);animation:bounce 1.2s infinite}
.typing i:nth-child(2){animation-delay:.15s}.typing i:nth-child(3){animation-delay:.3s}
@keyframes bounce{0%,60%,100%{transform:translateY(0);opacity:.45}30%{transform:translateY(-5px);opacity:1}}
.note{font-size:.82rem;color:var(--warn);margin-top:.4rem}
.errbox{background:#fef2f2;border:1px solid #fecaca;color:#991b1b;padding:.7rem 1rem;border-radius:14px;font-size:.93rem}
:root[data-theme=dark] .errbox{background:#2a1215;border-color:#5b1d22;color:#fca5a5}
.errbox .btn{margin-top:.5rem;padding:.4rem 1rem;font-size:.85rem}

.empty{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:24px;gap:6px;pointer-events:none}
.empty>*{pointer-events:auto}
.logo-lg{width:72px;height:72px;margin-bottom:8px;filter:drop-shadow(0 14px 22px rgba(37,99,235,.35))}
.empty h1{font-size:clamp(1.3rem,3.4vw,1.9rem);font-weight:900}
.empty p{color:var(--muted)}
.sugg{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:18px;max-width:640px;width:100%}
.sugg button{border:1px solid var(--line);background:var(--panel);padding:.8rem 1rem;border-radius:16px;text-align:start;font-size:.9rem;color:var(--text);transition:.2s}
.sugg button:hover{border-color:var(--blue);background:var(--soft-2);transform:translateY(-2px)}
.to-bottom{position:sticky;bottom:10px;margin-inline:auto;display:grid;place-items:center;width:38px;height:38px;border-radius:50%;border:1px solid var(--line);background:var(--bg);box-shadow:var(--shadow);float:left;margin-left:calc(50% - 19px)}

.composer-wrap{padding:8px 16px calc(10px + env(safe-area-inset-bottom));max-width:852px;width:100%;margin:0 auto}
.banner{background:var(--soft-2);border:1px solid var(--line);border-radius:14px;padding:.55rem .9rem;font-size:.86rem;margin-bottom:8px;display:flex;gap:.6rem;align-items:center;justify-content:space-between}
.banner.warn{background:#fffbeb;border-color:#fde68a;color:#92400e}
:root[data-theme=dark] .banner.warn{background:#2b2210;border-color:#6b5316;color:#fcd34d}
.composer{display:flex;align-items:flex-end;gap:8px;background:var(--soft);border:1.5px solid var(--line);border-radius:22px;padding:8px 8px 8px 10px;transition:.2s}
.composer:focus-within{border-color:var(--blue);background:var(--bg);box-shadow:0 0 0 4px rgba(37,99,235,.12)}
.composer textarea{flex:1;border:0;background:transparent;resize:none;outline:none;font-size:1rem;line-height:1.7;max-height:200px;padding:.45rem .6rem}
.send{width:44px;height:44px;border-radius:50%;border:0;background:var(--grad);color:#fff;display:grid;place-items:center;flex-shrink:0;box-shadow:0 8px 18px -8px rgba(37,99,235,.8);transition:.2s}
.send:hover{transform:scale(1.06)}
.send[disabled]{background:var(--line);color:var(--muted);box-shadow:none;transform:none;cursor:not-allowed}
.send svg{transform:scaleX(-1)}
.send.stop svg{transform:none}
.hint{text-align:center;font-size:.74rem;color:var(--muted);margin-top:6px}

/* مودال */
.modal{position:fixed;inset:0;background:rgba(8,16,40,.55);backdrop-filter:blur(6px);display:grid;place-items:center;z-index:100;padding:14px;overflow-y:auto}
.modal-box{background:var(--bg);border:1px solid var(--line);border-radius:26px;padding:24px;width:min(1040px,100%);max-height:calc(100dvh - 28px);overflow-y:auto;box-shadow:var(--shadow-lg);animation:pop .3s cubic-bezier(.2,.9,.3,1.2)}
.modal-box.sm{width:min(460px,100%)}.modal-box.md{width:min(620px,100%)}
@keyframes pop{from{opacity:0;transform:scale(.94) translateY(16px)}to{opacity:1;transform:none}}
.mh{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:16px}
.mh h2{font-size:1.35rem;font-weight:900}.mh p{color:var(--muted);font-size:.92rem}
.plans{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:12px}
.pc{position:relative;border:1.5px solid var(--line);border-radius:20px;padding:18px 16px;background:var(--panel);display:flex;flex-direction:column;gap:6px}
.pc.pop{border-color:var(--blue);background:var(--bg);box-shadow:var(--shadow)}
.pc.cur{outline:2px solid var(--ok);outline-offset:2px}
.pc .tag{position:absolute;top:-11px;inset-inline-start:50%;transform:translateX(50%);background:var(--grad);color:#fff;font-size:.72rem;font-weight:800;padding:.1rem .8rem;border-radius:99px;white-space:nowrap}
[dir=rtl] .pc .tag{transform:translateX(50%)}
.pc h3{font-size:1.1rem;font-weight:900}.pc .sub{font-size:.8rem;color:var(--muted);min-height:2.6em;line-height:1.6}
.pc .price{margin:6px 0}.pc .price b{font-size:1.7rem;font-weight:900;color:var(--blue-600)}.pc .price span{font-size:.78rem;color:var(--muted)}
:root[data-theme=dark] .pc .price b{color:var(--sky)}
.pc ul{list-style:none;display:grid;gap:5px;font-size:.84rem;margin-bottom:10px;flex:1}
.pc li{display:flex;gap:.4rem;align-items:flex-start;line-height:1.6}.pc li svg{width:16px;height:16px;color:var(--ok);margin-top:3px}
.pc .btn{width:100%;padding:.6rem}
.paytabs{display:grid;gap:8px;margin:12px 0}
.pm{display:flex;align-items:center;gap:.7rem;border:1.5px solid var(--line);border-radius:14px;padding:.75rem 1rem;cursor:pointer;background:var(--panel)}
.pm input{accent-color:var(--blue);width:18px;height:18px}
.pm:has(input:checked){border-color:var(--blue);background:var(--soft-2)}
.sum{display:flex;justify-content:space-between;background:var(--soft);border-radius:14px;padding:.8rem 1rem;margin-bottom:6px;font-weight:700}
.cardbox{background:var(--grad);color:#fff;border-radius:20px;padding:18px 20px;margin:10px 0;box-shadow:var(--shadow)}
.cardbox .num{font-size:1.45rem;font-weight:800;letter-spacing:2px;direction:ltr;text-align:center;margin:6px 0;cursor:pointer}
.cardbox .meta{display:flex;justify-content:space-between;font-size:.88rem;opacity:.95}
.cardbox small{opacity:.85;display:block;text-align:center}
.field{margin-bottom:12px}.field label{display:block;font-weight:700;font-size:.9rem;margin-bottom:4px}
.field input{width:100%;padding:.75rem 1rem;border:1.5px solid var(--line);border-radius:12px;background:var(--soft);outline:none;font-size:1rem;direction:ltr;text-align:left}
.field input:focus{border-color:var(--blue);background:var(--bg)}
.field input[type=file]{padding:.55rem;direction:rtl;text-align:right}
.field .help{font-size:.8rem;color:var(--muted);margin-top:3px}
.ferr{color:var(--no);font-size:.88rem;min-height:1.3rem}
.olist{display:grid;gap:10px}
.oi{border:1px solid var(--line);border-radius:16px;padding:.8rem 1rem;display:flex;justify-content:space-between;gap:10px;align-items:center;flex-wrap:wrap;background:var(--panel)}
.oi small{color:var(--muted)}
.st{font-size:.78rem;font-weight:800;border-radius:99px;padding:.1rem .8rem}
.st.paid{background:#dcfce7;color:#166534}.st.pending,.st.review{background:#fef3c7;color:#92400e}.st.failed,.st.rejected{background:#fee2e2;color:#991b1b}
.toast{position:fixed;bottom:22px;left:50%;transform:translate(-50%,140px);background:#0b1736;color:#fff;padding:.8rem 1.3rem;border-radius:14px;z-index:200;transition:.4s;box-shadow:var(--shadow-lg);font-size:.93rem;max-width:90vw;text-align:center}
.toast.show{transform:translate(-50%,0)}
.steps{margin:6px 0 0 0;padding-inline-start:1.2rem;color:var(--muted);font-size:.92rem}
.scrim{display:none}

/* موبایل */
@media(max-width:900px){
  .only-m{display:grid}
  .side{position:fixed;inset-block:0;inset-inline-start:0;width:min(86vw,320px);transform:translateX(100%)}
  [dir=ltr] .side{transform:translateX(-100%)}
  .app.open .side{transform:none;box-shadow:var(--shadow-lg)}
  .scrim{display:block;position:fixed;inset:0;background:rgba(8,16,40,.5);z-index:35;opacity:0;pointer-events:none;transition:.3s}
  .app.open .scrim{opacity:1;pointer-events:auto}
  .conv .acts{display:flex}
  .top{padding:8px 10px}
  .sugg{grid-template-columns:1fr}
  .msgs{padding:16px 12px 8px}
  .composer-wrap{padding-inline:10px}
  .hint{font-size:.72rem;margin-top:4px}
  .chip{padding:.3rem .7rem}
  .modal-box{padding:18px;border-radius:22px}
}

/* ===== حالت‌های تصویر/ویدئو، صدا ===== */
.mopt .fr{margin-inline-start:auto;font-size:.7rem;font-weight:700;color:#047857;background:#d1fae5;border-radius:99px;padding:.05rem .55rem;white-space:nowrap}
:root[data-theme=dark] .mopt .fr{background:#064e3b;color:#6ee7b7}
.modes{display:flex;gap:6px;margin:0 2px 8px;overflow-x:auto;scrollbar-width:none}
.modes button{display:flex;align-items:center;gap:.4rem;border:1.5px solid var(--line);background:var(--bg);border-radius:99px;padding:.28rem .85rem;font-size:.84rem;font-weight:600;color:var(--muted);white-space:nowrap;transition:.15s}
.modes button svg{width:16px;height:16px}
.modes button:hover{border-color:var(--blue);color:var(--blue)}
.modes button.on{background:var(--blue);border-color:var(--blue);color:#fff}
.modes button .lk{display:none;width:13px;height:13px;opacity:.75}
.modes button.locked .lk{display:block}
.modes button.locked{opacity:.75}
.mopts{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center;background:var(--soft);border:1px solid var(--line);border-radius:14px;padding:.5rem .8rem;margin:0 2px 8px;font-size:.82rem}
.mopts label{display:flex;align-items:center;gap:.4rem;color:var(--muted)}
.mopts select{border:1px solid var(--line);background:var(--bg);border-radius:10px;padding:.2rem .5rem;font-size:.84rem;max-width:200px}
.mcost{margin-inline-start:auto;color:var(--blue-600);font-weight:700}
:root[data-theme=dark] .mcost{color:var(--sky)}
.tool{width:40px;height:40px;border-radius:50%;border:0;background:transparent;color:var(--muted);display:grid;place-items:center;flex-shrink:0;transition:.2s}
.tool:hover{background:var(--soft-2);color:var(--blue)}
.tool.on{background:#fee2e2;color:#dc2626;animation:pulse 1.2s infinite}
@keyframes pulse{0%{box-shadow:0 0 0 0 rgba(220,38,38,.45)}100%{box-shadow:0 0 0 12px rgba(220,38,38,0)}}
.chip-voice svg{color:var(--blue)}
.msg-actions button.on{color:var(--blue);background:var(--soft-2)}
.row.media .bub{max-width:min(560px,100%)}
.mcard{border-radius:16px;overflow:hidden;border:1px solid var(--line);background:var(--soft);line-height:0}
.mcard img,.mcard video{display:block;width:100%;max-height:70vh;object-fit:contain;background:#000}
.mcard img{background:var(--soft)}
.mact{display:flex;align-items:center;gap:.6rem;margin-top:8px;flex-wrap:wrap}
.mact .sm{padding:.3rem .9rem;font-size:.82rem;border-radius:99px}
.mprompt{color:var(--muted);font-size:.8rem;line-height:1.6;flex:1;min-width:0;overflow-wrap:anywhere}
.mwait{display:flex;gap:.8rem;align-items:center;background:var(--soft);border:1px dashed var(--line);border-radius:16px;padding:.9rem 1.1rem}
.mwait small{display:block;color:var(--muted);font-size:.78rem;line-height:1.6}
.mwait+.mprompt{margin-top:6px}
.spin{width:22px;height:22px;border-radius:50%;border:3px solid var(--line);border-top-color:var(--blue);animation:spin 1s linear infinite;flex-shrink:0}
@keyframes spin{to{transform:rotate(360deg)}}
/* گفتگوی صوتی */
body.vopen{overflow:hidden}
.voice{position:fixed;inset:0;z-index:60;background:radial-gradient(circle at 50% 35%,#1e3a8a 0%,#0b1220 70%);color:#fff;display:flex;flex-direction:column;align-items:center;justify-content:space-between;padding:calc(18px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom))}
.vclose{align-self:flex-start;background:rgba(255,255,255,.1)!important;color:#fff!important}
.vbody{display:flex;flex-direction:column;align-items:center;gap:1.1rem;text-align:center;max-width:560px;width:100%}
.orb{width:150px;height:150px;border-radius:50%;background:var(--grad);display:grid;place-items:center;box-shadow:0 0 0 0 rgba(56,189,248,.5);transition:transform .3s}
.orb svg{width:56px;height:56px;color:#fff}
.voice[data-state=listening] .orb{animation:orbL 1.6s ease-in-out infinite}
.voice[data-state=thinking] .orb{animation:orbT 1.2s linear infinite;background:linear-gradient(135deg,#6366f1,#38bdf8)}
.voice[data-state=speaking] .orb{animation:orbS .9s ease-in-out infinite;background:linear-gradient(135deg,#10b981,#38bdf8)}
@keyframes orbL{0%{box-shadow:0 0 0 0 rgba(56,189,248,.55)}100%{box-shadow:0 0 0 46px rgba(56,189,248,0)}}
@keyframes orbT{to{transform:rotate(360deg)}}
@keyframes orbS{0%,100%{transform:scale(1)}50%{transform:scale(1.12)}}
.vstate{font-size:1.25rem;font-weight:800}
.vtext{font-size:1.02rem;line-height:1.9;color:#cfe0ff;min-height:5.5em;max-height:32vh;overflow:auto;width:100%}
.vacts{display:flex;gap:10px;flex-wrap:wrap;justify-content:center}
.vacts .btn-ghost{background:rgba(255,255,255,.1);border-color:rgba(255,255,255,.25);color:#fff}
.vnote{color:#fca5a5;font-size:.85rem;min-height:1.4em}
@media(max-width:560px){.mcost{margin-inline-start:0;width:100%}.chip-voice span{display:none}.orb{width:120px;height:120px}}
@media(prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
.chip{white-space:nowrap}
.model-btn span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:42vw}

.mgrp{position:sticky;top:-6px;z-index:1;background:var(--bg);padding:.55rem .8rem .3rem;font-size:.78rem;font-weight:800;color:var(--blue-600);display:flex;align-items:baseline;gap:.4rem;border-bottom:1px solid var(--line);margin:4px 0 2px}
:root[data-theme=dark] .mgrp{color:var(--sky)}
.mgrp i{font-style:normal;font-size:1rem}
.mgrp small{font-weight:500;color:var(--muted);font-size:.72rem}
.mopt small{margin-top:1px}
.mopt.sel b::after{content:'✓';color:var(--blue);margin-inline-start:.4rem}
.mopt.locked b{font-weight:600}

/* مهمان */
.guest-box{display:none;flex-direction:column;gap:.5rem;padding:.9rem;border:1px solid var(--line);background:var(--soft);border-radius:16px;font-size:.82rem;color:var(--muted);line-height:1.8;text-align:center}
.guest-box .btn{width:100%}
.btn-top{display:none;padding:.4rem 1.1rem;font-size:.88rem;border-radius:99px}
body.guest .guest-box{display:flex}
body.guest .btn-top{display:inline-flex}
body.guest #usage,body.guest #creditChip,body.guest #ordersBtn,body.guest #delAccBtn,body.guest #clearBtn,body.guest #logoutBtn,body.guest .who,body.guest .search{display:none!important}
.login-box h2{font-size:1.25rem;margin-bottom:.3rem}
.login-box p{color:var(--muted);font-size:.9rem;margin-bottom:1rem}
.login-box .draft{background:var(--soft);border:1px dashed var(--line);border-radius:12px;padding:.5rem .8rem;font-size:.85rem;color:var(--muted);margin-bottom:1rem;max-height:4.2em;overflow:hidden;text-overflow:ellipsis}
.login-box input.ph{width:100%;border:1.5px solid var(--line);background:var(--bg);border-radius:14px;padding:.75rem 1rem;font-size:1.1rem;text-align:center;letter-spacing:.08em;direction:ltr;outline:none}
.login-box input.ph:focus{border-color:var(--blue);box-shadow:0 0 0 4px rgba(37,99,235,.12)}
.login-box .btn{width:100%;margin-top:.8rem}
.login-box .lerr{color:#dc2626;font-size:.84rem;min-height:1.3em;margin-top:.4rem;text-align:center}
.otpbox{display:flex;gap:8px;justify-content:center;direction:ltr}
.otpbox input{width:46px;height:54px;border:1.5px solid var(--line);background:var(--bg);border-radius:14px;text-align:center;font-size:1.4rem;font-weight:700;outline:none}
.otpbox input:focus{border-color:var(--blue);box-shadow:0 0 0 4px rgba(37,99,235,.12)}
.login-meta{display:flex;justify-content:space-between;align-items:center;margin-top:.6rem;font-size:.82rem}
.login-box .terms{font-size:.74rem;color:var(--muted);text-align:center;margin-top:.8rem}
@media(max-width:420px){.otpbox input{width:40px;height:50px}}
.btn-top{white-space:nowrap}
.md th,.md td{min-width:96px;overflow-wrap:normal;word-break:normal}
.md table{-webkit-overflow-scrolling:touch;max-width:100%}
.md img{max-width:100%;height:auto}
.md pre,.md code{max-width:100%}
.md p,.md li,.md h1,.md h2,.md h3,.md h4,.bub{overflow-wrap:anywhere}
.voice{overflow-y:auto}
@media(max-height:520px){.voice{padding-top:calc(8px + env(safe-area-inset-top));padding-bottom:calc(10px + env(safe-area-inset-bottom))}.orb{width:76px;height:76px}.orb svg{width:34px;height:34px}.vbody{gap:.4rem}.vstate{font-size:1rem}.vtext{min-height:2.2em;max-height:16vh;font-size:.92rem;line-height:1.7}.vnote{min-height:0}}

/* ===== v1.4 — صفحه‌ی چت: تمیزتر، سبک‌تر، شبیه ابزارهای مدرن ===== */
:root{--bubble-user-soft:#eef3fb;--ring:rgba(37,99,235,.14)}
:root[data-theme=dark]{--bubble-user-soft:#18253f}
.stage{scroll-behavior:auto;scrollbar-width:thin;scrollbar-color:var(--line) transparent}
.top{border-bottom:0;padding:10px 14px;background:linear-gradient(var(--bg) 70%,transparent)}
.model-btn{border-color:transparent;background:transparent;font-size:1rem;padding:.4rem .75rem}
.model-btn:hover,.model-btn[aria-expanded=true]{background:var(--soft-2);border-color:transparent}
.chip{background:transparent}
.msgs{max-width:780px;padding:18px 16px 16px;gap:26px}
.row{animation:none;content-visibility:auto;contain-intrinsic-size:auto 90px}
.row.new{animation:rise .25s ease;content-visibility:visible}
.row.bot .av{display:none}
.row.bot .bub{padding-top:0;max-width:100%}
.md{font-size:1.02rem;line-height:2}
.md p{margin:0}
.md>*+*{margin-top:.9em}
.row.user .bub{background:var(--bubble-user-soft);color:var(--text);border-radius:22px;border-end-end-radius:8px;padding:.65rem 1.1rem;max-width:min(88%,600px);white-space:normal}
.row.user .utext{white-space:pre-wrap;line-height:1.9}
.row.user{justify-content:flex-start}
.achips{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:.35rem}
.achips:last-child{margin-bottom:0}
.athumb{width:120px;height:120px;max-width:100%;object-fit:cover;border-radius:14px;border:1px solid var(--line);display:block}
.fchip{display:inline-flex;align-items:center;gap:.45rem;background:var(--bg);border:1px solid var(--line);border-radius:12px;padding:.3rem .7rem;font-size:.83rem;max-width:100%}
.fchip svg{width:16px;height:16px;color:var(--blue)}
.fchip span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:220px}
.msg-actions{opacity:0;margin-top:4px}
.row.last .msg-actions{opacity:.85}
.md pre,.codebox{border-radius:12px}
.typing i{width:7px;height:7px}

/* کادر نوشتن */
.composer-wrap{max-width:812px;padding:6px 14px calc(8px + env(safe-area-inset-bottom))}
.composer{flex-direction:column;align-items:stretch;gap:0;background:var(--bg);border:1px solid var(--line);border-radius:26px;padding:8px 10px;box-shadow:0 2px 14px -6px rgba(15,27,61,.18)}
.composer:focus-within{border-color:#b9cdf5;box-shadow:0 4px 22px -8px rgba(37,99,235,.28),0 0 0 4px var(--ring);background:var(--bg)}
:root[data-theme=dark] .composer:focus-within{border-color:#2c4a86}
.crow{display:flex;align-items:flex-end;gap:4px}
.composer textarea{padding:.55rem .5rem;font-size:1.02rem;min-height:44px}
.tool{width:38px;height:38px}
.send{width:38px;height:38px;box-shadow:none}
.send:hover{transform:none;filter:brightness(1.08)}
.hint{margin-top:5px;opacity:.8}

/* سینی پیوست */
.tray{display:flex;gap:8px;overflow-x:auto;padding:2px 2px 8px;scrollbar-width:none}
.tray::-webkit-scrollbar{display:none}
.att{display:flex;align-items:center;gap:8px;flex:0 0 auto;max-width:230px;background:var(--soft);border:1px solid var(--line);border-radius:14px;padding:5px 6px 5px 10px;position:relative}
.att img,.att .aico{width:40px;height:40px;border-radius:10px;object-fit:cover;flex-shrink:0;background:var(--soft-2);display:grid;place-items:center;color:var(--blue)}
.att .aico svg{width:20px;height:20px}
.ameta{min-width:0;display:grid;line-height:1.45}
.ameta b{font-size:.8rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ameta small{font-size:.7rem;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.att.err{border-color:#fca5a5;background:#fef2f2}.att.err small{color:#b91c1c}
:root[data-theme=dark] .att.err{background:#2a1215;border-color:#5b1d22}
.att.busy .aico,.att.busy img{opacity:.5}
.arm{border:0;background:var(--bg);width:22px;height:22px;border-radius:50%;display:grid;place-items:center;color:var(--muted);flex-shrink:0;border:1px solid var(--line)}
.arm svg{width:12px;height:12px}
.arm:hover{color:#dc2626}
.eye{display:inline-flex;color:var(--muted);margin-inline-start:auto}
.eye svg{width:15px;height:15px}
.mopt .eye+.lk,.mopt .eye+.fr{margin-inline-start:.4rem}
.mopt .fr{margin-inline-start:auto}
body.dragging .composer{border-color:var(--blue);box-shadow:0 0 0 4px var(--ring)}
body.dragging .stage::after{content:'فایل را اینجا رها کنید';position:absolute;inset:12px;border:2px dashed var(--blue);border-radius:22px;background:rgba(37,99,235,.06);display:grid;place-items:center;font-weight:800;color:var(--blue);z-index:6;pointer-events:none}

/* سایدبار */
.side{border-inline-end:1px solid var(--line)}
.new-chat{border-radius:14px;box-shadow:none}
.convs .conv,.conv{border-radius:10px}
.sugg button{background:var(--bg);border-radius:14px;font-size:.88rem}
@media (max-width:640px){
  .msgs{padding:12px 12px 10px;gap:22px}
  .md{font-size:1rem;line-height:1.95}
  .row.user .bub{max-width:92%}
  .composer{border-radius:22px;padding:6px 8px}
  .composer-wrap{padding-inline:8px}
  .athumb{width:96px;height:96px}
  .att{max-width:180px}
}
@media (prefers-reduced-motion:reduce){.row.new{animation:none}}
.row.user .bub{width:fit-content}
.athumb{width:104px;height:104px}
@media (max-width:640px){.athumb{width:84px;height:84px}}

/* ===== v1.5 — اندازه‌ها جمع‌وجورتر (با امکان بزرگ‌کردن نوشته‌ها از تنظیمات) ===== */
html{font-size:15px}
svg{width:18px;height:18px}
.icon-btn{width:36px;height:36px;border-radius:10px}
.brand{font-size:1.1rem}.brand svg{width:28px;height:28px}
.btn{padding:.6rem 1.05rem;font-size:.93rem;border-radius:12px}
.btn-top{padding:.4rem .9rem;font-size:.88rem}
.new-chat{padding:.55rem 1rem}
.search input{padding:.5rem .8rem;font-size:.9rem}
.conv{padding:.42rem .65rem;font-size:.9rem;border-radius:10px}
.usage{padding:8px 10px;border-radius:12px;cursor:pointer}
.usage-sub{font-size:.74rem;line-height:1.6}
.plan-badge{font-size:.78rem}
.foot-actions .icon-btn svg{width:17px;height:17px}
.top{padding:6px 12px}
.model-btn{font-size:.95rem;padding:.3rem .65rem}
.chip{padding:.2rem .7rem;font-size:.78rem}
.chip svg{width:14px;height:14px}
.logo-lg{width:54px;height:54px}
.empty h1{font-size:clamp(1.15rem,3vw,1.55rem)}
.empty p{font-size:.92rem}
.sugg{gap:8px;margin-top:14px}
.sugg button{padding:.6rem .85rem;font-size:.85rem;border-radius:12px}
.banner{padding:.4rem .75rem;font-size:.8rem;border-radius:12px}
.modes button{padding:.28rem .75rem;font-size:.8rem}
.modes svg{width:15px;height:15px}
.mopts{font-size:.82rem}
.tool{width:34px;height:34px}.tool svg{width:18px;height:18px}
.send{width:36px;height:36px}.send svg{width:17px;height:17px}
.composer textarea{font-size:.98rem;min-height:38px;padding:.4rem .5rem}
.hint{font-size:.7rem;margin-top:3px}
.msg-actions button{width:28px;height:28px}.msg-actions svg{width:15px;height:15px}
.mopt{padding:.45rem .7rem}.mopt b{font-size:.9rem}.mopt small{font-size:.75rem}
.mgrp{font-size:.78rem}
.modal-box{padding:20px}
.mh h2{font-size:1.15rem}.mh p{font-size:.85rem}
.toast{font-size:.85rem;padding:.55rem 1rem}
@media (pointer:coarse){.icon-btn,.tool,.send{min-width:40px;min-height:40px}.conv{padding:.55rem .7rem}.msg-actions button{width:34px;height:34px}}
@media (max-width:640px){.top{padding:6px 8px}.btn-top{padding:.35rem .7rem}}

/* تنظیمات */
.stabs{display:flex;gap:4px;background:var(--soft);padding:4px;border-radius:12px;margin-bottom:14px}
.stabs button{flex:1;border:0;background:transparent;padding:.45rem .5rem;border-radius:9px;font-weight:700;font-size:.9rem;color:var(--muted)}
.stabs button.on{background:var(--bg);color:var(--blue-600);box-shadow:0 1px 4px rgba(15,27,61,.12)}
:root[data-theme=dark] .stabs button.on{color:var(--sky)}
.sec{margin-bottom:16px}.sec h3{font-size:.95rem;font-weight:800;margin-bottom:8px}
.meter{margin:4px 0}
.mrow{display:flex;justify-content:space-between;gap:8px;font-size:.85rem;flex-wrap:wrap}.mrow span{color:var(--muted)}
.hlp{color:var(--muted);font-size:.8rem;line-height:1.8;margin-top:6px}
.sgrid{display:grid;grid-template-columns:repeat(auto-fit,minmax(110px,1fr));gap:8px}
.sgrid>div{background:var(--soft);border:1px solid var(--line);border-radius:12px;padding:.55rem .7rem;text-align:center}
.sgrid b{display:block;font-size:1.05rem}.sgrid small{color:var(--muted);font-size:.74rem}
.sform{display:grid;gap:12px}
.sform label{display:grid;gap:5px;font-size:.88rem;font-weight:700}
.sform input:not([type=radio]),.sform textarea{border:1.5px solid var(--line);background:var(--bg);border-radius:12px;padding:.55rem .8rem;font-size:.95rem;font-weight:400;width:100%;outline:none}
.sform input:focus,.sform textarea:focus{border-color:var(--blue)}
.tones{display:flex;flex-wrap:wrap;gap:6px}
.tone{display:block!important;font-weight:400!important}
.tone input{position:absolute;opacity:0;pointer-events:none}
.tone span{display:inline-block;border:1.5px solid var(--line);border-radius:99px;padding:.3rem .85rem;font-size:.85rem;cursor:pointer}
.tone input:checked+span{border-color:var(--blue);background:var(--soft-2);color:var(--blue-600);font-weight:700}
.tone input:focus-visible+span{outline:2px solid var(--blue)}
.srow{display:flex;gap:8px;flex-wrap:wrap}
.seg{display:flex;gap:6px;flex-wrap:wrap}
.seg button{border:1.5px solid var(--line);background:var(--bg);border-radius:12px;padding:.45rem 1rem;font-weight:700;min-width:72px}
.seg button.on{border-color:var(--blue);background:var(--soft-2);color:var(--blue-600)}
.sgrid b{direction:ltr;unicode-bidi:isolate}

/* منوی مدل‌ها روی موبایل: تمام‌عرض و داخل صفحه (قبلاً از لبه‌ی چپ بیرون می‌زد) */
@media (max-width:640px){
  .model-pick{position:static}
  .model-menu{position:fixed;top:calc(env(safe-area-inset-top) + 50px);left:8px;right:8px;inset-inline-start:8px;inset-inline-end:8px;width:auto;max-height:calc(100dvh - 70px - env(safe-area-inset-top));max-width:none}
}
@media (max-width:640px){
  .top{gap:6px;flex-wrap:nowrap;min-width:0}
  .model-pick{min-width:0;flex:1 1 auto}
  .model-btn{max-width:100%;min-width:0}
  .model-btn #modelName{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}
  .top .grow{display:none}
  .top .chip,.top .btn-top,.top .icon-btn{flex-shrink:0}
  .chip-voice{padding:.2rem .5rem}
  .btn-top{padding:.3rem .65rem;font-size:.8rem;white-space:nowrap}
}

/* ===== v1.5.2 — اصلاحات تست زنده‌ی موبایل ===== */
/* سایدبار: هیچ‌چیز از کشو بیرون نزند (قبلاً ردیف دکمه‌های پایین ۲۹px به بیرون می‌زد و لبه‌ی چپ صفحه دیده می‌شد) */
.side{overflow-x:hidden;overflow-y:auto}
.side>*{min-width:0;max-width:100%}
.foot-actions{flex-wrap:wrap;gap:2px 0;justify-content:space-between}
.usage,.guest-box{max-width:100%}
.who{overflow:hidden;text-overflow:ellipsis}
/* اعلان‌ها: بالای صفحه، وسط، بدون پوشاندن کادر نوشتن */
.toast{left:0;right:0;margin-inline:auto;width:max-content;max-width:calc(100vw - 24px);bottom:auto;top:calc(env(safe-area-inset-top) + 56px);transform:translateY(-160%);opacity:0;visibility:hidden;pointer-events:none;transition:transform .35s,opacity .35s,visibility .35s}
.toast.show{transform:none;opacity:1;visibility:visible}
/* نام مدل: ابتدای نام دیده شود و انتهایش «…» بگیرد */
.model-btn #modelName{unicode-bidi:plaintext;text-align:start}
/* تب‌های تنظیمات روی صفحه‌ی باریک */
.stabs button{white-space:nowrap;font-size:.84rem;padding:.45rem .3rem}
.modal{align-items:start}
.modal-box{margin-block:auto}
@media (max-height:700px){
  .empty{justify-content:flex-start;padding-top:18px;overflow-y:auto}
  .empty p{display:none}
  .logo-lg{width:44px;height:44px}
  .sugg button:nth-child(n+3){display:none}
}
@media (max-height:520px){.sugg{display:none}.empty h1{font-size:1.05rem}.logo-lg{display:none}}
/* ردیف پایین سایدبار: فقط کارهای اصلی؛ تم/حذف گفتگوها/حذف حساب داخل «تنظیمات» است */
#themeBtn,#clearBtn,#delAccBtn{display:none}
.foot-actions{justify-content:space-around}
@media (max-height:420px){.hint{display:none}.top{padding-block:3px}.composer-wrap{padding-bottom:calc(4px + env(safe-area-inset-bottom))}.modes{margin-bottom:4px}}

/* iOS Safari: فیلد با فونت کمتر از ۱۶px هنگام فوکوس صفحه را زوم می‌کند و سرریز می‌شود */
html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
@media (hover:none) and (pointer:coarse){
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]),textarea,select,[contenteditable]{font-size:16px!important}
  .composer textarea{line-height:1.6}
}
.composer,.composer textarea{max-width:100%;min-width:0}
