/* پنل MentorAI.
 *
 * چیدمان: مثل تلگرام دسکتاپ؛ ستون باریک و تیره‌ی پوشه‌ها در لبه‌ی راست، و کنارش سطح کار. گفتگوها
 * دوستونه‌اند: فهرست، و گفتگوی باز روی پس‌زمینه‌ی نقش‌دار. روی گوشی ستون پوشه‌ها نوار پایین می‌شود.
 *
 * قلم وزیرمتن از خود سرور می‌آید (`fonts/`، مجوز SIL OFL). سیاست محتوا هیچ دامنه‌ی بیرونی و هیچ سبک
 * درون‌خطی را مجاز نمی‌کند؛ هر رنگ و عرض از کلاس می‌آید. دکمه‌ی آبی با متن سفید رنگ خودش را دارد
 * (--button) تا تضادش در هر دو حالت از ۴٫۵ کمتر نشود؛ آبی تلگرام (--accent) فقط برای آیکون، نشانه‌ی
 * فعال و حلقه‌ی تمرکز است.
 */

@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --surface-3: #eaeef3;
  --ink: #0f1720;
  --ink-2: #3a4653;
  --muted: #5a6572;
  --line: #e2e7ed;
  --accent: #3390ec;
  --accent-ink: #1b64b6;
  --accent-wash: #e6f1fd;
  --button: #1f6fc5;
  --mark: #3390ec;
  /* ستون پوشه‌ها با رنگ‌های تلگرام دسکتاپ (lib_ui colors.palette). متن پوشه کمی روشن‌تر از خود
   * تلگرام است تا تضادش از ۴٫۵ کمتر نشود. */
  --rail: #293a4c;
  --rail-ink: #a3b2c1;
  --rail-wash: #17212b;
  --rail-hover: #22313f;
  --rail-active: #64b9fa;
  /* ردیف انتخاب‌شده‌ی فهرست گفتگو: آبی تلگرام، یک درجه پررنگ‌تر برای متن سفید. */
  --selected: #1f6fc5;
  --selected-ink: #ffffff;
  /* دیوار گفتگو: پس‌زمینه‌ی سبز ملایم پیش‌فرض تلگرام، با گرادیان و نقطه‌های خود پنل. */
  --wall: #dde2c4;
  --wall-a: #cbdaa3;
  --wall-b: #a9cba2;
  --wall-c: #d9d9a6;
  --wall-dot: rgba(70, 95, 50, 0.12);
  --bubble-in: #ffffff;
  --bubble-out: #effdde;
  --meta-in: #5e6a77;
  --meta-out: #2b7322;
  --service: rgba(40, 62, 30, 0.66);
  --badge-warn: #f0a030;
  --badge-warn-ink: #1a1205;
  --ok: #16703f;
  --ok-wash: #e3f5ea;
  --warn: #9d5200;
  --warn-wash: #fff1de;
  --danger: #c0312f;
  --danger-wash: #fdeaea;
  --shadow: 0 1px 2px rgba(15, 23, 32, 0.06);
  --shadow-pop: 0 6px 24px rgba(15, 23, 32, 0.08);

  --font: "Vazirmatn", system-ui, "Segoe UI", Tahoma, sans-serif;
  --t-xs: 12px;
  --t-sm: 13px;
  --t-base: 15px;
  --t-md: 17px;
  --t-lg: 21px;
  --t-xl: 28px;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 18px;
  --rail-w: 72px;
}

/* تم تیره دو راه دارد (ADR-092): تنظیم دستگاه، مگر صاحب پنل «تم روشن» را برگزیده باشد؛ یا انتخاب صریح
 * «تم تیره» در پنل که کوکی می‌شود و سرور روی <html> می‌نویسد. رنگ‌ها در هر دو یکی‌اند. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1621;
    --surface: #17212b;
    --surface-2: #1c2834;
    --surface-3: #233140;
    --ink: #eef2f6;
    --ink-2: #c5ced8;
    --muted: #8a99a9;
    --line: #233140;
    --accent: #5eb5f7;
    --accent-ink: #8ccdfc;
    --accent-wash: #1b3147;
    --button: #2d74c0;
    --mark: #2d74c0;
    --rail: #0e1621;
    --rail-ink: #8496a8;
    --rail-wash: #25303e;
    --rail-hover: #1a2532;
    --rail-active: #64b9fa;
    --selected: #2b5278;
    --selected-ink: #ffffff;
    --wall: #0e1621;
    --wall-a: #13202d;
    --wall-b: #102331;
    --wall-c: #161f2b;
    --wall-dot: rgba(120, 150, 180, 0.07);
    --bubble-in: #182533;
    --bubble-out: #2b5278;
    --meta-in: #7f91a4;
    --meta-out: #a3cbf0;
    --service: rgba(0, 0, 0, 0.45);
    --ok: #6fd39a;
    --ok-wash: #12301f;
    --warn: #f2b363;
    --warn-wash: #33250f;
    --danger: #ff8f8a;
    --danger-wash: #3a1b1b;
    --shadow: none;
    --shadow-pop: 0 6px 24px rgba(0, 0, 0, 0.35);
    color-scheme: dark;

  }
}
:root[data-theme="dark"] {
  --bg: #0e1621;
  --surface: #17212b;
  --surface-2: #1c2834;
  --surface-3: #233140;
  --ink: #eef2f6;
  --ink-2: #c5ced8;
  --muted: #8a99a9;
  --line: #233140;
  --accent: #5eb5f7;
  --accent-ink: #8ccdfc;
  --accent-wash: #1b3147;
  --button: #2d74c0;
  --mark: #2d74c0;
  --rail: #0e1621;
  --rail-ink: #8496a8;
  --rail-wash: #25303e;
  --rail-hover: #1a2532;
  --rail-active: #64b9fa;
  --selected: #2b5278;
  --selected-ink: #ffffff;
  --wall: #0e1621;
  --wall-a: #13202d;
  --wall-b: #102331;
  --wall-c: #161f2b;
  --wall-dot: rgba(120, 150, 180, 0.07);
  --bubble-in: #182533;
  --bubble-out: #2b5278;
  --meta-in: #7f91a4;
  --meta-out: #a3cbf0;
  --service: rgba(0, 0, 0, 0.45);
  --ok: #6fd39a;
  --ok-wash: #12301f;
  --warn: #f2b363;
  --warn-wash: #33250f;
  --danger: #ff8f8a;
  --danger-wash: #3a1b1b;
  --shadow: none;
  --shadow-pop: 0 6px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--t-base);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { text-wrap: balance; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.icon { width: 22px; height: 22px; flex: 0 0 auto; }
.muted { color: var(--muted); font-size: var(--t-sm); }
.num-cell, .stamp, time { font-variant-numeric: tabular-nums; }
/* تاریخ و ساعت چپ‌به‌راست می‌مانند، وگرنه دوسویگی متن ساعت را پیش از تاریخ می‌نشاند. */
.num-cell, .stamp { direction: ltr; text-align: right; }
.stamp { display: inline-block; }

