/* ============ Raed AI — التصميم ============ */
:root {
  --ok: #16a34a;
  --warn: #d97706;
  --accent: #6d5dfc;
  --accent-2: #a78bfa;
  --accent-ink: #ffffff;
  --bg: #f7f7fb;
  --surface: #ffffff;
  --surface-2: #f0f0f6;
  --border: #e3e3ec;
  --text: #16161d;
  --muted: #6b6b7b;
  --user-bubble: #6d5dfc;
  --user-ink: #ffffff;
  --danger: #e5484d;
  --danger-bg: #fdecec;
  --shadow: 0 8px 30px rgba(20, 20, 40, .08);
  --radius: 16px;
  --sidebar-w: 280px;
  --font: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --border: #2a2f3a;
  --text: #ececf1;
  --muted: #9a9cab;
  --user-bubble: #5a4be0;
  --danger: #ff6b6f;
  --danger-bg: #3a1d20;
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 20px; height: 20px; flex: none; }

.app { display: flex; height: 100dvh; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ---------- الشريط العلوي ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; direction: ltr; }
.logo b { color: var(--accent); }
.logo-mark {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 700;
}
.top-actions { display: flex; gap: 4px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent;
  display: grid; place-items: center; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- تبويبات الأوضاع ---------- */
.modes {
  display: flex; gap: 6px; padding: 10px 16px 8px; overflow-x: auto; scrollbar-width: none;
}
.modes::-webkit-scrollbar { display: none; }
.mode-tab {
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font-weight: 500; font-size: .93rem;
  transition: .15s;
}
.mode-tab:hover { color: var(--text); }
.mode-tab[aria-selected="true"] {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(109, 93, 252, .35);
}

/* ---------- الرسائل ---------- */
.messages {
  flex: 1; overflow-y: auto; padding: 12px 16px 24px; scroll-behavior: smooth;
}
.messages > * { max-width: 820px; margin-inline: auto; }
.msg { display: flex; gap: 10px; margin: 14px auto; }
.msg.user { justify-content: flex-start; flex-direction: row-reverse; }
.msg.user .bubble {
  background: var(--user-bubble); color: var(--user-ink);
  padding: 10px 14px; border-radius: 18px 18px 18px 6px;
  max-width: 85%; white-space: pre-wrap; word-wrap: break-word;
}
.msg .tag { display: inline-block; font-size: .75rem; opacity: .8; margin-top: 4px; }
.avatar {
  width: 32px; height: 32px; border-radius: 10px; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 700; font-size: .9rem;
}
.msg.assistant .body { flex: 1; min-width: 0; }
.msg.error .body .err {
  background: var(--danger-bg); color: var(--danger); border-radius: 12px; padding: 10px 14px;
}
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; font-size: .78rem; color: var(--muted); }
.meta .model { direction: ltr; unicode-bidi: isolate; }
.meta .note { color: var(--accent); }
.chip-btn {
  display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border);
  background: var(--surface); border-radius: 999px; padding: 3px 10px; font-size: .78rem; color: var(--muted);
  text-decoration: none;
}
.chip-btn:hover { color: var(--text); border-color: var(--muted); }
.chip-btn svg { width: 14px; height: 14px; }
.chip-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Markdown */
.markdown { word-wrap: break-word; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown p { margin: .5em 0; }
.markdown h1, .markdown h2, .markdown h3 { line-height: 1.4; margin: 1em 0 .4em; }
.markdown h3 { font-size: 1.05rem; }
.markdown a { color: var(--accent); }
.markdown ul, .markdown ol { padding-inline-start: 1.4em; }
.markdown :not(pre) > code {
  background: var(--surface-2); padding: .1em .4em; border-radius: 6px; font-family: var(--mono); font-size: .88em;
  direction: ltr; unicode-bidi: isolate;
}
.markdown table { border-collapse: collapse; display: block; overflow-x: auto; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 6px 10px; }
.markdown blockquote { margin: .6em 0; padding-inline-start: 12px; border-inline-start: 3px solid var(--accent); color: var(--muted); }

.code-block { margin: .8em 0; border-radius: 12px; overflow: hidden; background: #0d1117; border: 1px solid #262b36; }
.code-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 10px; background: #161b22; color: #9aa4b2; font-size: .78rem; direction: ltr;
}
.code-head .actions { display: flex; gap: 6px; }
.code-head button {
  display: inline-flex; align-items: center; gap: 4px; border: 0; background: #222935; color: #d0d7de;
  border-radius: 8px; padding: 3px 9px; font-size: .76rem;
}
.code-head button:hover { background: #2d3542; }
.code-head button svg { width: 14px; height: 14px; }
.code-block pre { margin: 0; overflow-x: auto; }
.code-block pre code.hljs, .code-block pre code {
  display: block; padding: 12px 14px; font-family: var(--mono); font-size: .85rem; line-height: 1.6;
  background: transparent; color: #e6edf3;
}

.typing { display: inline-flex; gap: 4px; padding: 8px 0; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* الصور */
.gen-image { display: block; max-width: 100%; max-height: 70vh; border-radius: 14px; box-shadow: var(--shadow); background: var(--surface-2); }
.image-loading {
  display: grid; place-items: center; gap: 10px; width: min(100%, 360px); aspect-ratio: 1;
  border-radius: 14px; background: var(--surface-2); color: var(--muted); font-size: .9rem; text-align: center; padding: 16px;
}
.spinner { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* الحالة الفارغة */
.empty { text-align: center; padding: 8vh 8px 16px; }
.empty .big-mark {
  width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 20px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  box-shadow: 0 10px 30px rgba(109, 93, 252, .35);
}
.empty .big-mark svg { width: 30px; height: 30px; }
.empty h1 { margin: 0 0 4px; font-size: 1.5rem; }
.empty p { margin: 0 0 20px; color: var(--muted); }
.seo-copy { max-width: 680px; margin: 24px auto 8px; color: var(--muted); font-size: .9rem; line-height: 1.8; }
.seo-copy h2 { margin: 0 0 8px; color: var(--text); font-size: 1.05rem; line-height: 1.5; }
.seo-copy p { margin: 0 auto 12px; }
.seo-copy ul { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; list-style: none; margin: 0; padding: 0; }
.seo-copy li { padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); }
.suggestions { display: grid; gap: 8px; max-width: 520px; margin: 0 auto; }
.suggestion {
  text-align: start; border: 1px solid var(--border); background: var(--surface);
  padding: 12px 14px; border-radius: 14px; color: var(--text); white-space: pre-line;
}
.suggestion:hover { border-color: var(--accent); }

/* ---------- صندوق الكتابة ---------- */
.composer { padding: 8px 16px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.composer > * { max-width: 820px; margin-inline: auto; }
.composer-box {
  display: flex; flex-direction: column; gap: 4px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 22px; padding: 10px 10px 8px; box-shadow: var(--shadow);
}
.composer-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.model-pill {
  display: inline-flex; align-items: center; gap: 6px; max-width: 70%;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 999px; padding: 6px 10px 6px 12px; font-size: .84rem; font-weight: 500;
}
.model-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; unicode-bidi: plaintext; }
.model-pill svg { width: 16px; height: 16px; color: var(--accent); }
.model-pill svg:last-child { color: var(--muted); }
.model-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }
.model-pill:hover:not(:disabled) { border-color: var(--accent); }
.model-pill:disabled { opacity: .5; cursor: default; }
.composer-box:focus-within { border-color: var(--accent); }
#input {
  flex: 1; border: 0; outline: 0; resize: none; background: transparent; color: var(--text);
  font: inherit; max-height: 200px; padding: 6px 8px; line-height: 1.6;
}
.send-btn {
  width: 40px; height: 40px; border-radius: 14px; border: 0; flex: none; display: grid; place-items: center;
  background: var(--accent); color: #fff;
}
.send-btn:disabled { opacity: .45; cursor: default; }
.send-btn.stop { background: var(--text); color: var(--bg); }
.send-btn svg { transform: scaleX(-1); }
.send-btn.stop svg { transform: none; }
.hint { text-align: center; color: var(--muted); font-size: .72rem; margin: 6px auto 0; }
.ratios[hidden] { display: none; }
.ratios { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.ratio {
  white-space: nowrap; border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: 4px 12px; font-size: .82rem;
}
.ratio[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* ---------- الشريط الجانبي ---------- */
.sidebar {
  position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 30; width: var(--sidebar-w);
  background: var(--surface); border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform .25s ease;
}
.sidebar.open { transform: none; }
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 20; display: none; }
.overlay.show { display: block; }
.sidebar-head { padding: 14px; padding-top: max(14px, env(safe-area-inset-top)); }
.btn-primary {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: #fff; border: 0; border-radius: 12px; padding: 10px; font-weight: 600;
}
.chat-list { flex: 1; overflow-y: auto; padding: 0 8px; }
.chat-list .group { font-size: .74rem; color: var(--muted); padding: 10px 8px 4px; }
.chat-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; cursor: pointer; color: var(--text);
}
.chat-item:hover { background: var(--surface-2); }
.chat-item.active { background: var(--surface-2); font-weight: 600; }
.chat-item svg { width: 16px; height: 16px; color: var(--muted); }
.chat-item .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.chat-item .del { border: 0; background: transparent; color: var(--muted); padding: 2px; border-radius: 6px; opacity: .6; display: grid; }
.chat-item .del:hover { color: var(--danger); opacity: 1; }
.chat-list .none { color: var(--muted); font-size: .85rem; text-align: center; padding: 20px 8px; }
.sidebar-foot { padding: 10px 14px 14px; border-top: 1px solid var(--border); }
.btn-ghost { width: 100%; border: 0; background: transparent; padding: 8px; border-radius: 10px; color: var(--muted); font-size: .85rem; }
.btn-ghost.danger:hover { color: var(--danger); background: var(--danger-bg); }

@media (min-width: 900px) {
  .sidebar { position: static; transform: none; }
  .overlay, #menuBtn { display: none !important; }
  .topbar .logo { margin-inline-end: auto; }
}

/* ---------- المعاينة ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .55);
  display: grid; place-items: center; padding: 12px;
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(1100px, 100%); height: min(90dvh, 900px); background: var(--surface);
  border-radius: 18px; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--border); }
#previewFrame { flex: 1; width: 100%; border: 0; background: #fff; }

/* ---------- تنبيه ---------- */
.toast {
  position: fixed; bottom: 150px; left: 50%; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 999px; font-size: .88rem;
  transition: .2s; z-index: 60; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- قائمة اختيار النموذج ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, 0); display: flex;
  align-items: flex-end; justify-content: center; transition: background .2s;
}
.sheet-backdrop[hidden] { display: none; }
.sheet-backdrop.open { background: rgba(0, 0, 0, .5); }
.sheet {
  width: min(560px, 100%); max-height: 80dvh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 22px 22px 0 0; box-shadow: var(--shadow);
  transform: translateY(100%); transition: transform .22s ease;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet-backdrop.open .sheet { transform: none; }
.sheet-handle { width: 40px; height: 4px; border-radius: 4px; background: var(--border); margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px 8px 18px; }
.sheet-head strong { display: block; font-size: 1.05rem; }
.sheet-sub { font-size: .8rem; color: var(--muted); }
.sheet-body { overflow-y: auto; padding: 0 10px 14px; }
.pick-section { font-size: .76rem; color: var(--muted); padding: 14px 8px 6px; font-weight: 600; }
.pick-note { font-size: .85rem; color: var(--muted); padding: 6px 10px; }
.pick-row {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: start;
  border: 1px solid transparent; background: transparent; border-radius: 14px; padding: 10px;
}
.pick-row:hover { background: var(--surface-2); }
.pick-row.selected { background: var(--surface-2); border-color: var(--accent); }
.pick-row .radio {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); flex: none;
  display: grid; place-items: center; color: #fff;
}
.pick-row.selected .radio { background: var(--accent); border-color: var(--accent); }
.pick-row .radio svg { width: 14px; height: 14px; }
.pick-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pick-name { font-weight: 600; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-sub { font-size: .76rem; color: var(--muted); }
.pill { flex: none; font-size: .72rem; font-weight: 600; border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.pill.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.pill.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); }
.pill.bad { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }

