:root {
  --bg: #07070d;
  --fg: #ecebf5;
  --muted: #9b98b3;
  --line: rgba(255, 255, 255, 0.08);
  --glass: rgba(20, 19, 34, 0.55);
  --violet: #8b5cf6;
  --cyan: #22d3ee;
  --pink: #ec4899;
  --grad: linear-gradient(135deg, var(--violet), var(--pink) 55%, var(--cyan));
  --radius: 22px;
  --w: 820px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, select, textarea, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

/* ---------- Background ---------- */
.bg { position: fixed; inset: 0; overflow: hidden; z-index: 0; }
.blob {
  position: absolute; width: 46vmax; height: 46vmax; border-radius: 50%;
  filter: blur(90px); opacity: 0.32; mix-blend-mode: screen;
  animation: float 22s ease-in-out infinite alternate;
}
.b1 { background: var(--violet); top: -18vmax; right: -10vmax; }
.b2 { background: var(--pink); bottom: -22vmax; left: -12vmax; animation-delay: -7s; opacity: .22; }
.b3 { background: var(--cyan); top: 30%; left: 35%; width: 30vmax; height: 30vmax; animation-delay: -14s; opacity: .14; }
@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(6vmax, 4vmax) scale(1.12); }
  100% { transform: translate(-5vmax, -3vmax) scale(0.95); }
}
.grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at center, #000 10%, transparent 70%);
  opacity: .5;
}

/* ---------- Layout ---------- */
.app { position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; }
.glass {
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  border: 1px solid var(--line);
}

/* ---------- Orb ---------- */
.orb {
  position: relative; border-radius: 50%;
  background: conic-gradient(from 0deg, var(--violet), var(--pink), var(--cyan), var(--violet));
  animation: spin 6s linear infinite;
  box-shadow: 0 0 30px rgba(139, 92, 246, .45);
}
.orb::after {
  content: ''; position: absolute; inset: 18%; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff8, #0000 45%), #0b0a14;
}
.orb.sm { width: 38px; height: 38px; }
.orb.xs { width: 30px; height: 30px; }
.orb.lg { width: 120px; height: 120px; box-shadow: 0 0 80px rgba(139, 92, 246, .55), 0 0 160px rgba(236, 72, 153, .25); }
.orb.lg::after { inset: 10%; }
@keyframes spin { to { transform: rotate(360deg); } }
.msg.pending .orb, .msg.streaming .orb { animation-duration: 1.1s; box-shadow: 0 0 22px rgba(236, 72, 153, .8); }

/* ---------- Topbar ---------- */
.topbar {
  position: relative;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 7, 13, .45);
  backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 1.15rem; font-weight: 700; letter-spacing: -.2px; display: flex; align-items: center; gap: 8px; }
.badge {
  font-size: .62rem; font-weight: 700; padding: 2px 8px; border-radius: 99px;
  background: var(--grad); color: #fff; letter-spacing: 1px;
}
.sub { font-size: .75rem; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.model-select {
  appearance: none; background: rgba(255,255,255,.05); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 12px; font-size: .82rem; outline: none; cursor: pointer;
  transition: .2s;
}
.mode-select {
  border-color: rgba(139, 92, 246, 0.45);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(236, 72, 153, 0.1));
  font-weight: 600;
  color: #fff;
}
.mode-select:hover {
  border-color: rgba(236, 72, 153, 0.6);
}
.model-select option { background: #14131f; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  border: 1px solid var(--line); background: rgba(255,255,255,.04);
  transition: .2s;
}
.icon-btn:hover { background: rgba(255,255,255,.1); transform: translateY(-1px); }
.icon-btn svg, .send svg, .act svg {
  width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

.settings {
  position: absolute; top: calc(100% + 8px); left: 22px; width: 300px; z-index: 20;
  border-radius: 18px; padding: 18px; display: grid; gap: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  animation: pop .18s ease-out;
}
.settings[hidden] { display: none; }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
.field { display: grid; gap: 8px; font-size: .85rem; }
.field span { display: flex; justify-content: space-between; color: var(--muted); }
.field b { color: var(--fg); font-weight: 600; }
input[type=range] { -webkit-appearance: none; appearance: none; height: 6px; border-radius: 99px; background: rgba(255,255,255,.1); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--grad); box-shadow: 0 0 12px var(--pink); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: var(--pink); cursor: pointer; }
.switch { display: flex; align-items: center; gap: 10px; font-size: .85rem; color: var(--muted); cursor: pointer; }
.switch input { display: none; }
.switch i { width: 38px; height: 22px; border-radius: 99px; background: rgba(255,255,255,.12); position: relative; transition: .2s; flex: none; }
.switch i::after { content: ''; position: absolute; top: 3px; right: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + i { background: var(--violet); }
.switch input:checked + i::after { right: 19px; }

/* ---------- Chat ---------- */
.chat { flex: 1; overflow-y: auto; scroll-behavior: smooth; padding: 28px 18px 10px; }
.chat::-webkit-scrollbar { width: 8px; }
.chat::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 99px; }

.empty {
  max-width: var(--w); margin: 9vh auto 0; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  animation: rise .6s ease-out;
}
.empty[hidden] { display: none; }
.empty h2 {
  margin-top: 18px; font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 700;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.empty p { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 20px; }
.chips button {
  padding: 10px 16px; border-radius: 14px; font-size: .88rem;
  background: rgba(255,255,255,.04); border: 1px solid var(--line); transition: .2s;
}
.chips button:hover { border-color: rgba(139,92,246,.6); background: rgba(139,92,246,.12); transform: translateY(-2px); }

.messages { max-width: var(--w); margin: 0 auto; display: flex; flex-direction: column; gap: 26px; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

.msg { display: flex; gap: 14px; animation: rise .35s ease-out; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble {
  max-width: 78%; padding: 12px 18px; border-radius: 20px 20px 20px 6px;
  background: linear-gradient(135deg, rgba(139,92,246,.9), rgba(236,72,153,.85));
  box-shadow: 0 10px 30px rgba(139,92,246,.25);
  white-space: pre-wrap; word-wrap: break-word; line-height: 1.8;
}
.msg.bot .avatar { flex: none; padding-top: 2px; }
.msg.bot .content { flex: 1; min-width: 0; }
.name { font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; display: flex; gap: 8px; align-items: center; }
.mood:not(:empty) {
  font-size: .68rem; padding: 1px 8px; border-radius: 99px;
  border: 1px solid rgba(34,211,238,.4); color: var(--cyan);
}
.text {
  font-family: 'Amiri', serif; font-size: 1.28rem; line-height: 2.05;
  white-space: pre-wrap; word-wrap: break-word; color: #f2f0ff;
}
.cursor {
  display: inline-block; width: .55em; height: 1.05em; margin-inline-start: 3px;
  vertical-align: -.15em; border-radius: 3px; background: var(--grad);
  animation: blink .9s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* typing indicator */
.typing { display: inline-flex; align-items: center; gap: 12px; padding: 12px 18px; border-radius: 18px;
  background: rgba(255,255,255,.04); border: 1px solid var(--line);
  font-family: 'IBM Plex Sans Arabic', sans-serif; }
.dots { display: inline-flex; gap: 5px; }
.dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--grad); animation: bounce 1.2s infinite ease-in-out; }
.dots span:nth-child(2) { animation-delay: .15s; }
.dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-7px); opacity: 1; } }
.typing em {
  font-style: normal; font-size: .85rem;
  background: linear-gradient(90deg, var(--muted) 0%, #fff 50%, var(--muted) 100%);
  background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.meta { margin-top: 8px; font-size: .74rem; color: var(--muted); opacity: .8; }
.no-stats .meta { display: none; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; opacity: 0.92; transition: .2s; }
.msg.bot:hover .actions, .msg.user:hover .actions, .msg.bot.done:last-child .actions { opacity: 1; }
.msg.pending .actions, .msg.streaming .actions { display: none; }
.act { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); transition: .15s; cursor: pointer; }
.act:hover { background: rgba(255,255,255,.08); color: var(--fg); }
.act.on { color: var(--pink); }

/* ---------- Thinking / Reasoning Block (SmolLM2 Hybrid) ---------- */
.thinking-block {
  margin: 6px 0 14px;
  border-radius: 14px;
  background: rgba(20, 18, 35, 0.65);
  border: 1px solid rgba(139, 92, 246, 0.25);
  overflow: hidden;
  transition: all 0.25s ease;
  font-family: 'IBM Plex Sans Arabic', sans-serif;
}
.thinking-block.active {
  border-color: rgba(236, 72, 153, 0.45);
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.15);
}
.thinking-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  background: rgba(255, 255, 255, 0.035);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.84rem;
  font-weight: 600;
  color: #c4b5fd;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}