/* ── چیدمان ──────────────────────────────────────────────────────────── */
body.app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; }
.page {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding-block: 28px 72px;
  padding-inline: max(20px, env(safe-area-inset-left, 0px)) max(20px, env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ستون پوشه‌ها */
.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--rail);
  color: var(--rail-ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-block: 16px;
}
.mark {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--mark);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 19px;
  text-decoration: none;
}
.mark:hover { text-decoration: none; filter: brightness(1.06); }
/* پوشه‌ها مثل تلگرام دسکتاپ: بلوک تمام‌عرض بی‌گوشه، پوشه‌ی باز با زمینه‌ی تیره‌تر و آبی روشن. */
.rail-nav { display: flex; flex-direction: column; gap: 0; width: 100%; }
.rail-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 62px;
  padding: 8px 2px 6px;
  color: var(--rail-ink);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
}
.rail-nav a .icon { width: 26px; height: 26px; }
.rail-nav a:hover { background: var(--rail-hover); color: #fff; text-decoration: none; }
.rail-nav a.on { background: var(--rail-wash); color: var(--rail-active); }
.rail-ico { position: relative; display: inline-flex; }
/* شمار پوشه، با حاشیه‌ای هم‌رنگ ستون که آیکون را «می‌بُرد»، مثل تلگرام. */
.rail-ico .badge { position: absolute; top: -6px; inset-inline-end: -12px; border: 2px solid var(--rail); }
.rail-nav a.on .rail-ico .badge, .rail-nav a:hover .rail-ico .badge { border-color: var(--rail-wash); }

/* شمار گرد، مثل شمار خوانده‌نشده‌ی تلگرام. */
.badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--button);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.badge.warn { background: var(--badge-warn); color: var(--badge-warn-ink); }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.me {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--rail-wash);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
}
.rail-btn {
  width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--rail-ink);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.rail-btn:hover { background: var(--rail-wash); color: #fff; }

/* گوشی: ستون پوشه‌ها نوار پایین می‌شود، مثل تلگرام موبایل. */
@media (max-width: 760px) {
  body.app { display: block; padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px)); }
  .rail {
    position: fixed;
    inset: auto 0 0 0;
    top: auto;
    height: auto;
    z-index: 20;
    flex-direction: row;
    padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
    gap: 0;
  }
  .mark, .rail-foot .me { display: none; }
  .rail-nav { flex-direction: row; justify-content: space-around; padding: 0; }
  .rail-nav a { flex: 1 1 0; min-height: 56px; border-radius: 12px; }
  .rail-foot { margin: 0; }
  .page { padding-block: 20px 32px; }
}

/* ── سرصفحه و برچسب‌ها ──────────────────────────────────────────────── */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; }
.page-head h1 { margin: 0; font-size: var(--t-xl); font-weight: 700; letter-spacing: -0.3px; line-height: 1.3; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: var(--t-sm); max-width: 68ch; }
h2 { margin: 8px 0 0; font-size: var(--t-md); font-weight: 700; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: var(--t-sm);
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-2);
}
.pill .icon { width: 18px; height: 18px; }
.pill.ok { background: var(--ok-wash); border-color: transparent; color: var(--ok); }
.pill.warn { background: var(--warn-wash); border-color: transparent; color: var(--warn); }
.pill.bad { background: var(--danger-wash); border-color: transparent; color: var(--danger); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 9px;
  border-radius: 999px;
  font-size: var(--t-xs);
  font-weight: 600;
  background: var(--surface-3);
  color: var(--ink-2);
  white-space: nowrap;
}
.tag.accent { background: var(--accent-wash); color: var(--accent-ink); }
.tag.ok { background: var(--ok-wash); color: var(--ok); }
.tag.warn, .warn-tag { background: var(--warn-wash); color: var(--warn); }
.tag.bad { background: var(--danger-wash); color: var(--danger); }

.callout {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 14px 18px;
  border-radius: var(--r);
  background: var(--warn-wash);
  color: var(--warn);
  font-size: var(--t-sm);
}
.callout .icon { width: 22px; height: 22px; }
.callout b { font-size: var(--t-base); }
.callout a { color: inherit; font-weight: 700; text-decoration: underline; margin-inline-start: auto; display: inline-flex; align-items: center; min-height: 44px; padding-inline: 4px; }
.callout.bad { background: var(--danger-wash); color: var(--danger); }
.notice { padding: 12px 16px; border-radius: var(--r); background: var(--ok-wash); color: var(--ok); font-size: var(--t-sm); margin: 0; }
.alarm { padding: 12px 16px; border-radius: var(--r); background: var(--warn-wash); color: var(--warn); font-size: var(--t-sm); margin: 0; }

/* ── سطح‌ها ──────────────────────────────────────────────────────────── */
.surface { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.section { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head h2 { margin: 0; }

/* شاخص‌ها: یک سطح با خانه‌های جداشده، نه کارت جدا برای هر عدد. */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.stat {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 14px;
  align-items: center;
  padding: 18px 20px;
  border-inline-start: 1px solid var(--line);
}
.stat:first-child { border-inline-start: 0; }
.stat .chip { grid-row: span 2; }
.stat .num { font-size: 26px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat .lbl { font-size: var(--t-sm); color: var(--muted); line-height: 1.4; }
.stat.warn .num { color: var(--warn); }
.chip {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-wash);
  color: var(--accent-ink);
}
.chip.ok { background: var(--ok-wash); color: var(--ok); }
.chip.warn { background: var(--warn-wash); color: var(--warn); }
@media (max-width: 760px) {
  .stat { border-inline-start: 0; border-top: 1px solid var(--line); }
  .stat:first-child { border-top: 0; }
}

/* نوار نسبت. نام «track» فقط در خلاصه به کار می‌رود (آزمون). عرض از کلاس pN می‌آید، نه از style. */
.meter { display: flex; flex-direction: column; gap: 8px; }
.meter-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.meter .pct { font-size: var(--t-lg); font-weight: 700; font-variant-numeric: tabular-nums; }
.meter .track { display: block; height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.meter .track span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.meter .track span.p0 { width: 0%; }
.meter .track span.p5 { width: 5%; }
.meter .track span.p10 { width: 10%; }
.meter .track span.p15 { width: 15%; }
.meter .track span.p20 { width: 20%; }
.meter .track span.p25 { width: 25%; }
.meter .track span.p30 { width: 30%; }
.meter .track span.p35 { width: 35%; }
.meter .track span.p40 { width: 40%; }
.meter .track span.p45 { width: 45%; }
.meter .track span.p50 { width: 50%; }
.meter .track span.p55 { width: 55%; }
.meter .track span.p60 { width: 60%; }
.meter .track span.p65 { width: 65%; }
.meter .track span.p70 { width: 70%; }
.meter .track span.p75 { width: 75%; }
.meter .track span.p80 { width: 80%; }
.meter .track span.p85 { width: 85%; }
.meter .track span.p90 { width: 90%; }
.meter .track span.p95 { width: 95%; }
.meter .track span.p100 { width: 100%; }
.meter p { margin: 0; }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }

/* ── فهرست‌ها: ردیف تلگرامی با آواتار ─────────────────────────────── */
.list { display: flex; flex-direction: column; padding: 6px; }
.row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--ink);
  text-decoration: none;
}
a.row:hover, .row.on { background: var(--surface-2); text-decoration: none; }
.row.on { background: var(--accent-wash); }
.row-main { min-width: 0; min-height: 44px; display: flex; flex-direction: column; justify-content: center; line-height: 1.5; }
.row-title { font-weight: 700; font-size: var(--t-base); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--muted); font-size: var(--t-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: var(--t-xs); color: var(--muted); }
.row-actions { display: flex; align-items: center; gap: 8px; }

.avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  flex: 0 0 auto;
}
.avatar.sm { width: 38px; height: 38px; font-size: 15px; }
/* هفت جفت گرادیان آواتار تلگرام، از بالا به پایین: قرمز، نارنجی، بنفش، سبز، فیروزه‌ای، آبی، صورتی.
 * آواتار تزئینی است (aria-hidden)؛ نام کنارش نوشته شده. */
