/* ============================================================
   PERSONAL ASSISTANT — style.css
   تم مونوکروم (سیاه/سفید/خاکستری) — بدون هیچ رنگ آبی
   ============================================================ */

/* ============================================
   VARIABLES
   ============================================ */
:root {
  --bg: #f5f5f5;
  --bg-elevated: #ffffff;
  --text: #0a0a0a;
  --text-soft: #666666;
  --text-muted: #999999;
  --card: #ffffff;
  --card-elevated: #fafafa;
  --border: rgba(0,0,0,0.08);
  --border-strong: rgba(0,0,0,0.15);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.12);
  --shadow-xl: 0 20px 48px rgba(0,0,0,0.16);
  --overlay: rgba(0,0,0,0.45);
  --input-bg: #eeeeee;
  --danger: #d4183d;
  --success: #0a8a3a;
  --warning: #b86b00;

  /* حالت‌های خنثی */
  --hover: rgba(0,0,0,0.05);
  --hover-strong: rgba(0,0,0,0.09);
  --focus-ring: rgba(0,0,0,0.08);
  --track-bg: rgba(0,0,0,0.08);

  /* دکمه/اکشن اصلی */
  --action-bg: #0a0a0a;
  --action-text: #ffffff;
}

html.dark {
  --bg: #0a0a0a;
  --bg-elevated: #141414;
  --text: #f5f5f5;
  --text-soft: #888888;
  --text-muted: #555555;
  --card: #141414;
  --card-elevated: #1a1a1a;
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.15);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.6);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.7);
  --shadow-xl: 0 20px 48px rgba(0,0,0,0.8);
  --overlay: rgba(0,0,0,0.75);
  --input-bg: #1f1f1f;

  --hover: rgba(255,255,255,0.06);
  --hover-strong: rgba(255,255,255,0.1);
  --focus-ring: rgba(255,255,255,0.08);
  --track-bg: rgba(255,255,255,0.12);

  --action-bg: #f5f5f5;
  --action-text: #0a0a0a;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html[lang="fa"] body,
html[lang="ar"] body { font-family: 'Vazirmatn', 'Noto Sans Arabic', Tahoma, sans-serif; }
html[lang="zh"] body { font-family: 'Noto Sans SC', sans-serif; }
html[lang="ja"] body { font-family: 'Noto Sans JP', sans-serif; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
input, textarea { font-family: inherit; }

/* ============================================
   ICONS — مینیمال (1.5)
   ============================================ */
button svg,
.icon-btn svg,
.menu-item svg,
.settings-card-icon svg,
.context-menu-item svg,
.choice-btn svg,
.drawer svg,
.chat-bubble svg,
.code-block svg,
.premium-icon svg,
.user-badge svg,
.empty-icon svg,
.back-btn svg,
.close-btn svg,
.auth-back-btn svg,
.password-toggle svg,
.chat-handle-icon svg,
.chat-header-title svg,
.chat-attach-btn svg,
.chat-send-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.icon-btn svg [fill]:not([fill="none"]),
.user-badge svg [fill]:not([fill="none"]) {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  background: var(--bg);
  overflow-y: auto;
  animation: screenFadeIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.screen.active { display: flex; }

@keyframes screenFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   WELCOME
   ============================================ */
.welcome-screen { align-items: center; justify-content: center; padding: 24px; }
.welcome-container {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 30px 0;
  animation: fadeIn 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.welcome-logo {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--action-bg);
  color: var(--action-text);
  animation: pulse 3s ease-in-out infinite;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.welcome-logo svg {
  width: 52px;
  height: 52px;
  stroke-width: 1.5;
  stroke: var(--action-text);
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}
.welcome-title { font-size: 28px; font-weight: 800; text-align: center; }
.welcome-subtitle { font-size: 15px; color: var(--text-soft); text-align: center; margin-top: -10px; }
.welcome-actions { width: 100%; display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.welcome-footer { font-size: 12px; color: var(--text-soft); text-align: center; margin-top: 10px; line-height: 1.5; }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.15s ease;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--action-bg);
  color: var(--action-text);
  border: 1.5px solid var(--action-bg);
}
.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--border-strong);
}
.btn-secondary:active { background: var(--hover); }
.btn-full { width: 100%; }

.link-btn {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s ease;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border-strong);
}
.link-btn:hover { background: var(--hover); }

/* ============================================
   AUTH
   ============================================ */
.auth-screen { align-items: center; padding: 24px; }
.auth-container {
  width: 100%;
  max-width: 420px;
  padding: 30px 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: fadeIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.auth-back-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  transition: transform 0.15s ease, background 0.15s ease;
}
.auth-back-btn:hover { background: var(--hover); }
.auth-back-btn:active { transform: scale(0.92); }
.auth-back-btn svg { width: 20px; height: 20px; stroke: var(--text); }
html[dir="rtl"] .auth-back-btn svg { transform: rotate(180deg); }

.auth-header { display: flex; flex-direction: column; gap: 6px; }
.auth-title { font-size: 26px; font-weight: 800; }
.auth-subtitle { font-size: 14px; color: var(--text-soft); }

.auth-form { display: flex; flex-direction: column; gap: 16px; margin-top: 8px; }
.auth-input-group { display: flex; flex-direction: column; gap: 8px; }
.auth-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: 0.3px;
}
.auth-input-wrap { position: relative; width: 100%; }
.auth-input {
  width: 100%;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1.5px solid transparent;
  background: var(--input-bg);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: all 0.2s ease;
}
.auth-input:focus {
  border-color: var(--border-strong);
  background: var(--card);
  box-shadow: 0 0 0 4px var(--focus-ring);
}
.auth-input::placeholder { color: var(--text-muted); }
.auth-input-wrap .auth-input { padding-right: 50px; }
html[dir="rtl"] .auth-input-wrap .auth-input { padding-right: 18px; padding-left: 50px; }

.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  transition: background 0.15s ease;
}
.password-toggle:hover { background: var(--hover); }
html[dir="rtl"] .password-toggle { right: auto; left: 8px; }
.password-toggle svg { width: 18px; height: 18px; stroke: var(--text-soft); }
.password-toggle.showing svg { stroke: var(--text); }

.auth-options { display: flex; align-items: center; justify-content: space-between; }
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.checkbox-custom {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid var(--border-strong);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  position: relative;
}
.checkbox-custom::after {
  content: '';
  width: 5px;
  height: 10px;
  border: solid var(--action-text);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg) scale(0);
  position: absolute;
  top: 1px;
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.checkbox-label input:checked + .checkbox-custom {
  background: var(--action-bg);
  border-color: var(--action-bg);
}
.checkbox-label input:checked + .checkbox-custom::after {
  transform: rotate(45deg) scale(1);
}

.auth-error {
  display: none;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(212,24,61,0.08);
  color: var(--danger);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
}
.auth-error.show { display: block; }

.auth-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-soft);
  margin-top: 8px;
}

.password-strength {
  display: none;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}
.password-strength.show { display: flex; }
.strength-bar {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--track-bg);
  overflow: hidden;
}
.strength-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: var(--text);
  transition: width 0.3s ease;
}
.strength-fill.weak { width: 33%; }
.strength-fill.medium { width: 66%; }
.strength-fill.strong { width: 100%; }
.strength-text { font-size: 11px; color: var(--text-soft); }

/* ============================================
   APP
   ============================================ */
