/* =========================================================================
   ShamGPT — modern UI. Plain CSS, no build. RTL-ready via logical properties.
   ========================================================================= */

/* ---------- Design tokens ---------- */
:root {
  --font: 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-3: #d946ef;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
  --grad-soft: linear-gradient(135deg, rgba(99,102,241,.14), rgba(217,70,239,.10));

  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 26px;
  --radius-full: 999px;

  --ease: cubic-bezier(.22,.61,.36,1);
  --ease-out: cubic-bezier(.16,1,.3,1);
  --t-fast: .16s var(--ease);
  --t: .26s var(--ease);
}

/* Light */
:root[data-theme='light'] {
  --bg: #fbfaf9;
  --bg-grad-1: rgba(99,102,241,.10);
  --bg-grad-2: rgba(217,70,239,.08);
  --bg-grad-3: rgba(56,189,248,.07);
  --surface: rgba(255,255,255,.72);
  --surface-solid: #ffffff;
  --surface-2: rgba(255,255,255,.55);
  --elev: #ffffff;
  --border: rgba(17,17,26,.08);
  --border-strong: rgba(17,17,26,.14);
  --text: #15151c;
  --text-dim: #5a5a6e;
  --text-faint: #9292a3;
  --bubble-user: #3d3d75;
  --bubble-user-text: #ffffff;
  --code-bg: #f1f0f9;
  --code-block-bg: #f7f6fc;
  --code-block-border: rgba(17,17,26,.10);
  --code-text: #2b2b3a;
  --hl-comment: #8a8a99; --hl-keyword: #7c3aed; --hl-string: #15803d;
  --hl-number: #b45309; --hl-title: #2563eb; --hl-type: #a21caf; --hl-symbol: #0369a1;
  --shadow-sm: 0 1px 2px rgba(20,20,40,.05), 0 2px 8px rgba(20,20,40,.05);
  --shadow: 0 4px 16px rgba(20,20,40,.08), 0 12px 40px rgba(20,20,40,.07);
  --shadow-lg: 0 12px 50px rgba(30,20,60,.16);
  --glass-blur: saturate(160%) blur(20px);
}