.av-0 { background: linear-gradient(#ff845e, #d45246); }
.av-1 { background: linear-gradient(#febb5b, #f68136); }
.av-2 { background: linear-gradient(#b694f9, #6c61df); }
.av-3 { background: linear-gradient(#9ad164, #46ba43); }
.av-4 { background: linear-gradient(#53edd6, #28c9b7); }
.av-5 { background: linear-gradient(#5caffa, #408acf); }
.av-6 { background: linear-gradient(#ff8aac, #d95574); }

/* حالت خالی (`_empty.html`): نشان گرد، عنوان، یک توضیح کوتاه که می‌گوید چه چیزی اینجا را پر می‌کند. */
.empty {
  display: grid;
  justify-items: center;
  align-content: center;
  text-align: center;
  gap: 8px;
  padding: 52px 24px;
  color: var(--muted);
}
.empty-art {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin-bottom: 6px;
  border-radius: 50%;
  background: var(--accent-wash);
  color: var(--accent-ink);
}
.empty-art .icon { width: 34px; height: 34px; }
.empty.ok .empty-art { background: var(--ok-wash); color: var(--ok); }
.empty.off .empty-art { background: var(--surface-3); color: var(--muted); }
.empty b { color: var(--ink); font-size: var(--t-md); line-height: 1.5; text-wrap: balance; }
.empty-text {
  display: grid;
  justify-items: center;
  gap: 10px;
  max-width: 42ch;
  font-size: var(--t-sm);
  line-height: 1.9;
  text-wrap: pretty;
}
.empty-text p { margin: 0; }
.empty.compact { padding: 28px 16px; }
.empty.compact .empty-art { width: 52px; height: 52px; margin-bottom: 2px; }
.empty.compact .empty-art .icon { width: 26px; height: 26px; }
/* روی دیوار گفتگو، مثل پیام «یک گفتگو را انتخاب کنید» تلگرام: یک کارت آرام وسط دیوار. */
.wall > .empty {
  max-width: 420px;
  margin-inline: auto;
  padding: 36px 28px;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
}

/* ── گفتگو: دو ستون، مثل تلگرام دسکتاپ ─────────────────────────────── */
body.chat-page .page { max-width: none; padding-block: 0; padding-inline: 0; gap: 0; }
.chat {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  height: 100vh;
  background: var(--surface);
}
.chat-list { border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-list header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
}
.chat-list header .search { max-width: none; }
.chat-list .list { overflow-y: auto; padding: 0; }
/* ردیف‌ها مثل تلگرام دسکتاپ: تمام‌عرض و بی‌گوشه؛ انتخاب‌شده آبی یکدست با متن سفید. */
.chat-list .row { border-radius: 0; padding: 9px 12px; min-height: 66px; }
.chat-list .row-title { font-weight: 600; }
.chat-list .row.on { background: var(--selected); color: var(--selected-ink); }
.chat-list .row.on .row-sub, .chat-list .row.on .row-meta, .chat-list .row.on .muted-mark { color: var(--selected-ink); }
.chat-list .row.on .badge { background: var(--selected-ink); color: var(--selected); }
.muted-mark { display: inline-flex; color: var(--muted); }
.muted-mark .icon { width: 16px; height: 16px; }
.chat-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  min-height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.chat-head .who { min-width: 0; display: flex; flex-direction: column; line-height: 1.45; }
.chat-head .chat-title { margin: 0; font-size: var(--t-md); font-weight: 700; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .who small { color: var(--muted); font-size: var(--t-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head form { margin-inline-start: auto; }
.chat-head .btn { white-space: nowrap; }
.chat-back { display: none; color: var(--accent-ink); }
/* نوار پایین گفتگو، مثل دکمه‌ی «بی‌صدا»ی کانال در تلگرام دسکتاپ. */
.chat-foot { flex: 0 0 auto; display: flex; margin: 0; background: var(--surface); border-top: 1px solid var(--line); }
.bar-btn {
  flex: 1 1 auto;
  min-height: 54px;
  border-radius: 0;
  background: transparent;
  color: var(--accent-ink);
  font-size: var(--t-sm);
  font-weight: 700;
  gap: 8px;
}
.bar-btn:hover { background: var(--surface-2); filter: none; }
.bar-btn.danger { color: var(--danger); }
.wall {
  flex: 1 1 auto;
  overflow-y: auto;
  background-color: var(--wall);
  background-image:
    radial-gradient(var(--wall-dot) 1.2px, transparent 1.3px),
    radial-gradient(circle at 12% 18%, var(--wall-c), transparent 48%),
    radial-gradient(circle at 88% 22%, var(--wall-b), transparent 52%),
    radial-gradient(circle at 70% 88%, var(--wall-a), transparent 55%),
    radial-gradient(circle at 18% 82%, var(--wall-b), transparent 45%);
  background-size: 22px 22px, 100% 100%, 100% 100%, 100% 100%, 100% 100%;
  background-attachment: local, scroll, scroll, scroll, scroll;
  padding: 18px max(16px, 6%);
  /* ستون وارونه: گفتگو مثل تلگرام از آخرین پیام باز می‌شود، بی‌هیچ اسکریپتی (سیاست محتوا اسکریپت را
   * مجاز نمی‌کند). */
  display: flex;
  flex-direction: column-reverse;
}
.wall:has(> .empty) { justify-content: center; }
.thread { list-style: none; margin: 0 auto; padding: 0 10px; width: 100%; max-width: 760px; display: flex; flex-direction: column; gap: 2px; }
/* تاریخ هنگام پیمایش بالای دیوار می‌چسبد، مثل تلگرام. */
.day {
  position: sticky;
  top: 8px;
  z-index: 2;
  align-self: center;
  margin: 10px 0 8px;
  padding: 2px 12px;
  border-radius: 999px;
  background: var(--service);
  color: #fff;
  font-size: var(--t-xs);
  font-weight: 600;
}

.msg {
  position: relative;
  max-width: min(80%, 520px);
  padding: 7px 12px 5px;
  border-radius: 16px;
  background: var(--bubble-in);
  box-shadow: var(--shadow);
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.msg.assistant, .msg.mentor { align-self: flex-end; background: var(--bubble-out); }
/* گروه پیام: گوشه‌های سمت فرستنده ۶ پیکسل، جز بالای اولی؛ پایینِ آخری صفر است و دُم از آن بیرون می‌زند.
 * در راست‌به‌چپ، پیام دانشجو سمت شروع (راست) است و پیام ما سمت پایان (چپ). */
.msg.in { border-start-start-radius: 6px; border-end-start-radius: 6px; }
.msg.in.first { border-start-start-radius: 16px; }
.msg.in.last { border-end-start-radius: 0; }
.msg.out { border-start-end-radius: 6px; border-end-end-radius: 6px; }
.msg.out.first { border-start-end-radius: 16px; }
.msg.out.last { border-end-end-radius: 0; }
.msg.last { margin-bottom: 6px; }
.msg .tail { position: absolute; bottom: 0; width: 10px; height: 17px; fill: currentColor; }
.msg.in .tail { inset-inline-start: -9px; color: var(--bubble-in); }
.msg.out .tail { inset-inline-end: -9px; color: var(--bubble-out); }
.msg .body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; }
.msg .body.muted { font-style: italic; }
.msg-meta { display: flex; align-items: center; justify-content: flex-end; gap: 6px; font-size: 11px; color: var(--meta-in); margin-top: -2px; }
.msg.assistant .msg-meta, .msg.mentor .msg-meta { color: var(--meta-out); }
.msg-meta .icon { width: 16px; height: 16px; }
.by { font-weight: 700; }
.msg-head { display: none; }

.media {
  margin: 2px 0 4px;
  padding: 6px 10px;
  border-inline-start: 3px solid var(--accent);
  border-radius: 6px;
  background: rgba(127, 127, 127, 0.1);
  font-size: var(--t-sm);
}
.media.rejected { border-color: var(--warn); }

/* خط سرویس زیر پیام دانشجو: ربات چه کرد و چرا. */
.service { align-self: center; max-width: min(92%, 620px); text-align: center; margin: 2px 0 6px; }
.service summary, .service > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--service);
  color: #fff;
  font-size: var(--t-xs);
  cursor: pointer;
  list-style: none;
}
.service summary::-webkit-details-marker { display: none; }
.service.silent > span { background: var(--warn-wash); color: var(--warn); }
.service .icon { width: 15px; height: 15px; }
.service details[open] summary { margin-bottom: 6px; }
.why {
  text-align: right;
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow-pop);
  padding: 10px 14px;
  font-size: var(--t-sm);
}
.why.silent { color: var(--warn); }
.sources { margin: 6px 0 0; padding-inline-start: 18px; }

@media (max-width: 760px) {
  body.chat-page .page { padding: 0; }
  .chat { grid-template-columns: minmax(0, 1fr); height: calc(100vh - 68px - env(safe-area-inset-bottom, 0px)); }
  .chat.has-open .chat-list { display: none; }
  .chat:not(.has-open) .chat-pane { display: none; }
  .chat-back { display: grid; place-items: center; flex: none; width: 44px; height: 44px; }
  .wall { padding: 12px; }
  .msg { max-width: 88%; }
}

/* ── زبانه‌ها و کارت‌های یادگیری ────────────────────────────────────── */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tabs a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: var(--t-sm);
  text-decoration: none;
}
.tabs a:hover { background: var(--surface-2); text-decoration: none; }
.tabs a.on { background: var(--button); border-color: var(--button); color: #fff; font-weight: 600; }
.tabs .count { min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: var(--t-xs); text-align: center; font-variant-numeric: tabular-nums; }
.tabs a.on .count { background: #fff; color: var(--button); font-weight: 700; }

.cards { display: grid; gap: 12px; }
.card { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.qa { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 16px; }
.qa dt { color: var(--muted); font-size: var(--t-xs); font-weight: 600; padding-top: 4px; }
.qa dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.qa .q { font-weight: 700; }
.qa.raw dd { color: var(--ink-2); font-size: var(--t-sm); }
details > summary { cursor: pointer; }
.card details > summary { color: var(--accent-ink); font-size: var(--t-sm); }
.card details[open] > summary { margin-bottom: 8px; }

/* ── جدول ─────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
th, td { text-align: right; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: var(--t-xs); background: var(--surface-2); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
tr.stale td { background: var(--warn-wash); }

/* ── دکمه‌ها ───────────────────────────────────────────────────────── */
button {
  font: inherit;
  font-size: var(--t-sm);
  font-weight: 600;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--button);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
button:hover { filter: brightness(1.07); }
button .icon { width: 18px; height: 18px; }
.btn { background: var(--surface); color: var(--ink-2); border-color: var(--line); }
.btn:hover { background: var(--surface-2); filter: none; }
.btn.primary { background: var(--button); color: #fff; border-color: var(--button); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger-wash); }
.btn.soft { background: var(--accent-wash); color: var(--accent-ink); border-color: transparent; }
/* `summary` بازکننده‌ی تأیید `details` است و مثل دکمه دیده می‌شود. */
a.btn, summary.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 18px;
  border-width: 1px;
  border-style: solid;
  border-radius: 999px;
  font-size: var(--t-sm);
  font-weight: 600;
  text-decoration: none;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
button.link { background: none; border: 0; min-height: 32px; padding: 0; color: var(--accent-ink); font-weight: 600; }
form.inline { display: inline-flex; margin: 0; }

/* ── ورود ─────────────────────────────────────────────────────────── */
body.bare main { min-height: 100vh; display: grid; place-items: center; padding-block: 24px; padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)); }
.login { width: 100%; max-width: 380px; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.login .mark { width: 72px; height: 72px; font-size: 30px; }
.login-card { width: 100%; padding: 26px 24px; display: flex; flex-direction: column; gap: 14px; }
.login h1 { margin: 0; font-size: var(--t-lg); text-align: center; }
.login .muted { margin: -8px 0 0; text-align: center; }
.login form { display: flex; flex-direction: column; gap: 14px; }
.login label { display: flex; flex-direction: column; gap: 6px; font-size: var(--t-sm); color: var(--muted); }
.login input {
  font: inherit;
  color: var(--ink);
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}
.login input:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--surface); }
.login button { min-height: 48px; }
.error { background: var(--danger-wash); color: var(--danger); border-radius: 12px; padding: 10px 14px; font-size: var(--t-sm); margin: 0; }

code { color: var(--ink-2); background: var(--surface-3); border-radius: 6px; padding: 1px 6px; font-size: var(--t-xs); direction: ltr; display: inline-block; }
.muted .icon, .tag .icon { width: 15px; height: 15px; vertical-align: -3px; }

/* ── حرکت ──────────────────────────────────────────────────────────────
 * همه‌ی حرکت فقط وقتی هست که دستگاه «کاهش حرکت» نخواسته باشد (`no-preference`). جهت امن پیش‌فرض است:
 * مرورگری که این پرسش رسانه را نشناسد، هیچ حرکتی نمی‌بیند. بیرون از این بلوک هیچ `animation` یا
 * `transition` یا جابه‌جایی‌ای نیست (`tests/test_panel_css.py`). کوتاه و آرام، فقط جابه‌جایی و شفافیت؛
 * هر چیزی که حرکت دارد، بی‌حرکت هم کامل دیده می‌شود.
 */
:root {
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur-1: 100ms;
  --dur-2: 200ms;
  --dur-3: 300ms;
}

/* ── کنترل ربات: ردیف‌های تنظیمات مثل تلگرام دسکتاپ (ADR-087، ADR-088) ───── */
.settings { display: flex; flex-direction: column; }
.setting {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
}
.setting:last-child { border-bottom: 0; }
.setting.has-actions { grid-template-columns: auto minmax(0, 1fr) auto; }
.setting-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; line-height: 1.6; }
.row-sub.wrap { white-space: normal; }
.setting-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
.actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; }
.btn.danger-solid { background: var(--danger); color: var(--surface); border-color: var(--danger); }
@media (max-width: 760px) {
  .setting.has-actions { grid-template-columns: auto minmax(0, 1fr); }
  .setting.has-actions .setting-actions { grid-column: 2 / -1; justify-content: flex-start; }
  /* چند گزینه کنار متن جا نمی‌شود و متن را چند پیکسلی می‌کرد؛ روی گوشی زیر متن می‌آید. */
  .setting.has-choices { grid-template-columns: minmax(0, 1fr); }
  .setting.has-choices .setting-actions { justify-content: flex-start; }
}

/* دکمه‌ی چندگزینه‌ای، مثل انتخاب حالت در تنظیمات تلگرام. */
.seg { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 999px; background: var(--surface-3); }
.seg-item {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-size: var(--t-sm);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
button.seg-item { background: transparent; color: var(--ink-2); }
button.seg-item:hover { background: var(--surface-2); filter: none; }
.seg-item.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); cursor: default; }
summary.seg-item::-webkit-details-marker, .confirm > summary::-webkit-details-marker { display: none; }

/* تأیید بی‌اسکریپت: `details` باز می‌شود و دکمه‌ی اصلی داخلش است. روی گوشی مثل برگه‌ی پایین تلگرام. */
.confirm { position: relative; }
.confirm > summary { list-style: none; cursor: pointer; }
.confirm-box {
  position: absolute;
  z-index: 20;
  inset-inline-end: 0;
  top: calc(100% + 8px);
  width: min(300px, 80vw);
  padding: 14px;
  display: grid;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-pop);
  color: var(--ink-2);
  font-size: var(--t-sm);
  font-weight: 400;
}
.confirm-box p { margin: 0; line-height: 1.8; }
@media (max-width: 760px) {
  .confirm-box {
    position: fixed;
    inset-inline: 12px;
    top: auto;
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    width: auto;
  }
}

/* کلید روشن و خاموش، مثل تلگرام: ناحیه‌ی لمس ۴۴ پیکسل، خود کلید کوچک. */
.toggle { align-items: center; gap: 10px; }
.toggle-state { font-size: var(--t-sm); color: var(--muted); }
button.switch { position: relative; width: 52px; min-height: 44px; padding: 0; border: 0; background: transparent; }
button.switch:hover { filter: none; }
button.switch::before {
  content: "";
  position: absolute;
  inset-inline: 4px;
  top: 50%;
  height: 26px;
  margin-top: -13px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--line);
}
button.switch .knob {
  position: absolute;
  top: 50%;
  inset-inline-start: 7px;
  width: 20px;
  height: 20px;
  margin-top: -10px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(15, 23, 32, 0.3);
}
button.switch.on::before { background: var(--button); border-color: var(--button); }
button.switch.on .knob { inset-inline-start: 25px; }

/* ── پایگاه دانش: افزودن، جست‌وجو، خاموش و روشن (ADR-089) ───────────────── */
.add-form > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 20px;
  color: var(--accent-ink);
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.add-form > summary::-webkit-details-marker { display: none; }
.add-form > summary .icon { width: 20px; height: 20px; }
.stack { display: flex; flex-direction: column; gap: 14px; padding: 4px 20px 20px; }
.stack label, .fields label { display: flex; flex-direction: column; gap: 6px; font-size: var(--t-sm); color: var(--muted); }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.stack input, .stack textarea, .stack select {
  font: inherit;
  color: var(--ink);
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}
.stack textarea { resize: vertical; line-height: 1.8; }
.stack input:focus, .stack textarea:focus, .stack select:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--surface); }
.stack .muted { margin: 0; font-size: var(--t-sm); }

/* نوار بالای جدول: زبانه‌ها و جست‌وجو؛ کادر جست‌وجو گرد و خاکستری، مثل بالای فهرست تلگرام. */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.toolbar .tabs { margin: 0; }
.search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 240px;
  max-width: 360px;
}
.search .icon { position: absolute; inset-inline-start: 14px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%;
  min-height: 44px;
  padding-block: 0;
  padding-inline: 42px 16px;
  font: inherit;
  font-size: var(--t-sm);
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--surface-3);
}
.search input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.search input::placeholder { color: var(--muted); }
.doc-title { display: block; font-weight: 600; color: var(--ink); }
.doc-body > summary { display: inline-flex; align-items: center; min-height: 32px; color: var(--accent-ink); font-size: var(--t-xs); cursor: pointer; }
/* «پاسخ» کوچک دیده می‌شود ولی ناحیه‌ی لمسش با لایه‌ی نامرئی به ۴۴ پیکسل می‌رسد. */
.doc-body > summary { position: relative; }
.doc-body > summary::after { content: ""; position: absolute; inset: -6px -10px; }
.setting-main button.link { min-height: 44px; display: inline-flex; align-items: center; }
.doc-body p { margin: 4px 0 0; color: var(--ink-2); line-height: 1.8; white-space: pre-line; }
.cell-action { white-space: nowrap; vertical-align: middle; }
/* روی گوشی هر سند یک کارت است: پرسش تمام‌عرض، بقیه کوچک زیرش، دکمه سمت پایان. ستون باریک پرسش
   را واژه‌به‌واژه می‌شکست. */
@media (max-width: 760px) {
  .kb-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .kb-table, .kb-table tbody { display: block; }
  .kb-table tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
  }
  .kb-table tbody tr:last-child { border-bottom: 0; }
  .kb-table td { display: block; padding: 0; border: 0; color: var(--muted); font-size: var(--t-xs); }
  .kb-table td:first-child { flex: 1 0 100%; color: var(--ink); font-size: var(--t-sm); }
  .kb-table td.blank { display: none; }
  .kb-table td.cell-action { margin-inline-start: auto; }
  .kb-table tbody tr:hover td { background: transparent; }
}
.table-note { margin: 0; padding: 12px 16px; font-size: var(--t-sm); border-bottom: 1px solid var(--line); }

@media (prefers-reduced-motion: no-preference) {
  /* رفت‌وآمد میان صفحه‌ها (View Transitions، بی‌اسکریپت). ستون پوشه‌ها و فهرست گفتگوها نام دارند، پس
   * سر جایشان می‌مانند و فقط ردیف فعال جابه‌جا می‌شود. بقیه‌ی صفحه کوتاه محو می‌شود و تازه با کمی
   * بالا آمدن می‌رسد. گفتگوی تازه از سمت پایان (چپ) وارد می‌شود، همان جهتی که تلگرام فارسی باز می‌کند.
   * مرورگری که این را نشناسد، صفحه را مثل همیشه عوض می‌کند. */
  @view-transition { navigation: auto; }
  .rail { view-transition-name: rail; }
  .chat-list { view-transition-name: chat-list; }
  .chat-pane { view-transition-name: chat-pane; }
  ::view-transition-group(*) { animation-duration: var(--dur-2); animation-timing-function: var(--ease); }
  ::view-transition-old(root) { animation: vt-fade-out var(--dur-1) ease-in both; }
  ::view-transition-new(root) { animation: vt-rise-in var(--dur-2) var(--ease) both; }
  ::view-transition-old(chat-pane) { animation: vt-fade-out var(--dur-1) ease-in both; }
  ::view-transition-new(chat-pane) { animation: vt-slide-in var(--dur-2) var(--ease) both; }
  @keyframes vt-fade-out { to { opacity: 0; } }
  @keyframes vt-rise-in { from { opacity: 0; transform: translateY(6px); } }
  @keyframes vt-slide-in { from { opacity: 0; transform: translateX(-14px); } }

  @keyframes rise { from { opacity: 0; transform: translateY(8px); } }
  @keyframes bubble-in { from { opacity: 0; transform: translateY(6px) scale(0.98); } }
  @keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }
  @keyframes grow { from { transform: scaleX(0); } }

  /* بلوک‌های صفحه یکی‌یکی و پشت سر هم می‌آیند. */
  .page > * { animation: rise var(--dur-3) var(--ease) both; }
  .page > :nth-child(2) { animation-delay: 40ms; }
  .page > :nth-child(3) { animation-delay: 80ms; }
  .page > :nth-child(4) { animation-delay: 120ms; }
  .page > :nth-child(5) { animation-delay: 160ms; }
  .page > :nth-child(n + 6) { animation-delay: 200ms; }
  body.chat-page .page > * { animation: none; }

  /* حباب‌ها با فاصله‌ی کوتاه، آخرین پیام‌ها آخر از همه. */
  .thread > li { animation: bubble-in var(--dur-2) var(--ease) both; }
  .thread > li:nth-last-child(-n + 6) { animation-delay: 60ms; }
  .thread > li:nth-last-child(-n + 3) { animation-delay: 120ms; }
  /* باز و بسته شدن «چرا؟» و «گفتگوی اصلی»: ارتفاع نرم باز می‌شود و نرم بسته می‌شود، جایی که مرورگر
   * `::details-content` را می‌شناسد؛ جای دیگر فقط باز شدن با کمی جابه‌جایی. */
  @supports selector(::details-content) {
    :root { interpolate-size: allow-keywords; }
    details::details-content {
      height: 0;
      opacity: 0;
      overflow: clip;
      transition:
        height var(--dur-2) var(--ease),
        opacity var(--dur-2) var(--ease),
        content-visibility var(--dur-2) allow-discrete;
    }
    details[open]::details-content { height: auto; opacity: 1; }
  }
  @supports not selector(::details-content) {
    .service details[open] .why { animation: pop var(--dur-2) var(--ease); transform-origin: top center; }
    .card details[open] > :not(summary) { animation: rise var(--dur-2) var(--ease); }
  }
  /* نشانگر «چرا؟» با باز شدن می‌چرخد. */
  .service summary .icon { transition: transform var(--dur-2) var(--ease); }
  .service details[open] summary .icon { transform: rotate(-12deg) scale(1.08); }
  /* حلقه‌ی تمرکز صفحه‌کلید نرم جا می‌افتد. */
  :focus-visible { transition: outline-offset var(--dur-1) var(--ease); }

  /* نوار نسبت از صفر تا مقدارش پر می‌شود، از سمت شروع (راست). */
  .meter .track span { transform-origin: right center; animation: grow 700ms var(--ease) 150ms both; }

  /* لمس و نشانگر */
  .row, .tabs a, .rail-nav a, button, .btn, .rail-btn, .chip, .avatar {
    transition:
      background-color var(--dur-1) var(--ease),
      color var(--dur-1) var(--ease),
      border-color var(--dur-1) var(--ease),
      transform var(--dur-1) var(--ease),
      filter var(--dur-1) var(--ease);
  }
  .rail-nav a .icon { transition: transform var(--dur-2) var(--ease); }
  button.switch .knob { transition: inset-inline-start var(--dur-2) var(--ease); }
  button.switch::before { transition: background-color var(--dur-2) var(--ease); }
  .rail-nav a:hover .icon { transform: translateY(-1px) scale(1.06); }
  a.row:hover .avatar { transform: scale(1.04); }
  button:active, .tabs a:active, a.row:active, .rail-nav a:active { transform: scale(0.97); }
  .notice, .callout { animation: pop var(--dur-2) var(--ease) both; }
  .wall { scroll-behavior: smooth; }
}

/* تور ایمنی: اگر قاعده‌ای از بیرون این فایل حرکتی بیاورد، «کاهش حرکت» باز هم خاموشش می‌کند. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ── اندازه‌ی لمس و چیدمان باریک (ممیزی کاربرد) ─────────────────────── */
/* «چرا؟» کوچک دیده می‌شود ولی ناحیه‌ی لمسش دست‌کم ۴۴ پیکسل است. */
.service summary { position: relative; min-height: 30px; }
.service summary::after { content: ""; position: absolute; inset: -8px -4px; }
.card details > summary { display: inline-flex; align-items: center; min-height: 44px; }
.card details a { display: inline-flex; align-items: center; min-height: 44px; }
.chat-list header .muted { font-size: var(--t-sm); }
/* ردیف با دکمه (ارجاع): روی گوشی دکمه‌ها زیر متن می‌آیند، وگرنه متن به چند پیکسل فشرده می‌شد. */
.row.has-actions { grid-template-columns: auto minmax(0, 1fr) auto; }
@media (max-width: 760px) {
  .row.has-actions { grid-template-columns: auto minmax(0, 1fr); }
  .row.has-actions .row-actions { grid-column: 2 / -1; flex-wrap: wrap; }
}


/* ── ستون پوشه‌ها روی گوشی: چهار پوشه و «بیشتر» (ADR-091) ─────────────────────── */
.rail-extra { display: contents; }
.rail-more { display: none; }
.rail-more > summary { list-style: none; cursor: pointer; }
.rail-more > summary::-webkit-details-marker { display: none; }
@media (max-width: 760px) {
  .rail-extra { display: none; }
  .rail-foot { display: none; }
  .rail-more { display: block; flex: 1 1 0; }
  .rail-more > summary {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 56px;
    border-radius: 12px;
    color: var(--rail-ink);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
  }
  .rail-more > summary .icon { width: 26px; height: 26px; }
  .rail-more.on > summary, .rail-more[open] > summary { background: var(--rail-wash); color: var(--rail-active); }
  .more-sheet {
    position: fixed;
    inset-inline: max(8px, env(safe-area-inset-right, 0px));
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    z-index: 30;
    display: flex;
    flex-direction: column;
    padding: 6px;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-pop);
  }
  .rail-nav .more-sheet a, .more-sheet button {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 0 14px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: var(--t-base);
    font-weight: 600;
    text-decoration: none;
    justify-content: flex-start;
    width: 100%;
  }
  .rail-nav .more-sheet a .icon { width: 22px; height: 22px; }
  .rail-nav .more-sheet a.on { background: var(--accent-wash); color: var(--accent-ink); }
  .rail-nav .more-sheet a:hover, .more-sheet button:hover { background: var(--surface-2); color: var(--ink); filter: none; }
  .more-sheet .badge { margin-inline-start: auto; }
  .more-sheet form { margin: 0; }
  .more-sheet .theme-form { border-top: 1px solid var(--line); padding-top: 4px; margin-top: 4px; }
  .more-sheet .sheet-logout button { color: var(--danger); }
}

/* ── خلاصه: کارهای منتظر، شاخص‌ها، نمودار، حساب‌ها، هزینه (ADR-091) ───────────────── */
.chip.bad { background: var(--danger-wash); color: var(--danger); }
.section-head.pad { padding: 16px 20px 12px; }
.small-link { display: inline-flex; align-items: center; min-height: 44px; font-size: var(--t-sm); font-weight: 600; }
.todo { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.todo-item { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-top: 1px solid var(--line); }
.todo-item:first-child { border-top: 0; padding-top: 0; }
.todo-main { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; line-height: 1.6; }
.todo-main .muted { overflow-wrap: anywhere; }
.todo-item .btn { flex: none; }
@media (max-width: 560px) {
  .todo-item { flex-wrap: wrap; }
  .todo-main { flex-basis: calc(100% - 60px); }
  .todo-item .btn { margin-inline-start: 56px; }
}

.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); overflow: hidden; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 16px 20px; border-top: 1px solid var(--line); border-inline-start: 1px solid var(--line); min-width: 0; }
.kpi:nth-child(-n + 3) { border-top: 0; }
.kpi:nth-child(3n + 1) { border-inline-start: 0; }
.kpi .lbl { font-size: var(--t-sm); color: var(--muted); font-weight: 600; }
.kpi .num { font-size: 26px; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; }
.kpi .note { font-size: var(--t-xs); color: var(--muted); line-height: 1.6; }
.kpi.warn .num { color: var(--warn); }
@media (max-width: 760px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: 14px 16px; }
  .kpi:nth-child(-n + 3) { border-top: 1px solid var(--line); }
  .kpi:nth-child(-n + 2) { border-top: 0; }
  .kpi:nth-child(3n + 1) { border-inline-start: 1px solid var(--line); }
  .kpi:nth-child(2n + 1) { border-inline-start: 0; }
  .kpi .num { font-size: 22px; }
}