.app { width: 100%; height: 100%; position: relative; display: none; }
.app.active { display: block; }

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 100;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.icon-btn:hover { background: var(--hover); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg { width: 20px; height: 20px; stroke: var(--text); }

/* ============================================
   LIMIT BADGE — خنثی
   ============================================ */
.limit-badge {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 100px;
  background: transparent;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  border: 1.5px solid var(--border-strong);
  transition: all 0.25s ease;
  min-width: 46px;
}
.limit-badge.limit-low {
  color: var(--warning);
  border-color: var(--warning);
}
.limit-badge.limit-empty {
  color: var(--danger);
  border-color: var(--danger);
}

/* ============================================
   LANGUAGE PANEL — خنثی
   ============================================ */
.lang-panel {
  position: fixed;
  top: 75px;
  right: 18px;
  width: 230px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 8px;
  max-height: 70vh;
  overflow-y: auto;
  z-index: 400;
  display: none;
  opacity: 0;
  transform: translateY(-8px) scale(0.95);
  transition: opacity 0.2s cubic-bezier(0.32, 0.72, 0, 1), transform 0.2s cubic-bezier(0.32, 0.72, 0, 1);
  border: 1px solid var(--border);
}
html[dir="rtl"] .lang-panel { right: auto; left: 18px; }
.lang-panel.show { display: block; opacity: 1; transform: translateY(0) scale(1); }
.lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  width: 100%;
  text-align: left;
  font-size: 14px;
  transition: background 0.15s ease;
  font-family: inherit;
  color: var(--text);
}
html[dir="rtl"] .lang-option { text-align: right; }
.lang-option:hover { background: var(--hover); }
.lang-option.selected { background: var(--hover-strong); font-weight: 600; }
.lang-option .flag { font-size: 18px; }
.lang-option .lang-name { flex: 1; }
.lang-option .check { width: 14px; height: 14px; opacity: 0; stroke: var(--text); stroke-width: 2; }
.lang-option.selected .check { opacity: 1; }

/* ============================================
   ORB
   ============================================ */
.orb-wrapper {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  cursor: pointer;
  user-select: none;
  transition: top 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;
}
.orb-wrapper.hidden { opacity: 0; pointer-events: none; }
.orb-wrapper.chat-open { top: 15%; }
.orb-container {
  position: relative;
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1), height 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.orb-wrapper.chat-open .orb-container { width: 80px; height: 80px; }
.orb-container::before {
  content: '';
  position: absolute;
  inset: -40px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--hover-strong) 0%, transparent 70%);
  animation: pulse-halo 4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes pulse-halo {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.6; }
}
.orb {
  position: relative;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: var(--card);
  border: 1.5px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}
.orb-wrapper.chat-open .orb { width: 70px; height: 70px; }

/* حالت‌های orb — همه خاکستری */
.orb-wrapper.listening .orb {
  background: var(--text);
  border-color: var(--text);
  transform: scale(1.03);
}
.orb-wrapper.thinking .orb {
  background: var(--text-soft);
  border-color: var(--text-soft);
}
.orb-wrapper.speaking .orb {
  background: var(--text);
  border-color: var(--text);
  animation: speakPulse 1.5s ease-in-out infinite;
}
@keyframes speakPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.wave-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 50px;
  position: relative;
  z-index: 1;
}
.orb-wrapper.chat-open .wave-group { height: 24px; gap: 3px; }
.orb-wrapper.chat-open .wave-bar { width: 3px; }
.wave-bar {
  width: 5px;
  height: 10px;
  border-radius: 3px;
  background: var(--text-soft);
  transition: background 0.2s ease, height 0.15s ease-in-out;
}
.orb-wrapper.listening .wave-bar,
.orb-wrapper.speaking .wave-bar,
.orb-wrapper.thinking .wave-bar { background: var(--action-text); }
.orb-wrapper.chat-open .wave-bar { background: var(--text-soft); }

.status-text {
  font-size: 15px;
  color: var(--text-soft);
  font-weight: 500;
  text-align: center;
  min-height: 22px;
  padding: 0 20px;
  transition: opacity 0.25s ease;
}
.orb-wrapper.chat-open .status-text { opacity: 0; }

/* ============================================
   OVERLAY & DRAWERS
   ============================================ */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 200;
  display: none;
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
}
.overlay.show {
  display: block;
  opacity: 1;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 300px;
  max-width: 85vw;
  background: var(--card);
  z-index: 300;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  transition: transform 0.42s cubic-bezier(0.32, 0.72, 0, 1);
  will-change: transform;
}
html[dir="ltr"] .drawer { left: 0; transform: translateX(-100%); }
html[dir="rtl"] .drawer { right: 0; transform: translateX(100%); }
.drawer.open { transform: translateX(0) !important; }
.sub-drawer { z-index: 350; }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.user-profile { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.user-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--action-bg);
  color: var(--action-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: 16px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-email {
  font-size: 12px;
  color: var(--text-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}
.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 8px;
  background: var(--action-bg);
  color: var(--action-text);
  margin-top: 4px;
  letter-spacing: 0.3px;
  border: 1px solid var(--border-strong);
}
.user-badge svg { width: 10px; height: 10px; stroke-width: 1.5; stroke: var(--action-text); }

.close-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--hover);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  flex-shrink: 0;
  transition: all 0.2s ease;
}
.close-btn:hover { background: var(--hover-strong); }
.close-btn:active { transform: scale(0.92); }
.close-btn svg { width: 18px; height: 18px; }

.back-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  flex-shrink: 0;
  transition: all 0.2s ease;
}
.back-btn:hover { background: var(--hover); }
.back-btn:active { transform: scale(0.95); }
.back-btn svg { width: 20px; height: 20px; stroke: currentColor; }
html[dir="rtl"] .back-btn svg { transform: rotate(180deg); }

.drawer-title { font-size: 17px; font-weight: 700; flex: 1; text-align: center; }
.drawer-menu {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  transition: background 0.2s ease, color 0.2s ease;
  color: var(--text);
}
.menu-item:hover { background: var(--hover); }
.menu-item:active { transform: scale(0.98); }
.menu-item svg { width: 20px; height: 20px; stroke: currentColor; }
.menu-item span:first-of-type { flex: 1; }
.menu-badge {
  background: var(--action-bg);
  color: var(--action-text);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 10px;
  min-width: 22px;
  text-align: center;
}
.menu-divider { height: 1px; background: var(--border); margin: 8px 16px; }
.menu-item.logout { color: var(--danger); }
.menu-item.logout:hover { background: rgba(212,24,61,0.08); }
.menu-item.premium {
  background: transparent;
  border: 1.5px solid var(--border-strong);
  margin-bottom: 8px;
}
.menu-item.premium:hover { background: var(--hover); }
.menu-item.premium svg { stroke: var(--text); }

.drawer.open .menu-item { animation: slideInMenu 0.5s cubic-bezier(0.22, 1, 0.36, 1) backwards; }
.drawer.open .menu-item:nth-child(1) { animation-delay: 0.08s; }
.drawer.open .menu-item:nth-child(2) { animation-delay: 0.13s; }
.drawer.open .menu-item:nth-child(3) { animation-delay: 0.18s; }
.drawer.open .menu-item:nth-child(4) { animation-delay: 0.23s; }
.drawer.open .menu-item:nth-child(5) { animation-delay: 0.28s; }
.drawer.open .menu-item:nth-child(6) { animation-delay: 0.33s; }