@media (min-width: 900px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 22px; transform: translateY(16px); opacity: 0; transition: transform .2s, opacity .2s; }
  .sheet-backdrop.open .sheet { opacity: 1; }
}

/* =====================================================================
 *  تحسينات التصميم والتأثيرات
 * ===================================================================== */
:root {
  --grad: linear-gradient(135deg, #7c6cff 0%, #a78bfa 45%, #22d3ee 100%);
  --glow: 0 8px 30px rgba(124, 108, 255, .35);
  --ease: cubic-bezier(.2, .8, .2, 1);
}
:root[data-theme="dark"] { --bg: #0b0d12; --surface: #141821; --surface-2: #1c212c; --border: #262c38; }

body { transition: background-color .3s, color .3s; }
.app { position: relative; z-index: 1; }

/* إضاءة خلفية متحركة بهدوء */
body::before {
  content: ""; position: fixed; inset: -20%; z-index: 0; pointer-events: none;
  background:
    radial-gradient(40% 35% at 20% 15%, rgba(124, 108, 255, .16), transparent 70%),
    radial-gradient(35% 30% at 85% 80%, rgba(34, 211, 238, .12), transparent 70%);
  animation: drift 24s ease-in-out infinite alternate;
}
:root[data-theme="light"] body::before { opacity: .6; }
@keyframes drift { to { transform: translate(4%, -3%) rotate(8deg); } }

/* شريط علوي زجاجي */
.topbar {
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom-color: color-mix(in srgb, var(--border) 70%, transparent);
}
.logo-mark, .avatar, .empty .big-mark {
  background: var(--grad); background-size: 200% 200%; animation: gradShift 8s ease infinite;
}
.logo-mark { box-shadow: var(--glow); }
@keyframes gradShift { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }

/* أزرار: ضغطة ناعمة */
button, .chip-btn { transition: transform .15s var(--ease), background-color .2s, border-color .2s, color .2s, box-shadow .2s; }
button:active:not(:disabled), .chip-btn:active { transform: scale(.96); }
.chip-btn:hover { transform: translateY(-1px); }

/* التبويبات */
.mode-tab { transition: all .25s var(--ease); }
.mode-tab[aria-selected="true"] { background: var(--grad); background-size: 200% 200%; border-color: transparent; box-shadow: var(--glow); animation: gradShift 8s ease infinite; }
.mode-tab:not([aria-selected="true"]):hover { border-color: var(--accent); transform: translateY(-1px); }

/* الرسائل: ظهور ناعم */
.msg.enter { animation: msgIn .4s var(--ease) both; }
.msg.user.enter { animation-name: msgInUser; }
@keyframes msgIn { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes msgInUser { from { opacity: 0; transform: translateX(-12px) scale(.97); } to { opacity: 1; transform: none; } }
.msg.user .bubble { background: var(--grad); background-size: 160% 160%; box-shadow: 0 6px 20px rgba(124, 108, 255, .25); }
.msg.pending .avatar { animation: gradShift 2s ease infinite, pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(124, 108, 255, .5); } 50% { box-shadow: 0 0 0 8px rgba(124, 108, 255, 0); } }

/* مؤشر الكتابة أثناء التدفق */
.markdown.streaming > :last-child::after {
  content: ""; display: inline-block; width: .55em; height: 1.05em; margin-inline-start: 3px; vertical-align: -.15em;
  border-radius: 2px; background: var(--accent); animation: caret 1s steps(1) infinite;
}
.markdown.streaming > .code-block:last-child::after, .markdown.streaming > .typing:last-child::after { display: none; }
@keyframes caret { 50% { opacity: 0; } }
.typing span { background: var(--accent); }

.code-block { box-shadow: 0 8px 24px rgba(0, 0, 0, .18); }

/* صندوق الكتابة */
.composer-box { transition: border-color .2s, box-shadow .25s; }
.composer-box:focus-within { border-color: var(--accent); box-shadow: var(--shadow), 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.send-btn { background: var(--grad); background-size: 200% 200%; box-shadow: var(--glow); }
.send-btn:hover:not(:disabled) { transform: translateY(-1px) scale(1.04); }
.send-btn.stop { background: var(--text); box-shadow: none; animation: pulse 1.6s ease-in-out infinite; }

/* الشاشة الأولى */
.empty { padding-top: 12vh; animation: msgIn .6s var(--ease) both; }
.orb { position: relative; width: 96px; height: 96px; margin: 0 auto 22px; display: grid; place-items: center; animation: float 5s ease-in-out infinite; }
.orb::before {
  content: ""; position: absolute; inset: -6px; border-radius: 30px;
  background: conic-gradient(from 0deg, #7c6cff, #22d3ee, #a78bfa, #7c6cff);
  filter: blur(14px); opacity: .55; animation: spin 6s linear infinite;
}
.orb .big-mark { position: relative; width: 84px; height: 84px; border-radius: 26px; margin: 0; }
.orb .big-mark svg { width: 38px; height: 38px; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.empty h1 { font-size: 1.8rem; margin-bottom: 6px; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.empty p { max-width: 420px; margin-inline: auto; }

/* الصور */
.image-loading { position: relative; overflow: hidden; border: 1px solid var(--border); }
.image-loading::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, color-mix(in srgb, var(--accent) 14%, transparent) 50%, transparent 80%);
  transform: translateX(-100%); animation: shimmer 1.6s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.gen-image { animation: imgIn .6s var(--ease) both; }
@keyframes imgIn { from { opacity: 0; transform: scale(.96); filter: blur(8px); } to { opacity: 1; transform: none; filter: none; } }

/* الشريط الجانبي */
.chat-item { transition: background-color .2s, transform .2s var(--ease); }
.chat-item:hover { transform: translateX(-2px); }
.btn-primary { background: var(--grad); background-size: 200% 200%; box-shadow: var(--glow); }
.sidebar { background: color-mix(in srgb, var(--surface) 92%, transparent); }

/* قائمة النماذج */
.pick-row { transition: background-color .2s, border-color .2s, transform .15s var(--ease); }
.sheet-backdrop.open .pick-row { animation: msgIn .3s var(--ease) both; }
.model-pill:hover:not(:disabled) { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }

/* احترام تفضيل تقليل الحركة */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ---------- الوكيل ---------- */
.agent-steps {
  border: 1px solid var(--border); border-radius: 14px; background: color-mix(in srgb, var(--surface) 80%, transparent);
  margin-bottom: 10px; overflow: hidden;
}
.agent-steps summary {
  display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 9px 12px; font-size: .85rem; font-weight: 600;
  color: var(--muted); list-style: none;
}
.agent-steps summary::-webkit-details-marker { display: none; }
.agent-steps summary svg { width: 18px; height: 18px; color: var(--accent); }
.agent-steps ol { list-style: none; margin: 0; padding: 0 10px 10px; display: grid; gap: 6px; }
.step { display: flex; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); animation: msgIn .3s var(--ease) both; }
.step .ico { font-size: 1.05rem; line-height: 1.6; }
.step-body { flex: 1; min-width: 0; font-size: .85rem; }
.step-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.step-head .note { font-size: .74rem; color: var(--muted); direction: ltr; unicode-bidi: plaintext; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; }
.step .thought { color: var(--muted); margin-top: 2px; }
.step .detail { margin-top: 2px; overflow-wrap: anywhere; }
.step .output { margin: 6px 0 0; padding: 6px 8px; border-radius: 8px; background: #0d1117; color: #d0d7de; font-family: var(--mono); font-size: .76rem; white-space: pre-wrap; max-height: 140px; overflow: auto; }
.step .sources { display: grid; gap: 2px; margin-top: 4px; }
.step .sources a { color: var(--accent); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step.running { box-shadow: inset -3px 0 0 var(--accent); }
.step.running .ico { animation: pulse 1.6s ease-in-out infinite; border-radius: 50%; }
.step.done { box-shadow: inset -3px 0 0 var(--ok); }
.step.error { box-shadow: inset -3px 0 0 var(--danger); }
.agent-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 6px 0 10px; }
.agent-images .gen-image { width: 100%; height: auto; max-height: 260px; object-fit: cover; }

/* البحث في الإنترنت */
.status-line { color: var(--muted); font-size: .85rem; padding: 4px 0; animation: blink 1.4s infinite; }
.web-sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; font-size: .78rem; color: var(--muted); align-items: center; }
.web-sources a {
  color: var(--accent); text-decoration: none; border: 1px solid var(--border); border-radius: 999px;
  padding: 2px 10px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.web-sources a:hover { border-color: var(--accent); }
