/* دستیار — components, Grok Bot light language. */

body.phone, body.phone #app, body.phone .screen {
  width: 390px;
  height: 844px;
}
body.phone { overflow: hidden; }
#app { height: 100%; }

.screen {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}
.screen.is-list { background: var(--bg-list); }
.scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

.icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
html[dir="rtl"] .flip-rtl { transform: scaleX(-1); }

.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }

/* ——— circular icon buttons (search, +, back) ——— */
.ibtn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-chip);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  color: var(--text);
}
.ibtn svg { width: 20px; height: 20px; }

/* ——— avatars ——— */
.av {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  line-height: 0;
}
.av svg { display: block; }

/* ——— list header ——— */
.listhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  flex: none;
}
.listhead .actions { display: flex; align-items: center; gap: 8px; }

/* ——— bot rows ——— */
.bot-list { padding: 4px 10px 24px; }
.bot-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  width: 100%;
  text-align: start;
}
.bot-row.is-selected { background: var(--selected); }
.bot-row .mid { flex: 1; min-width: 0; }
.bot-row .name {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bot-row .prev {
  color: var(--dim);
  font-size: 13.5px;
  font-weight: 400;
  line-height: 1.45;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.unread-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--badge);
  flex: none;
}

.unread-pill {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: var(--badge);
  color: #fff;
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-float);
  white-space: nowrap;
  z-index: 3;
}
.unread-pill svg { width: 16px; height: 16px; }

/* ——— chat header ——— */
.chathead {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  flex: none;
  background: var(--bg);
}
.chathead .sp { flex: 1; display: flex; justify-content: center; min-width: 0; }
.name-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border-radius: var(--radius-pill);
  padding: 5px 12px 5px 8px;
  box-shadow: var(--shadow-chip);
  font-weight: 600;
  font-size: 14px;
  max-width: 70%;
  min-width: 0;
}
.name-pill .t {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.credit-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  box-shadow: var(--shadow-chip);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  max-width: 180px;
  overflow: hidden;
  white-space: nowrap;
}
.credit-chip.is-empty, .credit-chip.is-low { color: var(--text); }
.phone-state { font-size: 13px; color: var(--dim); margin-top: 8px; }

/* legacy plainhead (also used conceptually) */
.plainhead {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  flex: none;
  background: var(--bg);
}
.plainhead .t { font-weight: 600; font-size: 16px; }
.back.ibtn { /* already styled */ }

/* ——— chat messages ——— */
.msgs { padding: 8px 16px 16px; display: flex; flex-direction: column; gap: 8px; }
.msg { display: flex; flex-direction: column; max-width: 100%; }
.msg.user { align-items: flex-start; }   /* right in RTL */
.msg.bot { align-items: flex-end; }      /* left in RTL */
.bubble {
  max-width: 85%;
  padding: 10px 16px;
  font-size: 15px;
  line-height: 1.7;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  border: 0;
}
.msg.user .bubble {
  background: var(--user-bubble);
  color: var(--on-user);
  border-radius: 22px;
}
.msg.bot .bubble {
  background: var(--bubble);
  color: var(--text);
  border-radius: 22px;
}
.msg.bot.is-reminder .bubble {
  background: color-mix(in srgb, var(--badge) 12%, var(--bubble));
  box-shadow: inset 3px 0 0 var(--badge);
}
.msg.bot .bubble p { margin: 0 0 8px; }
.msg.bot .bubble p:last-child { margin-bottom: 0; }
.msg .meta {
  color: var(--faint);
  font-size: 11.5px;
  margin-top: 4px;
  padding: 0 6px;
  align-self: inherit;
}
.from-line {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  color: var(--faint);
  font-size: 12px;
  padding: 4px 4px 2px;
  align-self: flex-start;
}
.from-line .n { color: var(--dim); }

/* choice / question card */
.choice-card {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 22px;
  padding: 14px 16px 12px;
  max-width: 88%;
  align-self: flex-end;
  text-align: start;
}
.choice-card .q {
  color: var(--dim);
  font-size: 14.5px;
  line-height: 1.7;
  margin: 0 0 12px;
  font-weight: 400;
}
.choice-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 400;
  width: 100%;
  text-align: start;
}
.choice-letter {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--purple);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

/* composer */
.composer {
  padding: 8px 12px 16px;
  flex: none;
  background: var(--bg);
}
.inputbox {
  display: flex;
  align-items: flex-end;
  background: var(--bubble);
  border-radius: 28px;
  padding: 6px 18px 6px 6px;
  min-height: 52px;
}
.inputbox textarea {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  resize: none;
  font-size: 15px;
  line-height: 1.6;
  max-height: 140px;
  padding: 9px 0;
}
.inputbox textarea::placeholder { color: var(--faint); }
.sendbtn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--purple);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.sendbtn:disabled { opacity: .4; }
.composer.is-locked .inputbox { opacity: .55; }
.composer.is-locked textarea { pointer-events: none; }