@keyframes slideInMenu {
  from { opacity: 0; transform: translateX(-24px); }
  to { opacity: 1; transform: translateX(0); }
}
html[dir="rtl"] .drawer.open .menu-item { animation-name: slideInMenuRTL; }
@keyframes slideInMenuRTL {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-soft);
}
.empty-icon { opacity: 0.35; color: var(--text); animation: floatIcon 3s ease-in-out infinite; }
.empty-icon svg { width: 56px; height: 56px; }
@keyframes floatIcon {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.empty-text { font-size: 14px; font-weight: 500; line-height: 1.6; max-width: 260px; }

/* ============================================
   SETTINGS CARDS
   ============================================ */
.settings-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: 14px;
  background: transparent;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  margin-bottom: 10px;
  animation: slideIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
.settings-card:nth-child(1) { animation-delay: 0.08s; }
.settings-card:nth-child(2) { animation-delay: 0.13s; }
.settings-card:nth-child(3) { animation-delay: 0.18s; }
.settings-card:nth-child(4) { animation-delay: 0.23s; }
.settings-card:nth-child(5) { animation-delay: 0.28s; }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

.settings-card:hover {
  background: var(--hover);
  border-color: var(--border-strong);
}
.settings-card:active { transform: scale(0.99); }

.settings-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.settings-card:hover .settings-card-icon { transform: scale(1.1); }
.settings-card-info { flex: 1; min-width: 0; }
.settings-card-title { font-size: 15px; font-weight: 600; }
.settings-card-sub { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.settings-card-arrow { color: var(--text-muted); font-size: 18px; transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1); }
.settings-card:hover .settings-card-arrow { transform: translateX(3px); }
html[dir="rtl"] .settings-card:hover .settings-card-arrow { transform: translateX(-3px); }

.setting-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border-radius: 14px;
  background: transparent;
  border: 1px solid var(--border);
  margin-bottom: 10px;
  animation: slideIn 0.4s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
.setting-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.setting-label {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.setting-label svg { width: 16px; height: 16px; }
.setting-value { font-size: 13px; color: var(--text); font-weight: 700; }
.setting-hint {
  font-size: 11px;
  color: var(--text-soft);
  margin-top: 6px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.setting-hint svg {
  width: 12px;
  height: 12px;
  display: inline-block;
  vertical-align: middle;
  margin-right: 4px;
}
html[dir="rtl"] .setting-hint svg { margin-right: 0; margin-left: 4px; }

.setting-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--track-bg);
  outline: none;
}
.setting-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--action-bg);
  border: 1.5px solid var(--action-bg);
  cursor: pointer;
  transition: transform 0.15s ease;
}
.setting-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--action-bg);
  border: 1.5px solid var(--action-bg);
  cursor: pointer;
}
.setting-slider::-webkit-slider-thumb:active { transform: scale(1.2); }

.setting-switch {
  position: relative;
  width: 46px;
  height: 26px;
  border-radius: 13px;
  background: var(--track-bg);
  cursor: pointer;
  transition: background 0.25s ease;
  flex-shrink: 0;
}
.setting-switch.on { background: var(--action-bg); }
.setting-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-elevated);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
html.dark .setting-switch::after { background: #f5f5f5; }
.setting-switch.on::after { transform: translateX(20px); }

.choice-row { display: flex; gap: 8px; flex-wrap: wrap; }
.choice-btn {
  padding: 8px 14px;
  border-radius: 10px;
  background: transparent;
  border: 1.5px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text);
}
.choice-btn svg { width: 14px; height: 14px; stroke: currentColor; }
.choice-btn:hover { background: var(--hover); border-color: var(--border-strong); }
.choice-btn:active { transform: scale(0.96); }
.choice-btn.active {
  border-color: var(--text);
  background: var(--action-bg);
  color: var(--action-text);
}

.danger-btn {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  background: transparent;
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
  margin-bottom: 8px;
  border: 1.5px solid var(--danger);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.danger-btn svg { width: 16px; height: 16px; stroke: currentColor; }
.danger-btn:hover { background: rgba(212,24,61,0.08); }
.danger-btn:active { transform: scale(0.98); }

/* ============================================
   CHAT DRAWER
   ============================================ */
.chat-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 88vh;
  background: var(--bg);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  border-top: 1px solid var(--border);
  transform: translateY(calc(100% - 72px));
  transition: transform 0.45s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 250;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-drawer.open { transform: translateY(0); }

.chat-handle {
  width: 100%;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: grab;
  flex-shrink: 0;
  user-select: none;
  position: relative;
  touch-action: none;
}
.chat-handle:active { cursor: grabbing; }
.chat-handle-bar {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.chat-drawer.open .chat-handle-bar {
  opacity: 0;
  transform: translateX(-50%) scale(0.5);
}
.chat-handle-content {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--card);
  border-radius: 100px;
  box-shadow: var(--shadow-sm);
  margin-top: 8px;
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}
.chat-handle-icon { width: 16px; height: 16px; stroke: var(--text); }
.chat-handle-text { font-size: 13px; font-weight: 600; color: var(--text); }
.chat-handle-count {
  background: var(--action-bg);
  color: var(--action-text);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 100px;
  min-width: 20px;
  text-align: center;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 14px;
  flex-shrink: 0;
}
.chat-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.chat-header-title svg { width: 20px; height: 20px; stroke: currentColor; }

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.chat-list::-webkit-scrollbar { width: 4px; }
.chat-list::-webkit-scrollbar-track { background: transparent; }
.chat-list::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

.chat-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 20px;
  font-size: 14.5px;
  line-height: 1.55;
  word-wrap: break-word;
  animation: bubble-in 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
}
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.chat-bubble.user {
  align-self: flex-end;
  background: var(--action-bg);
  color: var(--action-text);
  border-bottom-right-radius: 6px;
}
html[dir="rtl"] .chat-bubble.user { align-self: flex-start; }
.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--card);
  color: var(--text);
  border-bottom-left-radius: 6px;
  border: 1px solid var(--border);
}
html[dir="rtl"] .chat-bubble.assistant { align-self: flex-end; }
.chat-bubble-image {
  max-width: 100%;
  border-radius: 14px;
  margin-bottom: 8px;
  display: block;
}
.chat-bubble-time {
  display: block;
  font-size: 10px;
  margin-top: 6px;
  opacity: 0.6;
  font-weight: 500;
}
.chat-bubble.user .chat-bubble-time { text-align: right; }
.chat-bubble.assistant .chat-bubble-time { text-align: left; }
html[dir="rtl"] .chat-bubble.user .chat-bubble-time { text-align: left; }
html[dir="rtl"] .chat-bubble.assistant .chat-bubble-time { text-align: right; }

.typing-indicator {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 6px 0;
}
.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-soft);
  animation: typing 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

.chat-input-area {
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  flex-shrink: 0;
}
.chat-image-preview {
  display: none;
  position: relative;
  margin-bottom: 10px;
  padding: 8px;
  background: var(--input-bg);
  border-radius: 14px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
}
.chat-image-preview.show { display: flex; }
.chat-image-preview img {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 10px;
}
.chat-image-preview-info {
  flex: 1;
  font-size: 12px;
  color: var(--text-soft);
}
.chat-image-preview-remove {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-image-preview-remove:hover { background: var(--hover); }
.chat-image-preview-remove svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 1.5;
}

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
}
.chat-attach-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
  align-self: flex-end;
}
.chat-attach-btn:hover { background: var(--hover); }
.chat-attach-btn:active { transform: scale(0.92); }
.chat-attach-btn svg { width: 20px; height: 20px; stroke: var(--text); }

