/* المكوّنات */

/* ───────── الشعار ───────── */
.brand { display: inline-flex; border-radius: 12px; }
.brand-plate {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 6px 10px;
  border-radius: 12px;
  background: var(--logo-plate);
}
.brand-plate .brand-mark { width: 30px; height: 30px; }
.brand-plate img { width: 92px; height: auto; }
[data-theme="dark"] .brand-plate { box-shadow: 0 0 0 1px rgb(255 255 255 / .06), 0 6px 18px -8px rgb(0 0 0 / .8); }
.brand:hover .brand-plate { background: color-mix(in srgb, var(--accent-soft) 70%, var(--logo-plate)); }
[data-theme="dark"] .brand:hover .brand-plate { background: var(--logo-plate); }

/* ───────── أدوات الشريط ───────── */
.bar-tools { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: 10px;
  color: var(--muted);
  transition: background .2s, color .2s;
}
.icon-btn:hover { background: var(--surface-alt); color: var(--text); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 8px; }
.icon-btn.sm svg { width: 16px; height: 16px; }

.preview-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 13px; border-radius: 99px;
  font-size: 12.5px; color: var(--muted);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border: 1px solid var(--border);
}
.pulse, .conn i, .status-ok i {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--logo-gold);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--logo-gold) 60%, transparent);
  animation: pulse 2.4s var(--ease) infinite;
}
@keyframes pulse { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* مفتاح المظهر: فاتح · داكن · النظام — مثل البرنامج */
.theme-switch {
  display: inline-flex; padding: 3px; gap: 2px;
  border-radius: 11px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}
.theme-switch button {
  display: inline-grid; place-items: center;
  width: 30px; height: 28px; border-radius: 8px;
  color: var(--faint);
  transition: background .2s, color .2s, box-shadow .2s;
}
.theme-switch button svg { width: 16px; height: 16px; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-checked="true"] { background: var(--surface); color: var(--accent-dark); box-shadow: var(--shadow-s); }
[data-theme="dark"] .theme-switch button[aria-checked="true"] { color: var(--accent); }

/* ───────── العتبة: الشعار الحيّ ───────── */
.hero-mark { width: 104px; height: 104px; margin: 8px 0 22px; }
.hero-mark svg { width: 100%; height: 100%; overflow: visible; }
.hero-mark .plate { fill: var(--logo-plate); }
.hero-mark .ring {
  fill: none; stroke: var(--logo-navy); stroke-width: 38; stroke-linecap: round;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: ring-draw 1.6s var(--ease-out) .15s forwards;
}
.hero-mark .dot {
  fill: var(--logo-gold);
  transform-origin: 300px 301px; transform: scale(0);
  animation: dot-in .7s var(--ease-out) 1.2s forwards, breathe 5s ease-in-out 2.2s infinite;
}
@keyframes ring-draw { to { stroke-dashoffset: 0; } }
@keyframes dot-in { 60% { transform: scale(1.12); } to { transform: scale(1); } }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(.9); } }

.hero-eyebrow {
  display: flex; align-items: center; gap: 12px;
  font-size: 13.5px; letter-spacing: .02em; color: var(--accent-dark);
  font-weight: 700; margin-bottom: 8px;
}
[data-theme="dark"] .hero-eyebrow { color: var(--accent); }
.hero-eyebrow span { width: 28px; height: 1px; background: currentColor; opacity: .5; }

.hero-title {
  font-weight: 300;
  font-size: clamp(32px, 5.4vw, 58px);
  line-height: 1.25;
  letter-spacing: -.01em;
}
.hero-title em {
  font-style: normal; font-weight: 700; position: relative; white-space: nowrap;
  color: var(--text);
}
.hero-title em::after {
  content: ""; position: absolute; inset-inline: -4px; bottom: .34em; height: .24em; z-index: -1;
  background: color-mix(in srgb, var(--logo-gold) 40%, transparent);
  border-radius: 3px;
  transform-origin: right; transform: scaleX(0);
  animation: underline-in .8s var(--ease-out) 1.5s forwards;
}
@keyframes underline-in { to { transform: scaleX(1); } }

.hero-lead {
  max-width: 600px; text-wrap: balance; margin-top: 14px;
  font-size: clamp(15px, 1.6vw, 17px); color: var(--muted); line-height: 1.9;
}

.threshold-main > * { animation: rise .8s var(--ease-out) both; }
.threshold-main > .hero-eyebrow { animation-delay: .35s; }
.threshold-main > .hero-title { animation-delay: .45s; }
.threshold-main > .hero-lead { animation-delay: .55s; }
.threshold-main > .omnibox { animation-delay: .65s; }
.threshold-main > .try-row { animation-delay: .75s; }
.threshold-main > .shelves { animation-delay: .85s; }
.threshold-main > .preview-note { animation-delay: .95s; }
.threshold-main > .hero-mark { animation: none; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* ───────── صندوق البحث الكبير ───────── */
.omnibox {
  width: 100%; max-width: 700px; margin-top: 30px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 8px;
  box-shadow: var(--shadow);
  transition: border-color .25s, box-shadow .25s;
}
.omnibox:focus-within { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); box-shadow: var(--shadow), 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent); }

.mode-switch { display: flex; gap: 4px; padding: 2px 2px 8px; }
.mode {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 10px;
  font-size: 13.5px; color: var(--muted);
  transition: background .2s, color .2s;
}
.mode svg { width: 16px; height: 16px; }
.mode:hover { color: var(--text); background: var(--surface-alt); }
.mode.is-active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 700; }
[data-theme="dark"] .mode.is-active { color: var(--accent); }