.thinking-header:hover {
  background: rgba(255, 255, 255, 0.07);
}
.thinking-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.thinking-header .toggle-icon {
  font-size: 0.72rem;
  transition: transform 0.2s ease;
  opacity: 0.7;
}
.thinking-block.collapsed .toggle-icon {
  transform: rotate(-90deg);
}
.thinking-block.collapsed {
  margin-bottom: 10px;
}
.thinking-block.collapsed .thinking-body {
  display: none;
}
.thinking-badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 500;
}
.thinking-badge.live {
  background: rgba(236, 72, 153, 0.18);
  color: #f472b6;
  border: 1px solid rgba(236, 72, 153, 0.4);
  animation: pulse-badge 1.5s infinite ease-in-out;
}
.thinking-badge.done {
  background: rgba(34, 211, 238, 0.15);
  color: #22d3ee;
  border: 1px solid rgba(34, 211, 238, 0.3);
}
@keyframes pulse-badge {
  0%, 100% { opacity: 0.8; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.04); }
}
.thinking-body {
  padding: 12px 14px;
  font-size: 0.88rem;
  line-height: 1.65;
  direction: ltr;
  text-align: left;
  color: #ddd6fe;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 250px;
  overflow-y: auto;
}
.thinking-body::-webkit-scrollbar {
  width: 5px;
}
.thinking-body::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.3);
  border-radius: 4px;
}
.translation-notice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  margin: 6px 0 10px;
  border-radius: 12px;
  background: rgba(34, 211, 238, 0.08);
  border: 1px dashed rgba(34, 211, 238, 0.35);
  font-size: 0.84rem;
  color: #67e8f9;
  font-family: 'IBM Plex Sans Arabic', sans-serif;
}
.translation-notice .spin-icon {
  display: inline-block;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  100% { transform: rotate(360deg); }
}
.answer-body {
  font-family: 'Amiri', serif;
  font-size: 1.28rem;
  line-height: 2.05;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: #f2f0ff;
}

/* ---------- Composer ---------- */
.composer-wrap { padding: 10px 18px 14px; }
.composer {
  max-width: var(--w); margin: 0 auto; border-radius: var(--radius);
  display: flex; align-items: flex-end; gap: 10px; padding: 10px 10px 10px 10px;
  box-shadow: 0 20px 50px rgba(0,0,0,.45);
  position: relative; transition: border-color .2s;
}
.composer::before {
  content: ''; position: absolute; inset: -1px; border-radius: inherit; padding: 1px;
  background: var(--grad); opacity: 0; transition: .3s;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none;
}
.composer:focus-within::before { opacity: .8; }
.composer textarea {
  flex: 1; min-width: 0; resize: none; border: 0; outline: none; background: transparent;
  padding: 10px 10px; font-size: 0.96rem; line-height: 1.55; max-height: 200px;
  overflow-y: hidden; scrollbar-width: none; -ms-overflow-style: none;
}
.composer textarea::-webkit-scrollbar { display: none; width: 0; height: 0; }
.composer textarea::placeholder { color: #6f6c88; }
.send {
  flex: none; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center;
  background: var(--grad); color: #fff; transition: .2s;
  box-shadow: 0 6px 20px rgba(236,72,153,.35);
}
.send:disabled { background: rgba(255,255,255,.08); box-shadow: none; color: #666; cursor: default; }
.send:not(:disabled):hover { transform: translateY(-2px) scale(1.04); }
.send .i-stop { display: none; fill: currentColor; stroke: none; }
.send.stop .i-stop { display: block; }
.attach-btn {
  flex: none; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.05); color: #a5a2c2; transition: .2s; border: 1px solid var(--line);
  cursor: pointer;
}
.attach-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; transform: translateY(-1px); }
.attach-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.attach-btn.has-img { background: rgba(34, 211, 238, 0.15); border-color: var(--cyan); color: var(--cyan); }

.image-preview-wrap {
  max-width: var(--w); margin: 0 auto 8px; display: flex; align-items: center; gap: 8px;
}
.image-preview-wrap[hidden] { display: none; }
.image-preview-card {
  position: relative; width: 64px; height: 64px; border-radius: 12px; overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2); box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}
.image-preview-card img { width: 100%; height: 100%; object-fit: cover; }
.remove-img-btn {
  position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.7); color: #fff; font-size: 11px; display: grid; place-items: center;
  border: 0; cursor: pointer; transition: .2s;
}
.remove-img-btn:hover { background: #ef4444; }

.chat-img {
  max-width: 260px; max-height: 200px; border-radius: 12px; margin-bottom: 8px; display: block;
  object-fit: cover; border: 1px solid rgba(255, 255, 255, 0.15);
}

.disclaimer { text-align: center; font-size: .72rem; color: #6f6c88; margin-top: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 110px; left: 50%; transform: translate(-50%, 20px);
  padding: 10px 18px; border-radius: 12px; background: #1b1a2b; border: 1px solid var(--line);
  font-size: .85rem; opacity: 0; pointer-events: none; transition: .25s; z-index: 9999;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.status-box {
  padding: 14px 18px; border-radius: 14px; font-size: .88rem; line-height: 1.6;
  border: 1px solid var(--line); display: grid; gap: 8px;
}
.status-box.err {
  background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.35); color: #fecaca;
}
.status-box.ok {
  background: rgba(34, 197, 94, 0.12); border-color: rgba(34, 197, 94, 0.35); color: #bbf7d0;
}
.status-box a { color: var(--cyan); text-decoration: underline; font-weight: 600; }

@media (max-width: 640px) {
  .sub, .model-select { display: none; }
  .text { font-size: 1.15rem; }
  .msg.user .bubble { max-width: 90%; }
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 18px;
}
.modal-backdrop[hidden] { display: none; }
.modal-card {
  width: 100%; max-width: 560px; border-radius: 20px; padding: 24px;
  display: flex; flex-direction: column; gap: 16px;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.6);
  animation: pop .2s ease-out;
}
.modal-header { display: flex; align-items: center; gap: 12px; }
.modal-header h3 { font-size: 1.1rem; font-weight: 700; flex: 1; }
.modal-header .sm { width: 28px; height: 28px; font-size: .85rem; }
.modal-body { display: flex; flex-direction: column; gap: 12px; font-size: .92rem; line-height: 1.6; color: #d6d3e8; }
.modal-body code {
  display: inline-block; direction: ltr; font-family: monospace; font-size: .82rem;
  background: rgba(255, 255, 255, 0.08); padding: 2px 8px; border-radius: 6px;
  color: var(--cyan); word-break: break-all; margin: 4px 0;
}
.step-card {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 10px 14px; border-radius: 12px; background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}
.step-num {
  width: 26px; height: 26px; border-radius: 50%; background: var(--grad);
  display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex: none; color: #fff;
}
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.btn-primary {
  padding: 10px 20px; border-radius: 12px; background: var(--grad); color: #fff;
  font-weight: 600; font-size: .9rem; border: none; cursor: pointer; transition: .2s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(236, 72, 153, 0.4); }

/* ---------- Web AI Modal & Progress Trackers ---------- */
.canvas-wrap {
  position: relative; width: 220px; height: 220px; margin: 4px auto 8px;
  display: flex; align-items: center; justify-content: center;
}
#webAiCanvas {
  width: 220px; height: 220px; display: block;
}