.legend { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: var(--t-xs); color: var(--muted); }
.legend .key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.key.answered, .key.cost { background: var(--accent); }
.key.silent { background: var(--warn); }
.key.over { background: var(--danger); }
.chart { list-style: none; margin: 0; padding: 4px 0 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; align-items: end; }
.chart-14 { grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 6px; }
.chart-day { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.chart-bar {
  width: 100%;
  max-width: 48px;
  height: 160px;
  display: flex;
  flex-direction: column-reverse;
  border-radius: 8px 8px 4px 4px;
  background: var(--surface-2);
  overflow: hidden;
}
.seg-answered, .seg-cost { background: var(--accent); }
.seg-silent { background: var(--warn); }
.seg-cost.over { background: var(--danger); }
.chart-bar .h0 { height: 0%; }
.chart-bar .h5 { height: 5%; }
.chart-bar .h10 { height: 10%; }
.chart-bar .h15 { height: 15%; }
.chart-bar .h20 { height: 20%; }
.chart-bar .h25 { height: 25%; }
.chart-bar .h30 { height: 30%; }
.chart-bar .h35 { height: 35%; }
.chart-bar .h40 { height: 40%; }
.chart-bar .h45 { height: 45%; }
.chart-bar .h50 { height: 50%; }
.chart-bar .h55 { height: 55%; }
.chart-bar .h60 { height: 60%; }
.chart-bar .h65 { height: 65%; }
.chart-bar .h70 { height: 70%; }
.chart-bar .h75 { height: 75%; }
.chart-bar .h80 { height: 80%; }
.chart-bar .h85 { height: 85%; }
.chart-bar .h90 { height: 90%; }
.chart-bar .h95 { height: 95%; }
.chart-bar .h100 { height: 100%; }
.chart-num, .chart-label { font-size: var(--t-xs); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.chart-day.today .chart-label { color: var(--ink); font-weight: 700; }
@media (max-width: 560px) {
  .chart { gap: 6px; }
  .chart-14 { gap: 3px; }
  .chart-14 .chart-num { display: none; }
  .chart-14 .chart-label { font-size: 11px; }
}
.table-toggle > summary { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent-ink); font-size: var(--t-sm); font-weight: 600; cursor: pointer; }
.table-toggle table { margin-top: 4px; }

.split.wide-first { grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); }
@media (max-width: 1040px) { .split.wide-first { grid-template-columns: minmax(0, 1fr); } }
.who-cell { display: inline-flex; align-items: center; gap: 10px; }
.who-cell .tag { margin-top: 2px; }
.cell-label { display: none; }
.meter .track.alert span { background: var(--warn); }
.cost-per { display: grid; gap: 2px; padding-top: 4px; border-top: 1px solid var(--line); }
.cost-per b { font-size: var(--t-lg); font-weight: 700; font-variant-numeric: tabular-nums; }
.cost-card > .btn { align-self: flex-start; }
.big-figure { display: flex; flex-direction: column; gap: 2px; }
.big-figure b { font-size: 32px; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; }
.facts { display: grid; gap: 8px; margin: 0; }
.facts div { display: flex; justify-content: space-between; gap: 12px; font-size: var(--t-sm); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.share-list { list-style: none; margin: 0; padding: 0 0 6px; }
.share-list li { display: flex; flex-direction: column; gap: 6px; padding: 12px 20px; border-top: 1px solid var(--line); }
.share-head { display: flex; justify-content: space-between; gap: 12px; font-size: var(--t-sm); }
.share-head b { font-variant-numeric: tabular-nums; }

/* جدولی که روی گوشی کارت می‌شود (همان رفتار جدول پایگاه دانش). */
@media (max-width: 760px) {
  .card-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .card-table, .card-table tbody { display: block; }
  .card-table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .card-table tbody tr:last-child { border-bottom: 0; }
  .card-table td { display: block; padding: 0; border: 0; color: var(--ink-2); font-size: var(--t-xs); }
  .card-table td:first-child { flex: 1 0 100%; color: var(--ink); font-size: var(--t-sm); }
  .card-table td.cell-action { margin-inline-start: auto; }
  .card-table .cell-label, .kb-table .cell-label { display: inline; color: var(--muted); }
}

/* ── گفتگو: پوشه‌ها، ابزار بالای گفتگو، «چرا این جواب؟»، نظر (ADR-091) ────────────── */
.folders { flex: none; display: flex; gap: 2px; overflow-x: auto; padding: 0 8px; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.folders::-webkit-scrollbar { display: none; }
.folders a {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  gap: 6px;
  min-height: 44px;
  padding: 0 10px;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-size: var(--t-sm);
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
}
.folders a:hover { color: var(--ink); text-decoration: none; }
.folders a.on { color: var(--accent-ink); border-bottom-color: var(--accent); }
.folders .count { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: var(--t-xs); text-align: center; line-height: 20px; font-variant-numeric: tabular-nums; }
.folders a.on .count { background: var(--accent); color: #fff; }
.chat-tools { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; flex: none; }
.chat-head .chat-tools form { margin: 0; }
.chat-notice { margin: 10px 14px 0; }
@media (max-width: 760px) {
  .chat-tools .btn.soft { width: 44px; padding: 0; font-size: 0; justify-content: center; }
  .chat-tools .btn.soft .icon { margin: 0; }
}
.service-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent-ink);
  font-size: var(--t-xs);
  font-weight: 600;
  box-shadow: var(--shadow);
}
.service-link::after { content: ""; position: absolute; inset: -10px -4px; }
.service-hint { display: inline-block; margin-top: 6px; padding: 3px 12px; border-radius: 999px; background: var(--service); color: #fff; font-size: var(--t-xs); }
dl.why { display: grid; gap: 8px; margin: 0; }
dl.why > div { display: grid; grid-template-columns: 7.5em minmax(0, 1fr); gap: 10px; }
dl.why dt { color: var(--muted); font-weight: 600; }
dl.why dd { margin: 0; }
dl.why .sources { margin: 0; }
@media (max-width: 560px) { dl.why > div { grid-template-columns: minmax(0, 1fr); gap: 0; } }
.feedback { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin-top: 6px; }
.chip-btn {
  position: relative;
  min-height: 32px;
  padding: 0 12px;
  gap: 5px;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--t-xs);
  font-weight: 600;
  box-shadow: var(--shadow);
}
.chip-btn::after { content: ""; position: absolute; inset: -6px 0; }
.chip-btn .icon { width: 15px; height: 15px; }
.chip-btn:hover { background: var(--surface-2); filter: none; }
.feedback-state { display: inline-flex; align-items: center; gap: 5px; padding: 3px 12px; border-radius: 999px; background: var(--service); color: #fff; font-size: var(--t-xs); }
.feedback-state .icon { width: 15px; height: 15px; }

.chat-foot.muted { justify-content: center; align-items: center; min-height: 54px; padding: 0 16px; text-align: center; }

/* ── ارجاع و پیش‌نویس ─────────────────────────────────────────────────── */
.notice.warn-notice { background: var(--warn-wash); color: var(--warn); }
.row-actions { flex-wrap: wrap; justify-content: flex-end; }
.drafts { list-style: none; margin: 0; padding: 0; }
.draft-card { display: flex; flex-direction: column; gap: 8px; padding: 14px 20px 16px; border-top: 1px solid var(--line); }
.draft-head { display: flex; align-items: center; gap: 10px; }
.draft-head .muted { margin-inline-start: auto; }
.draft-q { margin: 0; color: var(--ink-2); font-size: var(--t-sm); }
.draft-a {
  margin: 0;
  max-width: 62ch;
  padding: 10px 14px;
  border-radius: 16px 16px 16px 6px;
  background: var(--bubble-out);
  color: var(--ink);
  white-space: pre-line;
  line-height: 1.8;
}
.draft-card .muted p, .draft-card > .muted { margin: 0; }
@media (max-width: 760px) {
  .row.has-actions { flex-wrap: wrap; }
  .row.has-actions .row-actions { flex-basis: 100%; justify-content: flex-start; padding-inline-start: 56px; }
}

/* ── پایگاه دانش: نگاه کلی، بی‌جواب‌ها، ورود فایل ─────────────────────────── */
.facts-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.facts-strip > div { display: flex; flex-direction: column; gap: 2px; padding: 14px 18px; border-inline-start: 1px solid var(--line); min-width: 0; }
.facts-strip > div:first-child { border-inline-start: 0; }
.facts-strip .lbl { font-size: var(--t-xs); color: var(--muted); font-weight: 600; }
.facts-strip b { font-size: var(--t-lg); font-weight: 700; font-variant-numeric: tabular-nums; }
.facts-strip b.small { font-size: var(--t-base); }
.facts-strip .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--t-xs); }
@media (max-width: 760px) {
  .facts-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts-strip > div { border-inline-start: 0; border-top: 1px solid var(--line); }
  .facts-strip > div:nth-child(-n + 2) { border-top: 0; }
  .facts-strip > div:nth-child(2n) { border-inline-start: 1px solid var(--line); }
  .facts-strip > div:last-child { grid-column: 1 / -1; border-inline-start: 0; }
}
.gap-list { list-style: none; margin: 0; padding: 0; }
.gap-list li { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.gap-list li:last-child { border-bottom: 0; }
.gap-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; line-height: 1.7; }
.gap-list .btn { flex: none; }
@media (max-width: 560px) { .gap-list li { flex-direction: column; align-items: stretch; } .gap-list .btn { align-self: flex-start; } }
.preview { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border-radius: var(--r); background: var(--accent-wash); color: var(--ink); }
.preview p { margin: 0; }
.skipped { margin: 0; padding-inline-start: 18px; font-size: var(--t-xs); color: var(--ink-2); max-height: 220px; overflow-y: auto; }
.upload-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.upload-form label { display: flex; flex-direction: column; gap: 6px; font-size: var(--t-sm); color: var(--muted); min-width: 0; }
.upload-form input[type="file"] { font: inherit; font-size: var(--t-sm); color: var(--ink); min-height: 44px; max-width: 100%; }
.upload-form input[type="file"]::file-selector-button {
  font: inherit;
  min-height: 44px;
  margin-inline-end: 10px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
}