.omnibox-field {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg);
  border-radius: 15px;
  padding: 6px 6px 6px 6px;
  padding-inline-start: 18px;
  border: 1px solid transparent;
}
.omnibox-field input {
  flex: 1; min-width: 0; height: 46px;
  border: 0; outline: 0; background: transparent;
  font-size: 17px;
}
.omnibox-field input::placeholder { color: var(--faint); }
.omnibox-field input::-webkit-search-cancel-button { display: none; }
.omni-kbd { flex: none; }
.omni-submit {
  display: inline-flex; align-items: center; gap: 8px;
  height: 46px; padding: 0 20px; border-radius: 12px;
  background: var(--accent); color: var(--on-accent);
  font-weight: 700; font-size: 15px;
  box-shadow: inset 0 -2px 0 rgb(0 0 0 / .12);
  transition: background .2s, transform .15s;
}
.omni-submit:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
.omni-submit:active { transform: translateY(1px); }

.operators { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 6px 4px; }
.operators button {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--muted);
  padding: 3px 10px 3px 4px; border-radius: 8px;
  border: 1px dashed var(--border);
  transition: border-color .2s, color .2s, background .2s;
}
.operators button:hover { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.operators code {
  padding: 1px 6px; border-radius: 5px;
  background: var(--surface-alt); color: var(--accent-dark); font-weight: 700;
}
[data-theme="dark"] .operators code { color: var(--accent); }

.try-row {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px;
  margin-top: 18px; font-size: 13.5px;
}
.try-label { color: var(--faint); }
.try-row button, .chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 13px; border-radius: 99px;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  border: 1px solid var(--border);
  color: var(--text);
  transition: border-color .2s, background .2s, transform .2s;
}
.try-row button svg { width: 14px; height: 14px; color: var(--accent); }
.try-row button:hover, .chip:hover { border-color: var(--accent); transform: translateY(-1px); }

/* ───────── رفوف المكتبة ───────── */
.shelves { width: 100%; margin-top: 56px; text-align: start; }
.shelves-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.shelves-head h2 { font-size: 16px; white-space: nowrap; }
.shelves-head .rule { flex: 1; height: 1px; background: linear-gradient(to left, var(--border), transparent); }
.link-btn {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13.5px; color: var(--accent-dark); font-weight: 700; white-space: nowrap;
}
[data-theme="dark"] .link-btn { color: var(--accent); }
.link-btn svg { width: 15px; height: 15px; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 4px; }

.shelf-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.shelf {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px 18px 16px; text-align: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  transition: transform .3s var(--ease-out), box-shadow .3s, border-color .3s;
}
.shelf:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.shelf::before {
  content: ""; position: absolute; top: -34px; inset-inline-end: -34px;
  width: 96px; height: 96px; border-radius: 50%;
  border: 8px solid color-mix(in srgb, var(--logo-navy) 5%, transparent);
  border-top-color: transparent;
  transform: rotate(0deg);
  transition: transform .6s var(--ease-out);
}
[data-theme="dark"] .shelf::before { border-color: rgb(239 231 216 / .05); border-top-color: transparent; }
.shelf:hover::before { transform: rotate(40deg); }
.shelf-num { font-size: 12px; color: var(--accent-dark); font-weight: 700; letter-spacing: .08em; }
[data-theme="dark"] .shelf-num { color: var(--accent); }
.shelf h3 { font-size: 17px; }
.shelf p { font-size: 13px; color: var(--muted); line-height: 1.7; }
.shelf-meta { display: flex; gap: 12px; margin-top: 6px; font-size: 12px; color: var(--faint); }

.preview-note {
  display: flex; gap: 10px; align-items: flex-start;
  max-width: 640px; margin-top: 34px;
  font-size: 12.5px; color: var(--faint); text-align: start; line-height: 1.8;
}
.preview-note svg { width: 16px; height: 16px; margin-top: 3px; color: var(--accent); }

/* ───────── بحث المكتب ───────── */
.desk-search {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.desk-search:focus-within { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
.desk-search-icon { color: var(--faint); }
.desk-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font-size: 15px; }
.desk-search input::-webkit-search-cancel-button { display: none; }
.op-help {
  font-family: ui-monospace, Consolas, monospace; font-size: 11px; direction: ltr;
  color: var(--faint); padding: 3px 7px; border-radius: 6px; white-space: nowrap;
}
.op-help:hover { color: var(--accent-dark); background: var(--accent-soft); }

.conn {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--muted); white-space: nowrap;
  padding: 4px 10px; border-radius: 99px; border: 1px solid var(--border);
}
.conn i { background: var(--faint); animation: none; }

/* ───────── رأس اللوحة ───────── */
.pane-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 14px 10px 8px;
  border-bottom: 1px solid var(--border);
  min-height: 52px;
}
.pane-head h2 { display: flex; align-items: center; gap: 8px; font-size: 14.5px; }
.pane-head h2 svg { color: var(--accent); }
.pane-actions { display: flex; gap: 2px; }

.pane-rail {
  flex-direction: column; align-items: center; gap: 10px;
  padding: 14px 0; border-radius: var(--radius-l);
  background: var(--surface); border: 1px solid var(--border);
  color: var(--muted); font-size: 12.5px;
}
.pane-rail span { display: none; }
.pane-rail svg { color: var(--accent); }
.pane-rail:hover { color: var(--text); border-color: var(--accent); }

/* ───────── المساعد ───────── */
.chat-log { flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }

.chat-empty { margin: auto 0; text-align: center; padding: 10px 6px 20px; }
.chat-empty .mini-mark { width: 54px; height: 54px; margin: 0 auto 14px; }
.chat-empty h3 { font-size: 16px; }
.chat-empty p { font-size: 13px; color: var(--muted); margin: 6px auto 16px; max-width: 250px; }
.chat-empty .chips { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.chat-empty .chip { justify-content: flex-start; border-radius: 10px; font-size: 13px; text-align: start; }
.chat-empty .chip svg { width: 14px; height: 14px; color: var(--accent); }

.mini-mark { display: block; }
.mini-mark svg { width: 100%; height: 100%; overflow: visible; }
.mini-mark .plate { fill: var(--logo-plate); }
.mini-mark .ring { fill: none; stroke: var(--logo-navy); stroke-width: 44; stroke-linecap: round; }
.mini-mark .dot { fill: var(--logo-gold); transform-origin: 300px 301px; }
.mini-mark.is-thinking .ring { stroke-dasharray: .62 .38; animation: orbit 1.3s linear infinite; }
.mini-mark.is-thinking .dot { animation: breathe 1.3s ease-in-out infinite; }
@keyframes orbit { to { stroke-dashoffset: -1; } }

.msg { display: flex; flex-direction: column; gap: 5px; animation: rise .45s var(--ease-out) both; }
.msg-label { font-size: 11.5px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.msg.user { align-items: flex-start; }
.msg.user .msg-label { color: var(--user-label); }
.msg.user .bubble { background: var(--user-bg); border-radius: 14px 14px 14px 4px; }
.msg.bot .msg-label { color: var(--bot-label); }
.msg.bot .msg-label .mini-mark { width: 16px; height: 16px; }
.bubble {
  padding: 10px 13px; font-size: 14px; line-height: 1.9;
  border-radius: 14px 4px 14px 14px;
  max-width: 100%; overflow-wrap: anywhere;
}
.msg.bot .bubble { background: var(--surface-alt); border: 1px solid var(--border); }
.bubble p + p, .bubble p + ol, .bubble ol + p { margin-top: 8px; }
.bubble ol { list-style: arabic-indic; margin: 6px 0 0; padding-inline-start: 20px; display: grid; gap: 8px; }
.bubble li::marker { color: var(--accent); font-weight: 700; }
.cite {
  display: inline-grid; place-items: center; vertical-align: 2px;
  min-width: 19px; height: 19px; padding: 0 4px; margin-inline-start: 3px;
  border-radius: 6px; font-size: 11px; font-weight: 700; line-height: 1;
  background: var(--accent-soft); color: var(--accent-dark);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  transition: background .2s, color .2s;
}
[data-theme="dark"] .cite { color: var(--accent); }
.cite:hover { background: var(--accent); color: var(--on-accent); }
.answer-kind { font-size: 11.5px; color: var(--faint); display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.answer-kind::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--faint); }

.sources { margin-top: 6px; }
/* مراحل البحث كما يرسلها الخادم (مثل شريط الحالة في برنامج سطح المكتب) */
.trail { margin: 2px 0 6px; }
.trail summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--faint); padding: 2px 4px; border-radius: 6px;
}
.trail summary::-webkit-details-marker { display: none; }
.trail summary svg { width: 13px; height: 13px; color: var(--accent); }
.trail summary:hover { color: var(--muted); }
.trail .steps { margin: 4px 4px 2px; font-size: 12px; }
.trail .steps li { overflow-wrap: anywhere; }
.sources summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: var(--muted); padding: 2px 4px; border-radius: 6px;
}
.sources summary::-webkit-details-marker { display: none; }
.sources summary svg { width: 14px; height: 14px; color: var(--accent); }
.sources[open] summary { margin-bottom: 6px; }
.source {
  width: 100%; display: flex; align-items: center; gap: 8px; text-align: start; margin-top: 4px;
  padding: 7px 9px; border-radius: 10px; font-size: 12.5px;
  border: 1px solid var(--border); background: var(--surface);
  transition: border-color .2s, opacity .2s;
}
.source:not(.is-used) { opacity: .72; }
.source:hover { border-color: var(--accent); opacity: 1; }
.source b { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-dark); font-size: 11px; flex: none; }
[data-theme="dark"] .source b { color: var(--accent); }
.source > span { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.5; }
.source strong { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source span small { color: var(--faint); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source > small { color: var(--faint); font-size: 11px; flex: none; }

.thinking { display: flex; gap: 10px; align-items: flex-start; }
.thinking .mini-mark { width: 26px; height: 26px; flex: none; margin-top: 2px; }
.steps { list-style: none; margin: 0; padding: 0; font-size: 12.5px; color: var(--faint); display: grid; gap: 2px; }
.steps li { display: flex; align-items: center; gap: 7px; transition: color .3s; }
.steps li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; border: 1.5px solid currentColor; flex: none; }
.steps li.done { color: var(--muted); }
.steps li.done::before { background: var(--success); border-color: var(--success); }
.steps li.now { color: var(--text); }
.steps li.now::before { border-color: var(--accent); background: var(--accent); animation: pulse 1.2s infinite; }

.composer {
  position: relative;
  margin: 8px 12px 12px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg);
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "scope scope" "input send" "hint hint";
  gap: 4px 6px;
  transition: border-color .2s, box-shadow .2s;
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); background: var(--surface); }
.composer-scope { grid-area: scope; display: flex; gap: 4px; }
.scope {
  font-size: 11.5px; padding: 2px 9px; border-radius: 7px; color: var(--faint);
  border: 1px solid transparent;
}
.scope.is-active { color: var(--accent-dark); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); font-weight: 700; }
[data-theme="dark"] .scope.is-active { color: var(--accent); }
.composer textarea {
  grid-area: input; resize: none; border: 0; outline: 0; background: transparent;
  font-size: 14.5px; line-height: 1.7; padding: 6px 6px; max-height: 140px; min-height: 36px;
}
.composer textarea::placeholder { color: var(--faint); }
.send-btn {
  grid-area: send; align-self: end;
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px;
  background: var(--accent); color: var(--on-accent);
  transition: background .2s, transform .15s;
}
.send-btn:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
.send-btn:active { transform: scale(.96); }
.composer-hint { grid-area: hint; font-size: 11px; color: var(--faint); padding: 0 6px; }
.composer-hint kbd { font-size: 10px; padding: 2px 4px; }