.total-progress-wrap {
  width: 100%;
  max-width: 460px;
  margin: 6px auto 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.total-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.86rem;
}
.total-label {
  color: var(--muted);
  font-weight: 600;
}
.qwen-size {
  font-weight: 700;
  color: #fff;
  font-size: 0.95rem;
}

.linear-bar {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
}
.linear-bar.sm {
  height: 5px;
}
.linear-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.25s ease-out;
}
.grad-total {
  background: linear-gradient(90deg, #8b5cf6, #ec4899, #22d3ee);
  box-shadow: 0 0 10px rgba(236, 72, 153, 0.4);
}
.grad-file {
  background: linear-gradient(90deg, #22d3ee, #38bdf8);
}

.current-file-card {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px 14px;
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px auto 0;
}
.current-file-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}
.current-file-header .file-icon {
  font-size: 0.95rem;
}
.current-file-header .qwen-file {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
  direction: ltr;
  color: var(--cyan);
  font-family: monospace;
  font-size: 0.82rem;
}
.file-percent {
  font-weight: 700;
  color: var(--cyan);
  font-family: monospace;
  font-size: 0.85rem;
}
.file-detail {
  font-size: 0.74rem;
  color: var(--muted);
  text-align: left;
  direction: ltr;
  font-family: monospace;
}

.files-list-wrap {
  width: 100%;
  max-width: 460px;
  max-height: 110px;
  overflow-y: auto;
  font-size: 0.76rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 8px auto 0;
}
.files-list-wrap[hidden] {
  display: none;
}
.files-list-header {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 2px;
  text-align: right;
}
.files-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  direction: ltr;
  font-family: monospace;
  padding: 2px 4px;
  border-radius: 4px;
}
.file-item.done {
  color: #34d399;
}
.file-item.loading {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
}
.file-item.initiate {
  color: #a5a2c2;
}

/* ========================================================
   i18n & Multi-Language Support
   ======================================================== */
body.lang-en {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
body.lang-en .brand h1 {
  letter-spacing: -0.5px;
}
body.lang-en .switch i::after {
  right: auto;
  left: 3px;
}
body.lang-en .switch input:checked + i::after {
  left: 19px;
  right: auto;
}
body.lang-en .settings {
  left: auto;
  right: 22px;
}

/* ========================================================
   Top Navigation Tabs
   ======================================================== */
.nav-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px;
  border-radius: 14px;
  border: 1px solid var(--line);
}
.nav-tab {
  padding: 6px 14px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.2s ease;
  white-space: nowrap;
}
.nav-tab:hover {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.08);
}
.nav-tab.active {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 2px 14px rgba(139, 92, 246, 0.4);
}
.lang-btn {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid rgba(34, 211, 238, 0.4);
  background: rgba(34, 211, 238, 0.1);
  color: var(--cyan);
  transition: all 0.2s ease;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
.lang-btn:hover {
  background: rgba(34, 211, 238, 0.25);
  border-color: var(--cyan);
  color: #fff;
  transform: translateY(-1px);
}

/* ========================================================
   Content Views (Article & About)
   ======================================================== */
.content-view {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 24px 20px 80px;
  position: relative;
  z-index: 2;
}
.content-view::-webkit-scrollbar {
  width: 8px;
}
.content-view::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 99px;
}
.content-container {
  max-width: 860px;
  margin: 0 auto;
  background: rgba(20, 19, 34, 0.45);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 40px 36px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

@media (max-width: 768px) {
  .topbar {
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
  }
  .nav-tabs {
    order: 3;
    width: 100%;
    justify-content: center;
  }
  .content-container {
    padding: 24px 18px;
  }
}

/* ========================================================
   Professional Markdown Typography & Styling
   ======================================================== */
.md-article-content {
  color: #e5e4f2;
  font-size: 1.05rem;
  line-height: 1.85;
}
.md-h {
  color: #fff;
  font-weight: 700;
  line-height: 1.35;
  margin-top: 2rem;
  margin-bottom: 1rem;
}
.md-h1 {
  font-size: 2rem;
  margin-top: 0.5rem;
  margin-bottom: 1.25rem;
  background: linear-gradient(135deg, #fff, #ddd6fe 60%, var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.md-h2 {
  font-size: 1.45rem;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  color: #f3f0ff;
}
.md-h3 {
  font-size: 1.2rem;
  color: #c4b5fd;
}
.md-h4, .md-h5, .md-h6 {
  font-size: 1.05rem;
  color: var(--muted);
}
.md-p {
  margin-bottom: 1.25rem;
  color: #dedcee;
}
.md-hr {
  border: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line), rgba(139, 92, 246, 0.4), var(--line), transparent);
  margin: 2.5rem 0;
}
.md-link {
  color: var(--cyan);
  text-decoration: underline;
  text-underline-offset: 4px;
  transition: color 0.2s;
}
.md-link:hover {
  color: #38bdf8;
  text-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}
.md-quote {
  border-inline-start: 4px solid var(--violet);
  background: rgba(139, 92, 246, 0.08);
  padding: 16px 20px;
  border-radius: 12px;
  margin: 1.5rem 0;
  font-style: italic;
  color: #ede9fe;
}
.md-ul, .md-ol {
  margin: 1rem 0 1.5rem;
  padding-inline-start: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.md-ul li, .md-ol li {
  line-height: 1.7;
}

/* Code Blocks & Copy Button */
.md-code-wrap {
  border-radius: 14px;
  overflow: hidden;
  background: #090812;
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin: 1.75rem 0;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
.md-code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.035);
  border-bottom: 1px solid var(--line);
  font-size: 0.76rem;
  color: var(--muted);
}
.md-code-lang {
  font-family: monospace;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--cyan);
}
.md-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--fg);
  font-size: 0.74rem;
  transition: all 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.md-copy-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.md-copy-btn.copied {
  background: rgba(52, 211, 153, 0.2);
  border-color: rgba(52, 211, 153, 0.4);
  color: #34d399;
}
.md-pre {
  padding: 18px;
  overflow-x: auto;
  font-family: 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.88rem;
  line-height: 1.65;
  color: #f1f0fb;
  direction: ltr;
  text-align: left;
}
.md-inline-code {
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(236, 72, 153, 0.12);
  border: 1px solid rgba(236, 72, 153, 0.25);
  font-family: monospace;
  font-size: 0.88em;
  color: #f472b6;
  direction: ltr;
  display: inline-block;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  margin: 1.75rem 0;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(20, 19, 34, 0.35);
}
.md-table {
  width: 100%;
  border-collapse: collapse;
  text-align: start;
  font-size: 0.92rem;
}
.md-table th {
  background: rgba(255, 255, 255, 0.06);
  padding: 14px 18px;
  border-bottom: 2px solid var(--line);
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}
.md-table td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  color: #dedcee;
}
.md-table tr:last-child td {
  border-bottom: none;
}
.md-table tr:hover td {
  background: rgba(255, 255, 255, 0.025);
}

/* Math blocks & formulas */
.md-math-block {
  padding: 16px 20px;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: 14px;
  margin: 1.5rem 0;
  text-align: center;
  font-family: 'KaTeX_Main', 'Cambria Math', serif, monospace;
  font-size: 1.15rem;
  color: #c4b5fd;
  direction: ltr;
}
.md-inline-math {
  font-family: 'KaTeX_Main', 'Cambria Math', serif, monospace;
  color: #a78bfa;
  font-size: 1.05em;
  padding: 0 4px;
  direction: ltr;
  display: inline-block;
}