/* ── کتابخانه ───────────────────────────────────────────────────────── */
.library-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
@media (max-width: 400px) { .library-grid { grid-template-columns: minmax(0, 1fr); } }
.lib-card { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; min-width: 0; }
.lib-card.is-off { background: var(--surface-2); border-style: dashed; }
.lib-head { display: flex; align-items: center; gap: 12px; }
.lib-head .chip { flex: none; }
.lib-head .tag { margin-inline-start: auto; flex: none; }
.lib-title { min-width: 0; display: flex; flex-direction: column; line-height: 1.6; }
.lib-title b { overflow-wrap: anywhere; }
.lib-when { margin: 0; font-size: var(--t-sm); color: var(--ink-2); line-height: 1.8; }
.lib-card .cell-label { display: inline; color: var(--muted); }
.lib-foot { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }

/* ── سابقه و کاربران ─────────────────────────────────────────────────── */
.history { list-style: none; margin: 0; padding: 0; }
.history li { display: grid; grid-template-columns: 9.5em minmax(0, 1fr); gap: 14px; align-items: baseline; padding: 12px 20px; border-bottom: 1px solid var(--line); font-size: var(--t-sm); }
.history li:last-child { border-bottom: 0; }
.history .stamp { color: var(--muted); font-size: var(--t-xs); }
.history-main { min-width: 0; overflow-wrap: anywhere; }
.history.compact li { grid-template-columns: 5em minmax(0, 1fr); padding: 8px 0; }
@media (max-width: 560px) { .history li { grid-template-columns: minmax(0, 1fr); gap: 0; } .history .stamp { text-align: start; } }
.pager { display: flex; flex-wrap: wrap; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }
.setting.is-off .row-title { color: var(--muted); }
#users .add-form > summary { padding: 0; }
#users .stack { padding: 4px 0 0; }