/* banners in chat — same card language as choice cards */
.quota-banner {
  margin: 0 16px 8px;
  border-radius: 22px;
  padding: 14px 16px 16px;
  flex: none;
  background: var(--surface);
  border: 1px solid var(--divider);
}
.quota-banner.is-danger { border-color: color-mix(in srgb, var(--danger) 28%, var(--divider)); }
.quota-banner.is-soft { border-color: color-mix(in srgb, var(--warning) 30%, var(--divider)); }
.quota-banner h2 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
}
.quota-banner.is-danger h2 { color: var(--danger); }
.quota-banner.is-soft h2 { color: var(--warning); }
.quota-banner p {
  margin: 0 0 14px;
  color: var(--dim);
  font-size: 14px;
  line-height: 1.7;
  font-weight: 400;
}
.quota-banner .meta-line {
  color: var(--dim);
  font-size: 12.5px;
  margin: -8px 0 0;
}

/* ——— buttons ——— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 15px;
  width: 100%;
  text-align: center;
}
.btn-accent {
  background: var(--purple);
  color: #fff;
}
.btn-primary {
  /* kept for onboarding (inverted in dark, dark fill in light via --send) */
  background: var(--send);
  color: var(--onsend);
}
.btn-ghost {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-chip);
}
.btn-soft {
  background: var(--bubble);
  color: var(--dim);
  font-weight: 500;
}
.btn[disabled] { opacity: .45; }

/* ——— wallet / usage / plans ——— */
.page-body { padding: 16px var(--pad-x) 24px; }

.balance-card {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 22px;
  padding: 22px 20px 18px;
  text-align: center;
}
.free-badge {
  display: inline-flex;
  align-items: center;
  background: var(--success-soft);
  color: var(--success);
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 10px;
}
.balance-label { color: var(--dim); font-size: 13px; margin: 0 0 4px; }
.balance-amount {
  font-size: 56px;
  font-weight: 600;
  letter-spacing: -1px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  margin: 0;
}
.usage-bar {
  height: 6px;
  border-radius: 4px;
  background: var(--divider);
  overflow: hidden;
  direction: rtl;
  margin-top: 16px;
}
.usage-bar > i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--purple);
}
.usage-bar.is-low > i { background: var(--warning); }
.usage-bar.is-empty > i { background: var(--danger); }
.usage-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  color: var(--dim);
  font-size: 12.5px;
}
.usage-meta b { color: var(--text); font-weight: 600; }

.cta-gap { margin-top: 16px; }
.note { color: var(--dim); font-size: 13px; line-height: 1.7; margin: 12px 0 0; font-weight: 400; }

.section-title {
  margin: 26px 2px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--dim);
}

.tx-list { display: flex; flex-direction: column; }
.tx-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--divider);
}
.tx-row:last-child { border-bottom: 0; }
.tx-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  color: var(--dim);
  background: var(--bubble);
}
.tx-icon.is-grant { color: var(--success); background: var(--success-soft); }
.tx-icon.is-usage { color: var(--dim); background: var(--bubble); }
.tx-icon.is-purchase { color: var(--purple); background: var(--purple-soft); }
.tx-icon.is-plan { color: var(--purple); background: var(--purple-soft); }
.tx-icon.is-admin { color: #0F7A6C; background: #E6F5F2; }
:root.dark .tx-icon.is-admin { color: #4DB6A6; background: #1A2E2B; }
.tx-row .mid { flex: 1; min-width: 0; }
.tx-row .title { font-size: 14.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-row .when { color: var(--faint); font-size: 12px; }
.tx-type { color: var(--faint); font-size: 11.5px; margin-inline-start: 6px; }
.tx-amt { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 14.5px; flex: none; }
.tx-amt.is-pos { color: var(--success); }
.tx-amt.is-neg { color: var(--text); }

/* usage ring */
.ring-wrap { display: flex; flex-direction: column; align-items: center; padding: 20px 16px 8px; }
.ring { width: 200px; height: 200px; position: relative; }
.ring svg { width: 200px; height: 200px; transform: rotate(-90deg); }
.ring .track { stroke: var(--divider); }
.ring .val { stroke: var(--purple); stroke-linecap: round; }
.ring.is-low .val { stroke: var(--warning); }
.ring.is-empty .val { stroke: var(--danger); }
.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; pointer-events: none;
}
.ring-center .big { font-size: 40px; font-weight: 600; letter-spacing: -1px; line-height: 1; font-variant-numeric: tabular-nums; }
.ring-center .sub { color: var(--dim); font-size: 13px; margin-top: 6px; font-weight: 400; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 16px;
  padding: 14px 14px 12px;
}
.stat .k { color: var(--dim); font-size: 12px; margin-bottom: 4px; font-weight: 400; }
.stat .v { font-weight: 600; font-size: 15.5px; line-height: 1.4; }
.plan-pill {
  display: inline-flex;
  margin: 14px auto 0;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--bubble);
  color: var(--dim);
  font-size: 13px;
}

/* plans */
.plan-list { display: flex; flex-direction: column; gap: 8px; }
.plan-card {
  display: block;
  width: 100%;
  text-align: start;
  background: var(--surface);
  border-radius: 20px;
  padding: 12px 14px 11px;
  border: 1px solid var(--divider);
  position: relative;
}
.plan-card.is-selected {
  border-color: var(--purple);
  background: var(--purple-soft);
  box-shadow: 0 0 0 1px var(--purple);
}
.plan-card .top { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.plan-card .name { font-size: 16px; font-weight: 700; flex: 1; min-width: 0; }
.plan-badge {
  display: inline-flex;
  background: var(--purple);
  color: #fff;
  border-radius: var(--radius-pill);
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
}
.plan-badge.is-discount { background: var(--warning-soft); color: var(--warning); }
.plan-price { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin: 1px 0 4px; }
.plan-price .now { font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
.plan-price .cur { font-size: 13px; color: var(--dim); font-weight: 400; }
.plan-price .old { font-size: 13.5px; color: var(--faint); text-decoration: line-through; font-variant-numeric: tabular-nums; }
.plan-spec { color: var(--dim); font-size: 12px; margin-bottom: 4px; }
.plan-features { margin: 0; padding: 0; list-style: none; }
.plan-features li {
  position: relative;
  padding-inline-start: 16px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  font-weight: 400;
}
.plan-features li::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0.55em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--purple);
}
.plan-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--divider);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.plan-card.is-selected .plan-check {
  background: var(--purple);
  border-color: var(--purple);
  color: #fff;
}
.cta-bar {
  flex: none;
  padding: 8px 20px 14px;
  background: var(--bg);
}
.cta-bar .note { margin: 0 0 10px; text-align: center; }