/* GitHub Alerts / Callouts */
.md-alert {
  border-radius: 14px;
  padding: 16px 20px;
  margin: 1.75rem 0;
  border: 1px solid;
}
.md-alert-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 8px;
}
.md-alert-note {
  border-color: rgba(34, 211, 238, 0.35);
  background: rgba(34, 211, 238, 0.08);
  color: #7dd3fc;
}
.md-alert-tip {
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.08);
  color: #6ee7b7;
}
.md-alert-important {
  border-color: rgba(236, 72, 153, 0.35);
  background: rgba(236, 72, 153, 0.08);
  color: #f472b6;
}
.md-alert-warning {
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08);
  color: #fcd34d;
}
.md-alert-caution {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.08);
  color: #fca5a5;
}

/* Article Stats Cards */
.article-stats-card {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: center;
  padding: 14px 20px;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 14px;
  margin: 1.5rem 0;
  font-size: 0.88rem;
  color: #ddd6fe;
}
.article-stats-card.success {
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.35);
  color: #a7f3d0;
}

/* ==========================================================================
   Progressive Web App (PWA) Styles
   ========================================================================== */

/* Standalone & Safe-Area adjustments */
html.is-standalone {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html.is-standalone body {
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
  overscroll-behavior-y: none;
}

/* Header Install Button */
.install-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.22), rgba(6, 182, 212, 0.22));
  border: 1px solid rgba(139, 92, 246, 0.45);
  color: #f1f5f9;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.install-btn:hover {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.38), rgba(6, 182, 212, 0.38));
  border-color: rgba(6, 182, 212, 0.7);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.35);
  transform: translateY(-1px);
}

.install-btn:active {
  transform: translateY(1px) scale(0.98);
}

.install-btn svg {
  flex-shrink: 0;
  transition: transform 0.25s ease;
}

.install-btn:hover svg {
  transform: translateY(-1px);
}

/* Pulse animation on install button for subtle call to action */
.install-btn.pulse {
  animation: pwa-btn-pulse 2.4s infinite;
}

@keyframes pwa-btn-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(139, 92, 246, 0);
  }
}

/* Modal Overlay & Backdrop */
.pwa-layer {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.32s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.32s;
}

.pwa-layer.pwa-in,
.pwa-layer.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.pwa-layer.pwa-out {
  opacity: 0;
  pointer-events: none;
}

.pwa-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 10, 18, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* Modal Card */
.pwa-card {
  position: relative;
  background: linear-gradient(165deg, rgba(22, 28, 46, 0.96) 0%, rgba(12, 16, 28, 0.98) 100%);
  border: 1px solid rgba(139, 92, 246, 0.4);
  box-shadow: 0 30px 70px -15px rgba(0, 0, 0, 0.8), 0 0 35px rgba(139, 92, 246, 0.25);
  border-radius: 24px;
  max-width: 450px;
  width: 100%;
  padding: 24px 22px 20px;
  transform: scale(0.92) translateY(20px);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  color: #f1f5f9;
  z-index: 1;
  overflow: hidden;
}

.pwa-layer.pwa-in .pwa-card,
.pwa-layer.show .pwa-card {
  transform: scale(1) translateY(0);
}

/* Grabber for Mobile / Sheet feel */
.pwa-grabber {
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  margin: 0 auto 16px auto;
  display: block;
}

/* Header inside card */
.pwa-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  position: relative;
}

.pwa-app-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.35);
  border: 1px solid rgba(139, 92, 246, 0.45);
  flex-shrink: 0;
  object-fit: cover;
}

.pwa-head-text {
  flex: 1;
  min-width: 0;
}

.pwa-title {
  margin: 0;
  font-size: 1.18rem;
  font-weight: 700;
  color: #f8fafc;
  line-height: 1.3;
}

.pwa-sub {
  margin: 4px 0 0;
  font-size: 0.84rem;
  color: #94a3b8;
  line-height: 1.45;
}

/* Close button (pwa-x) */
.pwa-x {
  position: absolute;
  top: 0;
  inset-inline-end: 0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pwa-x:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  transform: rotate(90deg);
}

/* Perks Pills */
.pwa-perks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 20px;
  list-style: none;
  padding: 0;
}

.pwa-perks li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.32);
  color: #c4b5fd;
}

/* --------------------------------------------------------------------------
   Action Buttons
   -------------------------------------------------------------------------- */
.pwa-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}

.pwa-btn {
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.pwa-btn-primary {
  flex: 1;
  padding: 12px 18px;
  background: linear-gradient(135deg, #8b5cf6, #06b6d4);
  color: #ffffff;
  border: none;
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.4);
}

.pwa-btn-primary:hover {
  box-shadow: 0 10px 30px rgba(6, 182, 212, 0.55);
  transform: translateY(-2px);
}

.pwa-btn-primary svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
}

.pwa-btn-ghost {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
}

.pwa-btn-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
}

.pwa-btn-link {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 0.8rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 6px 10px;
}

.pwa-btn-link:hover {
  color: #cbd5e1;
}

/* --------------------------------------------------------------------------
   iOS Guided Steps (Add to Home Screen)
   -------------------------------------------------------------------------- */
.pwa-layer.pwa-layer-sheet {
  align-items: flex-end;
  padding: 0 14px 20px 14px;
}

@media (min-width: 640px) {
  .pwa-layer.pwa-layer-sheet {
    align-items: center;
    justify-content: center;
    padding: 20px;
  }
}

.pwa-layer.pwa-layer-corner {
  align-items: flex-end;
  justify-content: flex-end;
  padding: 24px;
}

.pwa-steps {
  list-style: none;
  padding: 0;
  margin: 16px 0 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pwa-steps li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  font-size: 0.88rem;
  color: #e2e8f0;
  line-height: 1.45;
}

.pwa-step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8b5cf6, #06b6d4);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.78rem;
  flex-shrink: 0;
}

.pwa-step-text {
  flex: 1;
}

.pwa-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: rgba(139, 92, 246, 0.22);
  border: 1px solid rgba(139, 92, 246, 0.45);
  border-radius: 6px;
  color: #38bdf8;
  vertical-align: middle;
  margin: 0 4px;
}

.pwa-ico svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

/* Floating animated arrow pointing to Safari's Share button at screen bottom */
.pwa-arrow {
  position: absolute;
  bottom: 8px;
  inset-inline-start: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #38bdf8;
  animation: pwa-bounce-down 1.4s ease-in-out infinite;
  pointer-events: none;
  z-index: 2;
}

[dir="rtl"] .pwa-arrow {
  transform: translateX(50%);
}

.pwa-arrow span {
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  font-weight: 600;
  color: #94a3b8;
  margin-bottom: 2px;
  background: rgba(10, 14, 25, 0.8);
  padding: 2px 8px;
  border-radius: 4px;
}

.pwa-arrow svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.6));
}

@keyframes pwa-bounce-down {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(8px);
  }
}

/* --------------------------------------------------------------------------
   Service Worker Update Toast
   -------------------------------------------------------------------------- */
.pwa-update-bar {
  position: fixed;
  bottom: 24px;
  inset-inline-start: 50%;
  transform: translateX(-50%) translateY(120%);
  background: linear-gradient(135deg, #1e1b4b, #0f172a);
  border: 1px solid rgba(139, 92, 246, 0.5);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6), 0 0 25px rgba(139, 92, 246, 0.35);
  padding: 12px 18px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 99998;
  color: #f1f5f9;
  font-size: 0.88rem;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 90vw;
}

[dir="rtl"] .pwa-update-bar {
  transform: translateX(50%) translateY(120%);
}

.pwa-update-bar.show {
  transform: translateX(-50%) translateY(0);
}

[dir="rtl"] .pwa-update-bar.show {
  transform: translateX(50%) translateY(0);
}