/* Dark */
:root[data-theme='dark'] {
  --bg: #0a0a0f;
  --bg-grad-1: rgba(99,102,241,.18);
  --bg-grad-2: rgba(217,70,239,.12);
  --bg-grad-3: rgba(45,150,220,.10);
  --surface: rgba(24,24,33,.66);
  --surface-solid: #16161f;
  --surface-2: rgba(255,255,255,.04);
  --elev: #1a1a24;
  --border: rgba(255,255,255,.08);
  --border-strong: rgba(255,255,255,.16);
  --text: #ececf2;
  --text-dim: #a6a6b8;
  --text-faint: #6e6e80;
  --bubble-user: linear-gradient(135deg, #6366f1, #8b5cf6);
  --bubble-user-text: #ffffff;
  --code-bg: #20202c;
  --code-block-bg: #0f0f18;
  --code-block-border: rgba(255,255,255,.08);
  --code-text: #e6e6f0;
  --hl-comment: #6b7280; --hl-keyword: #c084fc; --hl-string: #86efac;
  --hl-number: #fbbf24; --hl-title: #60a5fa; --hl-type: #f0abfc; --hl-symbol: #38bdf8;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow: 0 8px 30px rgba(0,0,0,.45);
  --shadow-lg: 0 20px 70px rgba(0,0,0,.6);
  --glass-blur: saturate(150%) blur(22px);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
/* Lock the page to the layout viewport so the background can't scroll behind
   the on-screen keyboard on mobile (the app's own panes scroll internally). */
html { overflow: hidden; overscroll-behavior: none; }

/* Icons are injected via v-html inside <span> wrappers. Spans are inline by
   default, so the SVG aligns to the text baseline and looks off-centre.
   Center any span that directly wraps an SVG, and drop the baseline gap. */
span:has(> svg) { display: inline-flex; align-items: center; justify-content: center; line-height: 0; }
button svg, .brand-mark svg, .msg-avatar svg, .hero-mark svg { display: block; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  overscroll-behavior: none;
  /* Pin to the layout viewport: prevents iOS/Android from scrolling the page
     body behind the keyboard. Inner scroll areas (.thread, .auth) handle their
     own overflow. */
  position: fixed;
  inset: 0;
  width: 100%;
}
/* --app-h is kept in sync with the visual viewport (see app.js) so the layout
   shrinks when the on-screen keyboard opens; 100dvh is the no-JS fallback. */
#app { height: var(--app-h, 100dvh); }

/* Animated aurora background */
body::before {
  content: '';
  position: fixed; inset: -20%;
  z-index: -1;
  background:
    radial-gradient(40% 50% at 18% 12%, var(--bg-grad-1), transparent 70%),
    radial-gradient(45% 45% at 85% 18%, var(--bg-grad-2), transparent 70%),
    radial-gradient(50% 55% at 60% 95%, var(--bg-grad-3), transparent 70%);
  filter: blur(10px);
  animation: drift 26s var(--ease) infinite alternate;
}
@keyframes drift {
  0%   { transform: translate3d(0,0,0) scale(1); }
  100% { transform: translate3d(0,-3%,0) scale(1.08); }
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; }
a { color: var(--accent); }
::selection { background: rgba(139,92,246,.28); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: padding-box; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px;
  background: var(--grad); display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 18px; flex: none;
  box-shadow: 0 6px 18px rgba(99,102,241,.4);
  position: relative; overflow: hidden;
}
.brand-mark::after { content: ''; position: absolute; inset: 0; background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,.5) 50%, transparent 70%); transform: translateX(-120%); animation: sheen 5s ease-in-out infinite; }
.brand-mark svg { width: 22px; height: 22px; display: block; }
.brand-mark span { display: inline-flex; }
@keyframes sheen { 0%,60% { transform: translateX(-120%);} 80%,100%{ transform: translateX(120%);} }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.brand-name b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: var(--radius-full);
  font-weight: 600; font-size: 14.5px; transition: transform var(--t-fast), box-shadow var(--t), background var(--t), opacity var(--t);
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 8px 22px rgba(99,102,241,.36); }
.btn-primary:hover { box-shadow: 0 10px 30px rgba(99,102,241,.5); }
.btn-primary:disabled { opacity: .55; cursor: default; box-shadow: none; }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface); border-color: var(--border-strong); }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 22px; font-size: 15.5px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  color: var(--text-dim); transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.icon-btn:disabled { opacity: .38; cursor: default; }
.icon-btn:disabled:hover { background: none; color: var(--text-dim); }
.icon-btn svg { width: 21px; height: 21px; }

/* ---------- App layout ---------- */
.app-shell { display: flex; height: var(--app-h, 100dvh); overflow: hidden; }

/* Sidebar */
.sidebar {
  width: 290px; flex: none; display: flex; flex-direction: column;
  background: var(--surface); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border-inline-end: 1px solid var(--border);
  transition: transform var(--t), width var(--t);
  z-index: 40;
}
.sidebar-head { padding: 16px 14px 10px; display: flex; align-items: center; justify-content: space-between; }
.sidebar-new {
  margin: 4px 14px 8px; padding: 12px 16px; border-radius: var(--radius);
  display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14.5px;
  background: var(--grad-soft); border: 1px solid var(--border); color: var(--text);
  transition: border-color var(--t), transform var(--t-fast), box-shadow var(--t);
}
.sidebar-new:hover { border-color: rgba(139,92,246,.5); box-shadow: 0 6px 18px rgba(99,102,241,.18); }
.sidebar-new svg { width: 19px; height: 19px; color: var(--accent); }
.sidebar-label { padding: 14px 18px 6px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-faint); }
.sidebar-tabs { display: flex; gap: 4px; margin: 8px 14px 6px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-full); }
.sidebar-tabs button { flex: 1; padding: 7px 10px; border-radius: var(--radius-full); font-size: 13px; font-weight: 600; color: var(--text-dim); transition: color var(--t-fast), background var(--t-fast); }
.sidebar-tabs button.active { background: var(--elev); color: var(--text); box-shadow: var(--shadow-sm); }
.conv-list { flex: 1; overflow-y: auto; padding: 0 8px 12px; }
.conv-empty { padding: 24px 16px; text-align: center; color: var(--text-faint); font-size: 13.5px; }