.chat-input {
  flex: 1;
  padding: 11px 18px;
  border-radius: 22px;
  background: var(--input-bg);
  border: 1.5px solid transparent;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 120px;
  min-height: 44px;
  line-height: 1.4;
  transition: border-color 0.2s ease, background 0.2s ease;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.chat-input::-webkit-scrollbar { display: none; width: 0; height: 0; }
.chat-input:focus {
  border-color: var(--border-strong);
  background: var(--card);
}
.chat-input::placeholder { color: var(--text-muted); }

.chat-send-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  background: var(--action-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  align-self: flex-end;
  border: 1.5px solid var(--action-bg);
}
.chat-send-btn:active { transform: scale(0.9); }
.chat-send-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.chat-send-btn svg {
  width: 18px;
  height: 18px;
  stroke: var(--action-text);
  stroke-width: 1.5;
  fill: none;
}

/* ============================================
   HISTORY
   ============================================ */
.history-item {
  padding: 14px 16px 14px 56px;
  border-radius: 12px;
  background: transparent;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  margin-bottom: 8px;
  position: relative;
  animation: slideIn 0.4s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
.history-item:hover { background: var(--hover); border-color: var(--border-strong); }
.history-item:active { transform: scale(0.99); }
.history-item.active-chat {
  background: var(--hover);
  border-color: var(--text);
}
html[dir="rtl"] .history-item.active-chat {
  border-left: none;
}
.history-item-title {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 4px;
}
.history-item-meta {
  font-size: 12px;
  color: var(--text-soft);
  display: flex;
  gap: 10px;
  align-items: center;
}
.history-item-delete {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
html[dir="rtl"] .history-item-delete { left: auto; right: 12px; }
.history-item-delete svg { width: 16px; height: 16px; stroke: currentColor; }
.history-item-delete:hover {
  background: rgba(212,24,61,0.08);
  border-color: var(--danger);
  color: var(--danger);
}

/* ============================================
   PREMIUM — خنثی
   ============================================ */
.premium-page { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.premium-hero {
  text-align: center;
  padding: 30px 20px;
  background: transparent;
  border-radius: 20px;
  border: 1.5px solid var(--border-strong);
  animation: slideIn 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.premium-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--text);
}
.premium-icon svg { width: 60px; height: 60px; stroke-width: 1.5; stroke: currentColor; }
.premium-title { font-size: 24px; font-weight: 800; color: var(--text); margin-bottom: 8px; }
.premium-subtitle { font-size: 14px; color: var(--text-soft); line-height: 1.6; }
.premium-plans { display: flex; flex-direction: column; gap: 12px; }
.premium-plan {
  padding: 20px;
  border-radius: 16px;
  background: transparent;
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
}
.premium-plan:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.premium-plan.selected {
  border-color: var(--text);
  background: var(--hover);
}
.premium-plan.featured { border-color: var(--text); }
.premium-badge {
  position: absolute;
  top: -8px;
  right: 16px;
  background: var(--action-bg);
  color: var(--action-text);
  font-size: 10px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 10px;
  letter-spacing: 0.3px;
}
html[dir="rtl"] .premium-badge { right: auto; left: 16px; }
.premium-plan-title { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.premium-plan-price { font-size: 22px; font-weight: 800; color: var(--text); margin-bottom: 12px; }
.premium-plan-price span { font-size: 14px; color: var(--text-soft); font-weight: 500; }
.premium-plan-features { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.premium-plan-features li {
  font-size: 13px;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: 8px;
}
.premium-plan-features li::before {
  content: '—';
  color: var(--text);
  font-weight: 700;
}
.premium-btn {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  background: var(--action-bg);
  color: var(--action-text);
  font-size: 15px;
  font-weight: 700;
  margin-top: 16px;
  transition: transform 0.2s ease;
  border: 1.5px solid var(--action-bg);
}
.premium-btn:active { transform: scale(0.98); }
.premium-active {
  text-align: center;
  padding: 24px;
  background: transparent;
  border-radius: 16px;
  border: 1.5px solid var(--border-strong);
}
.premium-active-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--text);
}
.premium-active-icon svg { width: 48px; height: 48px; stroke-width: 1.5; stroke: currentColor; }
.premium-active-title { font-size: 20px; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.premium-active-sub { font-size: 13px; color: var(--text-soft); line-height: 1.6; }
.premium-active-info {
  margin-top: 16px;
  padding: 12px;
  background: var(--input-bg);
  border-radius: 12px;
}
.premium-active-plan { font-size: 13px; color: var(--text-soft); margin-bottom: 4px; }
.premium-active-expiry { font-size: 12px; color: var(--text-soft); }

/* ============================================
   TOAST
   ============================================ */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 100%;
  max-width: 400px;
  padding: 0 16px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  animation: toastIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: auto;
  border: 1px solid var(--border);
  border-left: 3px solid var(--text);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast-icon { font-size: 18px; flex-shrink: 0; }
.toast.hide { animation: toastOut 0.3s ease forwards; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-20px); }
}

/* ============================================
   CONTEXT MENU
   ============================================ */
.context-menu {
  position: fixed;
  z-index: 10000;
  min-width: 200px;
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow-xl);
  padding: 6px;
  display: none;
  opacity: 0;
  transform: scale(0.92);
  transform-origin: top left;
  transition: opacity 0.2s cubic-bezier(0.22, 1, 0.36, 1), transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  border: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.context-menu.show { opacity: 1; transform: scale(1); }
.context-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  transition: background 0.15s ease;
}
html[dir="rtl"] .context-menu-item { text-align: right; flex-direction: row-reverse; }
.context-menu-item:hover { background: var(--hover); }
.context-menu-item:active { transform: scale(0.98); }
.context-menu-item svg { width: 18px; height: 18px; stroke: currentColor; }
.context-menu-divider { height: 1px; background: var(--border); margin: 4px 8px; }
.chat-bubble.msg-liked { border-left: 3px solid var(--text); }
.chat-bubble.msg-disliked { border-left: 3px solid var(--text-soft); }

/* ============================================
   CODE BLOCK — همیشه مشکی
   ============================================ */
.code-block {
  margin: 14px 0;
  border-radius: 14px;
  overflow: hidden;
  background: #0d1117;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2), 0 2px 6px rgba(0,0,0,0.1);
  direction: ltr;
  text-align: left;
  animation: codeBlockIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.code-block.incomplete {
  border-color: rgba(255,200,100,0.4);
}
@keyframes codeBlockIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #161b22;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.code-block-lang { display: flex; align-items: center; gap: 10px; }
.code-block-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #8b949e;
  flex-shrink: 0;
}
.code-block-lang-name {
  color: #f0f6fc;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.code-block-lines {
  color: #8b949e;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
}
.code-block-actions { display: flex; gap: 6px; }
.code-block-copy,
.code-block-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  color: #c9d1d9;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid rgba(255,255,255,0.08);
}
.code-block-copy:hover,
.code-block-wrap:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-color: rgba(255,255,255,0.2);
}
.code-block-copy:active,
.code-block-wrap:active { transform: scale(0.95); }
.code-block-copy svg,
.code-block-wrap svg { width: 14px; height: 14px; stroke: currentColor; }
.code-block-wrap.active { background: rgba(255,255,255,0.15); color: #fff; }
.code-block-copy .check-icon { display: none; }
.code-block-copy.copied {
  background: rgba(255,255,255,0.15);
  color: #fff;
}
.code-block-copy.copied .copy-icon { display: none; }
.code-block-copy.copied .check-icon { display: block; }
.code-block-body {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 500px;
  -webkit-overflow-scrolling: touch;
}
.code-block-body::-webkit-scrollbar { width: 8px; height: 8px; }
.code-block-body::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
.code-block-body::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
}
.code-block-body::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.25);
}
.code-block-pre {
  margin: 0;
  padding: 16px 18px;
  font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.65;
  color: #c9d1d9;
  white-space: pre;
  tab-size: 2;
  min-width: 100%;
  width: max-content;
  letter-spacing: 0.2px;
}
.code-block-pre.wrap {
  white-space: pre-wrap;
  word-wrap: break-word;
  width: 100%;
}
.code-block-code {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  white-space: inherit;
}
.code-block-incomplete {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255,200,100,0.08);
  border-top: 1px solid rgba(255,200,100,0.3);
  color: #e6b450;
  font-size: 12px;
  font-weight: 500;
}
.code-block-incomplete svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.5;
  flex-shrink: 0;
}
.cm-comment { color: #8b949e; font-style: italic; }
.cm-keyword { color: #ff7b72; font-weight: 600; }
.cm-string { color: #a5d6ff; }
.cm-number { color: #79c0ff; }
.cm-boolean { color: #79c0ff; font-weight: 600; }
.cm-tag { color: #7ee787; }
.cm-attr { color: #79c0ff; }
.cm-function { color: #d2a8ff; }

.inline-code {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  font-size: 0.88em;
  font-weight: 500;
  direction: ltr;
  border: 1px solid var(--border);
}
.msg-heading {
  font-size: 16px;
  font-weight: 700;
  margin: 12px 0 8px;
  color: var(--text);
}
.chat-bubble.assistant { max-width: 92% !important; }
.chat-bubble-text {
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.65;
  font-size: 14.5px;
}
.chat-bubble-text strong { color: var(--text); font-weight: 700; }
.chat-bubble-text em { font-style: italic; color: var(--text-soft); }
.chat-bubble-text a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border-strong);
}

.hidden { display: none !important; }
.no-select { user-select: none; -webkit-user-select: none; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 480px) {
  .code-block-pre { font-size: 12px; padding: 12px; }
  .code-block-copy .copy-label,
  .code-block-wrap .wrap-label { display: none; }
  .chat-bubble { font-size: 14px; }
  .chat-drawer { height: 92vh; }
  .settings-card-icon svg { width: 20px; height: 20px; }
  .limit-badge { padding: 5px 9px; font-size: 10px; min-width: 40px; }
}

/* ============================================
   UPSELL CARD — دعوت نرم به پرمیوم
   ============================================ */
.upsell-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 18px 16px;
  margin: 6px 0 14px;
  border-radius: 18px;
  background: var(--card);
  border: 1.5px solid var(--border-strong);
  position: relative;
  overflow: hidden;
  animation: upsellIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  animation-delay: 0.15s;
}
.upsell-card::before {
  content: '';
  position: absolute;
  top: -80px; right: -80px;
  width: 180px; height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--hover-strong) 0%, transparent 70%);
  pointer-events: none;
  opacity: 0.9;
}
.upsell-card::after {
  content: '✦';
  position: absolute;
  top: 14px; right: 18px;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.5;
  animation: upsellSparkle 3s ease-in-out infinite;
}
@keyframes upsellSparkle {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.15); }
}
@keyframes upsellIn {
  from { opacity: 0; transform: translateY(20px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.upsell-card.upsell-hide {
  opacity: 0;
  transform: translateY(10px) scale(0.96);
  transition: opacity 0.35s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.upsell-icon {
  font-size: 26px;
  line-height: 1;
  margin-bottom: 2px;
  display: inline-block;
  animation: upsellBrain 4s ease-in-out infinite;
}
@keyframes upsellBrain {
  0%, 100% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(-4deg) scale(1.03); }
  75% { transform: rotate(4deg) scale(1.03); }
}
.upsell-body { display: flex; flex-direction: column; gap: 4px; position: relative; z-index: 1; }
.upsell-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
  line-height: 1.35;
}
.upsell-sub { font-size: 12.5px; color: var(--text-soft); line-height: 1.5; }
.upsell-actions { display: flex; align-items: center; gap: 8px; margin-top: 4px; position: relative; z-index: 1; }
.upsell-btn {
  padding: 9px 16px;
  border-radius: 10px;
  background: var(--action-bg);
  color: var(--action-text);
  font-size: 13px;
  font-weight: 700;
  border: 1.5px solid var(--action-bg);
  transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  cursor: pointer;
  font-family: inherit;
  letter-spacing: -0.1px;
}
.upsell-btn:hover { transform: translateY(-1px); opacity: 0.92; }
.upsell-btn:active { transform: scale(0.97); }
.upsell-later {
  background: transparent;
  border: none;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease;
  font-family: inherit;
}
.upsell-later:hover { background: var(--hover); color: var(--text); }
.upsell-later:active { transform: scale(0.96); }

@media (max-width: 480px) {
  .upsell-card { padding: 16px 16px 14px; border-radius: 16px; }
  .upsell-icon { font-size: 24px; }
  .upsell-title { font-size: 14.5px; }
  .upsell-sub { font-size: 12px; }
  .upsell-btn { padding: 8px 14px; font-size: 12.5px; }
  .upsell-later { font-size: 11.5px; }
}


/* ============================================
   THINKING CARD — مثل DeepSeek R1
   ============================================ */
.thinking-card {
  align-self: flex-start;
  max-width: 92%;
  margin: 4px 0 8px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  overflow: hidden;
  animation: thinkingIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes thinkingIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.thinking-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s ease;
}
.thinking-header:hover { background: var(--hover); }

.thinking-dot-group {
  display: flex;
  gap: 4px;
  align-items: center;
}
.thinking-dot-group span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-soft);
  animation: thinkingPulse 1.4s infinite ease-in-out;
}
.thinking-dot-group span:nth-child(2) { animation-delay: 0.15s; }
.thinking-dot-group span:nth-child(3) { animation-delay: 0.3s; }

@keyframes thinkingPulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

.thinking-label {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  font-style: italic;
}

.thinking-toggle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-soft);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), background 0.15s ease;
}
.thinking-toggle:hover { background: var(--hover-strong); }
.thinking-toggle svg { width: 14px; height: 14px; }