.pwa-update-bar button {
  background: linear-gradient(135deg, #8b5cf6, #06b6d4);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s ease;
  white-space: nowrap;
}

.pwa-update-bar button:hover {
  opacity: 0.9;
}

/* --------------------------------------------------------------------------
   Offline Status Indicator
   -------------------------------------------------------------------------- */
.pwa-offline-indicator {
  position: fixed;
  top: 12px;
  inset-inline-start: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: rgba(239, 68, 68, 0.9);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 99997;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.35);
  transition: transform 0.3s ease;
}

[dir="rtl"] .pwa-offline-indicator {
  transform: translateX(50%) translateY(-100px);
}

.pwa-offline-indicator.show {
  transform: translateX(-50%) translateY(0);
}

[dir="rtl"] .pwa-offline-indicator.show {
  transform: translateX(50%) translateY(0);
}

@media (max-width: 480px) {
  .pwa-card {
    padding: 22px 18px 18px;
  }
  .install-btn span {
    display: none;
  }
  .install-btn {
    padding: 8px 10px;
  }
}

/* ==========================================================================
   Article & About Deep Navigation, Table of Contents (TOC) & Social Sharing
   ========================================================================== */

/* Reading Progress Bar (Fixed Top) */
.reading-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3.5px;
  background: linear-gradient(90deg, #8b5cf6, #06b6d4, #10b981);
  z-index: 9999;
  transform-origin: 0 50%;
  transform: scaleX(0);
  transition: transform 0.1s ease-out;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.6);
}

[dir="rtl"] .reading-progress-bar {
  transform-origin: 100% 50%;
}

/* Heading Anchors & Deep-linking Highlights */
.md-h {
  position: relative;
  scroll-margin-top: 85px; /* Offset for sticky topbar */
}

.md-h .md-h-anchor {
  opacity: 0;
  margin-inline-start: 10px;
  color: #38bdf8;
  text-decoration: none;
  font-size: 0.85em;
  vertical-align: middle;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  border-radius: 8px;
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.3);
  cursor: pointer;
}

.md-h:hover .md-h-anchor,
.md-h-anchor:focus {
  opacity: 1;
  transform: scale(1.05);
}

.md-h-anchor:hover {
  background: rgba(6, 182, 212, 0.25);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
}

/* Glowing flash animation for linked headings */
.target-highlight {
  animation: target-flash 2.6s ease-out;
}

@keyframes target-flash {
  0% {
    background: rgba(139, 92, 246, 0.35);
    border-radius: 12px;
    padding-inline: 14px;
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.6);
  }
  70% {
    background: rgba(139, 92, 246, 0.15);
  }
  100% {
    background: transparent;
    padding-inline: 0;
    box-shadow: none;
  }
}

/* --------------------------------------------------------------------------
   Table of Contents (TOC) Card Component
   -------------------------------------------------------------------------- */
.article-toc {
  margin: 1.5rem 0 2.5rem;
  padding: 22px 24px;
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(22, 28, 46, 0.75), rgba(13, 18, 31, 0.85));
  border: 1px solid rgba(139, 92, 246, 0.3);
  box-shadow: 0 15px 35px -10px rgba(0, 0, 0, 0.5), 0 0 20px rgba(139, 92, 246, 0.15);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 16px;
}

.toc-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toc-icon {
  font-size: 1.3rem;
}

.toc-title {
  font-size: 1.1rem;
  color: #f8fafc;
  font-weight: 700;
}

.toc-count {
  font-size: 0.76rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(139, 92, 246, 0.18);
  border: 1px solid rgba(139, 92, 246, 0.35);
  color: #c4b5fd;
  font-weight: 600;
}

.toc-toggle-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s ease;
}

.toc-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.toc-toggle-btn.collapsed svg {
  transform: rotate(-90deg);
}

[dir="rtl"] .toc-toggle-btn.collapsed svg {
  transform: rotate(90deg);
}

.toc-list-wrap {
  transition: all 0.3s ease;
}

.toc-list-wrap[hidden] {
  display: none;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 8px 16px;
}

.toc-item {
  display: flex;
  align-items: center;
}

.toc-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 10px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.88rem;
  width: 100%;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
}

.toc-link:hover {
  color: #38bdf8;
  background: rgba(6, 182, 212, 0.08);
  border-color: rgba(6, 182, 212, 0.3);
  transform: translateX(-3px);
}

[dir="ltr"] .toc-link:hover {
  transform: translateX(3px);
}

.toc-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(139, 92, 246, 0.18);
  color: #c4b5fd;
  font-weight: 700;
  font-size: 0.72rem;
  flex-shrink: 0;
}

.toc-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --------------------------------------------------------------------------
   Social Share Bar Inside TOC
   -------------------------------------------------------------------------- */
.toc-share-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.toc-share-label {
  font-size: 0.82rem;
  color: #94a3b8;
  font-weight: 600;
}

.toc-share-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #f1f5f9;
}

.share-btn:hover {
  transform: translateY(-1px);
}

.share-btn.copy {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(6, 182, 212, 0.25));
  border-color: rgba(6, 182, 212, 0.45);
  color: #38bdf8;
}

.share-btn.copy:hover {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.4), rgba(6, 182, 212, 0.4));
  box-shadow: 0 0 14px rgba(6, 182, 212, 0.35);
}

.share-btn.wa:hover {
  background: rgba(37, 211, 102, 0.2);
  border-color: rgba(37, 211, 102, 0.5);
  color: #4ade80;
}

.share-btn.x:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.4);
}

.share-btn.in:hover {
  background: rgba(10, 102, 194, 0.25);
  border-color: rgba(10, 102, 194, 0.5);
  color: #60a5fa;
}

.share-btn.native:hover {
  background: rgba(139, 92, 246, 0.25);
  border-color: rgba(139, 92, 246, 0.5);
  color: #c4b5fd;
}

/* Floating Back-To-Top Button */
.back-to-top-btn {
  position: fixed;
  bottom: 24px;
  inset-inline-end: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e1b4b, #0f172a);
  border: 1px solid rgba(139, 92, 246, 0.45);
  color: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6), 0 0 20px rgba(139, 92, 246, 0.3);
  cursor: pointer;
  z-index: 9990;
  opacity: 0;
  visibility: hidden;
  transform: translateY(15px);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.back-to-top-btn.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top-btn:hover {
  background: linear-gradient(135deg, #8b5cf6, #06b6d4);
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 12px 30px rgba(6, 182, 212, 0.45);
}

/* ========================================================
   Interactive Canvas Mascot (خلطبيطة الكرتوني المتحرك)
   ======================================================== */
.mascot-canvas {
  display: block;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex-shrink: 0;
}
.mascot-canvas:hover {
  transform: scale(1.08);
}
.mascot-canvas:active {
  transform: scale(0.92);
}
.mascot-canvas.sm {
  width: 46px;
  height: 46px;
}
.mascot-canvas.xs {
  width: 40px;
  height: 40px;
}
.mascot-canvas.chat-avatar-canvas {
  width: 64px;
  height: 64px;
  filter: drop-shadow(0 8px 18px rgba(139, 92, 246, 0.32));
}
.mascot-canvas.lg {
  width: 152px;
  height: 152px;
  filter: drop-shadow(0 14px 32px rgba(139, 92, 246, 0.42));
}

.msg.bot .avatar {
  flex: none;
  padding-top: 0;
  margin-top: -4px;
}

.hero-mascot-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.mascot-mood-pill {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 16px;
  border-radius: 99px;
  background: rgba(139, 92, 246, 0.16);
  border: 1px solid rgba(139, 92, 246, 0.4);
  color: #f3e8ff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
  transition: all 0.25s ease;
}

/* شريط ومسرح شخصيات خلطبيطة الكانفس المتحركة (6 شخصيات) */
.persona-stage-bar {
  display: grid;
  grid-template-columns: repeat(6, minmax(105px, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 780px;
  margin: 12px auto 4px;
}
.persona-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px 9px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
}
.persona-card:hover {
  transform: translateY(-4px);
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.45);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}
.persona-card.active {
  background: linear-gradient(145deg, rgba(139, 92, 246, 0.24), rgba(236, 72, 153, 0.16));
  border-color: rgba(236, 72, 153, 0.65);
  box-shadow: 0 10px 28px rgba(139, 92, 246, 0.32), 0 0 16px rgba(236, 72, 153, 0.22);
  transform: translateY(-2px);
}
.persona-card-canvas-wrap {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.persona-card-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.25;
}
.persona-card-role {
  font-size: 0.65rem;
  color: var(--muted);
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 760px) {
  .persona-stage-bar {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
}
@media (max-width: 480px) {
  .mascot-canvas.chat-avatar-canvas {
    width: 54px;
    height: 54px;
  }
  .persona-card {
    padding: 8px 6px;
  }
  .persona-card-role {
    display: none;
  }
}

/* ========================================================
   Chat History & Context Management Drawer (ChatGPT / Claude / Gemini Style)
   ======================================================== */
.history-toggle-btn {
  position: relative;
  border-color: rgba(139, 92, 246, 0.35);
  background: rgba(139, 92, 246, 0.1);
}
.history-count-badge {
  position: absolute;
  top: -5px;
  inset-inline-end: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--pink);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(236, 72, 153, 0.6);
}
.history-count-badge[hidden] {
  display: none;
}

.danger-btn:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}
.primary-icon-btn {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.22), rgba(236, 72, 153, 0.18));
  border-color: rgba(139, 92, 246, 0.4);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 4, 10, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 120;
  opacity: 0;
  transition: opacity 0.24s ease;
}
.sidebar-backdrop.show {
  opacity: 1;
}
.sidebar-backdrop[hidden] {
  display: none;
}