.conv-item {
  position: relative; display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text-dim); font-size: 14px; transition: background var(--t-fast), color var(--t-fast);
  margin-bottom: 2px;
}
.conv-item:hover { background: var(--surface-2); color: var(--text); }
.conv-item.active { background: var(--grad-soft); color: var(--text); font-weight: 600; }
.conv-item.active::before { content: ''; position: absolute; inset-inline-start: 0; top: 18%; bottom: 18%; width: 3px; border-radius: 3px; background: var(--grad); }
.conv-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-menu-btn { opacity: 0; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: var(--text-faint); transition: opacity var(--t-fast), background var(--t-fast); }
.conv-item:hover .conv-menu-btn { opacity: 1; }
.conv-menu-btn:hover { background: var(--border); color: var(--text); }
.conv-menu-btn svg { width: 17px; height: 17px; }
.conv-rename-input { flex: 1; background: var(--elev); border: 1px solid var(--accent); border-radius: 8px; padding: 5px 8px; font-size: 14px; color: var(--text); outline: none; }

.sidebar-foot { padding: 10px; border-top: 1px solid var(--border); }
.acct-wrap { position: relative; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); cursor: pointer; transition: background var(--t-fast); }
.user-chip:hover, .user-chip.active { background: var(--surface-2); }
.chip-expand { margin-inline-start: auto; color: var(--text-faint); display: inline-flex; }
.chip-expand svg { width: 18px; height: 18px; }