.thinking-card.collapsed .thinking-toggle { transform: rotate(-90deg); }
.thinking-card.collapsed .thinking-body { max-height: 0; opacity: 0; padding-top: 0; padding-bottom: 0; }

.thinking-body {
  max-height: 400px;
  overflow-y: auto;
  padding: 0 14px 12px;
  transition: max-height 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease, padding 0.3s ease;
}

.thinking-content {
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-soft);
  white-space: pre-wrap;
  word-wrap: break-word;
  font-style: italic;
  padding-left: 14px;
  border-left: 2px solid var(--border-strong);
  margin-top: 4px;
}

.thinking-card.done .thinking-label {
  font-style: normal;
  color: var(--text-muted);
}

@media (max-width: 480px) {
  .thinking-card { max-width: 95%; }
  .thinking-content { font-size: 12.5px; }
  .thinking-body { max-height: 280px; }
}/* ============================================
   CHAT UI — طراحی جدید (ChatGPT-like)
   ============================================ */

/* ─── دراور چت ─── */
.chat-drawer {
  height: 95vh !important;
  border-top-left-radius: 24px !important;
  border-top-right-radius: 24px !important;
  background: var(--bg) !important;
}

/* ─── هدر چت ─── */
.chat-header {
  padding: 12px 16px 10px !important;
  border-bottom: none !important;
}
.chat-header-title {
  font-size: 15px !important;
  font-weight: 600 !important;
  color: var(--text-soft) !important;
  gap: 8px !important;
}
.chat-header-title svg { width: 16px !important; height: 16px !important; }

/* ─── لیست پیام‌ها ─── */
.chat-list {
  padding: 8px 16px 20px !important;
  gap: 22px !important;
  scroll-behavior: smooth;
}

/* ─── پیام کاربر (حباب) ─── */
.chat-message.user {
  align-self: flex-end;
  max-width: 82%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  animation: bubbleIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
html[dir="rtl"] .chat-message.user { align-self: flex-start; align-items: flex-start; }

.chat-message.user .bubble {
  background: var(--hover-strong);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 20px 20px 6px 20px;
  font-size: 15px;
  line-height: 1.6;
  word-wrap: break-word;
  border: none;
}
html[dir="rtl"] .chat-message.user .bubble {
  border-radius: 20px 20px 20px 6px;
}

.chat-message.user .bubble .bubble-time {
  display: block;
  font-size: 10.5px;
  opacity: 0.5;
  margin-top: 4px;
  text-align: right;
}

/* ─── پیام دستیار (بدون حباب) ─── */
.chat-message.assistant {
  align-self: stretch;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: msgIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.chat-message.assistant .content {
  color: var(--text);
  font-size: 15px;
  line-height: 1.75;
  word-wrap: break-word;
  padding: 0 2px;
}

.chat-message.assistant .content .chat-bubble-text {
  font-size: 15px !important;
  line-height: 1.75 !important;
}

/* متن فرمت‌شده */
.chat-message.assistant .content p { margin: 0 0 10px; }
.chat-message.assistant .content ul,
.chat-message.assistant .content ol { padding-inline-start: 22px; margin: 8px 0; }
.chat-message.assistant .content li { margin-bottom: 5px; }
.chat-message.assistant .content h1,
.chat-message.assistant .content h2,
.chat-message.assistant .content h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 16px 0 8px;
  color: var(--text);
}
.chat-message.assistant .content strong { font-weight: 700; color: var(--text); }
.chat-message.assistant .content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}
.chat-message.assistant .content a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border-strong);
}