/* کادر عددی تنظیم‌ها: رقم فارسی هم پذیرفته می‌شود؛ مرز را سرور می‌سنجد. */
.number-form { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.number-field { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.number-field:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--surface); }
.number-field input { width: 5.5em; min-height: 44px; padding: 0 12px; border: 0; background: transparent; color: var(--ink); font: inherit; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.number-field input:focus { outline: 0; }
.number-field input[aria-invalid="true"] { color: var(--danger); }
.number-field:has(input[aria-invalid="true"]) { border-color: var(--danger); }
.number-field .unit { padding-inline-end: 12px; color: var(--muted); font-size: var(--t-sm); }
.number-form .range { flex-basis: 100%; text-align: end; font-size: var(--t-xs); color: var(--muted); }
.setting-main .error { display: block; margin-top: 4px; }
.cell-sub { display: block; color: var(--muted); font-size: var(--t-xs); }
@media (max-width: 760px) { .card-table .cell-sub { display: inline; margin-inline-start: 6px; } }
summary.btn { cursor: pointer; list-style: none; white-space: nowrap; }
summary.btn::-webkit-details-marker { display: none; }
summary.btn .icon { width: 18px; height: 18px; }
.chat-tools summary.btn { width: 44px; padding: 0; }
/* پیل «چرا این جواب؟» کوچک دیده می‌شود ولی ناحیه‌ی لمسش ۴۴ پیکسل است. */
.service summary { position: relative; }
.service summary::after { content: ""; position: absolute; inset: -7px 0; }
.draft-head a.doc-title { display: inline-flex; align-items: center; min-height: 44px; }

/* ── کلید تم (ADR-092) ─────────────────────────────────────────────────
 * هر دو دکمه در صفحه‌اند؛ فقط همانی دیده می‌شود که تم الان را عوض می‌کند. در ستون پوشه‌ها فقط آیکون است،
 * در برگه‌ی «بیشتر» گوشی آیکون و نام. */
.theme-form { margin: 0; }
.theme-form.in-rail .theme-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.theme-form.in-rail .theme-btn {
  width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--rail-ink);
  display: grid;
  place-items: center;
}
.theme-form.in-rail .theme-btn:hover { background: var(--rail-wash); color: #fff; filter: none; }
.theme-form .to-light { display: none !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-form .to-dark { display: none !important; }
  :root:not([data-theme="light"]) .theme-form.in-rail .to-light { display: grid !important; }
  :root:not([data-theme="light"]) .theme-form.in-sheet .to-light { display: flex !important; }
}
:root[data-theme="dark"] .theme-form .to-dark { display: none !important; }
:root[data-theme="dark"] .theme-form.in-rail .to-light { display: grid !important; }
:root[data-theme="dark"] .theme-form.in-sheet .to-light { display: flex !important; }

/* ── ستون پوشه‌ها هرگز بلندتر از پنجره نمی‌شود ───────────────────────────────
 * با هشت پوشه و کلید تم، ستون در پنجره‌ی کوتاه لپ‌تاپ (حدود ۶۵۰ پیکسل) بلندتر از صفحه می‌شد و کل صفحه چند
 * ده پیکسل پیمایش داشت: پیمایش گفتگو که به ته می‌رسید، کل صفحه را بالا می‌برد و چیدمان «می‌پرید». حالا ستون
 * خودش، اگر لازم شد، پیمایش دارد؛ در پنجره‌ی کوتاه پوشه‌ها کمی فشرده‌ترند؛ و پیمایش دیوار گفتگو و فهرست
 * به صفحه سرایت نمی‌کند. */
@media (min-width: 761px) {
  .rail { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; }
  .rail::-webkit-scrollbar { display: none; }
}
@media (min-width: 761px) and (max-height: 800px) {
  .rail { gap: 8px; padding-block: 10px; }
  .mark { width: 40px; height: 40px; font-size: 17px; }
  .rail-nav a { min-height: 52px; padding: 5px 2px 4px; }
  .rail-foot { gap: 2px; }
}
.wall, .chat-list .list { overscroll-behavior: contain; }