/* Account popup menu (Claude-style) */
.acct-menu {
  position: absolute; bottom: calc(100% + 8px); inset-inline: 0;
  background: var(--elev); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 6px; z-index: 60;
}
.acct-head { padding: 9px 12px 7px; font-size: 13px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: 11px; font-size: 14.5px; font-weight: 500; color: var(--text); text-align: start; transition: background var(--t-fast); }
.acct-item:hover { background: var(--surface-2); }
.acct-item .ic { display: inline-flex; color: var(--text-dim); flex: none; }
.acct-item .ic svg { width: 19px; height: 19px; }
.acct-item .lbl { flex: 1; min-width: 0; }
.acct-item .trail { font-size: 12.5px; color: var(--text-faint); }
.acct-item .chev { display: inline-flex; color: var(--text-faint); transition: transform var(--t); }
.acct-item .chev svg { width: 16px; height: 16px; }
.acct-item .chev.down { transform: rotate(180deg); }
.acct-sub { margin: 2px 6px; padding: 4px; background: var(--surface-2); border-radius: var(--radius-sm); }
.acct-item.sub { padding: 8px 10px; font-size: 14px; }
.acct-item.sub.on { color: var(--accent); font-weight: 600; }
.acct-item.sub .check { display: inline-flex; color: var(--accent); }
.acct-item.sub .check svg { width: 16px; height: 16px; }
.acct-sep { height: 1px; background: var(--border); margin: 6px 8px; }
.acct-enter-active, .acct-leave-active { transition: opacity .16s var(--ease), transform .16s var(--ease); transform-origin: bottom; }
.acct-enter-from, .acct-leave-to { opacity: 0; transform: translateY(8px) scale(.98); }
.avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; object-fit: cover; background: var(--grad); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px; }
.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-mail { font-size: 12px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Context menu */
.menu {
  position: fixed; z-index: 80; min-width: 184px; padding: 6px;
  background: var(--elev); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); animation: pop .14s var(--ease-out);
}
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(-4px); } to { opacity: 1; transform: none; } }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 10px; font-size: 14px; color: var(--text); transition: background var(--t-fast); text-align: start; }
.menu-item:hover { background: var(--surface-2); }
.menu-item.danger { color: #ef4444; }
.menu-item.danger:hover { background: rgba(239,68,68,.1); }
.menu-item svg { width: 17px; height: 17px; }

/* ---------- Main / chat ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.topbar {
  height: 58px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 14px;
  background: var(--surface); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border); z-index: 20;
}
.topbar .grow { flex: 1; }
.topbar-title { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-toggle { display: none; }

.thread { flex: 1; overflow-y: auto; scroll-behavior: smooth; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.thread-inner { max-width: 800px; margin: 0 auto; padding: 26px 20px 12px; }

/* Empty / hero state */
.hero { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; }
.hero-mark { width: 76px; height: 76px; border-radius: 24px; background: var(--grad); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 38px; box-shadow: 0 20px 50px rgba(99,102,241,.45); margin-bottom: 22px; animation: floaty 5s var(--ease) infinite alternate; }
.hero-mark svg { width: 46px; height: 46px; }
.hero-mark span { display: inline-flex; }
@keyframes floaty { to { transform: translateY(-9px); } }
.hero-title { font-size: clamp(26px, 4vw, 34px); font-weight: 800; letter-spacing: -.025em; margin: 0 0 8px; }
.hero-title b { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { color: var(--text-dim); font-size: 15.5px; max-width: 460px; margin: 0 0 28px; line-height: 1.6; }
.suggests { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; width: 100%; max-width: 560px; }
.suggest {
  text-align: start; padding: 16px 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  font-size: 14.5px; font-weight: 500; transition: transform var(--t), border-color var(--t), box-shadow var(--t);
  backdrop-filter: var(--glass-blur);
}
.suggest:hover { transform: translateY(-3px); border-color: rgba(139,92,246,.5); box-shadow: var(--shadow); }

/* Messages */
.msg { display: flex; gap: 14px; padding: 14px 0; animation: rise .35s var(--ease-out); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.msg-avatar { width: 34px; height: 34px; border-radius: 11px; flex: none; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.msg.assistant .msg-avatar { background: var(--grad); color: #fff; box-shadow: 0 6px 16px rgba(99,102,241,.35); }
.msg-avatar svg { width: 21px; height: 21px; }
.msg-avatar span { display: inline-flex; }
.msg.user .msg-avatar { background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border); }
.msg-body { flex: 1; min-width: 0; padding-top: 4px; }
.msg-role { font-size: 12.5px; font-weight: 700; color: var(--text-faint); margin-bottom: 4px; }

.bubble-user .prose { display: inline-block; background: var(--bubble-user); color: var(--bubble-user-text); padding: 11px 16px; border-radius: var(--radius); border-end-start-radius: 6px; }

/* Markdown prose */
.prose { font-size: 15.5px; line-height: 1.72; word-wrap: break-word; overflow-wrap: anywhere; }
.prose > *:first-child { margin-top: 0; }
.prose > *:last-child { margin-bottom: 0; }
.prose p { margin: 0 0 12px; }
.prose h1, .prose h2, .prose h3 { font-weight: 800; letter-spacing: -.02em; line-height: 1.3; margin: 22px 0 10px; }
.prose h1 { font-size: 1.5em; } .prose h2 { font-size: 1.3em; } .prose h3 { font-size: 1.12em; }
.prose ul, .prose ol { margin: 0 0 12px; padding-inline-start: 1.4em; }
.prose li { margin: 4px 0; }
.prose a { text-decoration: underline; text-underline-offset: 2px; }
.prose blockquote { margin: 0 0 12px; padding: 4px 16px; border-inline-start: 3px solid var(--accent); color: var(--text-dim); background: var(--grad-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.prose code { font-family: var(--mono); font-size: .88em; background: var(--code-bg); padding: 2px 6px; border-radius: 6px; direction: ltr; unicode-bidi: isolate; }

/* Code block = header bar (language + copy) + body.
   The header is sticky so the copy button stays visible while scrolling a long block.
   (No overflow:hidden on the wrapper — that would disable position:sticky.) */
.code-block { position: relative; margin: 0 0 14px; border: 1px solid var(--code-block-border); border-radius: var(--radius-sm); background: var(--code-block-bg); }
.code-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 6px 8px 6px 14px; direction: ltr;
  background: var(--code-block-bg);
  border-bottom: 1px solid var(--code-block-border);
  border-start-start-radius: calc(var(--radius-sm) - 1px);
  border-start-end-radius: calc(var(--radius-sm) - 1px);
}
.code-lang { font-family: var(--mono); font-size: 12px; color: var(--text-faint); text-transform: lowercase; letter-spacing: .02em; }
.code-copy { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--text-dim); transition: background var(--t-fast), color var(--t-fast); direction: ltr; }
.code-copy:hover { background: var(--surface-2); color: var(--text); }
.code-copy.copied { color: #16a34a; }
.code-copy .ic { display: inline-flex; }
.code-copy .ic svg { width: 14px; height: 14px; }
.prose .code-block pre { margin: 0; background: none; border: none; border-radius: 0 0 calc(var(--radius-sm) - 1px) calc(var(--radius-sm) - 1px); }
/* Code is always left-to-right, even when the UI language is Arabic. */
.prose pre code { display: block; background: none; padding: 16px; overflow-x: auto; font-size: 13.5px; line-height: 1.6; color: var(--code-text); direction: ltr; text-align: left; unicode-bidi: isolate; }
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 14px; font-size: 14px; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 12px; text-align: start; }
.prose th { background: var(--surface-2); font-weight: 700; }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.prose img { max-width: 100%; border-radius: var(--radius-sm); }

/* Streaming caret */
.caret { display: inline-block; width: 8px; height: 1.05em; vertical-align: -2px; margin-inline-start: 2px; border-radius: 2px; background: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Reasoning panel — DeepSeek-style: minimal header + quiet quoted thought */
.reasoning { margin: 2px 0 14px; }
.reasoning-head { display: inline-flex; align-items: center; gap: 7px; padding: 5px 0; font-size: 13.5px; font-weight: 500; color: var(--text-faint); transition: color var(--t-fast); text-align: start; }
.reasoning-head:hover { color: var(--text-dim); }
.reasoning-head .spark { width: 16px; height: 16px; color: var(--text-faint); flex: none; }
.reasoning-head .chev { width: 15px; height: 15px; transition: transform var(--t); color: var(--text-faint); }
.reasoning.open .chev { transform: rotate(180deg); }
.reasoning-head.live .spark { color: var(--accent-2); animation: spinpulse 2s var(--ease) infinite; }
.reasoning-head.live .label { background: linear-gradient(90deg, var(--text-faint), var(--accent-2), var(--text-faint)); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 1.8s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes spinpulse { 0%,100% { opacity: .5; transform: scale(.9); } 50% { opacity: 1; transform: scale(1.1); } }
.reasoning-body {
  margin-top: 6px; padding-block: 2px; padding-inline-start: 14px;
  border-inline-start: 2px solid var(--border-strong);
  font-size: 14px; line-height: 1.72; color: var(--text-dim);
  white-space: pre-wrap; max-height: 360px; overflow-y: auto;
}

/* Message actions */
.msg-actions { display: flex; gap: 4px; margin-top: 6px; opacity: 0; transition: opacity var(--t); }
.msg:hover .msg-actions { opacity: 1; }
.msg-action { display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border-radius: 8px; font-size: 12.5px; color: var(--text-faint); transition: background var(--t-fast), color var(--t-fast); }
.msg-action:hover { background: var(--surface-2); color: var(--text); }
.msg-action svg { width: 15px; height: 15px; }

/* Composer */
.composer-wrap { flex: none; padding: 8px 20px 18px; padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
.composer {
  max-width: 800px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px;
  background: var(--surface); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  padding: 8px 8px 8px 18px; box-shadow: var(--shadow);
  transition: border-color var(--t), box-shadow var(--t);
}
.composer:focus-within { border-color: rgba(139,92,246,.55); box-shadow: 0 10px 40px rgba(99,102,241,.18); }
.composer textarea {
  flex: 1; border: none; outline: none; background: none; resize: none;margin-right: 10px;
  font-size: 15.5px; line-height: 1.5; color: var(--text); max-height: 200px; padding: 10px 0; min-height: 24px;
}
.composer textarea::placeholder { color: var(--text-faint); }
.send-btn { width: 42px; height: 42px; border-radius: 14px; flex: none; display: grid; place-items: center; background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(99,102,241,.4); transition: transform var(--t-fast), opacity var(--t), box-shadow var(--t); }
.send-btn:hover { transform: scale(1.05); }
.send-btn:active { transform: scale(.94); }
.send-btn:disabled { opacity: .4; box-shadow: none; cursor: default; transform: none; }
.send-btn svg { width: 20px; height: 20px; }
.send-btn.stop { background: var(--text); }
.composer-hint { max-width: 800px; margin: 8px auto 0; text-align: center; font-size: 11.5px; color: var(--text-faint); }

/* ---------- Auth (simple centered card) ---------- */
.auth { height: var(--app-h, 100dvh); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding: 24px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.made-in-syria { color: var(--text-dim); font-size: 13px; font-weight: 500; letter-spacing: .01em; text-align: center; }
.auth-card { width: 100%; max-width: 380px; text-align: center; }
.auth-card .brand { display: flex; justify-content: center; gap: 12px; margin-bottom: 22px; }
.auth-card .brand-mark { width: 46px; height: 46px; border-radius: 14px; }
.auth-card .brand-mark svg { width: 27px; height: 27px; }
.auth-card .brand-name { font-size: 22px; }
.auth-card h2 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 6px; }
.auth-card .sub { color: var(--text-dim); font-size: 14.5px; margin: 0 0 26px; }

.field { margin-bottom: 13px; text-align: start; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; padding-inline-start: 2px; }
.input {
  width: 100%; padding: 13px 15px; border-radius: var(--radius); font-size: 15px; color: var(--text);
  background: var(--surface-solid); border: 1px solid var(--border-strong); outline: none;
  transition: border-color var(--t), box-shadow var(--t);
}
.input::placeholder { color: var(--text-faint); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(99,102,241,.14); }
textarea.input { resize: vertical; min-height: 96px; line-height: 1.6; }

.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--text-faint); font-size: 13px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.gbtn { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px; border-radius: var(--radius); background: var(--surface-solid); border: 1px solid var(--border-strong); font-weight: 600; font-size: 14.5px; color: var(--text); transition: background var(--t-fast), border-color var(--t); }
.gbtn:hover { background: var(--surface-2); border-color: var(--text-faint); }
.gbtn svg { width: 19px; height: 19px; }
#g_id_wrap { display: flex; justify-content: center; margin-top: 6px; color-scheme: light; }

.auth-switch { text-align: center; margin-top: 22px; font-size: 14.5px; color: var(--text-dim); }
.auth-switch button { color: var(--accent); font-weight: 700; }
.install-cta { margin-top: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.form-error { background: rgba(239,68,68,.1); color: #ef4444; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 14px; border: 1px solid rgba(239,68,68,.2); }

/* ---------- Modal (settings) ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(10,10,18,.5); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { width: 100%; max-width: 720px; max-height: 86dvh; background: var(--elev); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; animation: pop .22s var(--ease-out); }
.modal-head { display: flex; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 18px; font-weight: 800; flex: 1; }
.modal-body { display: flex; min-height: 0; flex: 1; }
.modal-tabs { width: 180px; flex: none; padding: 12px; border-inline-end: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.tab { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; color: var(--text-dim); text-align: start; transition: background var(--t-fast), color var(--t-fast); }
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--grad-soft); color: var(--text); }
.tab svg { width: 18px; height: 18px; }
.modal-pane { flex: 1; padding: 22px; overflow-y: auto; }
.pane-title { font-size: 15px; font-weight: 800; margin: 0 0 4px; }
.pane-desc { font-size: 13.5px; color: var(--text-dim); margin: 0 0 18px; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-full); padding: 4px; gap: 2px; }
.seg button { padding: 8px 16px; border-radius: var(--radius-full); font-size: 13.5px; font-weight: 600; color: var(--text-dim); transition: color var(--t-fast); }
.seg button.active { background: var(--elev); color: var(--text); box-shadow: var(--shadow-sm); }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { padding: 16px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.stat-val { font-size: 24px; font-weight: 800; letter-spacing: -.02em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-label { font-size: 12.5px; color: var(--text-faint); margin-top: 2px; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; padding: 10px 0; }
.bar { flex: 1; background: var(--grad); border-radius: 4px 4px 0 0; min-height: 3px; opacity: .85; transition: height var(--t); }

/* ---------- Toast ---------- */
.toast-host { position: fixed; bottom: 22px; inset-inline: 0; display: flex; justify-content: center; z-index: 200; pointer-events: none; }
.toast { pointer-events: auto; padding: 12px 18px; border-radius: var(--radius-full); background: var(--text); color: var(--bg); font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); animation: toastIn .3s var(--ease-out); max-width: 90vw; }
.toast.error { background: #ef4444; color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.96); } }

/* ---------- Loading ---------- */
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--border); border-top-color: var(--accent); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-load { height: 100%; display: grid; place-items: center; }
.dots { display: inline-flex; gap: 5px; align-items: center; padding: 8px 0; }
.dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: bob 1.2s var(--ease) infinite; }
.dots span:nth-child(2) { animation-delay: .15s; } .dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bob { 0%,80%,100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-7px); opacity: 1; } }

/* Backdrop for mobile sidebar */
.scrim { position: fixed; inset: 0; background: rgba(10,10,18,.4); backdrop-filter: blur(2px); z-index: 35; animation: fade .2s ease; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .menu-toggle { display: grid; }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: min(86vw, 320px); transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  :root[dir='rtl'] .sidebar { transform: translateX(100%); }
  /* The open state must beat the RTL rule's specificity — list both selectors. */
  .sidebar.open, :root[dir='rtl'] .sidebar.open { transform: translateX(0); }
  .suggests { grid-template-columns: 1fr; }
  .modal-body { flex-direction: column; }
  .modal-tabs { width: auto; flex-direction: row; overflow-x: auto; border-inline-end: none; border-bottom: 1px solid var(--border); }
  .tab span { display: none; }
  .tab { justify-content: center; }
}
.hidden { display: none !important; }

/* Toast transition */
.t-enter-active, .t-leave-active { transition: opacity .25s var(--ease), transform .25s var(--ease); }
.t-enter-from, .t-leave-to { opacity: 0; transform: translateY(16px) scale(.96); }

/* ---------- highlight.js (theme-aware via CSS variables) ---------- */
.hljs { color: var(--code-text); background: transparent; }
.hljs-comment, .hljs-quote { color: var(--hl-comment); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-name, .hljs-tag { color: var(--hl-keyword); }
.hljs-string, .hljs-title.class_, .hljs-doctag, .hljs-template-tag, .hljs-regexp { color: var(--hl-string); }
.hljs-number, .hljs-literal, .hljs-variable, .hljs-template-variable, .hljs-attr, .hljs-attribute { color: var(--hl-number); }
.hljs-title, .hljs-section, .hljs-title.function_ { color: var(--hl-title); }
.hljs-type, .hljs-class .hljs-title, .hljs-params { color: var(--hl-type); }
.hljs-symbol, .hljs-bullet, .hljs-link, .hljs-meta, .hljs-selector-id, .hljs-selector-class { color: var(--hl-symbol); }
.hljs-emphasis { font-style: italic; } .hljs-strong { font-weight: 700; }
.hljs-deletion { color: #ef4444; } .hljs-addition { color: var(--hl-string); }