/* ─── ردیف دکمه‌های اکشن ─── */
.chat-message.assistant .actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  margin-top: 2px;
  opacity: 0.85;
  transition: opacity 0.2s ease;
}
.chat-message.assistant .actions:hover { opacity: 1; }

.chat-message.assistant .actions button {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.chat-message.assistant .actions button:hover {
  background: var(--hover);
  color: var(--text);
}
.chat-message.assistant .actions button:active { transform: scale(0.9); }
.chat-message.assistant .actions button svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
}
.chat-message.assistant .actions button.active {
  color: var(--text);
  background: var(--hover);
}

/* ─── کارت فکر کردن (جمع‌وجور) ─── */
.chat-message.assistant .thinking-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
  transition: color 0.15s ease;
  background: transparent;
  border: none;
  width: fit-content;
  font-family: inherit;
}
.chat-message.assistant .thinking-inline:hover { color: var(--text); }
.chat-message.assistant .thinking-inline .arrow {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  transition: transform 0.25s ease;
}
.chat-message.assistant .thinking-inline.open .arrow {
  transform: rotate(90deg);
}
html[dir="rtl"] .chat-message.assistant .thinking-inline .arrow {
  transform: rotate(180deg);
}
html[dir="rtl"] .chat-message.assistant .thinking-inline.open .arrow {
  transform: rotate(90deg);
}

.chat-message.assistant .thinking-body {
  display: none;
  padding: 10px 14px;
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-soft);
  background: var(--card);
  border-left: 2px solid var(--border-strong);
  border-radius: 10px;
  font-style: italic;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 300px;
  overflow-y: auto;
}
html[dir="rtl"] .chat-message.assistant .thinking-body {
  border-left: none;
  border-right: 2px solid var(--border-strong);
}
.chat-message.assistant .thinking-body.open { display: block; }

/* ─── تصویر ─── */
.chat-message .bubble img,
.chat-message .content img {
  max-width: 100%;
  border-radius: 14px;
  margin: 6px 0;
  display: block;
}

/* ─── انیمیشن‌ها ─── */
@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── ردیف تایپینگ ─── */
.typing-indicator {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 6px 2px;
}
.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-soft);
  animation: typing 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* ─── کادر input جدید ─── */
.chat-input-area {
  padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
  background: var(--bg) !important;
  border-top: none !important;
}

.chat-input-box {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 24px;
  padding: 10px 12px 8px;
  transition: border-color 0.2s ease;
  box-shadow: var(--shadow-sm);
}
.chat-input-box:focus-within { border-color: var(--border-strong); }

.chat-input-box .input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.chat-input-box .input-row textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  max-height: 120px;
  min-height: 24px;
  padding: 6px 4px;
  scrollbar-width: none;
}
.chat-input-box .input-row textarea::-webkit-scrollbar { display: none; }
.chat-input-box .input-row textarea::placeholder { color: var(--text-muted); }

/* دکمه‌های پایین کادر */
.chat-input-box .bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
}
.chat-input-box .toggles {
  display: flex;
  gap: 6px;
}
.toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 100px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.18s ease;
}
.toggle-btn:hover { border-color: var(--border-strong); color: var(--text); }
.toggle-btn.on {
  border-color: var(--text);
  background: var(--action-bg);
  color: var(--action-text);
}
.toggle-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
}

.chat-input-box .actions-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.icon-circle-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}
.icon-circle-btn:hover { background: var(--hover); border-color: var(--border-strong); }
.icon-circle-btn:active { transform: scale(0.92); }
.icon-circle-btn.primary {
  background: var(--action-bg);
  color: var(--action-text);
  border-color: var(--action-bg);
}
.icon-circle-btn.primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.icon-circle-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.7;
  fill: none;
}

/* ─── پیش‌نمایش تصویر ─── */
.chat-input-box .image-preview-mini {
  display: none;
  padding: 6px;
  margin-bottom: 6px;
  background: var(--hover);
  border-radius: 12px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-soft);
}
.chat-input-box .image-preview-mini.show { display: flex; }
.chat-input-box .image-preview-mini img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 8px;
}
.chat-input-box .image-preview-mini button {
  margin-inline-start: auto;
  background: transparent;
  border: none;
  color: var(--text-soft);
  cursor: pointer;
  padding: 4px;
}
.chat-input-box .image-preview-mini button svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

/* ─── موبایل ─── */
@media (max-width: 480px) {
  .chat-message.assistant .content { font-size: 15px; line-height: 1.7; }
  .chat-message.user { max-width: 88%; }
  .chat-input-box { padding: 8px 10px 6px; border-radius: 22px; }
  .chat-input-box .input-row textarea { font-size: 15px; }
  .toggle-btn { padding: 5px 10px; font-size: 12px; }
  .icon-circle-btn { width: 34px; height: 34px; }
}

/* ============================================
   RTL / LTR / OVERFLOW — Comprehensive Fix
   ============================================ */

/* ─── Global overflow protection ─── */
html, body {
  overflow-x: hidden;
  max-width: 100%;
}

* { box-sizing: border-box; }

/* ─── Drawers & screens ─── */
.screen, .app, .drawer, .chat-drawer {
  overflow-x: hidden;
  max-width: 100%;
}

.chat-drawer * { max-width: 100%; }

/* ─── Chat list — no horizontal scroll ─── */
.chat-list {
  overflow-x: hidden;
  overflow-y: auto;
  max-width: 100%;
  width: 100%;
}