.history-sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  inset-inline-start: 0;
  width: min(340px, 88vw);
  z-index: 130;
  display: flex;
  flex-direction: column;
  background: rgba(14, 13, 26, 0.94);
  border-inline-end: 1px solid rgba(139, 92, 246, 0.28);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.75);
  transform: translateX(105%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  padding: env(safe-area-inset-top, 14px) 16px env(safe-area-inset-bottom, 16px);
}
[dir="ltr"] .history-sidebar {
  transform: translateX(-105%);
}
.history-sidebar.open {
  transform: translateX(0);
}
.history-sidebar[hidden] {
  display: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px 12px;
  border-bottom: 1px solid var(--line);
}
.sidebar-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-title-wrap h3 {
  font-size: 1.02rem;
  font-weight: 700;
  color: #fff;
}

.sidebar-new-wrap {
  margin: 12px 0;
}
.sidebar-new-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 14px;
  border-radius: 14px;
  background: var(--grad);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 8px 22px rgba(139, 92, 246, 0.32);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.sidebar-new-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(236, 72, 153, 0.45);
}

/* Context Manager & Compression Widget */
.context-manager-card {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 12px;
}
.context-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
}
.context-title {
  font-weight: 700;
  color: #c4b5fd;
}
.context-badge {
  font-size: 0.72rem;
  color: var(--cyan);
  background: rgba(34, 211, 238, 0.1);
  border: 1px solid rgba(34, 211, 238, 0.25);
  padding: 2px 8px;
  border-radius: 99px;
}
.context-meter {
  height: 6px;
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
}
.context-meter-fill {
  height: 100%;
  background: linear-gradient(90deg, #22d3ee, #8b5cf6);
  border-radius: 99px;
  transition: width 0.3s ease;
}
.context-meter-fill.med {
  background: linear-gradient(90deg, #f59e0b, #ec4899);
}
.context-meter-fill.high {
  background: linear-gradient(90deg, #ef4444, #ec4899);
}
.context-summary-box {
  background: rgba(0, 0, 0, 0.28);
  border: 1px dashed rgba(34, 211, 238, 0.3);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.74rem;
}
.context-summary-box[hidden] {
  display: none;
}
.context-summary-label {
  font-weight: 700;
  color: var(--cyan);
  margin-bottom: 3px;
}
.context-summary-text {
  color: #cbd5e1;
  line-height: 1.45;
  max-height: 54px;
  overflow-y: auto;
}
.context-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.context-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 0.74rem;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.context-btn.compress {
  background: rgba(139, 92, 246, 0.16);
  border-color: rgba(139, 92, 246, 0.4);
  color: #ddd6fe;
}
.context-btn.compress:hover {
  background: rgba(139, 92, 246, 0.3);
  color: #fff;
}
.net-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.net-dot.online {
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
}
.net-dot.offline {
  background: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
}

.sidebar-list-header {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--muted);
  padding: 4px 6px 8px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.history-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-inline-end: 2px;
}
.history-list::-webkit-scrollbar {
  width: 5px;
}
.history-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 99px;
}
.history-empty {
  text-align: center;
  padding: 28px 12px;
  color: var(--muted);
  font-size: 0.84rem;
}
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: all 0.18s ease;
}
.history-item:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(139, 92, 246, 0.35);
}
.history-item.active {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.22), rgba(236, 72, 153, 0.14));
  border-color: rgba(139, 92, 246, 0.55);
}
.history-item-info {
  flex: 1;
  min-width: 0;
}
.history-item-title {
  font-size: 0.86rem;
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-item-meta {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
}
.history-item-del {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 0.82rem;
  opacity: 0.65;
  transition: all 0.18s ease;
  flex-shrink: 0;
}
.history-item-del:hover {
  opacity: 1;
  background: rgba(239, 68, 68, 0.22);
}

.sidebar-footer {
  padding-top: 10px;
  margin-top: 8px;
  border-top: 1px solid var(--line);
}
.clear-all-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.22);
  transition: all 0.2s ease;
}
.clear-all-btn:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.45);
}

/* ========================================================
   Native Mobile App-Like Experience (100dvh PWA App Shell)
   ======================================================== */
html, body, .app {
  height: 100dvh;
}

@media (max-width: 640px) {
  .topbar {
    padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 10px;
    gap: 8px;
  }
  .brand {
    gap: 8px;
  }
  .brand h1 {
    font-size: 1rem;
  }
  .mascot-canvas.sm {
    width: 36px;
    height: 36px;
  }
  .mascot-canvas.lg {
    width: 118px;
    height: 118px;
  }
  .top-actions {
    gap: 5px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .mode-select {
    display: inline-block !important;
    max-width: 138px;
    padding: 6px 8px;
    font-size: 0.74rem;
    text-overflow: ellipsis;
  }
  .icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }
  .lang-btn {
    padding: 5px 8px;
    font-size: 0.74rem;
  }
  .nav-tabs {
    width: 100%;
    padding: 3px;
  }
  .nav-tab {
    flex: 1;
    text-align: center;
    padding: 6px 8px;
    font-size: 0.78rem;
  }
  .chat {
    padding: 16px 12px 10px;
  }
  .empty {
    margin-top: 3vh;
    gap: 10px;
  }
  .empty h2 {
    font-size: 1.55rem;
    margin-top: 6px;
  }
  .chips {
    margin-top: 10px;
    gap: 8px;
  }
  .chips button {
    padding: 8px 13px;
    font-size: 0.82rem;
  }
  .composer-wrap {
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(to top, rgba(7, 7, 13, 0.95) 65%, transparent);
  }
  .composer {
    padding: 7px 8px;
    border-radius: 18px;
  }
  .composer textarea {
    font-size: 16px; /* يمنع التكبير التلقائي المزعج في iOS Safari */
    padding: 7px 8px;
  }
  .attach-btn, .send {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }
  .disclaimer {
    font-size: 0.66rem;
    margin-top: 5px;
  }
  .msg.bot .actions {
    opacity: 1;
  }
}

/* ================================================================
 * تنبيه التحميل الأولي المضغوط + مركز إدارة النماذج والطبيب (Doctor) + إحصائيات IndexedDB
 * ================================================================ */