/* ───────── تبويبات النص ───────── */
.flip { transform: scaleX(-1); }
span.tab { cursor: pointer; }
.tabs {
  display: flex; align-items: flex-end; gap: 2px;
  padding: 8px 10px 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  flex: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  display: inline-flex; align-items: center; gap: 7px;
  max-width: 220px; height: 38px; padding: 0 12px;
  font-size: 13px; color: var(--muted);
  border-radius: 10px 10px 0 0;
  border: 1px solid transparent; border-bottom: 0;
  white-space: nowrap; flex: none;
  transition: color .2s, background .2s;
}
.tab:hover { color: var(--text); background: color-mix(in srgb, var(--surface) 55%, transparent); }
.tab[aria-selected="true"] {
  background: var(--surface); color: var(--text); font-weight: 700;
  border-color: var(--border); margin-bottom: -1px; height: 39px;
}
.tab[aria-selected="true"]::before {
  content: ""; position: absolute; top: -1px; inset-inline: 10px; height: 2px; border-radius: 2px; background: var(--accent);
}
.tab > svg { width: 15px; height: 15px; color: var(--accent); }
.tab-title { overflow: hidden; text-overflow: ellipsis; }
.tab-count { font-size: 11px; background: var(--accent-soft); color: var(--accent-dark); padding: 0 6px; border-radius: 99px; font-weight: 700; }
[data-theme="dark"] .tab-count { color: var(--accent); }
.tab-close { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; color: var(--faint); margin-inline-start: 2px; }
.tab-close svg { width: 13px; height: 13px; }
.tab-close:hover { background: var(--surface-alt); color: var(--danger); }

.work-view { flex: 1; overflow-y: auto; min-height: 0; }

