/* App-level glue between style.css (existing app components) and the designer's tokens.css + screens.css
   (Grok Bot light round). Loaded last. screens.css is written for fixed 390×844 mock pages; the app is full-viewport. */
html, body { height: 100%; overscroll-behavior: none; }
.screen { position: fixed; inset: 0; }                      /* screens.css sets relative (mock pages) */
.listhead { padding-top: calc(14px + env(safe-area-inset-top)); }
.chathead, .plainhead { padding-top: calc(10px + env(safe-area-inset-top)); border-bottom: 0; }
.composer { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
.cta-bar { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
.ob { padding-top: calc(16px + env(safe-area-inset-top)); padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
.back.ibtn { width: 40px; height: 40px; }

/* home: bot list */
.bot-row { user-select: none; -webkit-user-select: none; }
.bot-row:active { background: var(--selected); }
.bot-list .empty { padding: 40px; }
.unread-pill { bottom: calc(18px + env(safe-area-inset-bottom)); }
.list-search { padding: 0 16px 8px; flex: none; }
.list-search input { width: 100%; height: 42px; border: 0; outline: 0; border-radius: var(--radius-pill); background: var(--surface);
  box-shadow: var(--shadow-chip); padding: 0 16px; font-size: 15px; }
.list-search input::placeholder { color: var(--faint); }

/* chat: bubbles from screens.css; keep markdown / reasoning parts inside the assistant bubble */
.msg { margin: 0; line-height: 1.7; font-size: 15px; }
.msg.user .bubble { white-space: pre-wrap; }
.msg .meta { direction: ltr; display: flex; gap: 12px; align-items: center; }
.msg.bot .bubble .think { margin-bottom: 2px; }
.msg.bot .bubble .body p { margin: 0 0 8px; } .msg.bot .bubble .body p:last-child { margin-bottom: 0; }
.msg.bot .bubble .code { background: var(--surface); }
.msg.err .bubble { background: var(--danger-soft); }
.msg.err .body { color: var(--danger); }
.name-pill .av svg { width: 22px; height: 22px; }
.chathead .credit-chip { flex: none; }

/* settings money rows */
.action.money { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.action.money b { font-weight: 600; color: var(--dim); font-size: 15px; }
.composer.is-locked textarea:disabled { cursor: not-allowed; }

/* chat mode switch (عادی / خیلی قوی) above the composer */
.mode-switch { display: flex; gap: 6px; padding: 6px 12px 0; justify-content: flex-start; }
.mode-switch .chip { padding: 5px 12px; font-size: 13px; margin: 0; background: var(--surface); box-shadow: var(--shadow-chip); border: 0; }
.mode-switch .chip.sel { background: var(--purple-soft); color: var(--purple); box-shadow: 0 0 0 1.5px var(--purple); }
.mode-switch .chip small { opacity: .7; font-size: 11px; }
.toast { background: #1C1C1C; }
.unread-pill[hidden] { display: none; }
.sendbtn { background: var(--purple); color: #fff; }
.sendbtn:disabled { background: var(--purple); color: #fff; opacity: .4; }
/* design shows no per-message times; keep the meta row only for the retry button */
.msg .meta { font-size: 0; margin: 0; }
.msg .meta .retry { font-size: 13px; margin-top: 4px; }

/* 1.8 plan purchase sheet (Bale invoice) */
.pay-sheet{position:fixed;inset:0;z-index:60;background:rgba(0,0,0,.45);display:flex;align-items:flex-end;justify-content:center}
.pay-sheet .pay-card{width:100%;max-width:520px;background:var(--surface,#fff);color:var(--text,#141414);border-radius:22px 22px 0 0;padding:20px 18px calc(18px + env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:12px;text-align:center}
:root.dark .pay-sheet .pay-card{background:#1E1E1E;color:#F2F2F2}
.pay-sheet .pay-head{display:flex;justify-content:space-between;align-items:center;font-size:16px}
.pay-sheet .pay-msg{margin:0;line-height:1.9;font-size:14px;opacity:.85}
.pay-sheet .pay-actions{display:flex;flex-direction:column;gap:8px}
.pay-sheet .dots{display:flex;justify-content:center;gap:6px}
.pay-sheet.is-success{align-items:center}
.pay-sheet.is-success .pay-card{border-radius:22px;margin:16px;padding:28px 20px}
.pay-sheet .pay-icon{width:64px;height:64px;border-radius:50%;margin:0 auto;display:flex;align-items:center;justify-content:center;font-size:32px;color:#fff;background:#22A55B}
.pay-sheet h2{margin:4px 0 0;font-size:20px}
.pay-sheet .pay-plan{display:inline-block;margin:0 auto;padding:4px 14px;border-radius:999px;background:rgba(34,165,91,.12);color:#1C8A4C;font-weight:700}
.sheet .opt.is-busy{opacity:.6;pointer-events:none}
.sheet .opt:disabled{cursor:default}

/* 1.8 «بستهٔ من»: plan name + bare progress bar, no numbers */
.plan-status { text-align: center; }
.plan-status .plan-status-name { font-size: 22px; font-weight: 800; margin: 4px 0 14px; color: var(--text, inherit); }
.plan-status .usage-bar { margin: 0 auto 10px; }
.plan-status .plan-status-note { font-size: 13px; opacity: .75; margin: 8px 0 0; line-height: 1.8; }
.plan-status.is-empty .plan-status-name { color: var(--danger, #d64545); }

/* 1.8 desktop / wide viewports: one centered column, max 480px; header, chat, sheets and bottom bars stay inside it. */
@media (min-width: 520px) {
  html, body { background: #e9e9ec; }
  .screen, .scrim, .pay-sheet { left: calc(50% - 240px); right: calc(50% - 240px); width: auto; }
  .screen { box-shadow: 0 0 0 1px rgba(0,0,0,.06), 0 8px 40px rgba(0,0,0,.08); }
  .toast { max-width: 440px; }
}
@media (min-width: 520px) and (prefers-color-scheme: dark) { html, body { background: #0d0d0f; } }
/* 1.8.2: thin usage bar under the plan chip + near-limit warning in «بستهٔ من» (never a number) */
.credit-chip.has-bar { flex-direction: column; justify-content: center; align-items: stretch; gap: 3px; padding: 0 12px; }
.credit-chip .chip-name { overflow: hidden; text-overflow: ellipsis; line-height: 1.2; text-align: center; }
.chip-bar { display: block; height: 3px; min-width: 44px; border-radius: 2px; background: var(--divider); overflow: hidden; direction: rtl; }
.chip-bar > i { display: block; height: 100%; border-radius: 2px; background: var(--purple); transition: width .4s ease; }
.chip-bar.is-low > i, .usage-bar.is-low > i { background: var(--warning, #f59e0b); }
.chip-bar.is-empty > i, .usage-bar.is-empty > i { background: var(--danger, #d64545); }
.usage-bar > i { transition: width .4s ease; }
.plan-status .plan-status-note.is-warn { opacity: 1; font-weight: 700; color: var(--warning, #f59e0b); }
.plan-status.is-empty .plan-status-note.is-warn { color: var(--danger, #d64545); }
.plan-status .plan-warn-buy { margin-top: 14px; width: 100%; }
/* 1.8.2: composer RTL fix — placeholder / text start on the right and never run under the send button.
   The send button is a flex sibling outside the textarea; the textarea may shrink (min-width:0) and keeps a gap to it. */
.inputbox { display: flex; flex-direction: row; direction: rtl; align-items: flex-end; gap: 8px; padding-inline-start: 18px; padding-inline-end: 6px; }
.inputbox textarea { flex: 1 1 auto; min-width: 0; width: 100%; box-sizing: border-box; direction: rtl; text-align: right; unicode-bidi: plaintext; padding-inline: 0; overflow-wrap: anywhere; }
.inputbox textarea::placeholder { direction: rtl; text-align: right; opacity: 1; }
.inputbox textarea::-webkit-input-placeholder { direction: rtl; text-align: right; }
.inputbox .sendbtn { position: static; flex: 0 0 auto; order: 2; }
/* 1.9.0 web search: tool status line while searching, notice for free users, source links */
.tool-status { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 14px; padding: 2px 0; }
.tool-spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--divider); border-top-color: var(--purple); animation: tool-spin .8s linear infinite; flex: none; }
@keyframes tool-spin { to { transform: rotate(360deg); } }
.msg-notice { margin-top: 8px; max-width: 86%; background: var(--warning-soft, #FBF3E0); border-radius: 16px; padding: 12px 14px; font-size: 13.5px; line-height: 1.8; color: var(--text); }
.msg-notice p { margin: 0 0 10px; }
.msg-notice .btn { width: 100%; height: 40px; font-size: 14px; }
.msg.bot .body a { color: var(--purple); text-decoration: underline; text-underline-offset: 2px; word-break: break-word; }

/* 1.10.0 attachments + image generation (portable: file input, blob URLs, no Bale-only APIs) */
.inputbox .attbtn { position: static; flex: 0 0 auto; order: 0; width: 44px; height: 44px; border: 0; background: transparent; color: var(--text); display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.inputbox .attbtn:active { background: var(--divider); }
.composer { position: relative; }
.att-previews { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 18px 0; direction: rtl; }
.att-chip { display: flex; align-items: center; gap: 6px; background: var(--card, #fff); border: 1px solid var(--divider); border-radius: 16px; padding: 4px 8px 4px 4px; font-size: 12px; max-width: 100%; }
.att-chip img { width: 36px; height: 36px; object-fit: cover; border-radius: 10px; }
.att-chip.is-err { color: var(--danger, #d64545); }
.att-chip.is-gen { background: var(--purple-soft, #F3EAFE); }
.att-chip .att-x { width: 28px; height: 28px; border: 0; background: transparent; border-radius: 50%; font-size: 18px; line-height: 1; color: var(--dim); }
.att-menu { position: absolute; right: 12px; bottom: calc(100% - 4px); background: var(--card, #fff); border: 1px solid var(--divider); border-radius: 16px; box-shadow: 0 8px 24px rgba(0,0,0,.08); padding: 6px; z-index: 20; min-width: 180px; display: flex; flex-direction: column; }
.att-menu[hidden] { display: none; }
.att-menu button { border: 0; background: transparent; text-align: right; padding: 12px 14px; border-radius: 12px; font: inherit; color: var(--text); }
.att-menu button:active { background: var(--divider); }
.att-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 6px; }
.msg.user .att-list { justify-content: flex-start; }
.att-thumb { border: 0; padding: 0; background: transparent; border-radius: 14px; overflow: hidden; width: 168px; max-width: 70vw; }
.att-thumb img, .att-img { display: block; width: 100%; height: auto; max-height: 220px; object-fit: cover; background: var(--divider); }
.att-file { background: var(--card, #fff); border: 1px solid var(--divider); border-radius: 14px; padding: 10px 12px; font-size: 13px; max-width: 80%; }
.lightbox { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 24px; }
.lightbox[hidden] { display: none; }
.lb-backdrop { position: absolute; inset: 0; border: 0; background: rgba(0,0,0,.72); }
.lb-frame { position: relative; margin: 0; max-width: min(920px, 100%); max-height: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.lb-frame img { max-width: 100%; max-height: calc(100vh - 120px); border-radius: 12px; background: #111; }
.lb-frame figcaption { display: flex; gap: 8px; }

/* 1.12.0 voice: mic in the composer (same portable path as the attach button) + play on replies */
.inputbox .micbtn { position: static; flex: 0 0 auto; order: 0; width: 44px; height: 44px; border: 0; background: transparent; color: var(--text); display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.inputbox .micbtn.is-rec { color: #c0392b; background: color-mix(in srgb, #c0392b 14%, transparent); animation: micpulse 1.1s ease-in-out infinite; }
@keyframes micpulse { 50% { transform: scale(1.06); } }
.voice-status { margin: 6px 18px 0; font-size: 13px; color: var(--dim); }
.voice-status.is-rec { color: #c0392b; }
.msg.bot .playbtn { display: inline-flex; align-items: center; gap: 4px; margin-top: 8px; border: 0; background: transparent; color: var(--dim); font: inherit; font-size: 13px; padding: 0; cursor: pointer; }
.msg.bot .playbtn.is-on, .msg.bot .playbtn:active { color: var(--accent, #6c5ce7); }

/* 1.13.0 reminders + memory pages */
.page-note { margin: 8px 0 14px; font-size: 13px; line-height: 1.6; color: var(--dim); }
.rem-list, .mem-list { display: flex; flex-direction: column; gap: 8px; }
.rem-item, .mem-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 12px 14px; border-radius: 14px; background: var(--card, var(--hover)); }
.rem-when, .mem-key { font-size: 13px; color: var(--dim); margin-bottom: 4px; }
.rem-text, .mem-val { font-size: 15px; line-height: 1.5; }
.rem-del, .mem-del { flex-shrink: 0; }
.mem-toggle { display: flex; align-items: center; gap: 8px; margin: 4px 0 14px; font-size: 15px; }
.mem-toggle input { width: 18px; height: 18px; }
.rem-page .msg-notice, .mem-page .msg-notice { margin-top: 8px; }

/* 1.15.0 Android phone login + Cafe Bazaar top-ups */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 28px 20px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; font-weight: 700; line-height: 1.4; }
.login-sub { margin: 0 0 8px; color: var(--dim); font-size: 15px; line-height: 1.8; }
.login-sub .ltr-num { direction: ltr; unicode-bidi: isolate; display: inline-block; font-variant-numeric: tabular-nums; }
.login-err { margin: 0; color: var(--danger, #D92D20); font-size: 14px; line-height: 1.6; }
.login-card .btn { width: 100%; }
.topup-block { margin: 22px 4px 8px; }
.topup-block h3 { margin: 0 0 6px; font-size: 16px; }
.topup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--divider, #E8E8EA);
}
.topup-copy { display: flex; align-items: center; gap: 8px; }
/* 1.15.1: quiet one-line pointer to sending voice to the bot (Bale mini app, no mic button) */
.voice-bot-hint { display: block; width: 100%; margin: 6px 0 0; padding: 2px 8px; border: 0; background: transparent; color: var(--muted, #8a8f98); font: inherit; font-size: 12px; line-height: 1.6; text-align: center; cursor: pointer; }
.voice-bot-hint:active { opacity: .7; }
/* 1.16.0 Bale first run: one «connect your Bale number» screen (replaces the three intro slides) */
.welcome { display: flex; flex-direction: column; min-height: 100%; height: 100%; padding: calc(36px + env(safe-area-inset-top)) 24px calc(22px + env(safe-area-inset-bottom)); max-width: 440px; margin: 0 auto; }
.welcome-top { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 4px; }
.welcome-logo { width: 96px; height: 96px; border-radius: 28px; box-shadow: var(--shadow-chip); margin-bottom: 18px; object-fit: cover; }
.welcome-top h1 { margin: 0 0 8px; font-size: 24px; font-weight: 700; line-height: 1.4; color: var(--text); }
.welcome-top p { margin: 0; max-width: 320px; color: var(--dim); font-size: 15.5px; line-height: 1.8; }
.welcome-actions { display: flex; flex-direction: column; gap: 10px; }
.welcome-note { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.7; text-align: center; background: var(--bubble); color: var(--dim); }
.welcome-note.is-warn { color: var(--danger, #D92D20); background: transparent; padding: 4px 8px; }
.welcome-note .dots { flex: none; }
.welcome-guest { border: 0; background: transparent; color: var(--dim); font: inherit; font-size: 14.5px; font-weight: 500; padding: 10px 8px; cursor: pointer; }
.welcome-guest:active { opacity: .6; }
.welcome-privacy { margin: 2px 0 0; color: var(--dim); opacity: .75; font-size: 12px; line-height: 1.6; text-align: center; }
/* 1.16.2: Android in-app purchase not available → visible message instead of an empty buy bar */
.pay-soon { background: color-mix(in srgb, var(--accent, #7048e8) 10%, transparent); border: 1px solid color-mix(in srgb, var(--accent, #7048e8) 30%, transparent);
  border-radius: 14px; padding: 12px 14px; }
.pay-soon p { margin: 0; font-size: 14px; line-height: 1.8; text-align: center; }
/* 1.16.2: «پاسخ با مدل سبک‌تر» badge under a paid answer from a fallback model */
.msg.bot .msg-badge.lighter { display: inline-block; margin: 4px 6px 0; padding: 2px 8px; border-radius: 999px; font-size: 11px; line-height: 1.6; color: var(--dim, #6b7280); background: var(--chip, rgba(127,127,127,.12)); }