.model-mgr-top-btn {
  position: relative;
  border-color: rgba(34, 211, 238, 0.35);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.16), rgba(34, 211, 238, 0.14));
}
.model-mgr-top-btn:hover {
  border-color: rgba(34, 211, 238, 0.7);
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.3);
}
.model-mgr-top-btn .mgr-dot {
  position: absolute;
  top: 5px;
  inset-inline-end: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}

/* المرحلة ١: التنبيه القصير قبل التحميل الأولي */
.pre-download-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  padding: 18px 20px 22px;
}
.one-time-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #34d399;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
}
.pre-dl-metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}
.pre-dl-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pre-dl-label {
  font-size: 0.73rem;
  color: var(--muted);
}
.pre-dl-val {
  font-size: 0.96rem;
  color: #fff;
  font-weight: 700;
}
.pre-dl-val.net-badge.cellular {
  color: #fbbf24;
}
.pre-dl-val.net-badge.wifi {
  color: #38bdf8;
}
.pre-dl-notice {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.55;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.28);
  color: #e2e8f0;
}
.pre-dl-notice.cellular-warn {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.42);
  color: #fde68a;
}
.pre-dl-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 4px;
}
.confirm-dl-btn {
  flex: 1;
  padding: 11px 16px;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
}
.cancel-dl-btn {
  padding: 11px 16px;
  font-size: 0.85rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
}
.cancel-dl-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* نافذة مركز إدارة النماذج والطبيب (Model Manager & Doctor Modal) */
.model-mgr-modal-card {
  width: min(760px, 95vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}
.mgr-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.mgr-header-icon {
  font-size: 1.45rem;
}
.mgr-header-sub {
  display: block;
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 2px;
}
.mgr-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.doctor-all-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #34d399;
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.4);
  cursor: pointer;
  transition: all 0.2s ease;
}
.doctor-all-btn:hover {
  background: rgba(16, 185, 129, 0.24);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.25);
}
.model-mgr-body {
  overflow-y: auto;
  padding: 16px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* شريط قدرات الجهاز والشبكة الحالية */
.device-caps-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.09);
}
.cap-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
}
.cap-pill b {
  color: #fff;
}
.cap-pill.ok {
  border-color: rgba(16, 185, 129, 0.35);
  color: #a7f3d0;
}
.cap-pill.warn {
  border-color: rgba(245, 158, 11, 0.35);
  color: #fde68a;
}

/* شبكة بطاقات النماذج */
.models-mgr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}
.mgr-model-card {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.mgr-model-card:hover {
  border-color: rgba(139, 92, 246, 0.4);
}
.mgr-model-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.mgr-model-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}
.mgr-model-desc {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}
.mgr-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}
.mgr-status-badge.ready,
.mgr-status-badge.cached {
  background: rgba(16, 185, 129, 0.14);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}
.mgr-status-badge.not-dl {
  background: rgba(148, 163, 184, 0.12);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.25);
}
.mgr-status-badge.corrupted {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.mgr-doctor-report {
  font-size: 0.76rem;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.26);
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: #cbd5e1;
  line-height: 1.45;
}
.mgr-doctor-report.healthy {
  border-color: rgba(16, 185, 129, 0.35);
  color: #a7f3d0;
}
.mgr-doctor-report.bad {
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

/* أزرار التحكم بكل موديل: تحميل/إعادة تحميل + زر دكتور + أيقونة الإحصائيات */
.mgr-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.mgr-act-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 9px;
  font-size: 0.76rem;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #f1f5f9;
  cursor: pointer;
  transition: all 0.18s ease;
}
.mgr-act-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}
.mgr-act-btn.primary {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.28), rgba(236, 72, 153, 0.24));
  border-color: rgba(139, 92, 246, 0.45);
}
.mgr-act-btn.doctor {
  border-color: rgba(34, 211, 238, 0.38);
  color: #67e8f9;
}
.mgr-act-btn.stats-toggle {
  margin-inline-start: auto;
  border-color: rgba(168, 85, 247, 0.4);
  color: #d8b4fe;
}
.mgr-act-btn.stats-toggle.active {
  background: rgba(168, 85, 247, 0.25);
}

/* درج إحصائيات التوكنز والسرعة لكل موديل (مخزن في IndexedDB) */
.mgr-stats-drawer {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 9px;
  border-radius: 11px;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.24);
}
.mgr-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 5px 4px;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 8px;
}
.mgr-stat-lbl {
  font-size: 0.67rem;
  color: var(--muted);
}
.mgr-stat-num {
  font-size: 0.84rem;
  font-weight: 700;
  color: #fff;
  margin-top: 2px;
}
.mgr-stat-num.speed {
  color: #38bdf8;
}

@media (max-width: 640px) {
  .models-mgr-grid {
    grid-template-columns: 1fr;
  }
  .mgr-header-sub {
    display: none;
  }
}

/* ================================================================
 * بطاقة الهوية التقنية والمعرفية للنموذج (Model Passport & Glossary Modal)
 * ================================================================ */
.model-info-top-btn {
  border-color: rgba(168, 85, 247, 0.42);
  background: rgba(139, 92, 246, 0.14);
  color: #e9d5ff;
}
.model-info-top-btn:hover {
  border-color: rgba(236, 72, 153, 0.65);
  background: rgba(139, 92, 246, 0.25);
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.35);
}

.persona-stage-item {
  position: relative;
}
.stage-info-btn {
  position: absolute;
  top: 5px;
  inset-inline-start: 5px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(15, 23, 42, 0.78);
  color: #7dd3fc;
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 3;
  transition: all 0.18s ease;
  padding: 0;
}
.stage-info-btn:hover {
  transform: scale(1.12);
  background: rgba(56, 189, 248, 0.28);
  border-color: #38bdf8;
  color: #fff;
}

.mgr-act-btn.info-btn {
  border-color: rgba(56, 189, 248, 0.42);
  color: #7dd3fc;
  background: rgba(56, 189, 248, 0.1);
}
.mgr-act-btn.info-btn:hover {
  background: rgba(56, 189, 248, 0.22);
}

.passport-modal-card {
  width: min(680px, 95vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}
.passport-modal-body {
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: start;
}
.passport-hero-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 15px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.18), rgba(34, 211, 238, 0.12));
  border: 1px solid rgba(139, 92, 246, 0.35);
}
.passport-names-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.passport-alias-badge {
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
}
.passport-real-id {
  font-size: 0.78rem;
  color: #7dd3fc;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
.passport-size-tag {
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.38);
}

.passport-specs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}
.passport-spec-box {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.passport-spec-lbl {
  font-size: 0.74rem;
  color: var(--muted);
  font-weight: 600;
}
.passport-spec-val {
  font-size: 0.86rem;
  color: #f8fafc;
  font-weight: 700;
  line-height: 1.45;
}

.passport-caps-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 11px 14px;
}
.passport-caps-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #e9d5ff;
  margin-bottom: 6px;
}
.passport-caps-list {
  margin: 0;
  padding-inline-start: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.82rem;
  color: #cbd5e1;
  line-height: 1.5;
}

.passport-glossary-section {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.passport-glossary-heading {
  font-size: 0.86rem;
  font-weight: 800;
  color: #38bdf8;
}
.glossary-card {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(56, 189, 248, 0.24);
  border-radius: 11px;
  padding: 10px 12px;
}
.glossary-term-title {
  font-size: 0.81rem;
  font-weight: 700;
  color: #bae6fd;
  margin-bottom: 4px;
}
.glossary-term-body {
  font-size: 0.79rem;
  color: #cbd5e1;
  line-height: 1.55;
  margin: 0;
}

.passport-alias-banner {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.16), rgba(34, 211, 238, 0.1));
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: 14px;
  padding: 12px 14px;
}
.passport-alias-banner .alias-name {
  font-size: 1rem;
  font-weight: 800;
  color: #f472b6;
}
.passport-alias-banner .real-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #38bdf8;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
.passport-spec-item {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.passport-cap-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  margin: 3px;
  border-radius: 999px;
  font-size: 0.78rem;
  background: rgba(139, 92, 246, 0.14);
  border: 1px solid rgba(139, 92, 246, 0.32);
  color: #e9d5ff;
}
.passport-glossary-header {
  font-size: 0.88rem;
  font-weight: 800;
  color: #38bdf8;
  margin-bottom: 4px;
}
.passport-glossary-card {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(56, 189, 248, 0.24);
  border-radius: 11px;
  padding: 10px 12px;
}
.passport-glossary-card h5 {
  margin: 0 0 4px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #bae6fd;
}
.passport-glossary-card p {
  margin: 0;
  font-size: 0.79rem;
  color: #cbd5e1;
  line-height: 1.55;
}