.summary-card {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 20px;
  padding: 18px 16px;
}
.summary-card h2 { margin: 0 0 6px; font-size: 18px; font-weight: 700; }
.summary-card .price { font-size: 22px; font-weight: 600; margin: 0 0 8px; }
.summary-card p { margin: 0; color: var(--dim); font-size: 13.5px; }

/* ——— onboarding (unchanged structure; works in light or dark) ——— */
.ob { display: flex; flex-direction: column; height: 100%; padding: 16px 24px 20px; }
.ob-skip {
  align-self: flex-end;
  color: var(--dim);
  font-size: 15px;
  font-weight: 500;
  min-height: 40px;
  padding: 8px 4px;
}
.ob-art { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 220px; }
.ob-art .scene { width: 220px; height: 220px; }
.ob-copy { text-align: center; padding: 8px 8px 18px; }
.ob-copy h1 { margin: 0 0 10px; font-size: 24px; font-weight: 700; line-height: 1.4; }
.ob-copy p { margin: 0; color: var(--dim); font-size: 15.5px; line-height: 1.8; font-weight: 400; }
.ob-dots { display: flex; justify-content: center; gap: 8px; margin: 4px 0 18px; }
.ob-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--divider); display: block; }
.ob-dots i.is-on { background: var(--text); width: 22px; border-radius: 4px; }
.ob-actions { display: flex; flex-direction: column; gap: 8px; }

.gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 14px;
  text-align: center;
  padding: 36px 28px;
  color: var(--text);
}
.gate p { color: var(--dim); margin: 0; font-size: 15.5px; line-height: 1.8; }
.gate .av { margin-bottom: 8px; }

/* gallery */
body.gallery {
  background: #F4F4F4;
  color: #1C1C1C;
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}
.gallery h1 { font-size: 28px; margin: 0 0 6px; }
.gallery .lead { color: #5D5D5D; margin: 0 0 28px; font-size: 15px; }
.gallery h2 { font-size: 15px; color: #5D5D5D; font-weight: 600; margin: 28px 0 12px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 18px;
}
.thumb {
  display: block;
  color: inherit;
  background: #fff;
  border: 1px solid #E8E8EA;
  border-radius: 16px;
  overflow: hidden;
}
.thumb img, .thumb .frame {
  display: block;
  width: 100%;
  aspect-ratio: 390 / 844;
  object-fit: cover;
  object-position: top;
  background: #FCFCFC;
  border: 0;
}
.thumb .cap { padding: 10px 12px 12px; font-size: 13.5px; font-weight: 600; }
.thumb .cap span { display: block; color: #5D5D5D; font-weight: 400; font-size: 12px; margin-top: 2px; }
.links { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; }
.links a {
  color: #1C1C1C;
  background: #fff;
  border: 1px solid #E8E8EA;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
}