/* ───────── النتائج ───────── */
.results { padding: 18px clamp(14px, 3vw, 30px) 40px; max-width: 900px; margin: 0 auto; }
.results-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin-bottom: 12px; }
.results-head h2 { font-size: 20px; font-weight: 700; }
.results-head h2 q { quotes: "«" "»"; color: var(--accent-dark); }
[data-theme="dark"] .results-head h2 q { color: var(--accent); }
.results-stat { font-size: 12.5px; color: var(--faint); }
.query-explain { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.term {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; padding: 2px 9px; border-radius: 7px;
  background: var(--surface-alt); border: 1px solid var(--border); color: var(--text);
}
.term i { font-style: normal; font-size: 10.5px; color: var(--faint); }
.term.req { border-color: color-mix(in srgb, var(--success) 45%, var(--border)); }
.term.req i { color: var(--success); }
.term.not { text-decoration: line-through; text-decoration-color: var(--danger); color: var(--muted); }
.term.not i { color: var(--danger); text-decoration: none; }
.term.phrase { border-style: dashed; border-color: var(--accent); }

.filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 0 14px; margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.filters .label { font-size: 12px; color: var(--faint); display: inline-flex; align-items: center; gap: 5px; }
.filters .label svg { width: 14px; height: 14px; }
.fchip {
  font-size: 12.5px; padding: 4px 11px; border-radius: 99px;
  border: 1px solid var(--border); color: var(--muted);
  transition: all .2s;
}
.fchip:hover { color: var(--text); border-color: var(--border-strong); }
.fchip[aria-pressed="true"] { background: var(--neutral); color: var(--on-neutral); border-color: var(--neutral); }
[data-theme="dark"] .fchip[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.filters select {
  font-size: 12.5px; padding: 4px 10px; border-radius: 99px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
}
.filters .spacer { flex: 1; }

.result {
  padding: 18px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  animation: rise .4s var(--ease-out) both;
}
.result-top { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.result-title {
  font-size: 17px; font-weight: 700; text-align: start;
  transition: color .2s;
}
.result-title:hover { color: var(--accent-dark); }
[data-theme="dark"] .result-title:hover { color: var(--accent); }
.relevance { display: inline-flex; gap: 3px; margin-inline-start: auto; flex: none; }
.relevance i { width: 5px; height: 12px; border-radius: 2px; background: var(--border); }
.relevance i.on { background: var(--accent); }
.result-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--faint); margin-bottom: 8px; }
.result-meta span { display: inline-flex; align-items: center; gap: 4px; }
.result-meta svg { width: 13px; height: 13px; }
.passage {
  position: relative;
  font-size: 15px; line-height: 2; color: var(--text);
  padding-inline-start: 16px;
  border-inline-start: 2px solid var(--border);
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
  cursor: pointer;
  transition: border-color .2s;
}
.passage:hover { border-inline-start-color: var(--accent); }
.passage + .passage { margin-top: 10px; }
.passage-num { font-size: 11px; color: var(--faint); margin-inline-end: 6px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.act {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; color: var(--muted); padding: 4px 9px; border-radius: 8px;
  transition: background .2s, color .2s;
}
.act svg { width: 14px; height: 14px; }
.act:hover { background: var(--surface-alt); color: var(--text); }
.act.is-on { color: var(--accent-dark); }
[data-theme="dark"] .act.is-on { color: var(--accent); }
.act.is-on svg { fill: currentColor; }
.more-passages { font-size: 12.5px; color: var(--accent-dark); margin-top: 8px; font-weight: 700; }
[data-theme="dark"] .more-passages { color: var(--accent); }

.empty {
  text-align: center; padding: 56px 20px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.empty .mini-mark { width: 60px; height: 60px; margin-bottom: 8px; opacity: .9; }
.empty h3 { color: var(--text); font-size: 17px; }
.empty p { font-size: 13.5px; max-width: 400px; }
.empty .chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 10px; }

/* ───────── القارئ ───────── */
.reader { padding: 26px clamp(16px, 4vw, 48px) 60px; }
.reader-inner { max-width: 680px; margin: 0 auto; }
.reader-tools {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  margin: -26px calc(-1 * clamp(16px, 4vw, 48px)) 20px;
  padding: 8px clamp(16px, 4vw, 48px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.reader-tools .spacer { flex: 1; }
.font-ctl { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 9px; }
.font-ctl button { width: 30px; height: 28px; display: grid; place-items: center; color: var(--muted); }
.font-ctl button:hover { color: var(--text); }
.font-ctl button svg { width: 14px; height: 14px; }
.font-ctl span { font-size: 12px; color: var(--faint); min-width: 38px; text-align: center; }

.doc-head { text-align: center; padding: 8px 0 26px; margin-bottom: 26px; position: relative; }
.doc-head::after {
  content: ""; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 120px; height: 1px; background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
.doc-head .doc-series { font-size: 13px; color: var(--accent-dark); font-weight: 700; }
[data-theme="dark"] .doc-head .doc-series { color: var(--accent); }
.doc-head h1 { font-size: clamp(26px, 3.4vw, 34px); margin: 6px 0 10px; }
.doc-meta { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--faint); }
.doc-meta span { display: inline-flex; align-items: center; gap: 5px; }
.doc-meta svg { width: 14px; height: 14px; }
.demo-flag {
  display: inline-block; margin-top: 12px; font-size: 11.5px; color: var(--warning);
  background: color-mix(in srgb, var(--warning) 10%, transparent);
  padding: 2px 10px; border-radius: 99px;
}

.para {
  position: relative;
  font-size: calc(18px * var(--reader-scale, 1));
  line-height: 2.15;
  margin: 0 0 1.1em;
  padding: 4px 8px;
  margin-inline: -8px;
  border-radius: 8px;
  transition: background .6s var(--ease);
  text-align: justify;
}
.para-no {
  position: absolute; inset-inline-start: -34px; top: .55em;
  font-size: 12px; color: var(--faint); width: 24px; text-align: center;
  transition: opacity .2s;
}
.para-save {
  position: absolute; inset-inline-end: -40px; top: .35em;
  width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px;
  color: var(--faint); opacity: 0; transition: opacity .2s, color .2s, background .2s;
}
.para-save svg { width: 15px; height: 15px; }
.para:hover .para-save, .para-save:focus-visible, .para-save.is-on { opacity: 1; }
.para-save:hover { background: var(--surface-alt); color: var(--accent-dark); }
.para-save.is-on { color: var(--accent); }
.para-save.is-on svg { fill: currentColor; }
.para.flash { background: color-mix(in srgb, var(--highlight-bg) 70%, transparent); }
.para.is-saved { box-shadow: inset -3px 0 0 var(--accent); }

.doc-foot { margin-top: 36px; padding-top: 18px; border-top: 1px dashed var(--border); font-size: 12.5px; color: var(--faint); display: flex; gap: 12px; flex-wrap: wrap; justify-content: space-between; }

@media (max-width: 1100px) {
  .para-no { display: none; }
  .para-save { inset-inline-end: 0; top: auto; bottom: -6px; opacity: .8; }
}

/* ───────── المكتبة ───────── */
.seg {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px;
  margin: 10px 12px 4px; padding: 3px;
  background: var(--surface-alt); border-radius: 10px; border: 1px solid var(--border);
}
.seg-btn { font-size: 12.5px; padding: 5px 4px; border-radius: 8px; color: var(--muted); display: inline-flex; justify-content: center; align-items: center; gap: 5px; }
.seg-btn.is-active { background: var(--surface); color: var(--text); font-weight: 700; box-shadow: var(--shadow-s); }
.count { font-size: 10.5px; background: var(--accent-soft); color: var(--accent-dark); padding: 0 6px; border-radius: 99px; font-weight: 700; }
[data-theme="dark"] .count { color: var(--accent); }

.lib-view { flex: 1; overflow-y: auto; padding: 8px 8px 16px; }
.lib-caption { font-size: 11.5px; color: var(--faint); padding: 8px 8px 4px; }

.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree .children { padding-inline-start: 12px; border-inline-start: 1px dashed var(--border); margin-inline-start: 15px; }
.tree-row { display: flex; align-items: center; border-radius: 8px; }
.tree-row:hover { background: var(--surface-alt); }
.tree-row.is-active { background: var(--accent-soft); }
.tree-toggle {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; text-align: start;
  padding: 6px 8px; border-radius: 8px; font-size: 13.5px; font-weight: 700;
}
.tree-toggle span:not(.n) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-toggle .chev { width: 14px; height: 14px; color: var(--faint); transition: transform .2s; }
.tree-toggle[aria-expanded="true"] .chev { transform: rotate(-90deg); }
.tree-toggle .ic { color: var(--accent); width: 16px; height: 16px; }
.tree-toggle .n { font-size: 11px; color: var(--faint); font-weight: 400; }
.tree-scope { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 7px; color: var(--faint); opacity: 0; transition: opacity .2s; }
.tree-scope svg { width: 14px; height: 14px; }
.tree-row:hover .tree-scope, .tree-scope:focus-visible, .tree-row.is-active .tree-scope { opacity: 1; }
.tree-scope:hover { color: var(--accent-dark); background: var(--surface); }
.tree-loading { font-size: 12px; color: var(--faint); padding: 4px 10px; }
.tree-doc {
  width: 100%; display: flex; align-items: center; gap: 7px; text-align: start;
  padding: 5px 8px; border-radius: 8px; font-size: 13px; color: var(--muted);
}
.tree-doc svg { width: 15px; height: 15px; flex: none; color: var(--faint); }
.tree-doc span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-doc small { font-size: 11px; color: var(--faint); }
.tree-doc:hover { background: var(--surface-alt); color: var(--text); }
.tree-doc.is-open { color: var(--text); background: var(--accent-soft); }
.tree-doc.is-open svg { color: var(--accent); }
.tree-doc .hit { font-size: 10.5px; padding: 0 5px; border-radius: 99px; background: var(--highlight-bg); color: var(--highlight-fg); font-weight: 700; }

.toc { list-style: none; margin: 0; padding: 4px 0; counter-reset: toc; }
.toc button {
  width: 100%; display: flex; gap: 8px; text-align: start;
  padding: 6px 8px; border-radius: 8px; font-size: 13px; color: var(--muted); line-height: 1.7;
}
.toc button b { font-size: 11px; color: var(--faint); min-width: 16px; padding-top: 2px; }
.toc button:hover { background: var(--surface-alt); color: var(--text); }
.toc button.has-hit b { color: var(--accent-dark); }
.toc button.is-saved span::after { content: " ●"; color: var(--accent); font-size: 9px; vertical-align: 2px; }

.saved-card {
  position: relative;
  padding: 10px 12px; margin: 6px 4px; border-radius: 12px;
  background: var(--bg); border: 1px solid var(--border);
  font-size: 13px; line-height: 1.85;
}
.saved-card blockquote { margin: 0; padding-inline-start: 10px; border-inline-start: 2px solid var(--accent); display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.saved-card footer { display: flex; align-items: center; gap: 4px; margin-top: 8px; font-size: 11.5px; color: var(--faint); }
.saved-card footer span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-card footer button { padding: 3px; border-radius: 6px; color: var(--faint); }
.saved-card footer button:hover { color: var(--text); background: var(--surface-alt); }
.saved-card footer button svg { width: 15px; height: 15px; }

.lib-empty { text-align: center; padding: 34px 16px; font-size: 13px; color: var(--muted); }
.lib-empty svg { width: 28px; height: 28px; margin: 0 auto 10px; color: var(--accent); }

/* ───────── شريط الحالة ───────── */
.status-ok { display: inline-flex; align-items: center; gap: 7px; }
.status-ok i { background: var(--success); animation: none; }
.status-sep { width: 1px; height: 12px; background: var(--border); }
.status-query { overflow: hidden; text-overflow: ellipsis; }

/* ───────── تنقّل الجوّال ───────── */
.mobile-nav button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; border-radius: 10px; font-size: 11.5px; color: var(--faint);
}
.mobile-nav button svg { width: 20px; height: 20px; }
.mobile-nav button.is-active { color: var(--accent-dark); font-weight: 700; background: var(--accent-soft); }
[data-theme="dark"] .mobile-nav button.is-active { color: var(--accent); }

/* ───────── دليل البحث ───────── */
.sheet {
  width: min(560px, calc(100vw - 32px)); max-height: min(720px, calc(100dvh - 48px));
  padding: 0; border: 1px solid var(--border); border-radius: 20px;
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-l);
  overflow: hidden;
}
.sheet[open] { display: flex; flex-direction: column; animation: sheet-in .35s var(--ease-out); }
.sheet::backdrop { background: rgb(26 23 19 / .42); backdrop-filter: blur(3px); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 12px; border-bottom: 1px solid var(--border); }
.sheet-head h2 { font-size: 18px; }
.sheet-body { overflow-y: auto; padding: 16px 20px 22px; font-size: 14px; }
.sheet-body h3 { font-size: 14px; margin: 18px 0 8px; color: var(--accent-dark); }
[data-theme="dark"] .sheet-body h3 { color: var(--accent); }
.sheet-body h3:first-child { margin-top: 0; }
.rules { display: grid; gap: 6px; }
.rule-row { display: grid; grid-template-columns: 120px 1fr auto; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border); }
.rule-row code { color: var(--accent-dark); font-weight: 700; }
[data-theme="dark"] .rule-row code { color: var(--accent); }
.rule-row span { font-size: 13px; color: var(--muted); }
.rule-row button { font-size: 12px; color: var(--accent-dark); font-weight: 700; }
[data-theme="dark"] .rule-row button { color: var(--accent); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; color: var(--muted); align-items: center; }
.keys kbd { justify-self: start; }
.sheet-body p { color: var(--muted); font-size: 13px; line-height: 1.9; }

@media (max-width: 520px) {
  .rule-row { grid-template-columns: 1fr auto; }
  .rule-row span { grid-column: 1 / -1; grid-row: 2; }
}

/* ───────── عائم + تنبيه ───────── */
.save-float {
  position: fixed; z-index: 50;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 10px;
  background: var(--neutral); color: var(--on-neutral);
  font-size: 12.5px; font-weight: 700;
  box-shadow: var(--shadow);
  transform: translate(-50%, calc(-100% - 10px));
  animation: rise .2s var(--ease-out);
}
.save-float svg { width: 14px; height: 14px; }
[data-theme="dark"] .save-float { background: var(--accent); color: var(--on-accent); }

.toast {
  position: fixed; z-index: 60; bottom: 24px; left: 50%; transform: translateX(-50%);
  padding: 10px 18px; border-radius: 12px;
  background: var(--neutral); color: var(--on-neutral);
  font-size: 13.5px; box-shadow: var(--shadow);
  animation: rise .3s var(--ease-out);
}
[data-theme="dark"] .toast { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); }
@media (max-width: 860px) { .toast { bottom: 84px; } }

/* ───────── العتبة على الشاشات الصغيرة ───────── */
@media (max-width: 860px) {
  .shelf-grid { grid-template-columns: 1fr; }
  .omni-kbd { display: none; }
  .desk-search kbd, .desk-search .op-help { display: none; }
  .desk .brand-plate img { width: 78px; }
}
@media (max-width: 520px) {
  .hero-mark { width: 84px; height: 84px; margin-bottom: 16px; }
  .omni-submit span { display: none; }
  .omni-submit { padding: 0 14px; }
  .omnibox-field input { font-size: 16px; }
  .mode { font-size: 12.5px; padding: 6px 9px; }
  .threshold-bar .brand-plate img { width: 78px; }
  .threshold-foot { flex-direction: column; align-items: center; gap: 2px; }
}

/* عوامل البحث تُعرض بنفس اتجاه حقل البحث العربي («-كلمة» يظهر الشَّرط على اليمين) */
.operators code, .rule-row code { direction: rtl; }

/* ═══════════════ الإصدار ٠٫٢: الشريط الجانبي والاتصال بالخادم ═══════════════ */

/* ───────── الشريط الجانبي ───────── */
.sidebar {
  position: sticky; top: 0; z-index: 30;
  height: 100dvh; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column;
  padding: 16px 12px 14px;
  background: linear-gradient(180deg, var(--surface) 0%, color-mix(in srgb, var(--surface) 70%, var(--bg)) 100%);
  border-inline-end: 1px solid var(--border);
}
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 0 2px 16px; }
.side-top .brand-plate { padding: 4px 8px; }
.new-search {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 14px; border-radius: 12px;
  background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 14.5px;
  box-shadow: inset 0 -2px 0 rgb(0 0 0 / .12);
  transition: background .2s;
}
.new-search:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
.new-search kbd { margin-inline-start: auto; background: rgb(255 255 255 / .35); border-color: transparent; color: inherit; }
.side-caption { font-size: 11.5px; color: var(--faint); margin: 20px 12px 6px; letter-spacing: .02em; }
.side-nav { display: grid; gap: 2px; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: start;
  padding: 9px 12px; border-radius: 10px;
  font-size: 14px; color: var(--muted);
  transition: background .2s, color .2s;
}
.nav-item svg { width: 19px; height: 19px; }
.nav-item:hover:not(:disabled) { background: var(--surface-alt); color: var(--text); }
.nav-item[aria-current="page"] {
  background: var(--accent-soft); color: var(--text); font-weight: 700;
  box-shadow: inset -3px 0 0 var(--accent);
}
.nav-item[aria-current="page"] svg { color: var(--accent-dark); }
[data-theme="dark"] .nav-item[aria-current="page"] svg { color: var(--accent); }
.nav-count {
  margin-inline-start: auto; font-size: 11px; font-weight: 700;
  padding: 0 7px; border-radius: 99px; background: var(--surface-alt); color: var(--muted);
}
.side-recent { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.side-recent button {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: start;
  padding: 6px 12px; border-radius: 8px; font-size: 13px; color: var(--muted);
}
.side-recent button svg { width: 14px; height: 14px; color: var(--faint); }
.side-recent button span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-recent button:hover { background: var(--surface-alt); color: var(--text); }
.side-bottom { margin-top: auto; padding-top: 18px; display: grid; gap: 6px; }
.side-card {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border-radius: 12px;
  background: var(--bg); border: 1px solid var(--border);
}
.side-card > svg { width: 18px; height: 18px; color: var(--accent); margin-top: 2px; }
.side-card strong { display: block; font-size: 13px; }
.side-card p { font-size: 12px; color: var(--muted); line-height: 1.7; }
.side-card.is-wait > svg { animation: slow-turn 3s linear infinite; }
.account {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 6px 2px; margin-top: 4px; border-top: 1px solid var(--border);
}
.account > div { flex: 1; min-width: 0; line-height: 1.5; }
.account strong { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account small { display: block; font-size: 11.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: right; }
.avatar {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700;
  background: var(--accent-soft); color: var(--accent-dark);
}
[data-theme="dark"] .avatar { color: var(--accent); }
.avatar svg { width: 18px; height: 18px; }
.side-login {
  font-size: 12.5px; font-weight: 700; text-decoration: none;
  padding: 5px 12px; border-radius: 9px; background: var(--accent); color: var(--on-accent);
}

.shell {
  --side-w: 264px;
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100dvh;
}
.stage { position: relative; min-width: 0; }
.menu-btn { display: none; }
.shade { position: fixed; inset: 0; z-index: 35; background: rgb(26 23 19 / .4); backdrop-filter: blur(2px); }

/* الشريط المطويّ: أيقونات فقط */
.shell.is-rail { --side-w: 76px; }
.is-rail .sidebar { padding-inline: 10px; align-items: stretch; }
.is-rail .side-top { flex-direction: column; gap: 10px; }
.is-rail .brand-word, .is-rail .nav-label, .is-rail .side-caption, .is-rail .side-recent,
.is-rail .side-card > div, .is-rail .account > div, .is-rail .new-search kbd, .is-rail .side-login { display: none; }
.is-rail .new-search, .is-rail .nav-item { justify-content: center; padding-inline: 0; }
.is-rail .side-card { justify-content: center; padding: 10px 0; }
.is-rail .nav-count { position: absolute; top: 2px; inset-inline-end: 4px; font-size: 9.5px; padding: 0 4px; }
.is-rail .account { flex-direction: column; padding-inline: 0; }
.is-rail .side-nav { gap: 4px; }

/* ───────── بوابة الدخول ───────── */
.gate {
  width: 100%; max-width: 640px; margin-top: 30px;
  display: grid; grid-template-columns: auto 1fr; gap: 14px 16px; align-items: center;
  padding: 22px 24px; text-align: start;
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow);
  animation: rise .8s var(--ease-out) .6s both;
}
.gate-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-dark); }
[data-theme="dark"] .gate-icon { color: var(--accent); }
.gate-icon svg { width: 24px; height: 24px; }
.gate h2 { font-size: 18px; }
.gate p { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.gate-actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.gate-actions a { text-decoration: none; font-weight: 700; font-size: 14.5px; padding: 10px 22px; border-radius: 12px; }
.gate-primary { background: var(--accent); color: var(--on-accent); box-shadow: inset 0 -2px 0 rgb(0 0 0 / .12); }
.gate-secondary { border: 1px solid var(--border-strong); color: var(--text); }
.gate-secondary:hover { border-color: var(--accent); }

/* ───────── حالة الاتصال ───────── */
.conn[data-state="ok"] i { background: var(--success); }
.conn[data-state="wait"] i { background: var(--warning); animation: pulse 1.6s infinite; }

/* ───────── إضافات النتائج ───────── */
.strategy { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); padding: 2px 6px; margin-inline-start: auto; }
.strategy svg { width: 13px; height: 13px; color: var(--accent); }
.via {
  display: inline-flex; align-items: center; gap: 3px; vertical-align: 1px;
  font-size: 10.5px; font-weight: 700; margin-inline-end: 6px; padding: 0 7px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent-dark);
}
[data-theme="dark"] .via { color: var(--accent); }
.via svg { width: 11px; height: 11px; }
.result-meta .path { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.load-more { display: flex; justify-content: center; padding: 22px 0 6px; }
.load-more .chip { padding: 8px 20px; font-weight: 700; }
.filters select { max-width: 220px; }
.fchip svg { width: 13px; height: 13px; display: inline-block; vertical-align: -2px; }

.history { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.history button {
  width: 100%; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: center; text-align: start;
  padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
}
.history button:hover { border-color: var(--accent); }
.history svg { grid-row: span 2; color: var(--accent); }
.history span { font-size: 14.5px; font-weight: 700; }
.history small { font-size: 12px; color: var(--faint); }

/* ───────── إجابة المساعد ───────── */
.bubble h4 { font-size: 14px; margin: 10px 0 4px; }
.bubble ul { margin: 6px 0 0; padding-inline-start: 18px; display: grid; gap: 6px; }
.bubble ul li::marker { color: var(--accent); }
.bubble p + ul, .bubble ul + p, .bubble p + h4 { margin-top: 8px; }
.bubble.is-error { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.error-line { color: var(--danger); font-size: 13px; }
.cite-missing { color: var(--faint); font-size: 10px; margin-inline-start: 2px; }
.caret { display: inline-block; width: 7px; height: 1.1em; vertical-align: -3px; margin-inline-start: 3px; background: var(--accent); border-radius: 2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.send-btn.is-stop { background: var(--neutral); color: var(--on-neutral); }

/* ───────── الاستجابة ───────── */
@media (max-width: 860px) {
  .shell, .shell.is-rail { grid-template-columns: minmax(0, 1fr); --side-w: 0px; }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 40;
    width: min(300px, 86vw); height: 100dvh;
    transform: translateX(105%); transition: transform .3s var(--ease-out);
    box-shadow: var(--shadow-l);
  }
  [dir="rtl"] .sidebar { transform: translateX(105%); }
  .shell.is-open .sidebar { transform: none; }
  /* على الجوال يظهر الشريط كاملاً دائماً */
  .is-rail .brand-word, .is-rail .nav-label, .is-rail .side-caption, .is-rail .side-recent,
  .is-rail .side-card > div, .is-rail .account > div, .is-rail .side-login { display: revert; }
  .is-rail .new-search, .is-rail .nav-item { justify-content: flex-start; padding-inline: 12px; }
  .is-rail .side-top, .is-rail .account { flex-direction: row; }
  .is-rail .nav-count { position: static; font-size: 11px; padding: 0 7px; }
  .side-collapse { display: none; }
  .menu-btn { display: inline-grid; }
  .gate { grid-template-columns: 1fr; text-align: center; justify-items: center; padding: 20px; }
  .gate-actions { justify-content: center; }
}

/* المكتبة المباشرة */
.side-card.is-live strong { display: flex; align-items: center; gap: 6px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); flex: none; box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 50%, transparent); animation: pulse 2.4s infinite; }
.side-card p b { color: var(--warning); font-weight: 700; }
.side-time { font-size: 11px !important; color: var(--faint) !important; }