/* ================================================================
 * واجهة الموبايل النظيفة (Clean App Header + Unified Sidebar + Composer Model Switcher)
 * ================================================================ */
header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  min-height: 58px;
}
header.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

/* تنسيق أقسام القائمة الجانبية (Sidebar Sections) */
.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.sidebar-sec-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 0 4px;
}
.sidebar-nav-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: rgba(255, 255, 255, 0.03);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.sidebar-nav-btn {
  padding: 7px 6px;
  font-size: 0.78rem;
  border-radius: 9px;
  text-align: center;
  white-space: nowrap;
}

.sidebar-tools-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}
.sidebar-tool-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 11px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: all 0.18s ease;
}
.sidebar-tool-btn:hover {
  background: rgba(139, 92, 246, 0.16);
  border-color: rgba(139, 92, 246, 0.4);
}
.sidebar-tool-btn.danger-tool-btn {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.08);
}
.sidebar-tool-btn.danger-tool-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.45);
}

/* درج الإعدادات داخل القائمة الجانبية */
.sidebar-settings-drawer {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 13px;
  margin-bottom: 10px;
  overflow: hidden;
}
.sidebar-settings-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  font-size: 0.81rem;
  font-weight: 700;
  color: #e2e8f0;
  cursor: pointer;
  user-select: none;
}
.sidebar-settings-summary::-webkit-details-marker {
  display: none;
}
.sidebar-settings-drawer[open] .summary-chevron {
  transform: rotate(180deg);
}
.sidebar-settings-body {
  padding: 8px 12px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sidebar-select {
  width: 100%;
  max-width: 100% !important;
  margin-top: 4px;
  padding: 7px 10px;
  font-size: 0.78rem;
  border-radius: 9px;
}

/* شريط الأدوات ومبدّل النماذج داخل شريط الإدخال (Composer Model Switcher & Vision Attach) */
.composer-wrap {
  position: relative;
}
.composer-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.composer-model-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 38px;
  padding: 0 11px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(34, 211, 238, 0.12));
  border: 1px solid rgba(139, 92, 246, 0.42);
  color: #f8fafc;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.composer-model-btn:hover {
  border-color: rgba(34, 211, 238, 0.75);
  box-shadow: 0 0 14px rgba(139, 92, 246, 0.35);
}
.composer-model-btn .cm-icon {
  font-size: 0.95rem;
}
.composer-model-btn .cm-label {
  max-width: 86px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.composer-model-btn .cm-chevron {
  opacity: 0.75;
  transition: transform 0.2s ease;
}
.composer-model-btn.open .cm-chevron {
  transform: rotate(180deg);
}
.attach-btn[hidden] {
  display: none !important;
}

/* القائمة المنبثقة لاختيار النموذج فوق شريط الإدخال */
.model-picker-popover {
  position: absolute;
  bottom: calc(100% - 8px);
  inset-inline-start: 14px;
  width: min(360px, calc(100vw - 28px));
  max-height: 62vh;
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: rgba(13, 15, 26, 0.96);
  border: 1px solid rgba(139, 92, 246, 0.4);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.75), 0 0 24px rgba(139, 92, 246, 0.2);
  z-index: 90;
  overflow: hidden;
  backdrop-filter: blur(18px);
}
.model-picker-popover[hidden] {
  display: none !important;
}
.model-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.82rem;
  font-weight: 700;
  color: #e2e8f0;
}
.model-picker-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 10px 10px;
  overflow-y: auto;
}
.model-picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  cursor: pointer;
  transition: all 0.16s ease;
  text-align: start;
}
.model-picker-item:hover {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.38);
}
.model-picker-item.active {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.24), rgba(34, 211, 238, 0.14));
  border-color: rgba(34, 211, 238, 0.65);
}
.mp-item-main {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1;
}
.mp-item-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}
.mp-item-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.mp-item-title {
  font-size: 0.83rem;
  font-weight: 700;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mp-item-sub {
  font-size: 0.71rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mp-item-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.mp-info-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 0.82rem;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #7dd3fc;
  cursor: pointer;
  transition: all 0.15s ease;
}
.mp-info-btn:hover {
  background: rgba(56, 189, 248, 0.28);
  transform: scale(1.06);
}

/* زر التثبيت المصغر في الهيدر بجوار العنوان بخط هادئ لا ينازع العنوان */
.header-install-mini-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 8px;
  margin-inline-start: 4px;
  border-radius: 999px;
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: 0.1px;
  color: #a5f3fc;
  background: rgba(6, 182, 212, 0.11);
  border: 1px solid rgba(34, 211, 238, 0.32);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.18s ease;
}
.header-install-mini-btn:hover {
  background: rgba(6, 182, 212, 0.24);
  border-color: rgba(34, 211, 238, 0.65);
  color: #fff;
  transform: translateY(-1px);
}
.header-install-mini-btn[hidden] {
  display: none !important;
}
.header-install-mini-btn svg {
  flex-shrink: 0;
  opacity: 0.9;
}

/* إخفاء أي أسهم اسكرول في نافذة التثبيت */
.pwa-card,
.pwa-steps {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.pwa-card::-webkit-scrollbar,
.pwa-steps::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* أزرار النسخ والحذف للرسائل (سواء طلب المرسل أو رد الذكاء) */
.msg.user {
  position: relative;
}
.user-msg-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  max-width: 82%;
  min-width: 0;
}
.msg.user .user-msg-col .bubble {
  max-width: 100%;
}
.user-actions {
  justify-content: flex-end;
  margin-top: 5px;
  gap: 6px;
}
.act.labeled-act {
  width: auto;
  height: 27px;
  padding: 0 9px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: #cbd5e1;
}
.act.labeled-act svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}
.act.copy-act:hover {
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(56, 189, 248, 0.14);
}
.act.del-act {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.22);
  background: rgba(239, 68, 68, 0.08);
}
.act.del-act:hover {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.2);
}

/* تصغير زر تبديل الموديلات في الموبايل وتوسيع مساحة الكتابة */
@media (max-width: 640px) {
  .user-msg-col {
    max-width: 92%;
  }
  .composer {
    gap: 6px;
    padding: 7px 8px;
  }
  .composer textarea {
    padding: 7px 6px;
    font-size: 0.88rem;
  }
  .composer-tools {
    gap: 4px;
  }
  .composer-model-btn {
    height: 30px;
    padding: 0 7px;
    gap: 3px;
    border-radius: 9px;
    font-size: 0.67rem;
  }
  .composer-model-btn .cm-icon {
    font-size: 0.8rem;
  }
  .composer-model-btn .cm-label {
    max-width: 52px;
  }
  .composer-model-btn .cm-chevron {
    width: 10px;
    height: 10px;
  }
  .send,
  .attach-btn {
    width: 36px;
    height: 36px;
    border-radius: 11px;
  }
}

.confirm-delete-card {
  width: min(400px, 92vw);
}
.btn-danger-confirm {
  padding: 9px 18px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.86rem;
  color: #fff;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border: 1px solid rgba(248, 113, 113, 0.5);
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.32);
  transition: all 0.18s ease;
}
.btn-danger-confirm:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}