/* ─── Chat messages — safe wrapping ─── */
.chat-message,
.chat-message .content,
.chat-message .bubble {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.chat-message .bubble {
  max-width: min(88%, 100%);
}

.chat-message .content {
  width: 100%;
  overflow: hidden;
}

.chat-message.assistant {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  align-self: stretch;
}

/* ─── Text wrapping (aggressive) ─── */
.chat-bubble-text,
.chat-message .content,
.chat-message .bubble,
.thinking-body,
.thinking-content,
.chat-message .content p,
.chat-message .content ul,
.chat-message .content ol,
.chat-message .content li,
.chat-message .content h1,
.chat-message .content h2,
.chat-message .content h3,
.chat-message .content h4 {
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}

/* ─── Links — don't overflow ─── */
.chat-message a,
.chat-message .content a {
  overflow-wrap: anywhere;
  word-break: break-all;
  max-width: 100%;
}

/* ─── Inline code ─── */
.inline-code {
  overflow-wrap: anywhere;
  word-break: break-all;
  max-width: 100%;
}

/* ─── Code blocks — LTR safe in RTL pages ─── */
.code-block {
  max-width: 100%;
  overflow: hidden;
  direction: ltr;
  text-align: left;
}

.code-block * { direction: ltr; }

.code-block-body {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.code-block-pre {
  direction: ltr !important;
  text-align: left !important;
  min-width: 100%;
  max-width: 100%;
}

.code-block-header {
  flex-wrap: wrap;
  min-width: 0;
}

.code-block-lang,
.code-block-actions {
  flex-wrap: wrap;
  min-width: 0;
}

/* ─── Tables — RTL safe ─── */
.chat-message .content div[style*="overflow"] {
  max-width: 100%;
  overflow-x: auto;
}

.chat-message table {
  max-width: 100%;
  width: 100%;
}

.chat-message th,
.chat-message td {
  text-align: start !important;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ─── Images ─── */
.chat-message img,
.chat-bubble-image {
  max-width: 100%;
  height: auto;
}

/* ─── Input area ─── */
.chat-input-area,
.chat-input-box {
  max-width: 100%;
  overflow: hidden;
}

.chat-input-box .input-row textarea {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

html[dir="rtl"] .chat-input-box .input-row textarea { text-align: right; }
html[dir="ltr"] .chat-input-box .input-row textarea { text-align: left; }

.chat-input-box .bottom-row {
  flex-wrap: wrap;
  gap: 6px;
}

.chat-input-box .toggles,
.chat-input-box .actions-right {
  flex-wrap: wrap;
}

/* ─── Actions row ─── */
.chat-message.assistant .actions {
  flex-wrap: wrap;
  max-width: 100%;
}

/* ─── Bubbles alignment (RTL/LTR) ─── */
html[dir="rtl"] .chat-message.user { align-self: flex-start; }
html[dir="ltr"] .chat-message.user { align-self: flex-end; }

html[dir="rtl"] .chat-message.user .bubble {
  border-radius: 20px 20px 20px 6px;
}
html[dir="ltr"] .chat-message.user .bubble {
  border-radius: 20px 20px 6px 20px;
}

/* ─── Lists — correct padding in RTL ─── */
.chat-message .content ul,
.chat-message .content ol {
  padding-inline-start: 22px;
  padding-inline-end: 0;
}

/* ─── History / menu / settings — safe ─── */
.drawer, .drawer-menu, .settings-card,
.history-item, .menu-item, .user-profile, .user-info {
  max-width: 100%;
  min-width: 0;
}

.history-item-title,
.user-name, .user-email,
.settings-card-title, .settings-card-sub,
.menu-item span:first-of-type {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Premium cards — no overflow ─── */
.premium-plan,
.premium-hero,
.premium-active {
  max-width: 100%;
  overflow-wrap: anywhere;
}

/* ─── Thinking card body — safe ─── */
.thinking-body,
.thinking-content {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ─── Mobile ─── */
@media (max-width: 480px) {
  .chat-drawer {
    width: 100%;
    max-width: 100%;
  }
  .chat-list {
    padding-inline: 12px;
  }
  .chat-message .bubble {
    max-width: min(90%, 100%);
  }
  .chat-input-box .input-row textarea {
    font-size: 15px;
  }
}

/* ─── Prevent horizontal scroll everywhere ─── */
body, html, .screen, .app, .chat-drawer, .drawer, .chat-list {
  overscroll-behavior-x: none;
}

/* ─── Fix container queries edge cases ─── */
.chat-message pre,
.chat-message code,
.chat-message blockquote {
  max-width: 100%;
  overflow-wrap: anywhere;
}


/* ============================================
   PWA STANDALONE FIXES — حذف خط سفید و safe area
   ============================================ */

/* ─── حذف هر border / shadow اضافه ─── */
.chat-drawer:not(.open) {
  border-top-color: transparent !important;
  box-shadow: none !important;
}

.chat-handle {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
}

.chat-handle-bar {
  background: var(--border-strong) !important;
  opacity: 0.3;
}

/* ─── حذف border-bottom از هرچیزی که ممکنه خط سفید بده ─── */
.app, .screen, body, html {
  border-bottom: none !important;
}

.topbar, .chat-header, .chat-list, .chat-input-area, .chat-input-box {
  border-bottom: none !important;
}

/* ─── Safe area — فضای پایین گوشی ─── */
body {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.chat-drawer {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.chat-handle {
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

.chat-input-area {
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
}

/* ─── PWA standalone — رنگ پس‌زمینه یکدست ─── */
@media (display-mode: standalone), (display-mode: fullscreen) {
  html, body {
    background: var(--bg) !important;
    background-color: var(--bg) !important;
  }

  /* نوار پایین گوشی رو با تم هماهنگ کن */
  body::after {
    content: '';
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: env(safe-area-inset-bottom, 0px);
    background: var(--bg);
    pointer-events: none;
    z-index: 99999;
  }

  /* حذف خط سفید احتمالی بالای chat-drawer */
  .chat-drawer {
    border-top: none !important;
    background: var(--bg) !important;
  }
}

/* ─── موبایل: خط اضافه‌ی مرورگر رو بپوشون ─── */
@media (max-width: 480px) {
  .chat-drawer {
    border-top: none !important;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.4) !important;
  }
}


/* ============================================
   PWA FINAL FIX — رفع قطعی خط سفید
   ============================================ */

/* ─── پایه: تمام صفحه تیره ─── */
html {
  background-color: var(--bg) !important;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
}

body {
  background-color: var(--bg) !important;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  position: relative;
}

.app, .screen {
  background-color: var(--bg) !important;
  height: 100dvh;
  min-height: 100dvh;
}

/* ─── نوار پوشاننده‌ی پایین صفحه (safe area) ─── */
body::after {
  content: '';
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 200px;
  background: var(--bg);
  pointer-events: none;
  z-index: 1;
}

/* ─── chat-drawer بالاتر از نوار پوشاننده ─── */
.chat-drawer {
  z-index: 250;
  height: 95dvh !important;
  max-height: 95dvh !important;
  transform: translate3d(0, calc(100% - 72px), 0);
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-top: none !important;
  outline: none !important;
  background: var(--bg) !important;
  box-shadow: none !important;
}

.chat-drawer.open {
  transform: translate3d(0, 0, 0) !important;
  box-shadow: 0 -4px 32px rgba(0,0,0,0.5) !important;
}

/* ─── حذف همه‌ی border/shadow اضافه ─── */
.chat-handle,
.chat-handle-content,
.chat-handle-bar,
.chat-header,
.chat-list,
.chat-input-area,
.chat-input-box {
  border-top: none !important;
  border-bottom: none !important;
  outline: none !important;
}

.chat-handle {
  background: transparent !important;
  box-shadow: none !important;
}

.chat-handle-content {
  box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
  border: 1px solid var(--border) !important;
}

/* ─── نوار پایین اندروید رو با تم همرنگ کن ─── */
@supports (padding: env(safe-area-inset-bottom)) {
  body {
    padding-bottom: 0;
  }
  body::after {
    height: calc(env(safe-area-inset-bottom, 0px) + 100px);
  }
}

/* ─── در حالت standalone کاملاً یکدست ─── */
@media (display-mode: standalone) {
  html, body, .app {
    background: var(--bg) !important;
  }

  /* پوشش کامل پایین */
  body::before {
    content: '';
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: env(safe-area-inset-bottom, 0px);
    background: var(--bg);
    z-index: 99999;
    pointer-events: none;
  }

  body::after {
    z-index: 1;
  }
}

/* ─── موبایل ─── */
@media (max-width: 480px) {
  .chat-drawer {
    height: 94dvh !important;
    max-height: 94dvh !important;
  }
}

/* ─── Fallback برای مرورگرهای قدیمی ─── */
@supports not (height: 100dvh) {
  html, body, .app, .screen {
    height: 100vh;
    min-height: 100vh;
  }
  .chat-drawer {
    height: 95vh !important;
  }
}


/* ============================================
   ARABIC/PERSIAN TEXT RENDERING FIX
   ============================================ */

/* ─── فونت صحیح برای همه جا ─── */
html,
body,
button,
input,
textarea,
select,
.chat-message,
.chat-message *,
.chat-bubble-text,
.chat-message .content,
.thinking-body,
.thinking-inline {
  font-family: 'Vazirmatn', 'Noto Sans Arabic', 'Segoe UI', Tahoma, -apple-system, sans-serif !important;
  letter-spacing: 0 !important;
  word-spacing: normal !important;
}

/* ─── برای متن لاتین فونت متفاوت ─── */
html[lang="en"] body,
html[lang="en"] button,
html[lang="en"] input,
html[lang="en"] textarea,
html[lang="en"] .chat-message,
html[lang="en"] .chat-message *,
html[lang="en"] .chat-bubble-text {
  font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif !important;
}

html[lang="zh"] body,
html[lang="zh"] .chat-message *,
html[lang="zh"] .chat-bubble-text {
  font-family: 'Noto Sans SC', 'Vazirmatn', sans-serif !important;
  letter-spacing: 0 !important;
}

html[lang="ja"] body,
html[lang="ja"] .chat-message *,
html[lang="ja"] .chat-bubble-text {
  font-family: 'Noto Sans JP', 'Vazirmatn', sans-serif !important;
  letter-spacing: 0 !important;
}

/* ─── ligature و اتصال حروف ─── */
.chat-message,
.chat-bubble-text,
.chat-message .content,
.thinking-body {
  font-feature-settings: "calt" 1, "liga" 1, "kern" 1;
  -webkit-font-feature-settings: "calt" 1, "liga" 1, "kern" 1;
  font-variant-ligatures: common-ligatures contextual;
  text-rendering: optimizeLegibility;
}

/* ─── اعداد: تمیز ─── */
.chat-message,
.chat-bubble-text {
  font-variant-numeric: normal;
}

/* ─── هرجای دیگه که letter-spacing داره رو ریست کن ─── */
.user-badge,
.premium-badge,
.limit-badge,
.code-block-lang-name,
.code-block-lines {
  letter-spacing: 0.3px;
}

/* ─── متن فارسی: چپ‌چین/راست‌چین درست ─── */
.chat-bubble-text,
.chat-message .content {
  unicode-bidi: plaintext;
}

/* ─── خط جدید در متن: فاصله درست ─── */
.chat-bubble-text br {
  line-height: 1.7;
}

/* ─── برای اطمینان: متن‌های فارسی رو کاملاً یکدست ─── */
[dir="rtl"] .chat-message,
[dir="rtl"] .chat-bubble-text,
[dir="rtl"] .chat-message .content {
  font-family: 'Vazirmatn', 'Noto Sans Arabic', Tahoma, sans-serif !important;
  letter-spacing: 0 !important;
  text-align: right;
}

/* ─── حروف الفبا: اتصال درست ─── */
.chat-message,
.chat-bubble-text,
.chat-message .content,
.thinking-body,
.thinking-inline {
  word-break: normal;
  overflow-wrap: break-word;
  -webkit-hyphens: none;
  hyphens: none;
}


/* ============================================
   SELF-HOSTED FONTS
   ============================================ */
@font-face {
  font-family: 'Vazirmatn';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/vazirmatn-regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Vazirmatn';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/vazirmatn-medium.woff2') format('woff2');
}
@font-face {
  font-family: 'Vazirmatn';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/vazirmatn-bold.woff2') format('woff2');
}
@font-face {
  font-family: 'Vazirmatn';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('../fonts/vazirmatn-extrabold.woff2') format('woff2');
}


/* ============================================
   USER MESSAGE — بدون حباب (مثل assistant)
   ============================================ */

.chat-message.user {
  align-self: stretch !important;
  max-width: 100% !important;
  width: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 4px !important;
  padding: 4px 2px !important;
  background: transparent !important;
  border: none !important;
  animation: msgIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

html[dir="rtl"] .chat-message.user { align-items: flex-start !important; }
html[dir="ltr"] .chat-message.user { align-items: flex-start !important; }

/* برچسب "You" بالای پیام */
.chat-message.user .user-label {
  font-size: 11px !important;
  font-weight: 700 !important;
  color: var(--text-muted) !important;
  letter-spacing: 0.3px !important;
  padding: 0 2px !important;
  text-transform: uppercase;
}

/* محتوای پیام کاربر */
.chat-message.user .content {
  color: var(--text) !important;
  font-size: 15px !important;
  line-height: 1.75 !important;
  padding: 0 2px !important;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  unicode-bidi: plaintext;
}

.chat-message.user .content .chat-bubble-text {
  font-size: 15px !important;
  line-height: 1.75 !important;
  white-space: pre-wrap;
}

.chat-message.user .content img {
  max-width: 100%;
  border-radius: 12px;
  margin: 6px 0;
}

/* زمان کوچیک */
.chat-message.user .time-small {
  font-size: 10.5px !important;
  color: var(--text-muted) !important;
  opacity: 0.6 !important;
  padding: 0 2px !important;
  direction: ltr !important;
  unicode-bidi: isolate !important;
  font-variant-numeric: tabular-nums;
  white-space: nowrap !important;
}

/* جداکننده ملایم بین پیام‌ها */
.chat-message.user + .chat-message.assistant,
.chat-message.assistant + .chat-message.user {
  padding-top: 12px !important;
}

/* موبایل */
@media (max-width: 480px) {
  .chat-message.user .content { font-size: 15px !important; }
  .chat-message.user .content .chat-bubble-text { font-size: 15px !important; }
}


/* ============================================
   HISTORY ITEM — لایوت درست RTL/LTR
   ============================================ */

.history-item {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 14px 16px !important;
  border-radius: 14px !important;
  background: transparent !important;
  border: 1px solid var(--border) !important;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  margin-bottom: 8px !important;
  position: relative !important;
  overflow: hidden !important;
}

.history-item:hover {
  background: var(--hover) !important;
  border-color: var(--border-strong) !important;
}

.history-item.active-chat {
  background: var(--hover) !important;
  border-color: var(--text) !important;
}

/* ─── بخش اصلی (عنوان + متا) ─── */
.history-item .history-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

.history-item .history-item-title {
  font-size: 14px !important;
  font-weight: 600 !important;
  color: var(--text) !important;
  margin: 0 !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: start;
  direction: auto;
}

.history-item .history-item-meta {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  font-size: 11.5px !important;
  color: var(--text-soft) !important;
  direction: ltr !important;
  unicode-bidi: isolate !important;
  font-variant-numeric: tabular-nums;
}

html[dir="rtl"] .history-item .history-item-meta { justify-content: flex-end; }
html[dir="ltr"] .history-item .history-item-meta { justify-content: flex-start; }

.history-item .history-item-meta .msg-count {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--hover);
  font-weight: 600;
  font-size: 10.5px;
  color: var(--text-soft);
}

.history-item .history-item-meta .sep {
  opacity: 0.4;
  font-size: 10px;
}

.history-item .history-item-meta .time {
  font-size: 11px;
  color: var(--text-muted);
}

/* ─── بخش دکمه‌ها ─── */
.history-item .history-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0.4;
  transition: opacity 0.2s ease;
}

.history-item:hover .history-actions,
.history-item.active-chat .history-actions {
  opacity: 1;
}

.history-item .icon-mini {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.history-item .icon-mini:hover {
  background: var(--hover-strong);
  color: var(--text);
}

.history-item .icon-mini:active { transform: scale(0.88); }

.history-item .icon-mini.danger:hover {
  background: rgba(239,68,68,0.12);
  color: var(--danger);
}

.history-item .icon-mini svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
}

/* ─── موبایل کوچیک: دکمه‌ها همیشه نمایش ─── */
@media (max-width: 480px) {
  .history-item .history-actions { opacity: 1; }
  .history-item { padding: 12px 14px !important; }
  .history-item .icon-mini { width: 30px; height: 30px; }
  .history-item .icon-mini svg { width: 14px; height: 14px; }
}

/* ─── Modal ویرایش نام ─── */
.rename-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(8px);
  z-index: 9998;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.rename-modal-backdrop.show { display: flex; }
.rename-modal {
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 24px;
  max-width: 380px;
  width: 100%;
  animation: modalIn 0.25s ease;
}
.rename-modal h3 {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 14px;
}
.rename-modal input {
  width: 100%;
  padding: 13px 16px;
  background: var(--input-bg);
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  margin-bottom: 16px;
  transition: border-color 0.15s ease;
}
.rename-modal input:focus { border-color: var(--text); }
.rename-modal-actions {
  display: flex;
  gap: 8px;
}
.rename-modal-actions button {
  flex: 1;
  padding: 12px;
  border-radius: 11px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid var(--border-strong);
  background: transparent;
  color: var(--text);
  transition: all 0.15s ease;
}
.rename-modal-actions button:hover { background: var(--hover); }
.rename-modal-actions button.primary {
  background: var(--action-bg);
  color: var(--action-text);
  border-color: var(--action-bg);
}
.rename-modal-actions button:active { transform: scale(0.97); }

