/* ============================================================
   دستیار — سیستم بصری
   الهام از Todoist: سایدبار گرم و روشن، صفحهٔ سفید، خط‌های نازک به‌جای جعبه،
   یک رنگ تأکید (قرمز-نارنجی) برای کار اصلی و جای فعلی. بقیهٔ رنگ‌ها فقط
   جایی می‌آیند که معنا دارند: وضعیت، اولویت، سررسید.

   قاعده: هر اندازه، فاصله و رنگی از توکن‌های همین بالا می‌آید. اگر چیزی غلط
   به نظر می‌رسد، توکن را درست کنید نه نمونه را.
   ============================================================ */

@font-face {
  font-family: Vazirmatn;
  src: url('/fonts/Vazirmatn.woff2') format('woff2-variations');
  font-weight: 300 800;
  font-display: swap;
}

:root {
  color-scheme: light;

  /* سطوح */
  --bg: #ffffff;
  --sidebar: #fcfaf8;
  --surface: #ffffff;          /* کارت، مودال، پنل */
  --surface-2: #faf9f8;        /* پرکردن‌های آرام: پای جدول، ناحیه‌های فرورفته */
  --hover: #f4f2f0;            /* زیر ماوس: ردیف، آیتم منو */
  --fill: #f1efed;             /* دکمهٔ معمولی */
  --fill-hover: #e8e5e2;
  --border: #ededed;
  --border-strong: #d9d9d9;    /* لبهٔ ورودی‌ها */

  /* رنگ سری‌های نمودار — ترتیب ثابت، با validate_palette سنجیده روی همین زمینه‌ها */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
  --chart-grid: #ececec;
  --control: #b9b9b9;          /* لبهٔ چک‌باکس */

  /* متن — سه درجه، همه با کنتراست قابل‌قبول روی سفید */
  --text: #202020;
  --text-2: #555555;
  --muted: #737373;            /* ۴.۷:۱ روی سفید */
  --faint: #c4c4c4;            /* فقط تزئین: خط تیرهٔ خانهٔ خالی */

  /* تأکید */
  --accent: #dc4c3e;
  --accent-hover: #c53727;
  --accent-soft: #ffefe5;
  --accent-text: #b8392b;      /* متن تأکیدی روی سطح روشن */
  --on-accent: #ffffff;

  /* هیوهای معنایی — پیل‌ها و تاریخ‌ها از همین‌ها ساخته می‌شوند */
  --h-red: #d1453b;
  --h-orange: #e07a00;
  --h-amber: #b88a00;
  --h-green: #058527;
  --h-teal: #0f8a86;
  --h-blue: #246fe0;
  --h-indigo: #4f5bd5;
  --h-violet: #692ec2;
  --h-pink: #c63b80;
  --h-slate: #707070;

  --pill-bg: 12%;
  --pill-text: 78%;

  /* تایپوگرافی — یک مقیاس کوچک */
  --fs-xs: 12px;     /* سرستون، شمارنده، راهنما */
  --fs-sm: 13px;     /* خانه‌های جدول، متن دوم */
  --fs: 14px;        /* متن اصلی، ورودی، عنوان ردیف */
  --fs-lg: 16px;     /* عنوان مودال و بخش */
  --fs-xl: 20px;     /* عنوان صفحه */

  /* فاصله — مقیاس ۴ */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s8: 32px;
  --s10: 40px;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 8px 24px rgba(0, 0, 0, .12);
  --ring: color-mix(in srgb, var(--accent) 55%, transparent);
  --toast-bg: #2b2b2b;
  --tint-mix: 8%;
}

/* تیره: یا سیستم تیره است و کاربر «روشن» را انتخاب نکرده، یا کاربر خودش «تیره» را زده (منوی ظاهر در سایدبار) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: #1f1f1f;
    --sidebar: #262626;
    --surface: #262626;
    --surface-2: #2a2a2a;
    --hover: #2f2f2f;
    --fill: #333333;
    --fill-hover: #3d3d3d;
    --border: #333333;
    --border-strong: #474747;
    --control: #6b6b6b;

    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --chart-grid: #333333;

    --text: #ececec;
    --text-2: #bdbdbd;
    --muted: #949494;
    --faint: #4a4a4a;

    --accent: #de4c4a;
    --accent-hover: #e8655f;
    --accent-soft: #3a2624;
    --accent-text: #ff8f80;
    --on-accent: #ffffff;

    --h-red: #ff7066;
    --h-orange: #ff9a3d;
    --h-amber: #e8c04a;
    --h-green: #4cc06d;
    --h-teal: #44c2b9;
    --h-blue: #6fa3ff;
    --h-indigo: #8f97ff;
    --h-violet: #b28cff;
    --h-pink: #f27fb5;
    --h-slate: #a3a3a3;

    --pill-bg: 18%;
    --pill-text: 88%;

    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .55);
    --toast-bg: #3a3a3a;
  --tint-mix: 14%;
    --tint-mix: 14%;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #1f1f1f;
  --sidebar: #262626;
  --surface: #262626;
  --surface-2: #2a2a2a;
  --hover: #2f2f2f;
  --fill: #333333;
  --fill-hover: #3d3d3d;
  --border: #333333;
  --border-strong: #474747;
  --control: #6b6b6b;

  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  --chart-grid: #333333;

  --text: #ececec;
  --text-2: #bdbdbd;
  --muted: #949494;
  --faint: #4a4a4a;

  --accent: #de4c4a;
  --accent-hover: #e8655f;
  --accent-soft: #3a2624;
  --accent-text: #ff8f80;
  --on-accent: #ffffff;

  --h-red: #ff7066;
  --h-orange: #ff9a3d;
  --h-amber: #e8c04a;
  --h-green: #4cc06d;
  --h-teal: #44c2b9;
  --h-blue: #6fa3ff;
  --h-indigo: #8f97ff;
  --h-violet: #b28cff;
  --h-pink: #f27fb5;
  --h-slate: #a3a3a3;

  --pill-bg: 18%;
  --pill-text: 88%;

  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .55);
  --toast-bg: #3a3a3a;
}
:root[data-theme="light"] { color-scheme: light; }

/* ============================================================ پایه */

* { box-sizing: border-box; }
/* hidden همیشه برنده است، حتی روی عنصری که کلاسش display:flex/grid می‌دهد */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Vazirmatn, 'Segoe UI', Tahoma, sans-serif;
  font-size: var(--fs);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-weight: 700; line-height: 1.4; margin: 0; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

.i { flex: none; display: block; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; unicode-bidi: isolate; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.en { direction: ltr; unicode-bidi: isolate; font-family: 'Segoe UI', system-ui, sans-serif; font-size: .95em; }
.dash { color: var(--faint); user-select: none; }
.spacer { margin-inline-start: auto; }
.row { display: flex; gap: var(--s2); align-items: center; }
.hint { color: var(--muted); font-size: var(--fs-xs); line-height: 1.7; }

.kbd {
  font-family: ui-monospace, 'Cascadia Mono', monospace;
  font-size: 11px;
  line-height: 1.6;
  padding: 0 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--muted);
  background: var(--surface);
  direction: ltr;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ============================================================ چیدمان */

.app { display: grid; grid-template-columns: var(--sidebar-w, 264px) minmax(0, 1fr); min-height: 100vh; }
.main { padding: var(--s8) var(--s10) 96px; min-width: 0; }

/* ============================================================ سایدبار */

.sidebar {
  background: var(--sidebar);
  padding: var(--s3) var(--s2);
  display: flex;
  flex-direction: column;
  gap: 1px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: var(--s2); padding: var(--s1) var(--s2) var(--s2); }
.brand .drawer-close { display: none; margin-inline-start: auto; }
/* زیرِ لوگو: حساب (هرچه جا هست) و زنگوله */
.side-tools { display: flex; align-items: center; gap: var(--s1); padding: 0 var(--s1) var(--s2) 0; margin-bottom: var(--s1); border-bottom: 1px solid var(--border); }
.side-tools .user-chip { flex: 1; max-width: none; min-width: 0; height: 34px; border-radius: var(--radius-sm); padding-inline: var(--s1) var(--s2); }
.side-tools .user-chip .user-name { flex: 1; text-align: start; }
.mobilebar, .drawer-backdrop { display: none; }
.logo-mark { display: grid; flex: none; }
.logo-mark svg, .logo-full { display: block; user-select: none; -webkit-user-drag: none; }
.logo-full { width: auto; max-width: 100%; }
.brand b { font-size: 15px; font-weight: 700; display: block; line-height: 1.3; }
.brand .sub { color: var(--muted); font-size: var(--fs-xs); line-height: 1.3; }

.nav-label {
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: var(--s4) var(--s2) var(--s1);
}

.nav-group { display: flex; flex-direction: column; gap: 1px; }

.nav-item, .quick-open {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: 34px;
  padding: 0 var(--s2);
  border-radius: var(--radius-sm);
  border: 0;
  background: transparent;
  width: 100%;
  text-align: start;
  color: var(--text);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.nav-item:hover, .quick-open:hover { background: var(--hover); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav-item .ico {
  width: 22px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 16px;
  line-height: 1;
  color: var(--muted);
}
.nav-item.active .ico { color: var(--accent-text); }
.nav-item .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.nav-item .count {
  margin-inline-start: auto;
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  flex: none;
}
.nav-item.active .count { color: var(--accent-text); }
.nav-item[draggable="true"] { position: relative; }
.nav-item .grip { position: absolute; inset-inline-end: var(--s1); top: 50%; transform: translateY(-50%); margin: 0; }
.nav-item:hover .grip { opacity: .6; }
.nav-item[draggable="true"]:hover .count { visibility: hidden; }

.quick-open { color: var(--muted); margin-bottom: var(--s1); }
.quick-open .ico { width: 22px; display: grid; place-items: center; }
.quick-open .kbd { margin-inline-start: auto; }

/* ============================================================ ریتمِ صفحه */

/* کارت‌های پشتِ سرِ هم هیچ‌وقت به هم نمی‌چسبند (حاشیه‌ها روی هم می‌افتند، پس با حاشیه‌های قبلی جمع نمی‌شود) */
.main > .card + .card, .main > .card + .integrations, .main > .integrations + .card, .integrations > .card + .card { margin-top: var(--s4); }

/* ============================================================ سرصفحه */

.page-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s5); flex-wrap: wrap; }
.page-head > .page-title { display: flex; align-items: center; gap: var(--s2); min-width: 0; flex: 1 1 340px; }
.page-head h1 { font-size: var(--fs-xl); overflow: hidden; text-overflow: ellipsis; }
.page-head .desc {
  color: var(--muted); font-size: var(--fs-sm); margin: 0;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
.page-head .actions { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.page-icon { font-size: 22px; line-height: 1; width: 32px; display: grid; place-items: center; flex: none; color: var(--muted); }

/* ============================================================ دکمه */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 var(--s3);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--fill);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background .12s, color .12s, border-color .12s;
}
.btn:hover { background: var(--fill-hover); }
.btn:active:not(:disabled) { transform: translateY(.5px); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.danger { background: transparent; color: var(--h-red); }
.btn.danger:hover { background: color-mix(in srgb, var(--h-red) 10%, transparent); }
.btn.danger-fill { background: var(--h-red); color: #fff; }
.btn.danger-fill:hover { background: color-mix(in srgb, var(--h-red) 85%, #000); }
.btn.icon { width: 32px; padding: 0; }
.btn.sm { height: 28px; padding: 0 var(--s2); font-size: var(--fs-xs); }
.btn.sm.icon { width: 28px; padding: 0; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn.primary .kbd {
  background: rgba(255, 255, 255, .18);
  border-color: rgba(255, 255, 255, .28);
  color: inherit;
}

/* ============================================================ ورودی */

.input, .select, .textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  transition: border-color .12s, box-shadow .12s;
}
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: .8; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--control); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--muted);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 7%, transparent);
}
.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--surface-2);
  color: var(--muted);
  border-color: var(--border);
  cursor: not-allowed;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.8; }
.input.short { max-width: 160px; }

.search-box { position: relative; width: 220px; }
.search-box .i { position: absolute; inset-inline-start: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-box .input { min-height: 32px; padding-inline-start: 32px; background: var(--surface-2); border-color: var(--border); }
.search-box .input:focus { background: var(--surface); }

/* ============================================================ فرم */

.field label, .field-label {
  display: block;
  margin-bottom: 6px;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text);
}
.req { color: var(--h-red); }
.field .hint { margin-top: var(--s1); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }

.check { display: inline-flex; align-items: center; gap: var(--s2); cursor: pointer; font-size: var(--fs); }
.check-main { font-weight: 500; padding: 2px 0; }

/* چک‌باکس — همه‌جای برنامه یکی */
.tick,
.check input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  margin: 0;
  border: 1.5px solid var(--control);
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  position: relative;
  vertical-align: middle;
  flex: none;
  transition: background .14s, border-color .14s, transform .1s;
}
.tick:hover, .check input[type="checkbox"]:hover { border-color: var(--text-2); }
.tick:active, .check input[type="checkbox"]:active { transform: scale(.9); }
.tick:checked, .check input[type="checkbox"]:checked { background: var(--h-green); border-color: var(--h-green); }
.tick::after, .check input[type="checkbox"]::after {
  content: '';
  position: absolute;
  inset-inline-start: 5px;
  top: 1.5px;
  width: 4.5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  opacity: 0;
}
.tick:checked::after, .check input[type="checkbox"]:checked::after { opacity: 1; }
/* نیمه‌انتخاب (مثلاً «انتخاب همه» وقتی فقط بعضی تیک خورده‌اند): خطِ افقی */
.check input[type="checkbox"]:indeterminate { background: var(--h-green); border-color: var(--h-green); }
.check input[type="checkbox"]:indeterminate::after { opacity: 1; transform: none; border-width: 0 0 2px; width: 8px; height: 0; top: 7px; inset-inline-start: 3.5px; }
.tick:disabled, .check input[type="checkbox"]:disabled { cursor: default; opacity: .55; }

/* «انجام شد»: همان مربع، با لبهٔ کم‌رنگ‌تر. زیر ماوس تیکش کم‌رنگ پیدا می‌شود. */
.tick.round, .check .tick.round { border-color: var(--muted); }
.tick.round::after, .check .tick.round::after { inset-inline-start: 5px; top: 2px; border-color: var(--muted); }
.tick.round:hover:not(:checked)::after, .check .tick.round:hover:not(:checked)::after { opacity: .5; }
.tick.round:checked, .check .tick.round:checked { border-color: var(--h-green); }
.tick.round:checked::after, .check .tick.round:checked::after { border-color: #fff; }

/* ============================================================ پیل */

.pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 var(--s2);
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
  background: color-mix(in srgb, var(--hue, var(--h-slate)) var(--pill-bg), transparent);
  color: color-mix(in srgb, var(--hue, var(--h-slate)) var(--pill-text), var(--text));
  border: 1px solid transparent;
}
.gone-pill { --hue: var(--h-slate); opacity: .85; }
.gone-pill bdi { text-decoration: line-through; text-decoration-color: color-mix(in srgb, currentColor 55%, transparent); }
.gone-pill .gone-by { margin-inline-start: 3px; font-weight: 400; }
.pills { display: inline-flex; flex-wrap: wrap; gap: var(--s1); vertical-align: middle; }
td .pills { flex-wrap: nowrap; }   /* در جدول، ردیف‌ها هم‌ارتفاع بمانند */
.pill[role="button"] { cursor: pointer; }
.pill[role="button"]:hover { border-color: color-mix(in srgb, var(--hue, var(--h-slate)) 40%, transparent); }

/* پیل انتخابی در فرم */
.pick {
  height: 28px;
  padding: 0 var(--s3);
  cursor: pointer;
  background: transparent;
  color: var(--text-2);
  border-color: var(--border-strong);
  transition: background .13s, color .13s, border-color .13s;
}
.pick:hover { border-color: color-mix(in srgb, var(--hue) 55%, transparent); color: var(--text); }
.pick.on {
  background: color-mix(in srgb, var(--hue) var(--pill-bg), transparent);
  color: color-mix(in srgb, var(--hue) var(--pill-text), var(--text));
  border-color: color-mix(in srgb, var(--hue) 55%, transparent);
  font-weight: 600;
}
.pick-group { display: flex; flex-wrap: wrap; gap: 6px; }

.tag {
  display: inline-block;
  margin-inline-start: 6px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.8;
}

/* ============================================================ تاریخ */

.date { display: inline-flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.date-rel { font-size: var(--fs-xs); color: var(--muted); }
.date.overdue, .date.overdue .date-rel { color: var(--h-red); }
.date.today, .date.today .date-rel { color: var(--h-green); }
.date.tomorrow, .date.tomorrow .date-rel { color: var(--h-orange); }
.date.week, .date.week .date-rel { color: var(--h-violet); }

/* ============================================================ کارت و جدول */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-wrap { overflow-x: auto; }
/* جدول اصلی خودش اسکرول می‌خورد تا سرستون و جمع همیشه دیده شوند */
.table-wrap.scroll-y { max-height: calc(100vh - 170px); overflow: auto; }

table { width: 100%; border-collapse: separate; border-spacing: 0; white-space: nowrap; }

th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 38px;
  padding: 0 var(--s3);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 500;
  text-align: start;
  user-select: none;
}
th.sortable { cursor: pointer; transition: color .12s; }
th.sortable:hover { color: var(--text); }
th .sort-mark { color: var(--accent-text); margin-inline-start: var(--s1); font-size: 10px; }

td {
  height: 44px;
  padding: var(--s1) var(--s3);
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  font-size: var(--fs-sm);
  text-align: start;
  vertical-align: middle;
  background: var(--surface);
}
th:first-child, td:first-child { padding-inline-start: var(--s4); }
th:last-child, td:last-child { padding-inline-end: var(--s2); }
tbody tr:last-child > td { border-bottom: 0; }

tbody tr[data-id] { cursor: pointer; }
tbody tr[data-id]:hover > td { background: var(--hover); }
tbody tr[data-id]:focus-visible { outline: none; }
tbody tr[data-id]:focus-visible > td { background: var(--hover); box-shadow: inset 0 1px 0 var(--ring), inset 0 -1px 0 var(--ring); }

td.title-cell { color: var(--text); font-size: var(--fs); max-width: 420px; }
/* ستونِ «انجام شد»: همیشه اول (سمتِ راست)، باریک، با خطی سمتِ چپش؛ ستونِ بعدی نزدیکش می‌نشیند */
th.done-col, td.done-col { width: 1%; padding-inline: var(--s3) var(--s2); text-align: center; border-inline-end: 1px solid var(--border-strong); }
th.done-col + th, td.done-col + td { padding-inline-start: var(--s2); }
th.done-col .icon { vertical-align: middle; color: var(--text-2); }
td.wide { white-space: normal; min-width: 220px; max-width: 340px; line-height: 1.65; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.link-cell { display: inline-flex; align-items: center; gap: var(--s1); }
.cell-text { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 2;
  height: 40px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  border-bottom: 0;
}
.sum-label { color: var(--muted); font-size: var(--fs-xs); margin-inline-end: 6px; }
.sum-value { color: var(--text); font-weight: 700; }

/* ستون‌های ابتدایی تا «عنوان» موقع اسکرول افقی سر جا می‌مانند.
   افست‌ها در JS اندازه گرفته می‌شوند و با تغییر اندازه دوباره حساب می‌شوند. */
td.frozen, th.frozen { position: sticky; z-index: 3; }
th.frozen { z-index: 4; }
tfoot td.frozen { z-index: 4; }
.frozen-last::after {
  content: '';
  position: absolute;
  inset-block: 0;
  inset-inline-end: -8px;
  width: 8px;
  background: linear-gradient(to left, rgba(0, 0, 0, .06), transparent);
  opacity: 0;
  transition: opacity .15s;
  pointer-events: none;
}
.table-wrap.scrolled .frozen-last::after { opacity: 1; }

/* ردیف‌های تمام‌شده: خط روی عنوان، بقیه کم‌رنگ */
tbody tr.struck .title-cell .cell-text {
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--muted) 70%, transparent);
  color: var(--muted);
}
tbody tr.struck > td { color: var(--muted); }
tbody tr.struck .pill, tbody tr.struck .date { opacity: .55; }
tbody tr.struck .date, tbody tr.struck .date .date-rel { color: var(--muted); }
tbody tr.struck .mono { opacity: .7; }

.row-actions { white-space: nowrap; width: 1%; }
.row-actions .btn { opacity: 0; transition: opacity .12s, background .12s, color .12s; }
tbody tr:hover .row-actions .btn,
tbody tr:focus-within .row-actions .btn,
.row-actions .btn:focus-visible { opacity: 1; }
@media (hover: none) { .row-actions .btn { opacity: .7; } }

.table-meta { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s3); color: var(--muted); font-size: var(--fs-xs); }

/* ============================================================ درخت */

.cell-tree { display: flex; align-items: center; min-height: 28px; }
.rail { width: 24px; flex: none; }

.twisty {
  width: 22px;
  height: 22px;
  margin-inline-end: 2px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex: none;
  transition: background .12s, color .12s;
}
.twisty:hover { background: var(--fill-hover); color: var(--text); }
.twisty-space { width: 24px; flex: none; }

.kid-count {
  display: inline-block;
  min-width: 20px;
  margin-inline-end: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.7;
  text-align: center;
  font-variant-numeric: tabular-nums;
  flex: none;
}

.grip { color: var(--muted); opacity: 0; cursor: grab; margin-inline-end: 2px; flex: none; transition: opacity .12s; display: grid; place-items: center; }
tr:hover .grip { opacity: .6; }
[draggable="true"] { -webkit-user-drag: element; }
.dragging { opacity: .4; }

tbody tr.drop-into > td { background: var(--accent-soft) !important; }
tbody tr.drop-before > td { box-shadow: inset 0 2px 0 var(--accent); }
tbody tr.drop-after > td { box-shadow: inset 0 -2px 0 var(--accent); }

/* ============================================================ حالت خالی */

.empty { padding: 56px var(--s5); text-align: center; color: var(--muted); }
.empty .big { font-size: 32px; display: flex; justify-content: center; margin-bottom: var(--s2); opacity: .55; }
.empty .title { color: var(--text); font-weight: 600; margin-bottom: var(--s1); }
.empty .actions { margin-top: var(--s4); display: flex; gap: var(--s2); justify-content: center; }

/* ============================================================ مودال */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 15, .45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px var(--s4);
  overflow-y: auto;
  z-index: 100;
  animation: fade-in .14s ease;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 96px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: pop-in .16s cubic-bezier(.2, .9, .3, 1.1);
}
.modal.wide { max-width: 760px; }
.modal.narrow { max-width: 420px; }
.modal-head { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s3) var(--s3) var(--s5); border-bottom: 1px solid var(--border); flex: none; }
.modal-head h2 { font-size: var(--fs-lg); font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: var(--s5); display: flex; flex-direction: column; gap: var(--s4); overflow-y: auto; flex: 1; }
.modal-foot { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s5); border-top: 1px solid var(--border); flex: none; }
.confirm-text { color: var(--text-2); margin: 0; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in {
  from { opacity: 0; transform: translateY(-6px) scale(.985); }
  to { opacity: 1; transform: none; }
}

/* ============================================================ خلاصهٔ فیلدها (تنظیمات موجودیت) */

.field-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.field-chip {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding-inline: 10px;
  border-radius: 999px;
  background: var(--fill);
  font-size: var(--fs-sm);
}
.field-chip.is-section { background: none; color: var(--muted); font-weight: 600; padding-inline: 4px; }
.field-chip.is-section::before { content: '§'; margin-inline-end: 4px; color: var(--faint); }

/* ============================================================ فرم‌ساز */

.builder {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 360px;
  gap: var(--s5);
  align-items: start;
}
.bld-palette, .bld-panel {
  position: sticky;
  top: var(--s4);
  max-height: calc(100vh - 2 * var(--s4));
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

/* پالت */
.bld-palette { padding: var(--s3); display: flex; flex-direction: column; gap: var(--s3); }
.bld-palette-title { font-weight: 600; padding-inline: var(--s1); }
.bld-group-title { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; padding-inline: var(--s1); margin-bottom: 4px; }
.bld-types { display: flex; flex-direction: column; gap: 2px; }
.bld-type {
  display: flex;
  align-items: center;
  gap: var(--s2);
  height: 34px;
  padding-inline: var(--s2);
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: var(--fs-sm);
  text-align: start;
  cursor: grab;
}
.bld-type .i { color: var(--muted); flex: none; }
.bld-type:hover { background: var(--hover); border-color: var(--border); }
.bld-type:hover .i { color: var(--accent); }
.bld-type:active { cursor: grabbing; }

/* فرم */
.bld-canvas {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  min-height: 320px;
  padding: var(--s3);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  transition: border-color .12s, background .12s;
}
.bld-canvas.drop-on { border-color: var(--accent); }
.bld-card {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
}
.bld-card:hover { border-color: var(--border-strong); }
.bld-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.bld-card.dragging { opacity: .4; }
.bld-card.draft { border-style: dashed; cursor: default; }
.bld-grip { width: 14px; flex: none; color: var(--faint); cursor: grab; padding-top: 6px; opacity: 0; transition: opacity .12s; }
.bld-card:hover .bld-grip, .bld-card.selected .bld-grip { opacity: 1; }
.bld-ico {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: var(--radius-sm);
  background: var(--fill);
  color: var(--muted);
}
.bld-card.selected .bld-ico { background: var(--accent-soft); color: var(--accent-text); }
.bld-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bld-label { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-weight: 600; }
.bld-label-text { overflow-wrap: anywhere; }
.bld-label .tag.muted { color: var(--muted); }
.bld-meta { color: var(--muted); font-size: var(--fs-xs); line-height: 1.6; }
.bld-meta .code { font-family: ui-monospace, 'Cascadia Mono', monospace; font-size: 11.5px; direction: ltr; unicode-bidi: isolate; }
.bld-move { display: flex; flex-direction: column; gap: 2px; flex: none; opacity: 0; transition: opacity .12s; }
.bld-card:hover .bld-move, .bld-card.selected .bld-move, .bld-card:focus-within .bld-move { opacity: 1; }

/* پیش‌نمایشِ کنترل زیرِ هر کارت */
.bld-preview { margin-top: var(--s2); }
.bld-fake {
  height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding-inline: var(--s2);
  display: flex;
  align-items: center;
  gap: var(--s2);
  color: var(--muted);
  font-size: var(--fs-xs);
  overflow: hidden;
  white-space: nowrap;
}
.bld-fake.tall { height: 54px; }
.bld-fake.mono { font-family: ui-monospace, 'Cascadia Mono', monospace; }
.bld-fake.check { border: 0; background: none; padding: 0; color: var(--text-2); font-size: var(--fs-sm); }
.bld-fake.check .box { width: 16px; height: 16px; border: 1.5px solid var(--border-strong); border-radius: 4px; }
.bld-pills { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.bld-cols { display: flex; flex-wrap: wrap; gap: 4px; }
.bld-col {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding-inline: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--fs-xs);
}
.bld-col.add { border-style: dashed; color: var(--muted); background: none; }

/* «عنوان بخش» روی فرم: سرتیتری با خطِ زیر، نه یک جعبهٔ معمولی */
.bld-card.is-section { background: none; border-color: transparent; border-bottom: 2px solid var(--border-strong); border-radius: 0; padding-block: var(--s4) var(--s2); }
.bld-card.is-section:hover { border-color: transparent; border-bottom-color: var(--accent); }
.bld-card.is-section.selected { box-shadow: none; border-color: transparent; border-bottom-color: var(--accent); }
.bld-card.is-section .bld-label { font-size: var(--fs-lg); }
.bld-card.is-section .bld-ico { background: none; }

.bld-marker { height: 3px; margin-block: -3px; border-radius: 3px; background: var(--accent); flex: none; }
.bld-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 260px;
  color: var(--muted);
  text-align: center;
}

/* تنظیمات */
.bld-panel { display: flex; flex-direction: column; scroll-margin-top: 72px; }
.bld-panel-head {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.bld-panel-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bld-panel-body { padding: var(--s4); display: flex; flex-direction: column; gap: var(--s4); }
.bld-panel-body .grid-2 { grid-template-columns: 1fr; }
.bld-panel-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: var(--s2);
  justify-content: space-between;
  padding: var(--s3) var(--s4);
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.bld-panel-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  padding: var(--s8) var(--s5);
  color: var(--muted);
  text-align: center;
  line-height: 1.8;
}
.bld-panel-empty .title { color: var(--text); font-weight: 600; }

/* «عنوان بخش» در فرمِ رکورد */
.form-section {
  grid-column: 1 / -1;
  padding-top: var(--s3);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  color: var(--text);
}
.form-section:first-child { padding-top: 0; }

/* پهنا از خودِ صفحهٔ محتوا گرفته می‌شود نه پنجره، چون سایدبار هم جا می‌گیرد */
.builder-wrap { container-type: inline-size; }
@container (max-width: 1040px) {
  /* پالت یک ردیفِ لغزانِ بالای فرم؛ فرم و تنظیمات کنارِ هم */
  .builder { grid-template-columns: minmax(0, 1fr) 320px; gap: var(--s4); }
  .bld-palette { grid-column: 1 / -1; position: static; max-height: none; flex-direction: row; overflow-x: auto; padding: var(--s2); gap: var(--s4); }
  .bld-palette-title { display: none; }
  .bld-group { flex: none; }
  .bld-types { flex-direction: row; }
  .bld-type { white-space: nowrap; }
}
@container (max-width: 680px) {
  .builder { grid-template-columns: minmax(0, 1fr); }
  .bld-panel { position: static; max-height: none; }
  .bld-type { border-color: var(--border); }
  .bld-move, .bld-grip { opacity: 1; }
}

.section { border-top: 1px solid var(--border); padding-top: var(--s4); }
.section-title { font-weight: 600; font-size: var(--fs); margin-bottom: var(--s2); }

/* ============================================================ تاریخ و تقویم */

.date-wrap { position: relative; display: flex; gap: var(--s1); align-items: center; }
.date-wrap .input { max-width: 150px; }
.calendar {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-start: 0;
  width: 264px;
  padding: var(--s3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  z-index: 60;
}
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s2); }
.cal-head b { font-size: var(--fs-sm); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-grid span { text-align: center; font-size: 11px; color: var(--muted); padding: 2px 0; }
.cal-grid button {
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  height: 32px;
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.cal-grid button:hover { background: var(--hover); color: var(--text); }
.cal-grid button.today { color: var(--accent-text); font-weight: 700; }
.cal-grid button.sel { background: var(--accent); color: var(--on-accent); }

/* ============================================================ کاشی‌ها */

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--s3); }
.tile {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  padding: var(--s4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color .12s;
}
.tile:hover { border-color: var(--border-strong); }
.tile h3 { font-size: var(--fs); font-weight: 600; }
.tile p { margin: 0 0 var(--s3); color: var(--muted); font-size: var(--fs-sm); flex: 1; }
.tile .btn, .tile .pill { align-self: flex-start; }

/* ============================================================ انتخاب آیکون */

.icon-picker { position: relative; display: inline-block; }
.icon-preview { width: 44px; height: 36px; padding: 0; justify-content: center; background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-2); }
.icon-panel {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-start: 0;
  width: 300px;
  max-height: 300px;
  overflow-y: auto;
  padding: var(--s3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  z-index: 70;
}
.icon-group-title { color: var(--muted); font-size: 11px; font-weight: 600; margin: var(--s2) 2px var(--s1); }
.icon-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.icon-cell { border: 0; background: transparent; border-radius: var(--radius-sm); height: 34px; display: grid; place-items: center; color: var(--text-2); cursor: pointer; }
.icon-cell:hover { background: var(--hover); color: var(--text); }
.icon-cell.sel { background: var(--accent-soft); color: var(--accent-text); box-shadow: inset 0 0 0 1px var(--accent); }

/* آیکونِ خطیِ موجودیت و فضا، کنار اسمشان */
.ent-ico { display: inline-grid; place-items: center; flex: none; line-height: 0; }
.with-ico { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; vertical-align: middle; }
.with-ico .ent-ico { color: var(--muted); }
.act-ico { display: inline-grid; place-items: center; color: var(--muted); }
.act.structural .act-ico { color: var(--accent-text); }
.formula-err, .formula-val { display: inline-flex; align-items: center; gap: 4px; }

/* ============================================================ دستیار */

/* دکمه و پنجرهٔ دستیار سمت چپِ صفحه (انتهای خط)، تا روی سایدبار نیفتند */
#chat-toggle {
  position: fixed;
  bottom: var(--s6);
  inset-inline-end: var(--s6);
  z-index: 80;
  height: 40px;
  padding: 0 var(--s4);
  display: flex;
  gap: var(--s2);
  align-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: background .12s;
}
#chat-toggle:hover { background: var(--accent-hover); }

#chat {
  position: fixed;
  bottom: var(--s6);
  inset-inline-end: var(--s6);
  width: 400px;
  max-width: calc(100vw - 48px);
  height: min(640px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  z-index: 81;
}
#chat header { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s2) var(--s2) var(--s4); border-bottom: 1px solid var(--border); }
#chat header b { font-size: var(--fs); }
#chat header .ico { color: var(--accent); display: grid; }
.chat-log { flex: 1; overflow-y: auto; padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); }
.msg { max-width: 88%; font-size: var(--fs-sm); line-height: 1.8; }
.msg.user {
  align-self: flex-start;
  background: var(--fill);
  color: var(--text);
  padding: 6px var(--s3);
  border-radius: var(--radius-lg);
  border-end-start-radius: 4px;
  white-space: pre-wrap;
}
.msg.assistant { align-self: flex-end; width: 100%; white-space: pre-wrap; color: var(--text-2); }
.msg.thinking { color: var(--muted); display: flex; align-items: center; gap: var(--s2); white-space: normal; }
.thinking-dots { display: inline-flex; gap: 4px; padding: 6px 10px; border-radius: 999px; background: var(--fill); }
.thinking-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: .35; animation: thinking-dot 1.2s ease-in-out infinite; }
.thinking-dots i:nth-child(2) { animation-delay: .15s; }
.thinking-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes thinking-dot { 0%, 80%, 100% { opacity: .35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.thinking-text::after { content: '…'; }
.thinking-time { font-size: var(--fs-xs); color: var(--muted); opacity: .8; }
@media (prefers-reduced-motion: reduce) { .thinking-dots i { animation: none; opacity: .7; } }
.msg .error { color: var(--h-red); }

.act {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-top: 6px;
  padding: var(--s1) var(--s2) var(--s1) var(--s3);
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-2);
  white-space: normal;
}
.act.structural { border-inline-start: 3px solid var(--accent); }
.act .undo { margin-inline-start: auto; }

.chat-input { border-top: 1px solid var(--border); padding: var(--s2); display: flex; gap: var(--s2); align-items: flex-end; }
.chat-input textarea {
  flex: 1;
  min-height: 40px;
  max-height: 140px;
  padding: var(--s2) var(--s3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  resize: none;
  line-height: 1.7;
}
.chat-input textarea:focus { outline: none; border-color: var(--muted); }
.chat-input .btn { height: 40px; }

/* ---- گفتگوها: عنوانِ گفتگوی فعلی، فهرست و جستجوی گفتگوهای قبلی */
#chat { width: 420px; }
.chat-view, .chat-sessions { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-view[hidden], .chat-sessions[hidden] { display: none; }
.chat-title-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  height: 30px;
  padding: 0 var(--s2);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.chat-title-btn:hover { background: var(--hover); }
.chat-title-btn .i { color: var(--muted); flex: none; }
.chat-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 210px; }
#chat header .btn.on { background: var(--accent-soft); color: var(--accent-text); }
.chat-loading { color: var(--muted); font-size: var(--fs-sm); text-align: center; padding: var(--s6) 0; }
.chat-welcome { display: flex; flex-direction: column; gap: var(--s2); margin: auto 0; color: var(--text-2); font-size: var(--fs-sm); line-height: 1.8; }
.chat-welcome b { color: var(--text); font-size: var(--fs); }
.chat-welcome p { margin: 0; }
/* زیرکارها داخلِ هر رکورد: فهرستِ کوتاه و یک خطِ «+ زیرکار تازه» */
.subtasks { display: flex; flex-direction: column; gap: var(--s1); }
.subtasks-head { display: flex; align-items: center; gap: var(--s2); font-weight: 600; color: var(--text); }
.subtasks-list { display: flex; flex-direction: column; }
.subtask { display: flex; align-items: center; gap: var(--s2); padding: 6px var(--s1); border-radius: var(--r-sm, 6px); }
.subtask:hover { background: var(--hover); }
.subtask .subtask-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.subtask.struck .subtask-title { text-decoration: line-through; color: var(--muted); }
.subtask-add { display: flex; align-items: center; gap: var(--s2); padding: 4px var(--s1); }
.subtask-add .input { flex: 1; }
.subtask-add .icon { color: var(--text-2); flex: none; }
.move-pick { display: flex; flex-direction: column; gap: var(--s2); }
.move-pick-list { display: flex; flex-direction: column; max-height: 50vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.move-pick-list button { text-align: start; padding: 8px var(--s3); background: none; border: 0; border-bottom: 1px solid var(--border); cursor: pointer; color: var(--text); font: inherit; }
.move-pick-list button:last-child { border-bottom: 0; }
.move-pick-list button:hover, .move-pick-list button:focus-visible { background: var(--hover); outline: none; }
/* فیلدِ «برچسبی»: چیپ‌های رنگی با دکمهٔ برداشتن، داخلِ همان قابِ ویرایشگرِ هشتگ */
.label-chip { display: inline-flex; align-items: center; gap: 2px; }
.label-chip-x { display: inline-flex; padding: 0; margin-inline-start: 2px; border: 0; background: none; color: inherit; opacity: .6; cursor: pointer; }
.label-chip-x:hover { opacity: 1; }
/* آندو / ری‌دو کنارِ جستجو */
/* بخشِ تاشوی «انجام‌شده‌ها» پایینِ جدول */
tbody tr.section-row > td { padding: var(--s2) var(--s3); background: var(--surface-2, var(--hover)); border-bottom: 1px solid var(--border); }
.section-toggle { display: inline-flex; align-items: center; gap: var(--s2); border: 0; background: none; padding: 0;
  font: inherit; font-weight: 600; color: var(--text-2); cursor: pointer; }
.section-toggle:hover { color: var(--text); }
/* فیلتر با کلیک روی پیل/هشتگ، و نوارِ فیلترهای فعال بالای جدول */
.filter-pill { cursor: pointer; }
.filter-pill:hover { filter: brightness(.95); box-shadow: 0 0 0 1px currentColor inset; }
.filter-pill.filter-on, .tag-chip.filter-on { box-shadow: 0 0 0 1.5px currentColor inset; font-weight: 600; }
.filter-bar { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2); margin: 0 0 var(--s3); padding: var(--s2) var(--s3);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.filter-bar-label { display: inline-flex; align-items: center; gap: var(--s1); font-weight: 600; color: var(--text-2); }
.filter-chip { display: inline-flex; align-items: center; gap: var(--s1); padding: 2px var(--s1) 2px var(--s2); border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); }
.filter-chip-x { display: inline-flex; padding: 2px; border: 0; background: none; color: var(--text-2); cursor: pointer; border-radius: 50%; }
.filter-chip-x:hover { background: var(--hover); color: var(--text); }
.filter-bar .btn { margin-inline-start: auto; }
.undo-controls { display: inline-flex; gap: 2px; }
.undo-btn:disabled { opacity: .35; cursor: default; }
.chat-resume { align-self: flex-start; gap: var(--s1); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-fresh { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2); }
.chat-ideas { display: flex; flex-direction: column; gap: 6px; margin-top: var(--s2); }
.chat-idea {
  padding: var(--s2) var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: var(--fs-sm);
  text-align: start;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.chat-idea:hover { background: var(--hover); border-color: var(--border-strong); color: var(--text); }
.chat-sessions-head { display: flex; gap: var(--s2); align-items: center; padding: var(--s3); border-bottom: 1px solid var(--border); }
.chat-sessions-head .search-box { flex: 1; width: auto; }
.chat-session-list { flex: 1; overflow-y: auto; padding: var(--s1) var(--s2) var(--s3); }
.chat-group { padding: var(--s3) var(--s2) var(--s1); color: var(--muted); font-size: 11.5px; font-weight: 600; }
.chat-session {
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  padding: var(--s2);
  border-radius: var(--radius);
  cursor: pointer;
}
.chat-session:hover, .chat-session:focus-visible { background: var(--hover); outline: none; }
.chat-session.current { background: var(--accent-soft); }
.chat-session-ico { display: grid; place-items: center; width: 26px; height: 26px; flex: none; border-radius: 50%; background: var(--fill); color: var(--muted); }
.chat-session.current .chat-session-ico { color: var(--accent-text); background: var(--surface); }
.chat-session-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.6; }
.chat-session-text .input { min-height: 30px; }
.chat-session-title { font-size: var(--fs-sm); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-session-preview { font-size: var(--fs-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-session-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.chat-session-time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.chat-session-actions { display: flex; gap: 0; opacity: 0; transition: opacity .12s; }
.chat-session:hover .chat-session-actions, .chat-session:focus-within .chat-session-actions { opacity: 1; }
.chat-empty { display: flex; flex-direction: column; align-items: center; gap: var(--s2); padding: var(--s8) var(--s4); color: var(--muted); font-size: var(--fs-sm); text-align: center; line-height: 1.8; }
.chat-empty .i { color: var(--faint); }
@media (hover: none) { .chat-session-actions { opacity: .7; } }

.notice {
  padding: var(--s3);
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: var(--fs-sm);
  line-height: 1.85;
}

/* ============================================================ توست */

#toasts {
  position: fixed;
  bottom: var(--s6);
  inset-inline: 0;
  margin-inline: auto;
  width: max-content;
  max-width: calc(100vw - 32px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  z-index: 200;
  pointer-events: none;
}
#toasts > * { pointer-events: auto; }
.toast {
  display: flex;
  align-items: center;
  gap: var(--s3);
  max-width: 400px;
  padding: 10px var(--s4);
  border-radius: var(--radius);
  background: var(--toast-bg);
  color: #f5f5f5;
  font-size: var(--fs-sm);
  box-shadow: var(--shadow);
  animation: slide-in .18s ease;
}
.toast.err { border-inline-start: 3px solid #ff6b5e; }
.toast-action {
  margin-inline-start: auto;
  border: 0;
  background: transparent;
  color: #ff9d8f;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}
@keyframes slide-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============================================================ فرمول و جمع */

.formula-val { color: var(--text); font-weight: 500; }
.formula-err { color: var(--h-red); font-size: var(--fs-xs); cursor: help; }
.formula-expr { color: var(--muted); font-size: var(--fs-xs); font-family: ui-monospace, 'Cascadia Mono', monospace; }
.negative { color: var(--h-red); }

/* ============================================================ تنظیمات */

.settings-card { padding: 0 var(--s5); }
.settings-card:has(> .settings-card-head) { padding-block: var(--s4); }
.settings-card-head + .hint { margin: var(--s1) 0 var(--s2); }
.setting-row { display: flex; align-items: center; gap: var(--s4); padding: var(--s4) 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: 0; }
.setting-row .select { max-width: 200px; }
.info-card { margin-top: var(--s4); padding: var(--s4) var(--s5); }
.scope-card { margin-bottom: var(--s4); padding: var(--s4) var(--s5); }
.exceptions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); margin-top: var(--s1); }
.exceptions .tag { margin: 0; border: 0; cursor: pointer; font: inherit; font-size: 11px; font-weight: 600; }
.exceptions .tag:hover { background: var(--fill-hover); }

/* ============================================================ بخش تاشو و صفحهٔ رکورد */

.fold-card + .fold-card { margin-top: var(--s4); }
.fold-top { display: flex; align-items: center; gap: var(--s2); padding: var(--s1) var(--s3) var(--s1) var(--s2); }
.fold-head {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  text-align: start;
  cursor: pointer;
}
.fold-head:hover { background: var(--hover); }
.fold-arrow { color: var(--muted); display: grid; flex: none; }
.fold-title { font-weight: 600; font-size: var(--fs); flex: none; }
.fold-sub { color: var(--muted); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fold-actions { flex: none; }
.fold-body { border-top: 1px solid var(--border); }
.fold-body > .detail-grid, .fold-body > .detail-foot { padding: var(--s5); }
.fold-body > .detail-foot { padding-top: 0; }
.fold-body > .detail-tags { padding: 0 var(--s5) var(--s5); }

.modal-body .fold { border-top: 1px solid var(--border); padding-top: var(--s2); }
.modal-body .fold-top { padding: 0; }
.modal-body .fold-body { border-top: 0; padding: var(--s2) var(--s2) 0; display: flex; flex-direction: column; gap: var(--s2); }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s4) var(--s5); }
.detail-grid .span-2 { grid-column: 1 / -1; }

/* ============================================================ نوار بارگذاری */

#loading {
  position: fixed;
  top: 0;
  inset-inline: 0;
  height: 2px;
  background: var(--accent);
  /* transform-origin مقدار منطقی ندارد؛ برنامه همیشه راست‌به‌چپ است */
  transform-origin: right;
  transform: scaleX(0);
  opacity: 0;
  z-index: 300;
  transition: transform .3s ease, opacity .25s;
  pointer-events: none;
}
#loading.on { opacity: 1; transform: scaleX(.75); transition-duration: 1.4s; }
#loading.done { opacity: 0; transform: scaleX(1); transition-duration: .18s; }

/* ============================================================ جستجوگر سریع */

.palette-overlay { padding-top: 12vh; }
.palette {
  width: 100%;
  max-width: 540px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: pop-in .16s cubic-bezier(.2, .9, .3, 1.1);
}
.palette-top { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); color: var(--muted); }
.palette-input { flex: 1; border: 0; background: transparent; outline: none; font-size: 15px; color: var(--text); }
.palette-input:focus-visible { outline: none; }
.palette-input::placeholder { color: var(--muted); }
.palette-list { max-height: 54vh; overflow-y: auto; padding: 6px; }
.palette-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); border-radius: var(--radius-sm); cursor: pointer; color: var(--text); }
.palette-row.active { background: var(--hover); }
.palette-row .ico { width: 22px; display: grid; place-items: center; flex: none; color: var(--muted); }
.palette-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-hint { margin-inline-start: auto; padding-inline-start: var(--s3); color: var(--muted); font-size: var(--fs-xs); flex: none; }
.palette-empty { padding: 28px; text-align: center; color: var(--muted); font-size: var(--fs-sm); }
.palette-foot { display: flex; gap: var(--s4); padding: var(--s2) var(--s4); border-top: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font-size: var(--fs-xs); }

/* ============================================================ فضای کار در سایدبار */

.nav-space { font-weight: 600; }
.nav-space .count { font-weight: 400; }
.nav-toggle {
  width: 18px;
  height: 18px;
  margin-inline-end: -4px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex: none;
}
.nav-toggle:hover { background: var(--fill-hover); color: var(--text); }
/* خط راهنمای عمودی: موجودیت‌های یک فضا زیر سرتیترش آویزان دیده می‌شوند */
.nav-space-block + .nav-space-block { margin-top: 2px; }
/* موجودیتِ انتخاب‌شده: اسمِ کارپوشه‌های بالادستی‌اش (حتی اگر بسته باشند) هم همان رنگِ انتخاب را می‌گیرد */
.nav-space-block:has(.nav-item.active:not(.nav-space)) > .nav-space,
.nav-space-block:has(.nav-item.active:not(.nav-space)) > .nav-space .count { color: var(--accent-text); }
/* کارپوشهٔ انتخاب‌شده: خودش و هرچه زیرش است روی یک زمینهٔ ملایم */
.nav-space-block.current { background: color-mix(in srgb, var(--accent) 6%, transparent); border-radius: var(--radius); padding-bottom: 2px; }
.nav-space-block.current .nav-item:not(.active):hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.nav-group.nested {
  margin-inline-start: 18px;
  padding-inline-start: 6px;
  border-inline-start: 1px solid var(--border-strong);
}
/* زیرکارپوشه‌ها: همان خطِ راهنما، یک لایه جلوتر؛ قبل از موجودیت‌های خودِ کارپوشه */
.nav-children { margin-inline-start: 18px; padding-inline-start: 6px; border-inline-start: 1px solid var(--border-strong); display: flex; flex-direction: column; gap: 1px; }
.nav-children[hidden] { display: none; }
.nav-children .nav-group.nested, .nav-children .nav-children { margin-inline-start: 12px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.crumbs .crumb + .crumb::before { content: '‹'; color: var(--faint); margin-inline-end: 4px; }
.crumb.static { cursor: default; }
.crumb.static:hover { color: inherit; text-decoration: none; }
.member-row.inherited { opacity: .85; }
/* ---- نمای گانت. در RTL زمان از راست به چپ جلو می‌رود؛ ستونِ عنوان‌ها سمتِ راست ثابت است */
.gantt-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-bottom: var(--s3); }
.gantt-card { padding: 0; overflow: hidden; }
.gantt { --g-label: 230px; --g-row: 36px; }
.gantt.compact { --g-label: 190px; --g-row: 32px; }
.g-scroll { overflow: auto; max-height: calc(100vh - 230px); overscroll-behavior: contain; }
.gantt.compact .g-scroll { max-height: 440px; }
.g-grid { width: calc(var(--g-label) + var(--g-track)); position: relative; }
.g-row { display: flex; min-height: var(--g-row); }
.g-label {
  position: sticky; inset-inline-start: 0; z-index: 3; flex: none; width: var(--g-label);
  display: flex; align-items: center; gap: 6px; padding: 0 var(--s3);
  background: var(--surface); border-inline-end: 1px solid var(--border); border-bottom: 1px solid var(--border);
  min-width: 0; font-size: var(--fs-sm);
}
.g-title { flex: 1; min-width: 0; border: 0; background: none; color: var(--text); font: inherit; text-align: start; padding: 0; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-title:hover { color: var(--accent-text); }
.g-row.struck .g-title { text-decoration: line-through; color: var(--muted); }
.g-track { position: relative; flex: none; border-bottom: 1px solid var(--border); }
.g-head { position: sticky; top: 0; z-index: 5; min-height: 52px; }
.g-head .g-label { z-index: 6; background: var(--surface-2); color: var(--muted); font-size: var(--fs-xs); font-weight: 600; }
.g-head .g-track { background: var(--surface-2); }
.g-months { position: relative; height: 26px; border-bottom: 1px solid var(--border); }
.g-month { position: absolute; top: 0; height: 26px; border-inline-start: 1px solid var(--border-strong); padding-inline: 6px; font-size: var(--fs-xs); font-weight: 600; line-height: 26px; white-space: nowrap; overflow: hidden; }
.g-ticks { position: relative; height: 25px; }
.g-tick { position: absolute; top: 0; height: 25px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 10.5px; color: var(--muted); line-height: 1.1; font-variant-numeric: tabular-nums; }
.g-tick small { font-size: 9px; color: var(--faint); }
.g-tick.off { color: var(--h-red); }
.g-body { position: relative; }
.g-lines { position: absolute; inset-block: 0; inset-inline-start: var(--g-label); pointer-events: none; }
.g-line { position: absolute; inset-block: 0; width: 1px; background: var(--border); opacity: .6; }
.g-line.month { background: var(--border-strong); opacity: 1; }
.g-off { position: absolute; inset-block: 0; background: var(--fill); opacity: .6; }
.g-today { position: absolute; inset-block: 0; width: 2px; margin-inline-start: -1px; background: var(--h-red); z-index: 2; }
.g-bounds { position: absolute; inset-block: 0; background: var(--accent-soft); opacity: .45; border-inline: 1px dashed var(--accent); }
.g-group .g-label { background: var(--surface-2); gap: var(--s2); }
.g-group .g-label b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-group .g-label .muted { font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.g-group .g-track { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.g-summary { position: absolute; top: 50%; height: 8px; margin-top: -4px; border-radius: 4px; background: var(--text-2); opacity: .55; }
.g-bar {
  position: absolute; top: 50%; height: 24px; margin-top: -12px; z-index: 1;
  display: flex; align-items: center; overflow: hidden; padding: 0;
  border: 0; border-radius: 6px; cursor: grab; font: inherit;
  background: color-mix(in srgb, var(--g-hue) 22%, var(--surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--g-hue) 55%, transparent);
  color: var(--text); transition: box-shadow .12s;
}
.g-bar:hover { box-shadow: inset 0 0 0 1.5px var(--g-hue), var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, .12)); }
.g-bar:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.g-bar.dragging { cursor: grabbing; opacity: .85; z-index: 4; }
.g-bar.done { opacity: .55; }
.g-bar.late { box-shadow: inset 0 0 0 1.5px var(--h-red); }
.g-bar.outside { background-image: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--h-amber) 25%, transparent) 6px 9px); }
.g-fill { position: absolute; inset-block: 0; inset-inline-start: 0; background: color-mix(in srgb, var(--g-hue) 45%, transparent); pointer-events: none; }
.g-bar-text { position: relative; padding-inline: 8px; font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.g-h { position: absolute; inset-block: 0; width: 7px; cursor: ew-resize; z-index: 2; }
.g-h.start { inset-inline-start: 0; }
.g-h.end { inset-inline-end: 0; }
.g-h:hover { background: color-mix(in srgb, var(--g-hue) 45%, transparent); }
.g-milestone { position: absolute; top: 50%; width: 16px; height: 16px; margin-top: -8px; transform: rotate(45deg); border: 0; border-radius: 3px; background: var(--g-hue); cursor: grab; z-index: 1; }
.g-side { position: absolute; top: 50%; transform: translateY(-50%); font-size: var(--fs-xs); color: var(--text-2); white-space: nowrap; pointer-events: none; }
.g-undated { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); padding: var(--s3); border-top: 1px solid var(--border); }
.project-plan { padding-bottom: 0; overflow: hidden; margin-bottom: var(--s4); }
.project-plan .card-head h2 { display: flex; align-items: center; gap: var(--s2); }
.plan-stats { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); padding: 0 var(--s4) var(--s3); }
.plan-progress { flex: 1 1 240px; display: flex; flex-direction: column; gap: 6px; }
.plan-progress-head { display: flex; align-items: baseline; gap: var(--s2); }
.plan-progress-head b { font-size: var(--fs-lg); font-variant-numeric: tabular-nums; }
.meter { height: 8px; border-radius: 999px; background: var(--fill); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--h-green); }
.plan-flag { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 var(--s2); border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; }
.plan-flag.late { background: color-mix(in srgb, var(--h-red) 12%, transparent); color: var(--h-red); }
.plan-flag.outside { background: color-mix(in srgb, var(--h-amber) 15%, transparent); color: var(--h-amber); }
.project-plan .gantt { border-top: 1px solid var(--border); }
@media (max-width: 860px) {
  .gantt { --g-label: 130px; }
  .gantt.compact { --g-label: 120px; }
  .g-label .avatar { display: none; }
}

/* ---- چیدمان: درختِ راست‌چینِ کارپوشه‌ها و موجودیت‌ها؛ تورفتگی با --level از سمتِ راست */
.arrange { padding: var(--s2) 0; }
.arr-row {
  display: flex; align-items: center; gap: var(--s2); min-height: 44px;
  padding-block: 4px; padding-inline: calc(var(--s4) + var(--level) * 26px) var(--s4);
  position: relative;
}
.arr-row + .arr-row { border-top: 1px solid var(--border); }
.arr-row:hover { background: var(--hover); }
.arr-row[style*="--level:1"]::before, .arr-row[style*="--level:2"]::before, .arr-row[style*="--level:3"]::before {
  content: ''; position: absolute; inset-block: 0; inset-inline-start: calc(var(--s4) + var(--level) * 26px - 14px);
  border-inline-start: 1px solid var(--border-strong);
}
.arr-ico { display: grid; place-items: center; width: 24px; flex: none; color: var(--muted); }
.arr-folder .arr-ico { color: var(--text-2); }
.arr-name { border: 0; background: none; padding: 0; font: inherit; color: var(--text); text-align: start; cursor: pointer; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arr-name:hover { color: var(--accent-text); }
.arr-name.static { cursor: default; }
.arr-name.static:hover { color: var(--text); }
.arr-folder .arr-name { font-weight: 700; }
.arr-meta { font-size: var(--fs-xs); white-space: nowrap; }
.arr-tools { display: flex; align-items: center; gap: 2px; margin-inline-start: auto; flex: none; }
.arr-tools .select { width: 190px; margin-inline: var(--s2); }
.arr-general { background: var(--surface-2); }
.arr-grip { display: grid; place-items: center; width: 22px; height: 30px; flex: none; color: var(--faint); cursor: grab; touch-action: none; border-radius: var(--radius-sm); }
.arr-grip:hover { color: var(--text-2); background: var(--fill); }
.arr-grip.off { cursor: default; background: none; }
.arr-row.dragging { opacity: .4; }
.arr-row.drop-into { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.arr-row.drop-before { box-shadow: inset 0 3px 0 var(--accent); }
.arr-row.drop-after { box-shadow: inset 0 -3px 0 var(--accent); }
.arr-row.drop-no { background: var(--fill); cursor: no-drop; }
.arr-ghost { position: fixed; z-index: 200; pointer-events: none; padding: 6px var(--s3); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow); font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; }
body:has(.arr-ghost) { cursor: grabbing; user-select: none; }
/* زباله‌دان */
.trash-list { padding: 0; }
.trash-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); }
.trash-row + .trash-row { border-top: 1px solid var(--border); }
.trash-bar { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s4); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.trash-count { font-size: var(--fs-sm); }
.trash-pick { flex: none; }
.trash-row.picked { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.trash-ico { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: var(--radius-sm); background: var(--fill); color: var(--muted); }
.trash-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.7; }
.trash-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-text .muted { font-size: var(--fs-xs); }
.trash-left { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
.trash-left.soon { color: var(--h-red); font-weight: 600; }
.trash-actions { display: flex; align-items: center; gap: var(--s1); flex: none; }
@media (max-width: 860px) { .trash-row { flex-wrap: wrap; } .trash-actions { width: 100%; justify-content: flex-end; } .trash-bar { flex-wrap: wrap; } }
.arr-empty { font-size: var(--fs-xs); min-height: 32px; }
@media (max-width: 860px) {
  .arr-row { flex-wrap: wrap; padding-inline: calc(var(--s3) + var(--level) * 16px) var(--s3); }
  .arr-row::before { display: none; }
  .arr-tools { width: 100%; margin-inline-start: 0; flex-wrap: wrap; }
  .arr-tools .select { flex: 1; width: auto; margin-inline: 0 var(--s2); }
}

/* برچسب‌ها */
.tag-chip { display: inline-flex; align-items: center; height: 22px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; max-width: 180px; }
.tag-chip.sm { height: 19px; font-size: 11px; font-weight: 500; }
.tag-chip-name { border: 0; background: none; color: inherit; font: inherit; padding: 0 8px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; height: 100%; border-radius: 999px; }
.tag-chip-name:hover { text-decoration: underline; }
.tag-chip-x { display: grid; place-items: center; width: 18px; height: 18px; margin-inline-end: 2px; border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer; opacity: .7; }
.tag-chip-x:hover { opacity: 1; background: rgba(0, 0, 0, .08); }
.tag-chip-name:has(+ .tag-chip-x) { padding-inline-end: 2px; }
.row-tags { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-inline-start: var(--s2); vertical-align: middle; }
.tag-editor { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 36px; padding: 3px var(--s2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: text; transition: border-color .12s, box-shadow .12s; }
.tag-editor:hover { border-color: var(--control); }
.tag-editor:focus-within { border-color: var(--muted); box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 7%, transparent); }
.tag-editor > .i { color: var(--muted); flex: none; }
.tag-editor-chips { display: contents; }
.tag-editor-input { flex: 1; min-width: 140px; border: 0; outline: 0; background: none; color: var(--text); font: inherit; font-size: var(--fs-sm); height: 28px; }
.field-wide { grid-column: 1 / -1; }
.record-form > .field { margin-top: var(--s3); }
.detail-tags { margin-top: var(--s4); }
.tag-cloud { display: flex; flex-wrap: wrap; gap: var(--s2); padding: var(--s4); }
.tag-cloud-item { display: inline-flex; align-items: center; gap: var(--s2); height: 34px; padding: 0 var(--s3); border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.tag-cloud-item:hover { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
.tag-cloud-item .count { color: var(--muted); font-weight: 400; font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.tag-group { margin-bottom: var(--s4); }
.tag-group .card-head h2 { display: flex; align-items: center; gap: var(--s2); }
.kcard-labels .tag-chip { max-width: 140px; }

/* حافظهٔ روزبان */
.memory { display: flex; flex-direction: column; gap: var(--s3); }
.memory-list { border: 1px solid var(--border); border-radius: var(--radius); }
.memory-row { display: flex; align-items: flex-start; gap: var(--s2); padding: var(--s2) var(--s3); }
.memory-row + .memory-row { border-top: 1px solid var(--border); }
.memory-ico { display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 50%; background: var(--fill); color: var(--muted); margin-top: 2px; }
.memory-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.8; overflow-wrap: anywhere; }
.memory-text .muted { font-size: var(--fs-xs); }
.memory-actions { display: flex; flex: none; opacity: .55; transition: opacity .12s; }
.memory-row:hover .memory-actions, .memory-row:focus-within .memory-actions { opacity: 1; }
.memory-edit { flex: 1; display: flex; flex-direction: column; gap: var(--s2); }
.memory-empty { display: flex; align-items: center; gap: var(--s2); padding: var(--s3); color: var(--muted); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.memory-add { display: flex; flex-direction: column; gap: var(--s2); }
.memory-add .row { align-items: center; gap: var(--s3); }
@media (hover: none) { .memory-actions { opacity: 1; } }
/* منوی راست‌کلیک و لمسِ طولانیِ سایدبار */
.sidebar .nav-item { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.nav-menu { min-width: 230px; }
.nav-menu .menu-head { padding-block: var(--s1); color: var(--muted); }

.delete-choices { display: flex; flex-direction: column; gap: var(--s2); }
.delete-choice { display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; text-align: start; cursor: pointer; }
.delete-choice:hover:not(:disabled) { background: var(--hover); border-color: var(--border-strong); }
.delete-choice > div { display: flex; flex-direction: column; gap: 2px; line-height: 1.8; }
.delete-choice span { color: var(--muted); font-size: var(--fs-sm); }
.delete-choice > .i { color: var(--muted); flex: none; margin-top: 3px; }
.delete-choice.danger > .i, .delete-choice.danger b { color: var(--danger, var(--h-red)); }
.delete-choice.danger:hover:not(:disabled) { border-color: var(--danger, var(--h-red)); }
.delete-choice:disabled { opacity: .5; cursor: not-allowed; }
.widget-list.sub-spaces { border-bottom: 1px solid var(--border); }
.nav-divider { border: 0; border-top: 1px solid var(--border); margin: var(--s3) var(--s2) 0; }
/* هر گروهی که بعد از خطِ جداکننده می‌آید همان فاصله‌ای را دارد که «سیستم» دارد */
.nav-divider + .nav-group { margin-top: var(--s2); }
.nav-divider.short { width: 50%; margin-inline: auto; margin-block: var(--s2) var(--s1); }
.brand-home { display: flex; align-items: center; gap: var(--s2); color: inherit; text-decoration: none; border-radius: var(--radius-sm); padding: 2px 4px; margin: -2px -4px; }
.brand-home:hover { background: var(--hover); }
.brand-home:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
/* دکمه‌های ساختن: کم‌رنگ‌تر از آیتم‌های فهرست، چون «جا» نیستند، «کار»ند */
.nav-actions { margin-top: var(--s2); }
.nav-create { color: var(--muted); }
.nav-create:hover { color: var(--text); }
.nav-create .ico { color: var(--accent-text); }
.nav-group[hidden] { display: none; }
.nav-empty {
  margin: 0 var(--s2) 2px;
  padding: 2px var(--s2);
  border: 1px dashed transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: var(--fs-xs);
}
.nav-dragging .nav-empty { border-color: var(--border-strong); padding-block: var(--s1); }
.nav-space.drop-target { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }

.crumb {
  display: inline-block;
  padding: 0;
  margin-bottom: 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-xs);
  cursor: pointer;
}
.crumb:hover { color: var(--accent-text); text-decoration: underline; }

/* ============================================================ صفحهٔ خانه */

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); margin-bottom: var(--s5); }
.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: var(--s3) var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: start;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.stat:hover { border-color: var(--border-strong); background: var(--surface-2); }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.3; color: var(--text); }
.stat-label { font-size: var(--fs-xs); color: var(--muted); }
.stat.overdue .stat-value { color: var(--h-red); }
.stat.today .stat-value { color: var(--h-green); }
.stat.done .stat-value { color: var(--h-green); }

.home-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: var(--s4); align-items: start; }
.home-col { display: flex; flex-direction: column; gap: var(--s4); min-width: 0; }

.card-head { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s3) var(--s3) var(--s4); border-bottom: 1px solid var(--border); }
.card-head h2 { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs); font-weight: 600; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.card-head h2 .i { color: var(--muted); }
.card-head .count { color: var(--muted); font-size: var(--fs-xs); }
.card-body { padding: var(--s4); }

/* دستورکار — فهرستی مثل Todoist، نه جدول */
.agenda-section + .agenda-section { border-top: 1px solid var(--border); }
.agenda-title {
  display: flex;
  align-items: baseline;
  gap: var(--s2);
  margin: 0;
  padding: var(--s3) var(--s4) var(--s1);
  font-size: var(--fs-sm);
  font-weight: 700;
}
.agenda-title.overdue { color: var(--h-red); }
.agenda-title.today { color: var(--h-green); }
.agenda-title .count { color: var(--muted); font-weight: 400; font-size: var(--fs-xs); }
.agenda-list { padding: 0 var(--s2) var(--s2); }
.agenda-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: 48px;
  padding: 6px var(--s2);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .12s, opacity .25s;
}
.agenda-row:hover, .agenda-row:focus-visible { background: var(--hover); outline: none; }
.agenda-row.done { opacity: .45; }
.agenda-row.done .agenda-text { text-decoration: line-through; }
.agenda-dot { width: 18px; height: 18px; flex: none; display: grid; place-items: center; }
.agenda-dot::after { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.agenda-main { flex: 1; min-width: 0; }
.agenda-text { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--s2); color: var(--muted); font-size: var(--fs-xs); line-height: 1.6; }
.agenda-folder, .agenda-sub { display: inline-flex; align-items: center; gap: 3px; color: var(--muted); white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.agenda-folder bdi { overflow: hidden; text-overflow: ellipsis; }
.agenda-sub.all { color: var(--h-green); }
.agenda-meta .pill { height: 18px; font-size: 11px; padding: 0 6px; }
.agenda-col { white-space: nowrap; }
.agenda-row .date { font-size: var(--fs-xs); flex: none; }
.agenda-more {
  margin: var(--s1) var(--s2);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-text);
  font-size: var(--fs-xs);
  cursor: pointer;
}
.agenda-more:hover { text-decoration: underline; }

/* گزارش */
.report-title { font-weight: 600; display: flex; align-items: center; flex-wrap: wrap; gap: var(--s1); }
.report-when { font-size: var(--fs-xs); margin-bottom: var(--s3); }
.report-chips { display: flex; flex-wrap: wrap; gap: var(--s1); margin-bottom: var(--s3); }
.report-text { white-space: pre-wrap; color: var(--text-2); line-height: 1.9; font-size: var(--fs-sm); }
.report-list { margin-top: var(--s3); }
.report-list-title { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.report-list ul { margin: var(--s1) 0 0; padding-inline-start: var(--s5); color: var(--text-2); font-size: var(--fs-sm); }
.report-history { display: flex; flex-direction: column; gap: var(--s3); }
.report-history .fold-card + .fold-card { margin-top: 0; }

/* نماهای سنجاق‌شده */
.widget-list { padding: var(--s1) var(--s2); }
.widget-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: 40px;
  padding: var(--s1) var(--s2);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.widget-row:hover, .widget-row:focus-visible { background: var(--hover); outline: none; }
.widget-row + .widget-row { border-top: 1px solid var(--border); }
.widget-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.widget-row.struck .widget-title { text-decoration: line-through; color: var(--muted); }
.widget-cells { display: flex; align-items: center; gap: var(--s2); flex: none; font-size: var(--fs-xs); color: var(--text-2); }
.widget-cell .pill { height: 20px; font-size: 11px; }
.widget-foot { display: flex; flex-wrap: wrap; gap: var(--s4); padding: var(--s2) var(--s4); border-top: 1px solid var(--border); background: var(--surface-2); font-size: var(--fs-sm); }

.home-hint { padding: var(--s4); }
.home-hint .title { display: flex; align-items: center; gap: var(--s2); font-weight: 600; margin-bottom: var(--s1); }
.home-hint p { margin: 0 0 var(--s3); color: var(--muted); font-size: var(--fs-sm); }

/* چیدمان با کشیدن: دستگیره بالای هر کارت، فقط زیر ماوس */
.home-card { position: relative; }
.home-col { min-height: 80px; }
.card-grip {
  position: absolute;
  top: -1px;
  inset-inline: 0;
  margin-inline: auto;
  width: 40px;
  height: 14px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 0 0 6px 6px;
  background: var(--fill);
  color: var(--muted);
  cursor: grab;
  opacity: 0;
  z-index: 3;
  transition: opacity .12s;
}
.card-grip .i { transform: rotate(90deg); }
.home-card:hover > .card-grip, .card-grip:focus-visible { opacity: 1; }
.card-grip:active { cursor: grabbing; }
@media (hover: none) { .card-grip { opacity: .7; } }
.home-card.dragging { opacity: .45; }
.home-grid.arranging .home-col {
  outline: 2px dashed var(--border-strong);
  outline-offset: 4px;
  border-radius: var(--radius-lg);
}

/* برنامهٔ امروز */
.schedule-day { padding: var(--s2) var(--s2) 0; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.schedule-time { flex: none; min-width: 64px; font-size: var(--fs-sm); color: var(--accent-text); font-weight: 600; }
.agenda-title .i { color: var(--muted); }

@media (max-width: 1100px) {
  .home-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ============================================================ اتصال‌ها */

.section-heading { font-size: var(--fs-lg); font-weight: 700; margin: var(--s8) 0 var(--s3); }
.integration-body { display: flex; flex-direction: column; gap: var(--s4); }
.integration-setup, .integration-sync { display: flex; flex-direction: column; gap: var(--s4); }
.steps { margin: 0; padding-inline-start: var(--s5); display: flex; flex-direction: column; gap: var(--s2); color: var(--text-2); font-size: var(--fs-sm); line-height: 1.9; }
.copyable {
  display: inline-block;
  padding: 2px var(--s2);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: ui-monospace, 'Cascadia Mono', monospace;
  font-size: 12px;
  user-select: all;
  overflow-wrap: anywhere;
}
.push-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); }
.push-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); }
.push-row + .push-row { border-top: 1px solid var(--border); }
.push-row .select { max-width: 200px; }
.error-text { color: var(--h-red); }

/* ============================================================ ورود و ثبت‌نام */

body.auth-mode .app { grid-template-columns: minmax(0, 1fr); }
body.auth-mode .sidebar { display: none; }
body.auth-mode .main { padding: 0; }

.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s4);
  padding: var(--s8) var(--s4);
  background:
    radial-gradient(1200px 500px at 50% -10%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
    var(--sidebar);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  padding: var(--s8) var(--s8) var(--s6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.auth-brand { display: flex; justify-content: center; margin-bottom: var(--s4); }
.auth-card h1 { font-size: 22px; text-align: center; }
.auth-sub { color: var(--muted); text-align: center; font-size: var(--fs-sm); margin: var(--s1) 0 var(--s6); }
.auth-form { display: flex; flex-direction: column; gap: var(--s4); }
.auth-form .input { min-height: 42px; }
.auth-submit { height: 42px; font-size: var(--fs); margin-top: var(--s1); }
.auth-error {
  padding: var(--s2) var(--s3);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--h-red) 10%, transparent);
  color: var(--h-red);
  font-size: var(--fs-sm);
}
.auth-link { border: 0; background: none; padding: 0; color: var(--accent-text); font-weight: 600; cursor: pointer; }
.auth-link:hover { text-decoration: underline; }
.auth-link.small { align-self: flex-start; font-weight: 500; font-size: var(--fs-xs); margin-top: calc(-1 * var(--s2)); }
.auth-switch { color: var(--muted); font-size: var(--fs-sm); margin: 0; }
.auth-done { display: flex; flex-direction: column; align-items: center; gap: var(--s3); text-align: center; color: var(--text-2); }
.auth-done .i { color: var(--h-green); }

/* ============================================================ کاربر و منو */

.brand .spacer { margin-inline-start: auto; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 150px;
  height: 30px;
  padding: 0 6px 0 4px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.user-chip:hover { background: var(--hover); }
.user-chip .user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); }
.user-chip .tag { margin: 0; }
.avatar {
  width: 24px;
  height: 24px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--hue, var(--h-blue)) 18%, var(--surface));
  color: color-mix(in srgb, var(--hue, var(--h-blue)) 85%, var(--text));
  font-size: 12px;
  font-weight: 700;
}
.menu-pop {
  position: fixed;
  z-index: 150;
  min-width: 220px;
  padding: var(--s1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  animation: pop-in .14s ease;
}
.menu-pop hr { border: 0; border-top: 1px solid var(--border); margin: var(--s1) 0; }
.menu-head { display: flex; flex-direction: column; padding: var(--s2) var(--s3); line-height: 1.5; }
.menu-head .muted { font-size: var(--fs-xs); }
.menu-item {
  display: flex;
  align-items: center;
  gap: var(--s2);
  width: 100%;
  min-height: 34px;
  padding: 0 var(--s3);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  text-align: start;
  cursor: pointer;
}
.menu-item:hover { background: var(--hover); }
.menu-item .i { color: var(--muted); }
.menu-item.danger, .menu-item.danger .i { color: var(--h-red); }

/* ============================================================ زبانه‌ها و پنل مدیریت */

.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--border); margin-bottom: var(--s5); overflow-x: auto; }
.tab {
  height: 38px;
  padding: 0 var(--s3);
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--accent-text); border-bottom-color: var(--accent); }
.admin-body { display: flex; flex-direction: column; gap: var(--s3); }
.admin-body .stats { margin-bottom: 0; }
.stat.static { cursor: default; }
.stat.static:hover { background: var(--surface); border-color: var(--border); }
.mail-body {
  margin: var(--s3) 0 0;
  padding: var(--s3);
  background: var(--surface-2);
  border-radius: var(--radius);
  white-space: pre-wrap;
  font-family: inherit;
  font-size: var(--fs-sm);
  color: var(--text-2);
  overflow-wrap: anywhere;
}

/* ============================================================ خوشامد */

.onboard {
  max-width: 760px;
  margin: 6vh auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--s3);
}
.onboard h1 { font-size: 26px; }
.onboard-sub { color: var(--text-2); max-width: 520px; margin: 0 0 var(--s4); }
.onboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--s3); width: 100%; }
.onboard-choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s2);
  padding: var(--s5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  text-align: start;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.onboard-choice:hover { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.onboard-choice.primary { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 4%, var(--surface)); }
.onboard-ico { font-size: 22px; color: var(--accent-text); display: grid; }
.onboard-title { font-weight: 700; font-size: var(--fs-lg); }
.onboard-text { color: var(--muted); font-size: var(--fs-sm); line-height: 1.8; }

/* چیدنِ اولیه با دستیار */
.onboard-chat { max-width: 680px; margin-top: 3vh; text-align: start; align-items: stretch; }
.onboard-chat h1 { text-align: center; }
.onboard-chat-log {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  min-height: 160px;
  max-height: 52vh;
  overflow-y: auto;
  padding: var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.onboard-chat-log .msg { font-size: var(--fs); }
.onboard-examples { display: flex; flex-wrap: wrap; gap: 6px; }
.onboard-examples .pick { --hue: var(--accent); height: auto; min-height: 28px; padding: 4px var(--s3); white-space: normal; text-align: start; }
.onboard-input { display: flex; gap: var(--s2); align-items: flex-end; }
.onboard-input .textarea { flex: 1; resize: none; }
.onboard-title .tag { margin-inline-start: var(--s2); vertical-align: middle; }

/* ============================================================ اشتراک و پلن‌ها */

.menu-plan { margin-top: var(--s1); }
.current-plan { padding: var(--s5); display: flex; flex-direction: column; gap: var(--s4); }
.plan-name { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: var(--s2); }
.usage { display: flex; flex-direction: column; gap: var(--s2); max-width: 420px; }
.usage-label { font-size: var(--fs-sm); color: var(--text-2); }
.usage-bar { height: 6px; border-radius: 999px; background: var(--fill); overflow: hidden; }
.usage-bar span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.period-toggle { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--radius); background: var(--fill); }
.period-toggle .tab { height: 30px; border: 0; margin: 0; border-radius: calc(var(--radius) - 2px); }
.period-toggle .tab.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm, 0 1px 2px rgb(0 0 0 / .08)); }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--s4); }
.plan-card {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  padding: var(--s5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.plan-card.featured {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 3%, var(--surface));
  box-shadow: var(--shadow);
}
.plan-card > .btn { margin-top: auto; justify-content: center; }
.plan-title { font-size: var(--fs-lg); font-weight: 700; }
.plan-price { font-size: 24px; font-weight: 700; }
.plan-price .muted { font-size: var(--fs-sm); font-weight: 400; }
.plan-desc { margin: 0; color: var(--text-2); font-size: var(--fs-sm); line-height: 1.8; }
.plan-features { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); font-size: var(--fs-sm); }
.plan-features li { display: flex; align-items: center; gap: var(--s2); }
.plan-features li.yes .i { color: var(--h-green); }
.plan-features li.no { color: var(--muted); }
.plan-features li.no .i { color: var(--muted); }

.upgrade { display: flex; flex-direction: column; align-items: center; gap: var(--s3); text-align: center; }
.upgrade .plan-features { align-self: stretch; text-align: start; }
.upgrade-ico {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--accent-text);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.upgrade-text { margin: 0; font-weight: 600; }
.upgrade-notice { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); }

/* ============================================================ گزارش‌ها */

.report-cats { margin-bottom: var(--s4); }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s3); }
.report-card {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  text-align: start;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
}
.report-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.report-card-head { display: flex; align-items: center; gap: var(--s2); }
.report-card-ico { color: var(--accent-text); display: grid; }
.report-card-title { font-size: var(--fs-lg); }
.report-card-desc { margin: 0; color: var(--text-2); font-size: var(--fs-sm); line-height: 1.8; }
.report-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); font-size: var(--fs-xs); }
.report-card-foot { display: flex; gap: var(--s2); font-size: var(--fs-xs); margin-top: auto; }
.report-empty p { max-width: 520px; margin: var(--s2) auto 0; color: var(--text-2); line-height: 1.9; }
.report-empty .actions { flex-wrap: wrap; }
.report-empty .select { max-width: 240px; }

.report-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s4);
  padding: var(--s3);
  margin-bottom: var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}
.report-toolbar .select { width: auto; max-width: 280px; }
.report-run { display: flex; flex-direction: column; gap: var(--s4); }
.report-period { font-size: var(--fs-sm); }
.report-status { padding: var(--s4) var(--s5); }
.report-status-head { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s2); }
.report-status-ico { color: var(--accent-text); display: grid; }
.report-status-body { white-space: pre-wrap; line-height: 2; color: var(--text); }

.report-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s3); }
.kpi { padding: var(--s4); display: flex; flex-direction: column; gap: var(--s1); }
.kpi-label { color: var(--text-2); font-size: var(--fs-sm); }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1.3; }
.kpi-delta { display: flex; align-items: center; gap: 4px; font-size: var(--fs-xs); }
.kpi-delta.good { color: var(--h-green); }
.kpi-delta.bad { color: var(--h-red); }
.kpi-delta .muted { color: var(--muted); }

/* dense: بلوک‌های نیم‌عرض کنار هم می‌نشینند، حتی اگر یک بلوکِ تمام‌عرض بینشان باشد */
.report-blocks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-flow: row dense; gap: var(--s3); }
.report-block { display: flex; flex-direction: column; min-width: 0; }
.report-block.full { grid-column: 1 / -1; }
.report-block-head { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s4) 0; }
.report-block-tools { display: flex; align-items: center; gap: var(--s1); font-size: var(--fs-xs); }
.report-block-body { padding: var(--s3) var(--s4); min-width: 0; }
.report-block-foot { padding: 0 var(--s4) var(--s3); font-size: var(--fs-xs); }
.report-block-error { display: flex; align-items: center; gap: var(--s2); padding: var(--s4); color: var(--h-red); font-size: var(--fs-sm); }
.report-text { white-space: pre-wrap; line-height: 2; }
.empty.small { padding: var(--s5); font-size: var(--fs-sm); }
.link-btn { border: 0; background: none; padding: 0; color: var(--text); cursor: pointer; text-align: start; font: inherit; }
.link-btn:hover { color: var(--accent-text); text-decoration: underline; }
tfoot td { font-weight: 600; background: var(--surface-2); }

.progress-big { display: flex; flex-direction: column; gap: var(--s3); }
.progress-num { font-size: 34px; font-weight: 700; line-height: 1; }
.progress-meter { height: 10px; border-radius: 999px; background: color-mix(in srgb, var(--series-1) 18%, var(--surface)); overflow: hidden; }
.progress-meter span { display: block; height: 100%; border-radius: inherit; background: var(--series-1); }
.progress-legend { display: flex; flex-wrap: wrap; gap: var(--s4); font-size: var(--fs-sm); color: var(--text-2); }
.progress-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.chart-swatch.track { background: color-mix(in srgb, var(--series-1) 18%, var(--surface)); }
.overdue-note { color: var(--h-red); }

/* ویرایشگر گزارش */
.block-list { display: flex; flex-direction: column; gap: var(--s2); margin: var(--s3) 0; }
.block-editor { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--s3); display: flex; flex-direction: column; gap: var(--s3); background: var(--surface-2); }
.block-editor-head { display: flex; align-items: center; gap: var(--s2); }
.block-editor-head .input { flex: 1; }
.block-editor-head .flip .i { transform: rotate(180deg); }

/* نمودارها */
.chart { position: relative; min-width: 0; }
.chart-canvas { width: 100%; min-width: 0; }
.chart-svg { display: block; overflow: visible; font-family: inherit; }
.chart-grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart-base { stroke: var(--border-strong); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 11px; }
.chart-label { fill: var(--text-2); font-size: 12px; }
.chart-value { fill: var(--text-2); font-size: 11px; }
.chart-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { opacity: .1; }
.chart-dot { stroke: var(--surface); stroke-width: 2; }
.chart-cross { stroke: var(--border-strong); stroke-width: 1; }
.chart-hit { fill: transparent; cursor: default; }
.chart-hit.on { fill: color-mix(in srgb, var(--text) 4%, transparent); }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); margin-bottom: var(--s2); font-size: var(--fs-xs); color: var(--text-2); }
.chart-key { display: inline-flex; align-items: center; gap: 6px; }
.chart-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }
.chart-tip {
  position: absolute;
  z-index: 5;
  min-width: 140px;
  max-width: 260px;
  padding: var(--s2) var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: var(--fs-xs);
  pointer-events: none;
}
.chart-tip-title { font-weight: 600; margin-bottom: 4px; color: var(--text); }
.chart-tip-row { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.chart-tip-name { flex: 1; }
.chart-tip-row b { color: var(--text); }
.chart-table td, .chart-table th { white-space: nowrap; }
.donut-body { display: flex; align-items: center; gap: var(--s5); flex-wrap: wrap; }
.donut-track { fill: none; stroke: var(--surface-2); }
.donut-seg { cursor: default; }
.donut-total { fill: var(--text); font-size: 20px; font-weight: 700; }
.donut-legend { display: flex; flex-direction: column; gap: var(--s2); flex: 1; min-width: 160px; font-size: var(--fs-sm); }
.donut-row { display: flex; align-items: center; gap: var(--s2); }
.donut-name { flex: 1; color: var(--text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-val { color: var(--text); }
.donut-pct { width: 40px; text-align: end; }

@media (max-width: 860px) {
  .report-blocks { grid-template-columns: minmax(0, 1fr); }
  .report-toolbar { align-items: stretch; }
}

/* چاپ / PDF: فقط خودِ گزارش */
/* ============================================================ روتین‌ها */

.routine-list { display: flex; flex-direction: column; gap: var(--s3); }
.routine-card { padding: var(--s4); display: flex; flex-direction: column; gap: var(--s2); }
.routine-card.off { background: var(--surface-2); }
.routine-card.off .routine-title, .routine-card.off .routine-prompt { color: var(--text-2); }
.routine-head { display: flex; align-items: center; gap: var(--s2); }
.routine-title { font-size: var(--fs-lg); min-width: 0; }
.routine-prompt {
  margin: 0; color: var(--text-2); font-size: var(--fs-sm); line-height: 1.9;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.routine-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); font-size: var(--fs-xs); }
.routine-chan {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border: 1px solid var(--border); border-radius: 999px; color: var(--text-2);
}
.routine-chan.warn { color: var(--h-orange); border-color: currentColor; }
.routine-last summary {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font-size: var(--fs-sm); color: var(--text-2);
}
.routine-last summary .ico, .routine-last summary svg { color: var(--h-red); }
.routine-output {
  margin-top: var(--s2); padding: var(--s3) var(--s4); border-radius: var(--radius);
  background: var(--surface-2); white-space: pre-wrap; line-height: 2; color: var(--text);
}
.routine-output.failed { color: var(--h-red); }
.routine-runs { display: flex; flex-direction: column; gap: var(--s3); max-height: 60vh; overflow: auto; }
.routine-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.routine-say {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3);
  margin-top: var(--s4); padding: var(--s3) var(--s4);
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
  color: var(--text-2); font-size: var(--fs-sm); line-height: 1.9;
}
.routine-say > span:nth-child(2) { flex: 1 1 260px; }
.routine-say-ico { color: var(--accent-text); display: grid; }
.routine-empty p { max-width: 520px; margin: var(--s2) auto 0; color: var(--text-2); line-height: 1.9; }
.routine-empty + .routine-templates { margin-top: var(--s4); }
.routine-upgrade { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); }
.routine-upgrade p { margin: 0; color: var(--text-2); line-height: 1.9; }

/* کلیدِ روشن/خاموش */
.switch { position: relative; display: inline-flex; cursor: pointer; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch-track {
  width: 36px; height: 20px; border-radius: 999px; background: var(--border-strong);
  position: relative; transition: background .15s;
}
.switch-track::after {
  content: ''; position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .25); transition: inset-inline-start .15s;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { inset-inline-start: 18px; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============================================================ نما: جدول | تخته */

.seg {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border-radius: var(--radius-sm);
  background: var(--fill);
}
.seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 var(--s3);
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.select.sm { min-height: 28px; height: 28px; padding: 0 8px; font-size: var(--fs-xs); width: auto; }

/* ============================================================ تخته (کانبان) */

.board-bar { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s3); min-height: 28px; }
.board-group-by { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--fs-xs); }
.board-count { font-size: var(--fs-xs); }
.board-tip { margin-inline-start: auto; font-size: var(--fs-xs); }

.board {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  overflow-x: auto;
  padding-bottom: var(--s4);
  /* تخته تا لبهٔ صفحه می‌رود تا ستون‌های بیشتری جا شوند */
  margin-inline: calc(-1 * var(--s10));
  padding-inline: var(--s10);
  scroll-padding-inline: var(--s10);
  min-height: 60vh;
}
.kcol {
  flex: 0 0 280px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 210px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color .12s, background .12s;
}
.kcol.drop { border-color: color-mix(in srgb, var(--hue, var(--accent)) 55%, transparent); background: color-mix(in srgb, var(--hue, var(--accent)) 5%, var(--surface-2)); }
.kcol-head {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s3) var(--s3) var(--s2);
  border-top: 3px solid color-mix(in srgb, var(--hue, var(--h-slate)) 70%, transparent);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.kcol.none .kcol-head { border-top-style: dashed; }
.kcol-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--hue, var(--h-slate)); flex: none; }
.kcol-title { font-size: var(--fs-sm); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcol-count {
  margin-inline-start: auto;
  min-width: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.kcol-cards {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: var(--s1) var(--s2) var(--s2);
  overflow-y: auto;
  min-height: 48px;
  flex: 1;
}
.kcol-add { padding: 0 var(--s2) var(--s2); display: flex; flex-direction: column; gap: var(--s2); }
.kcol-add .row { gap: var(--s1); }
.kcol-add-btn {
  display: flex;
  align-items: center;
  gap: var(--s2);
  width: 100%;
  height: 34px;
  padding: 0 var(--s2);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.kcol-add-btn:hover { background: var(--hover); color: var(--text); }
.kcol.add-col { background: transparent; border-style: dashed; padding: var(--s2); gap: var(--s2); }
.kcard-input { min-height: 60px; resize: none; }

.kcard {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: 10px var(--s3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
  cursor: pointer;
  user-select: none;
  -webkit-touch-callout: none;
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.kcard:hover { border-color: var(--border-strong); box-shadow: 0 2px 6px rgba(0, 0, 0, .07); }
.kcard:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.kcard.lifted { transform: scale(1.02); box-shadow: var(--shadow); }
.kcard-title { display: flex; align-items: flex-start; gap: var(--s2); font-size: var(--fs); line-height: 1.6; overflow-wrap: anywhere; }
.kcard-title .tick { margin-top: 3px; flex: none; }
.kcard.struck .kcard-title span { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.kcard-labels { display: flex; flex-wrap: wrap; gap: 4px; }
.pill.sm { height: 18px; padding: 0 6px; font-size: 11px; }
.kcard-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.kchip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 6px;
  border-radius: 5px;
  color: var(--text-2);
  font-size: 11.5px;
  white-space: nowrap;
  unicode-bidi: isolate;
}
.kchip .i { color: var(--muted); flex: none; }
.kchip.done { background: color-mix(in srgb, var(--h-green) var(--pill-bg), transparent); color: color-mix(in srgb, var(--h-green) var(--pill-text), var(--text)); }
.kchip.done .i { color: inherit; }
.date-chip.overdue { background: color-mix(in srgb, var(--h-red) var(--pill-bg), transparent); color: color-mix(in srgb, var(--h-red) var(--pill-text), var(--text)); }
.date-chip.today { background: color-mix(in srgb, var(--h-green) var(--pill-bg), transparent); color: color-mix(in srgb, var(--h-green) var(--pill-text), var(--text)); }
.date-chip.tomorrow { background: color-mix(in srgb, var(--h-orange) var(--pill-bg), transparent); color: color-mix(in srgb, var(--h-orange) var(--pill-text), var(--text)); }
.date-chip.overdue .i, .date-chip.today .i, .date-chip.tomorrow .i { color: inherit; }
.kcard-people { display: inline-flex; margin-inline-start: auto; }
.kcard-people .avatar + .avatar { margin-inline-start: -6px; }
.kcard-people .avatar { box-shadow: 0 0 0 2px var(--surface); }

/* کارتی که در دست است؛ مختصاتِ fixed از خودِ اشاره‌گر می‌آید (فیزیکی، نه منطقی) */
.kcard-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 200;
  pointer-events: none;
  box-shadow: var(--shadow);
  opacity: .96;
  transition: none;
}
.kcard-placeholder {
  border: 2px dashed color-mix(in srgb, var(--accent) 40%, var(--border-strong));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 4%, transparent);
  flex: none;
}
body.board-dragging, body.board-dragging * { cursor: grabbing !important; user-select: none; }

/* ============================================================ آدم‌ها */

.avatar.ghost { background: var(--fill); color: var(--muted); }
.avatar.more { background: var(--fill); color: var(--text-2); font-size: 11px; }
.person-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.person-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people-pick { gap: var(--s1); }
.person-pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding-block: 0;
  padding-inline: 4px var(--s3);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.person-pick:hover { background: var(--hover); }
.person-pick.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.shared-mark { display: inline-flex; margin-inline-start: 6px; color: var(--muted); vertical-align: -1px; }
.row-comments {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-inline-start: 6px;
  color: var(--muted);
  font-size: 11px;
  vertical-align: middle;
  unicode-bidi: isolate;
  flex: none;
}

.member-stack {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding-block: 0;
  padding-inline: var(--s2) var(--s3);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
}
.member-stack:hover { background: var(--hover); }
.member-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.member-stack .avatar + .avatar { margin-inline-start: -8px; }
.member-stack .stack-label { margin-inline: var(--s2) 6px; }

.members { display: flex; flex-direction: column; gap: var(--s4); }
.invite-form { display: flex; flex-direction: column; gap: var(--s2); }
.invite-row { display: flex; gap: var(--s2); align-items: center; }
.invite-row .input { flex: 1; min-width: 0; }
.invite-row .select { width: auto; flex: none; }
.invite-result {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: var(--s3);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--h-green) 7%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--h-green) 25%, transparent);
  font-size: var(--fs-sm);
  line-height: 1.8;
}
.invite-result .i { color: var(--h-green); vertical-align: -3px; }
.member-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); }
.member-row { display: flex; align-items: center; gap: var(--s3); padding: 10px var(--s3); }
.member-row + .member-row { border-top: 1px solid var(--border); }
.member-row.pending { background: var(--surface-2); }
.member-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.5; }
.member-text b { font-size: var(--fs-sm); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-text span { font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-help { font-size: var(--fs-sm); color: var(--text-2); }
.role-help summary { cursor: pointer; color: var(--muted); }
.role-help ul { margin: var(--s2) 0 0; padding-inline-start: var(--s5); line-height: 1.9; }

.backup-actions { text-align: end; white-space: nowrap; width: 1%; }

/* ---- اشتراک‌گذاری: راهنمای همکاری و انتخابِ فضا برای موجودیتِ بی‌فضا */
.collab-how { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: var(--s2) var(--s3); font-size: var(--fs-sm); color: var(--text-2); }
.collab-how summary { display: flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 600; color: var(--text); list-style: none; }
.collab-how summary::-webkit-details-marker { display: none; }
.collab-how ol { margin: var(--s2) 0 var(--s1); padding-inline-start: var(--s5); line-height: 1.9; }
.shared-scope { display: flex; align-items: flex-start; gap: 6px; line-height: 1.8; }
.shared-scope .i { flex: none; margin-top: 4px; }
.share-lead { margin: 0 0 var(--s4); line-height: 1.9; color: var(--text-2); }
.share-choices { display: flex; flex-direction: column; gap: var(--s2); }
.share-choice { display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s3); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; }
.share-choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.share-choice input[type=radio] { margin-top: 5px; accent-color: var(--accent); }
.share-choice > div { display: flex; flex-direction: column; gap: var(--s2); flex: 1; min-width: 0; }
.share-choice .input:disabled, .share-choice .select:disabled { opacity: .5; }
.upgrade-note { display: flex; align-items: center; gap: var(--s2); }
.upgrade-note .btn { margin-inline-start: auto; }
.invite-banner { display: flex; gap: var(--s2); align-items: flex-start; margin-bottom: var(--s3); background: color-mix(in srgb, var(--h-blue) 7%, var(--surface)); border-color: color-mix(in srgb, var(--h-blue) 22%, transparent); }
.invite-banner .i { color: var(--h-blue); flex: none; margin-top: 4px; }

/* ============================================================ زنگولهٔ اعلان */

.bell-btn { position: relative; color: var(--text-2); }
.bell-badge {
  position: absolute;
  top: 2px;
  inset-inline-end: 1px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--sidebar);
}
.note-pop {
  position: fixed;
  z-index: 150;
  width: 380px;
  max-height: min(560px, calc(100vh - 80px));
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  animation: pop-in .16s cubic-bezier(.2, .9, .3, 1.1);
}
.note-head { display: flex; align-items: center; gap: var(--s1); padding-block: var(--s3) var(--s2); padding-inline: var(--s4) var(--s2); }
.note-head b { font-size: var(--fs); }
.note-head .spacer { flex: 1; }
.note-tabs { display: flex; gap: var(--s1); padding: 0 var(--s3); border-bottom: 1px solid var(--border); }
.note-tab {
  height: 34px;
  padding: 0 var(--s2);
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
}
.note-tab.on { color: var(--text); border-bottom-color: var(--accent); }
.note-list { overflow-y: auto; padding: var(--s1); display: flex; flex-direction: column; }
.note-item {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  width: 100%;
  padding: 10px var(--s3);
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  text-align: start;
  font: inherit;
  cursor: pointer;
}
.note-item:hover { background: var(--hover); }
.note-item { position: relative; padding: 0; cursor: default; }
.note-main { display: flex; align-items: flex-start; gap: var(--s3); flex: 1; min-width: 0; padding: 10px var(--s3); border: 0;
  background: none; color: inherit; font: inherit; text-align: start; cursor: pointer; border-radius: var(--radius); }
.note-actions { display: flex; gap: 2px; padding-block-start: 8px; opacity: 0; transition: opacity .12s; }
.note-item:hover .note-actions, .note-item:focus-within .note-actions { opacity: 1; }
@media (hover: none) { .note-actions { opacity: 1; } }
.note-item .note-dot { margin-inline-end: var(--s2); margin-top: 18px; }
.note-invite { display: flex; gap: var(--s2); padding: 0 var(--s3) var(--s3); padding-inline-start: calc(30px + var(--s3) * 2); width: 100%; }
.note-item:has(.note-invite) { flex-wrap: wrap; }
.note-invite-state { font-size: var(--fs-xs); color: var(--muted); }
.my-invites { margin-bottom: var(--s4); }

/* ============================================================ گفتگوی تیم */
body:has(.tc-layout) #chat-toggle { display: none; }   /* روی جعبهٔ نوشتن می‌افتاد؛ روزبان از صفحه‌های دیگر در دسترس است */
.tc-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); height: calc(100vh - 150px); min-height: 460px; padding: 0; overflow: hidden; }
.tc-side { border-inline-end: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: var(--surface-2); }
.tc-side-head { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s3); border-bottom: 1px solid var(--border); }
.tc-side-head .search-box { width: 100%; }
.tc-filters { display: flex; gap: var(--s1); }
.tc-filter { height: 28px; padding: 0 var(--s3); border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font: inherit; font-size: var(--fs-xs); cursor: pointer; }
.tc-filter.on { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); font-weight: 600; }
.tc-convs { overflow-y: auto; flex: 1; padding: var(--s2) var(--s2) var(--s4); }
.tc-section + .tc-section { margin-top: var(--s3); }
.tc-section-head { display: flex; align-items: center; gap: var(--s1); padding: 0 var(--s1); }
.tc-section-toggle { flex: 1; display: flex; align-items: center; gap: 6px; height: 28px; border: 0; background: none; padding: 0;
  font: inherit; font-size: var(--fs-xs); font-weight: 700; color: var(--muted); cursor: pointer; text-align: start; }
.tc-section-toggle:hover { color: var(--text); }
.tc-caret { width: 12px; font-size: 10px; }
.tc-section-empty { padding: var(--s2) var(--s3); font-size: var(--fs-xs); }
.tc-conv { --depth: 0; display: flex; align-items: center; gap: var(--s2); padding: 8px var(--s2); padding-inline-start: calc(var(--s2) + var(--depth) * 18px);
  border-radius: var(--radius); cursor: pointer; position: relative; }
.tc-conv:hover { background: var(--hover); }
.tc-conv.on { background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); }
.tc-conv.on::before { content: ''; position: absolute; inset-inline-start: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: var(--accent); }
.tc-conv.muted-conv { opacity: .7; }
.tc-conv-ico { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); flex: none; }
.tc-conv-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.tc-conv-top, .tc-conv-bottom { display: flex; align-items: center; gap: var(--s1); min-width: 0; }
.tc-conv-title { font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.tc-conv.unread .tc-conv-title { font-weight: 800; color: var(--text); }
.tc-conv-time { font-size: 11px; color: var(--muted); flex: none; }
.tc-conv.unread .tc-conv-time { color: var(--accent-text); }
.tc-conv-last { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.tc-muted-ico { font-size: 11px; }
.tc-badge, .tc-nav-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: var(--on-accent);
  font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; flex: none; }
.tc-badge.sm { min-width: 18px; height: 18px; font-size: 10.5px; }
.tc-thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--surface); }
.tc-thread-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); min-height: 64px; }
.tc-thread-head .spacer { flex: 1; }
.tc-thread-head .member-stack .stack-label { display: none; }
.tc-head-ico { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); flex: none; }
.tc-head-ico.big { width: 64px; height: 64px; border-radius: 18px; }
.tc-head-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.6; }
.tc-head-text b { font-size: var(--fs-lg); }
.tc-head-text .muted { font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-back { display: none; }
.tc-scroll { flex: 1; overflow-y: auto; padding: var(--s4) var(--s5); display: flex; flex-direction: column;
  background: var(--surface-2); }
.tc-older { align-self: center; margin-bottom: var(--s3); }
.tc-log { display: flex; flex-direction: column; gap: 3px; }
.tc-day { display: flex; justify-content: center; margin: var(--s4) 0 var(--s2); position: sticky; top: 0; z-index: 1; }
.tc-day span { font-size: 11px; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); padding: 2px 12px; border-radius: 999px; }
.tc-msg { display: flex; align-items: flex-end; gap: var(--s2); position: relative; max-width: 100%; }
.tc-msg:not(.compact) { margin-top: var(--s2); }
.tc-msg.mine { flex-direction: row-reverse; }
.tc-avatar-gap { width: 30px; flex: none; }
.tc-bubble { min-width: 64px; max-width: min(560px, 78%); display: flex; flex-direction: column; gap: 3px; padding: 8px 12px 6px;
  border-radius: 16px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 1px 1px rgba(0,0,0,.03); }
.tc-msg:not(.mine) .tc-bubble { border-end-start-radius: 6px; }
.tc-msg.mine .tc-bubble { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 18%, transparent); border-end-end-radius: 6px; }
.tc-msg.compact:not(.mine) .tc-bubble { border-start-start-radius: 6px; }
.tc-msg.compact.mine .tc-bubble { border-start-end-radius: 6px; }
.tc-who { font-size: var(--fs-xs); font-weight: 700; color: color-mix(in srgb, var(--hue, var(--h-slate)) 75%, var(--text)); }
.tc-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.8; font-size: var(--fs); }
.tc-body a { color: var(--h-blue); }
.tc-stamp { align-self: flex-end; font-size: 10.5px; color: var(--muted); line-height: 1.2; }
.tc-mention { color: var(--accent-text); font-weight: 600; }
.tc-mention.me { background: color-mix(in srgb, var(--accent) 14%, transparent); border-radius: 4px; padding: 0 3px; }
.tc-ref { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border-strong); border-radius: 6px; padding: 0 7px; margin: 0 2px;
  background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-sm); cursor: pointer; vertical-align: baseline; }
.tc-ref:hover { border-color: var(--accent); color: var(--accent-text); }
.tc-quote { display: flex; flex-direction: column; border-inline-start: 3px solid var(--accent); background: color-mix(in srgb, var(--text) 4%, transparent);
  padding: 3px 8px; border-radius: 6px; font-size: var(--fs-xs); cursor: pointer; }
.tc-quote span { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-files { display: flex; flex-wrap: wrap; gap: var(--s2); }
.tc-file { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px;
  padding: 4px 10px; font-size: var(--fs-xs); color: var(--text); }
.tc-image img { max-width: 280px; max-height: 220px; border-radius: 10px; display: block; }
.tc-actions { align-self: center; display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.tc-msg:hover .tc-actions, .tc-msg:focus-within .tc-actions { opacity: 1; }
@media (hover: none) { .tc-actions { opacity: .7; } }
.tc-compose { border-top: 1px solid var(--border); padding: var(--s3) var(--s4) var(--s2); position: relative; display: flex; flex-direction: column; gap: var(--s1); background: var(--surface); }
.tc-compose-row { display: flex; align-items: flex-end; gap: var(--s2); border: 1px solid var(--border-strong); border-radius: 14px; padding: 4px; background: var(--surface); }
.tc-compose-row:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.tc-input { flex: 1; resize: none; border: 0; outline: 0; padding: 7px 6px; font: inherit; line-height: 1.7; background: transparent; color: var(--text); max-height: 160px; }
.tc-send { border-radius: 10px; width: 36px; height: 36px; }
.tc-hint { font-size: 11px; padding-inline-start: var(--s2); }
.tc-replybar, .tc-pending { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-xs); color: var(--text-2); flex-wrap: wrap;
  background: var(--surface-2); border-radius: 8px; padding: 4px 8px; }
.tc-suggest { position: absolute; bottom: calc(100% - 4px); inset-inline-start: var(--s4); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px; display: flex; flex-direction: column; min-width: 220px; z-index: 5; }
.tc-suggest-item { display: flex; align-items: center; gap: var(--s2); padding: 6px 8px; border: 0; background: none; font: inherit; text-align: start; border-radius: 6px; cursor: pointer; color: var(--text); }
.tc-suggest-item:hover, .tc-suggest-item:first-child { background: var(--hover); }
.tc-empty { display: flex; flex-direction: column; align-items: center; gap: var(--s2); padding: var(--s8) var(--s4); color: var(--muted); text-align: center; line-height: 1.8; margin: auto; max-width: 380px; }
.tc-empty b { color: var(--text); font-size: var(--fs-lg); }
.tc-pick { margin-top: var(--s3); max-height: 360px; overflow-y: auto; }
.tc-pick-row { width: 100%; border: 0; background: none; font: inherit; color: inherit; text-align: start; cursor: pointer; border-radius: var(--radius); }
.tc-pick-row:hover { background: var(--hover); }
@media (max-width: 760px) {
  .tc-page .page-head { margin-bottom: var(--s3); }
  .tc-page .page-head .desc { display: none; }
  .tc-layout { grid-template-columns: 1fr; height: calc(100vh - 170px); }
  .tc-layout.has-thread .tc-side { display: none; }
  .tc-layout:not(.has-thread) .tc-thread { display: none; }
  .tc-back { display: inline-flex; }
  .tc-thread-head { padding: var(--s2) var(--s3); min-height: 56px; }
  .tc-thread-head .member-stack { display: none; }
  .tc-scroll { padding: var(--s3); }
  .tc-bubble { max-width: 86%; }
  .tc-image img { max-width: 200px; }
  .tc-hint { display: none; }
}

.tag.limited { --hue: var(--h-orange); background: color-mix(in srgb, var(--hue) var(--pill-bg), transparent); color: color-mix(in srgb, var(--hue) var(--pill-text), var(--text)); }
.rules-editor { display: flex; flex-direction: column; gap: var(--s3); }
.rule-row { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s3); display: flex; flex-direction: column; gap: var(--s2); }
.rule-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.rule-head .rule-presets { margin-inline-start: auto; display: flex; flex-wrap: wrap; gap: 4px; }
.rule-presets .btn.on { background: var(--hover); color: var(--accent); }
.rule-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s2); }
.rule-cell { display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-xs); }
.rule-cell .select { width: 100%; }
.rule-effective { font-size: var(--fs-xs); }
.select.invite-policy { width: auto; max-width: 260px; flex: none; }
.my-invites .member-row { align-items: center; }
.invite-answer { display: flex; gap: var(--s2); flex: none; }
.invite-message { font-size: var(--fs-xs); color: var(--text-2); }
.invite-status.s-declined { color: var(--h-red, #c0392b); }
.invite-status.s-expired, .invite-status.s-cancelled { color: var(--faint); }
.person-chip.former { opacity: .75; }
.note-seen { display: inline-flex; align-items: center; gap: 2px; color: var(--faint); }
.note-item.archived { opacity: .85; }
.page-tabs { padding: 0; margin-bottom: var(--s3); }
.note-list.card { padding: var(--s1); }
.note-more { display: flex; justify-content: center; padding: var(--s3); }
.note-item.static { cursor: default; padding: 10px var(--s3); }
.note-item.unread { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.note-item.unread:hover { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.note-ico {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  --hue: var(--h-slate);
  background: color-mix(in srgb, var(--hue) var(--pill-bg), transparent);
  color: color-mix(in srgb, var(--hue) var(--pill-text), var(--text));
}
.note-ico.k-reminder { --hue: var(--h-orange); }
.note-ico.k-assign { --hue: var(--h-blue); }
.note-ico.k-mention, .note-ico.k-comment { --hue: var(--h-violet); }
.note-ico.k-invite { --hue: var(--h-green); }
.note-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; line-height: 1.6; }
.note-text.linkish { border: 0; background: none; padding: 0; text-align: start; font: inherit; color: inherit; cursor: pointer; }
.note-title { font-size: var(--fs-sm); font-weight: 600; overflow-wrap: anywhere; }
.note-item:not(.unread) .note-title { font-weight: 500; }
.note-body { font-size: var(--fs-xs); color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note-meta { display: flex; align-items: center; gap: var(--s2); font-size: 11.5px; color: var(--muted); }
.note-sent { display: inline-flex; gap: 3px; }
.note-dot { width: 8px; height: 8px; margin-top: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.note-empty { display: flex; flex-direction: column; align-items: center; gap: var(--s2); padding: var(--s8) var(--s5); text-align: center; color: var(--muted); font-size: var(--fs-sm); line-height: 1.8; }
.note-empty b { color: var(--text); }
.note-empty .i { color: var(--faint); }
.note-foot { padding: var(--s2) var(--s3); border-top: 1px solid var(--border); margin-top: var(--s1); }

/* ============================================================ گفتگوی رکورد */

.modal.record-modal { max-width: 1040px; }
.record-modal .modal-body { padding: 0; overflow: hidden; }
.record-split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; min-height: 0; height: 100%; }
.record-form { padding: var(--s5); overflow-y: auto; display: flex; flex-direction: column; gap: var(--s4); max-height: calc(100vh - 210px); }
.record-form .form-grid { display: flex; flex-direction: column; gap: var(--s4); }
.record-side { border-inline-start: 1px solid var(--border); background: var(--surface-2); display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 210px); }
.record-tools { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.reminder-chips { display: inline-flex; flex-wrap: wrap; gap: var(--s1); }
.reminder-chips:empty { display: none; }
.reminder-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding-inline: 8px 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--h-orange) var(--pill-bg), transparent);
  color: color-mix(in srgb, var(--h-orange) var(--pill-text), var(--text));
  font-size: var(--fs-xs);
  font-weight: 500;
}
.chip-x { display: grid; place-items: center; width: 18px; height: 18px; border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer; opacity: .7; }
.chip-x:hover { opacity: 1; background: color-mix(in srgb, currentColor 14%, transparent); }

.thread { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.thread-head { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); color: var(--text-2); }
.thread-head b { color: var(--text); font-size: var(--fs-sm); }
.thread-head .spacer { flex: 1; }
.thread-count { font-size: var(--fs-xs); }
.thread-toggle { font-size: var(--fs-xs); color: var(--muted); gap: 6px; }
.thread-list { flex: 1; overflow-y: auto; padding: var(--s3) var(--s4); display: flex; flex-direction: column; gap: var(--s3); min-height: 120px; }
.thread-empty { color: var(--muted); font-size: var(--fs-sm); line-height: 1.9; padding: var(--s4) 0; text-align: center; }
.comment { display: flex; gap: var(--s2); align-items: flex-start; }
.comment-main { flex: 1; min-width: 0; }
.comment-meta { display: flex; align-items: baseline; gap: var(--s2); flex-wrap: wrap; font-size: var(--fs-xs); }
.comment-meta b { font-size: var(--fs-sm); }
.comment-actions { display: inline-flex; gap: var(--s2); margin-inline-start: auto; opacity: 0; transition: opacity .12s; }
.comment:hover .comment-actions, .comment:focus-within .comment-actions { opacity: 1; }
.comment-actions .link-btn { font-size: var(--fs-xs); color: var(--muted); }
.comment-actions .link-btn.danger:hover { color: var(--h-red); }
.comment-body {
  margin-top: 4px;
  padding: var(--s2) var(--s3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-start-start-radius: 4px;
  font-size: var(--fs-sm);
  line-height: 1.85;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.comment.mine .comment-body { background: color-mix(in srgb, var(--accent) 5%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 14%, var(--border)); }
.comment-edit { display: flex; flex-direction: column; gap: var(--s2); margin-top: 4px; }
.mention { color: var(--h-blue); font-weight: 600; }
.event { display: flex; gap: var(--s2); align-items: flex-start; font-size: var(--fs-xs); color: var(--text-2); line-height: 1.8; padding-inline-start: 9px; }
.event-dot { width: 9px; height: 9px; margin-top: 6px; border-radius: 50%; flex: none; background: var(--border-strong); }
.event-dot.k-completed { background: var(--h-green); }
.event-dot.k-created { background: var(--h-blue); }
.event-dot.k-reopened { background: var(--h-amber); }
.event-text b { color: var(--text); font-weight: 600; }

.composer { display: flex; gap: var(--s2); align-items: flex-start; padding: var(--s3) var(--s4); border-top: 1px solid var(--border); background: var(--surface); }
.composer-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; position: relative; }
.composer-input { min-height: 40px; max-height: 220px; resize: none; line-height: 1.8; }
.composer-foot { display: flex; align-items: center; gap: var(--s2); }
.composer-hint { font-size: 11px; color: var(--muted); flex: 1; }
.onboard-joined { display: flex; align-items: center; gap: var(--s3); max-width: 720px; margin: 0 auto var(--s5); text-align: start; }
.onboard-joined > .i { color: var(--h-blue); flex: none; }
.onboard-joined .btn { flex: none; }
.switch input:disabled + .switch-track { opacity: .45; cursor: not-allowed; }
.kbd-inline { font-family: inherit; direction: ltr; unicode-bidi: isolate; }
.mention-pop {
  position: absolute;
  bottom: calc(100% + 4px);
  inset-inline-start: 0;
  z-index: 5;
  min-width: 200px;
  padding: var(--s1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.mention-opt { display: flex; align-items: center; gap: var(--s2); width: 100%; height: 34px; padding: 0 var(--s2); border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); font: inherit; font-size: var(--fs-sm); cursor: pointer; text-align: start; }
.mention-opt.on, .mention-opt:hover { background: var(--hover); }

.detail-split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: var(--s4); align-items: start; margin-bottom: var(--s4); }
.detail-split > .card { margin: 0; }
.thread-card { padding: 0; overflow: hidden; position: sticky; top: var(--s4); max-height: calc(100vh - 40px); display: flex; }
.thread-card .thread { width: 100%; }

/* ============================================================ یادآوری و ترجیح اعلان‌ها */

.reminder-presets { gap: var(--s1); }
.rule-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) 0; flex-wrap: wrap; }
.rule-row + .rule-row { border-top: 1px solid var(--border); }
.rule-row .spacer { flex: 1; }
.rule-row .select { width: auto; }
.rule-row .row { gap: var(--s2); align-items: center; }
.rule-row .input[type=time] { width: 110px; }
.rule-row.off b { color: var(--muted); }
.rule-row.off .select, .rule-row.off .row { opacity: .45; pointer-events: none; }

.settings-card-head { display: flex; align-items: center; gap: var(--s2); color: var(--text-2); }
.settings-card-head h2 { font-size: var(--fs-lg); color: var(--text); }
#notify-settings { display: flex; flex-direction: column; gap: var(--s2); scroll-margin-top: var(--s4); }
.pref-title { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; margin: var(--s3) 0 0; }
.pref-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) 0; }
.pref-row + .pref-row { border-top: 1px solid var(--border); }
.pref-row > .i { color: var(--muted); flex: none; }
.pref-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.6; }
.pref-text b { font-weight: 500; font-size: var(--fs-sm); }
.pref-text .muted { font-size: var(--fs-xs); }
.pref-text > .ltr { align-self: flex-start; }

/* ============================================================ قالب‌ها */

.section-head { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs); font-weight: 700; margin: var(--s6) 0 var(--s3); }
.section-head .i { color: var(--muted); }
.section-head .muted { font-weight: 400; font-size: var(--fs-sm); }
.page-head + .section-head { margin-top: 0; }
.inline-field { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); }
.inline-field .select { width: auto; min-width: 160px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s4); }
.tpl {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  transition: border-color .12s, box-shadow .12s;
}
.tpl:hover { border-color: var(--border-strong); box-shadow: 0 2px 10px rgba(0, 0, 0, .06); }
.tpl-preview {
  height: 92px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--tpl) 9%, var(--surface-2));
  border-bottom: 1px solid var(--border);
}
.tpl-body { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s3) var(--s4) var(--s4); flex: 1; }
.tpl-body h3 { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs); }
.tpl-body h3 .ent-ico { color: var(--tpl); }
.tpl-ico { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: var(--radius); background: color-mix(in srgb, var(--tpl) 14%, var(--surface)); }
.tpl-body h3 .tag { margin-inline-start: auto; font-weight: 500; }
.tpl { border-top: 3px solid var(--tpl); }
.tpl-fields { display: flex; flex-wrap: wrap; gap: 4px; }
.tpl-field { height: 22px; display: inline-flex; align-items: center; padding-inline: 8px; border-radius: 999px; background: var(--fill); color: var(--text-2); font-size: 11.5px; }
.tpl-field.more { background: none; color: var(--muted); }
.tpl-cats { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: var(--s2); }
.tpl-sections > section:first-child .section-head { margin-top: var(--s3); }
.tpl-body p { margin: 0; color: var(--text-2); font-size: var(--fs-sm); line-height: 1.8; flex: 1; }
.tpl-foot { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-xs); }
.tpl-foot .spacer { flex: 1; }
.pv-board { display: flex; gap: 6px; align-items: flex-start; }
.pv-col { width: 46px; padding: 5px; border-radius: 6px; background: var(--surface); display: flex; flex-direction: column; gap: 4px; box-shadow: 0 1px 2px rgba(0, 0, 0, .06); }
.pv-col i { height: 3px; border-radius: 2px; background: var(--hue); }
.pv-col b { height: 10px; border-radius: 3px; background: color-mix(in srgb, var(--tpl) 22%, var(--fill)); }
.pv-table { width: 150px; padding: 6px; border-radius: 6px; background: var(--surface); display: flex; flex-direction: column; gap: 5px; box-shadow: 0 1px 2px rgba(0, 0, 0, .06); }
.pv-row { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 5px; }
.pv-row b { height: 6px; border-radius: 3px; background: var(--fill-hover); }
.pv-row.head b { background: color-mix(in srgb, var(--tpl) 35%, var(--fill)); }

@media (max-width: 1100px) {
  .record-split, .detail-split { grid-template-columns: minmax(0, 1fr); }
  .record-side { border-inline-start: 0; border-top: 1px solid var(--border); max-height: none; }
  .record-form { max-height: none; overflow: visible; }
  .record-modal .modal-body { overflow-y: auto; }
  .thread-card { position: static; max-height: none; }
  .thread-list { max-height: 420px; }
}

@media (max-width: 860px) {
  .board { margin-inline: calc(-1 * var(--s4)); padding-inline: var(--s4); scroll-padding-inline: var(--s4); scroll-snap-type: x proximity; }
  .kcol { flex-basis: 84vw; max-width: 320px; scroll-snap-align: start; max-height: calc(100vh - 200px); }
  .board-tip { display: none; }
  .seg-label { display: none; }
  .seg-btn { padding: 0 var(--s2); }
  .btn-label { display: none; }
  .note-pop {
    inset: auto 0 0 0;
    width: auto;
    max-height: 80vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    animation: sheet-up .2s cubic-bezier(.2, .9, .3, 1);
  }
  .invite-row { flex-wrap: wrap; }
  .invite-row .btn { flex: 1; }
  .member-stack .stack-label { display: none; }
  .inline-field { width: 100%; }
  .inline-field .select { flex: 1; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }


@media print {
  body.printing-report .sidebar, body.printing-report #chat-toggle, body.printing-report #chat,
  body.printing-report .report-toolbar, body.printing-report .page-head .actions, body.printing-report .crumb,
  body.printing-report .report-block-tools, body.printing-report .toast { display: none !important; }
  body.printing-report .app { display: block; }
  body.printing-report main { padding: 0; max-width: none; }
  body.printing-report .card { box-shadow: none; break-inside: avoid; }
  body.printing-report .report-blocks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ربات تلگرام و بله */
.plan-features.levels { flex-direction: row; flex-wrap: wrap; gap: var(--s2) var(--s4); }
.link-steps { display: flex; flex-direction: column; gap: var(--s2); }
.link-steps p { margin: 0; }

/* مصرف و هزینه: نمودار ستونی ساده */
.usage-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 180px;
  padding-top: var(--s2);
  direction: ltr;              /* زمان از چپ به راست، مثل محور نمودار */
}
.usage-col {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
}
.usage-fill {
  width: 100%;
  max-width: 28px;
  border-radius: 4px 4px 0 0;
  background: color-mix(in srgb, var(--accent) 75%, transparent);
  transition: background .12s;
}
.usage-col:hover .usage-fill { background: var(--accent); }
.usage-x { font-size: 10px; color: var(--muted); line-height: 1; }

/* پنل مدیریت: ویرایش پلن */
.plan-editor { display: flex; flex-direction: column; gap: var(--s4); }
.check-grid { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s4); }
.card-body > b { font-size: var(--fs); }
.admin-body .card-body { display: flex; flex-direction: column; gap: var(--s3); }

/* ============================================================ واکنش‌گرا */

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }

  /* گوشی: نوارِ بالا با دکمهٔ همبرگری؛ سایدبار کشویی است که از سمتِ راست باز می‌شود */
  .mobilebar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 45;
    align-items: center;
    gap: var(--s1);
    height: 54px;
    padding: 0 var(--s2);
    background: var(--sidebar);
    border-bottom: 1px solid var(--border);
  }
  body.auth-mode .mobilebar { display: none; }
  .mobilebar .spacer { flex: 1; }
  .mobilebar .btn.icon { width: 40px; height: 40px; }
  .mobilebar-brand { display: flex; align-items: center; gap: var(--s2); border: 0; background: none; color: var(--text); font: inherit; font-size: 15px; padding: 0 var(--s1); cursor: pointer; }
  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 60;
    width: min(300px, 86vw);
    height: 100dvh;
    padding: var(--s3) var(--s2) var(--s6);
    box-shadow: var(--shadow);
    transform: translateX(105%);
    visibility: hidden;
    transition: transform .22s ease, visibility 0s .22s;
  }
  body.drawer-open .sidebar { transform: none; visibility: visible; transition: transform .22s ease; }
  .drawer-backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .4); opacity: 0; pointer-events: none; transition: opacity .2s; display: block; }
  body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
  body.drawer-open { overflow: hidden; }
  body.drawer-open #chat-toggle { display: none; }
  .brand .drawer-close { display: inline-flex; }
  .nav-item, .quick-open { min-height: 42px; }
  .quick-open .kbd { display: none; }

  .main { padding: var(--s5) var(--s4) 96px; }
  .grid-2 { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .search-box { width: 100%; }
  .page-head .actions { width: 100%; }
  .page-head .actions .search-box { flex: 1; }
  .table-wrap.scroll-y { max-height: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-toggle { width: 28px; height: 28px; }
}

/* ============================================================ حریم خصوصی */

.auth-legal { margin: 0; color: var(--muted); font-size: var(--fs-xs); text-align: center; }
.auth-legal a { color: var(--accent-text); }
.auth-privacy { display: block; margin-top: var(--s3); text-align: center; font-size: var(--fs-xs); color: var(--muted); }
.privacy-text { min-height: 420px; font-size: var(--fs-sm); }

/* ============================================================ صندوق دریافت و پلنِ سازمانی */

.tab-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-inline-start: 6px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 700; }
.tab-badge[hidden] { display: none; }
.inbox-head { margin-bottom: var(--s3); flex-wrap: wrap; gap: var(--s2); }
.inbox-list { padding: 0; }
.inbox-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); cursor: pointer; }
.inbox-row + .inbox-row { border-top: 1px solid var(--border); }
.inbox-row:hover { background: var(--hover); }
.inbox-row:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.inbox-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.inbox-row.unread .inbox-dot { background: var(--accent); }
.inbox-row.unread .inbox-subject { font-weight: 700; }
.inbox-from { width: 200px; flex: none; display: flex; flex-direction: column; min-width: 0; line-height: 1.6; }
.inbox-from b, .inbox-from span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-from span { font-size: var(--fs-xs); align-self: flex-start; max-width: 100%; }
.inbox-row:not(.unread) .inbox-from b { font-weight: 500; }
.inbox-main { flex: 1; min-width: 0; line-height: 1.6; }
.inbox-subject, .inbox-snippet { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-snippet { font-size: var(--fs-xs); }
.inbox-meta { display: flex; align-items: center; gap: var(--s2); flex: none; color: var(--muted); font-size: var(--fs-xs); }
.inbox-headers { display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-sm); padding-bottom: var(--s3); border-bottom: 1px solid var(--border); margin-bottom: var(--s3); }
.inbox-body { flex: none; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.9; padding: var(--s3) 0; max-height: 50vh; overflow: auto; }
.inbox-flip { align-self: flex-start; }
.inbox-html { flex: none; width: 100%; height: 50vh; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; margin: var(--s2) 0; }
.inbox-attachments { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); margin: var(--s2) 0; }
@media (max-width: 700px) { .inbox-row { flex-wrap: wrap; } .inbox-from { width: auto; flex: 1 1 100%; } }
.plan-card.org { border-style: dashed; }
.plan-card.org .plan-title { display: flex; align-items: center; gap: var(--s2); }
.plan-card.org > .btn { margin-top: auto; justify-content: center; }

/* ============================================================ مدیریت اعضا */

.people-list { padding: 0; max-width: 960px; }
.people-head, .person { display: grid; grid-template-columns: minmax(180px, 260px) 1fr; gap: var(--s4); align-items: center; padding: var(--s3) var(--s4); }
.people-head { padding-block: var(--s2); background: var(--surface-2); border-bottom: 1px solid var(--border); color: var(--muted); font-size: var(--fs-xs); font-weight: 600; }
.person + .person { border-top: 1px solid var(--border); }
.person:hover { background: var(--surface-2); }
.person-id { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.person-id .member-text { min-width: 0; }
.person-id .member-text > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-id .member-text .ltr { align-self: flex-start; max-width: 100%; font-size: var(--fs-xs); }
.person-access { display: flex; flex-wrap: wrap; gap: var(--s2); min-width: 0; }
.access-chip { display: inline-flex; align-items: center; height: 30px; max-width: 100%; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); font-size: var(--fs-sm); overflow: hidden; }
.chip-place { display: inline-flex; align-items: center; gap: 6px; min-width: 0; height: 100%; padding: 0; padding-inline: var(--s3) var(--s2); border: 0; background: none; color: var(--text); font: inherit; cursor: pointer; }
.chip-place:hover { background: var(--hover); }
.chip-place .i { color: var(--muted); flex: none; }
.chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 340px; }
.chip-role { display: inline-flex; align-items: center; height: 100%; padding: 0 var(--s2); border-inline-start: 1px solid var(--border); color: var(--text-2); font-size: var(--fs-xs); background: var(--surface-2); }
.chip-select { appearance: none; border: 0; border-inline-start: 1px solid var(--border); font: inherit; font-size: var(--fs-xs); cursor: pointer; padding-inline: var(--s2) 18px;
  background: var(--surface-2) no-repeat left 6px center / 10px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
.chip-select:hover { background-color: var(--hover); }
.chip-select:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.chip-x { display: grid; place-items: center; width: 28px; height: 100%; border: 0; border-inline-start: 1px solid var(--border); background: var(--surface-2); color: var(--muted); cursor: pointer; }
.chip-x:hover { background: color-mix(in srgb, var(--h-red) 12%, transparent); color: var(--h-red); }
@media (max-width: 700px) {
  .people-head { display: none; }
  .person { grid-template-columns: 1fr; gap: var(--s2); }
}
.share-sub { display: flex; align-items: center; gap: var(--s1); margin: var(--s4) 0 var(--s2); color: var(--text-2); }
@media (max-width: 600px) { .person-access { margin-inline-start: 0; } .access-row { flex-wrap: wrap; } }
.members > .btn { align-self: flex-start; }

/* ============================================================ پیوست */

.file-field { display: flex; flex-direction: column; gap: var(--s2); }
.file-list { display: flex; flex-direction: column; gap: var(--s1); }
.file-list:empty { display: none; }
.file-item { display: flex; align-items: center; gap: var(--s2); padding: 6px var(--s2); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.file-item.uploading { opacity: .65; }
.file-thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 4px; flex: none; background: var(--fill); }
.file-ico { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 4px; background: var(--fill); color: var(--muted); flex: none; }
.file-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.5; }
.file-text a, .file-text > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.file-text a:hover { text-decoration: underline; }
.file-text .muted { font-size: var(--fs-xs); }
.file-cell { display: inline-flex; align-items: center; gap: 4px; max-width: 220px; }
.file-cell a { display: inline-flex; align-items: center; gap: 4px; min-width: 0; color: var(--text); }
.file-cell a:hover .file-name { text-decoration: underline; }
.file-cell .i { color: var(--muted); flex: none; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================ عکسِ پروفایل */

.avatar.photo { overflow: hidden; background: var(--fill); }
.avatar.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-photo { display: flex; align-items: center; gap: var(--s4); padding-bottom: var(--s3); border-bottom: 1px solid var(--border); }
.profile-photo-actions { display: flex; flex-direction: column; gap: var(--s1); }

/* ============================================================ پیام به پشتیبانی */

.support-form { display: flex; flex-direction: column; gap: var(--s3); max-width: 720px; }
.support-thread, .support-admin { display: flex; flex-direction: column; gap: var(--s3); max-width: 720px; }
.support-item { display: flex; flex-direction: column; gap: var(--s2); padding-bottom: var(--s3); border-bottom: 1px solid var(--border); }
.support-msg { padding: var(--s3); border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; gap: var(--s1); }
.support-msg.reply { background: var(--accent-soft); border-color: transparent; margin-inline-start: var(--s8); }
.support-meta { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-xs); }
.support-from { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--accent-text); }
.support-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.9; }
.support-wait { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); margin-inline-start: var(--s8); }
.support-card { padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); }
.support-card.unread { border-inline-start: 3px solid var(--accent); }
.support-card-head { display: flex; align-items: center; gap: var(--s2); }
.support-card .support-msg.reply { margin-inline-start: 0; }

/* ============================================================ انتخابگرِ ساعت */

.time-wrap { position: relative; display: inline-flex; align-items: center; gap: 2px; }
.time-input { width: 92px; text-align: center; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.time-btn { color: var(--muted); }
.time-pop {
  position: absolute; top: calc(100% + 6px); inset-inline-start: 0; z-index: 60;
  width: 312px; padding: var(--s3);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.time-cols { display: grid; grid-template-columns: 3fr 2fr; gap: var(--s3); }
.time-col { display: flex; flex-direction: column; gap: var(--s1); }
.time-col + .time-col { border-inline-start: 1px solid var(--border); padding-inline-start: var(--s3); }
.time-col-title { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.time-grid { display: grid; gap: 2px; }
.time-grid.hours { grid-template-columns: repeat(4, 1fr); }
.time-grid.minutes { grid-template-columns: repeat(3, 1fr); }
.time-grid button {
  height: 30px; border: 0; border-radius: var(--radius-sm); background: transparent; cursor: pointer;
  font-size: var(--fs-sm); color: var(--text-2); font-variant-numeric: tabular-nums;
}
.time-grid button:hover { background: var(--hover); color: var(--text); }
.time-grid button.sel { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.time-grid button:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.time-foot { display: flex; align-items: center; margin-top: var(--s2); padding-top: var(--s2); border-top: 1px solid var(--border); }

/* ============================================================ امنیت (پنل مدیریت) */

.security-rules { display: flex; flex-direction: column; gap: var(--s2); }
.security-list { margin: 0; padding-inline-start: 20px; color: var(--text-2); font-size: var(--fs-sm); line-height: 1.9; }
.security-grid { align-items: start; }
.security-past { margin-top: var(--s5); }
.security-past summary { cursor: pointer; color: var(--muted); font-size: var(--fs-sm); margin-bottom: var(--s2); }

/* ============================================================ انتخابِ چندتایی در جدول */

/* ستونِ آخر (سمتِ چپ)، کنارِ «باز کردن» و سطلِ زباله؛ خاکستری، نه سبزِ «انجام شد» — برای حذف است */
th.sel-col, td.sel-col { width: 1%; padding-inline: 0 var(--s3); text-align: center; white-space: nowrap; }
.sel-head { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 400; }
.sel-label { font-size: var(--fs-xs); color: var(--muted); opacity: 0; transition: opacity .12s; }
table.sel-hover .sel-label, table.selecting .sel-label { opacity: 1; }
.sel-box {
  appearance: none; width: 17px; height: 17px; margin: 0; flex: none; position: relative; vertical-align: middle; cursor: pointer;
  border: 1.5px solid var(--control); border-radius: 4px; background: var(--surface);
  opacity: 0; transition: opacity .12s, background .12s, border-color .12s;
}
.sel-box:hover { border-color: var(--text-2); }
.sel-box:checked, .sel-box:indeterminate { background: var(--text-2); border-color: var(--text-2); }
.sel-box::after { content: ''; position: absolute; opacity: 0; border: solid var(--surface); }
.sel-box:checked::after { opacity: 1; inset-inline-start: 4.5px; top: 1.5px; width: 4px; height: 8px; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.sel-box:indeterminate::after { opacity: 1; inset-inline-start: 3px; top: 6.5px; width: 8px; height: 0; border-width: 0 0 2px; }
.sel-box:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
tr:hover .sel-box, .sel-box:focus-visible, .sel-box:checked, .sel-box:indeterminate, table.selecting .sel-box, table.sel-hover thead .sel-box { opacity: 1; }
tbody tr.selected > td { background: var(--hover); }
@media (hover: none) { .sel-box { opacity: 1; } .sel-label { opacity: 1; } }

.bulk-bar {
  position: fixed; bottom: var(--s5); left: 50%; transform: translateX(-50%); z-index: 70;
  display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s3);
  background: var(--toast-bg); color: #fff; border-radius: 999px; box-shadow: var(--shadow);
  animation: slide-in .16s ease-out;
}
.bulk-bar .btn.ghost { color: #fff; }
.bulk-bar .btn.ghost:hover { background: rgba(255, 255, 255, .12); }
.bulk-count { font-weight: 600; font-size: var(--fs-sm); padding-inline: var(--s2); white-space: nowrap; }
.bulk-sep { width: 1px; height: 20px; background: rgba(255, 255, 255, .2); }
@media (max-width: 600px) { .bulk-bar { left: var(--s3); right: var(--s3); transform: none; justify-content: center; flex-wrap: wrap; border-radius: var(--radius-lg); } }
.bulk-bar .btn.danger { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.bulk-bar .btn.danger:hover { background: var(--accent-hover); }

/* گزینه‌های سؤالِ روزبان زیرِ پیامش */
.msg-choices { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); margin-top: var(--s2); }
.msg-choices .hint { flex-basis: 100%; }

/* ============================================================ جدولِ داخلی (ردیف‌های تکرارشونده) */

.itable { display: flex; flex-direction: column; gap: var(--s1); }
.itable-head, .itable-row { display: grid; grid-template-columns: var(--itable-grid, 22px 1fr 1fr 30px); gap: var(--s2); align-items: center; }
.itable-head { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; padding-bottom: 2px; }
.itable-head[hidden] { display: none; }
.itable-rows { display: flex; flex-direction: column; gap: var(--s1); }
.itable-row { padding: 4px 0; border-radius: var(--radius-sm); }
.itable-row.dragging { background: var(--hover); opacity: .8; }
.itable-grip { display: grid; place-items: center; color: var(--muted); cursor: grab; touch-action: none; opacity: .6; }
.itable-row:hover .itable-grip { opacity: 1; }
.itable-cell .input, .itable-cell .select, .itable-cell .textarea { min-height: 34px; }
.itable-cell .textarea { min-height: 34px; }
.itable-cell .time-input { width: 100%; }
.itable-cell .date-wrap .input { max-width: none; }
.itable-add { align-self: flex-start; margin-top: 2px; }
.itable-empty { padding: var(--s1) 0; }
.table-cell { display: inline-flex; align-items: center; gap: 6px; max-width: 260px; }
.table-count { display: inline-flex; align-items: center; gap: 3px; padding: 0 6px; height: 20px; border-radius: 999px; background: var(--fill); color: var(--text-2); font-size: var(--fs-xs); flex: none; }
.table-first { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.tcol-list { display: flex; flex-direction: column; gap: var(--s2); }
.tcol-row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.tcol-row .input { flex: 1 1 160px; min-width: 0; }
.tcol-row .select { width: 130px; }
.tcol-move { display: flex; flex-direction: column; }
.tcol-move .btn { height: 16px; }
@media (max-width: 640px) { .itable-head { display: none; } .itable-row { grid-template-columns: 22px 1fr 30px; } .itable-cell { grid-column: 2; } }
.tcol-list > .btn { align-self: flex-start; }
/* در ستونِ باریکِ فرم‌ساز: عنوان و نوع کنارِ هم، گزینه‌های «انتخاب» زیرشان */
.bld-panel .tcol-row .input { flex: 1 1 90px; }
.bld-panel .tcol-row .select { width: 104px; }
.bld-panel .tcol-row .input + .select + .input { flex-basis: 100%; order: 5; }

/* ============================================================ بایگانی */

.archive-toggle { position: relative; }
.archive-toggle.on { background: var(--accent-soft); color: var(--accent-text); }
.archive-count {
  position: absolute;
  top: 1px;
  inset-inline-end: 1px;
  min-width: 16px;
  height: 16px;
  padding-inline: 4px;
  border-radius: 999px;
  background: var(--fill-hover);
  color: var(--text-2);
  font-size: 10px;
  line-height: 16px;
  text-align: center;
}
.archive-bar {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-wrap: wrap;
  padding: var(--s2) var(--s3);
  margin-bottom: var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-sm);
}

/* ویرایشگرِ فیلد: جستجوی موجودیتِ مقصد و فیلدهای فرمول */
.rel-pick { display: flex; flex-direction: column; gap: var(--s2); }
.formula-fields { display: flex; flex-wrap: wrap; gap: 4px; margin-top: var(--s2); }
.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 26px;
  padding-inline: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: var(--fs-xs);
  cursor: pointer;
}
.chip-btn:hover { border-color: var(--accent); color: var(--accent-text); }

/* ============================================================ تنظیماتِ کارپوشه و بایگانی */

.ss-wrap { container-type: inline-size; }
.ss-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: var(--s5); align-items: start; }
.ss-main { display: flex; flex-direction: column; gap: var(--s4); min-width: 0; }
/* overflow: visible: تقویم و انتخابگرِ آیکون از لبهٔ کارت بیرون می‌زنند و نباید بریده شوند */
.ss-card { padding: var(--s5); display: flex; flex-direction: column; gap: var(--s4); overflow: visible; }
.ss-title { margin: 0; font-size: var(--fs); font-weight: 700; }
.ss-action { display: flex; align-items: center; gap: var(--s4); justify-content: space-between; }
.ss-action + .ss-action { border-top: 1px solid var(--border); padding-top: var(--s4); }
.ss-action .muted { font-size: var(--fs-sm); line-height: 1.7; }
.ss-side { position: sticky; top: var(--s4); gap: var(--s3); }
.ss-list-head {
  display: flex;
  align-items: center;
  gap: var(--s2);
  width: 100%;
  padding: var(--s2);
  margin: calc(-1 * var(--s2));
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.ss-list-head:hover { background: var(--hover); }
.ss-list-title { font-weight: 700; flex: 1; }
.ss-list-head .muted { font-size: var(--fs-xs); }
.ss-list { display: flex; flex-direction: column; border-top: 1px solid var(--border); }
.ss-row, .arc-row { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) 0; min-height: 44px; }
.ss-row + .ss-row, .arc-row + .arc-row { border-top: 1px solid var(--border); }
.ss-row.dim .ss-name, .ss-row.dim .ss-ico { opacity: .55; }
.ss-ico { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: var(--radius-sm); background: var(--fill); color: var(--muted); }
.ss-name { border: 0; background: none; padding: 0; color: var(--text); font: inherit; font-weight: 500; cursor: pointer; text-align: start; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-name:hover { color: var(--accent-text); text-decoration: underline; }
.ss-meta { font-size: var(--fs-xs); white-space: nowrap; }
.ss-tools { display: flex; align-items: center; gap: 2px; margin-inline-start: auto; flex: none; }
.ss-tools .btn.off { color: var(--faint); }
.arc-list { display: flex; flex-direction: column; gap: var(--s4); }
.arc-card { padding: var(--s4) var(--s5); }
.arc-body { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.arc-meta { font-size: var(--fs-xs); }
.nav-hidden-link { border: 0; background: none; font: inherit; cursor: pointer; text-align: start; width: 100%; }
.nav-hidden-link { display: flex; align-items: center; gap: 6px; }
.nav-hidden-link:hover { color: var(--accent-text); }
.nav-hidden-item { opacity: .6; }
.nav-hidden-item:hover, .nav-hidden-item.active { opacity: 1; }
/* موردهای پنهان یکی‌یکی از بالا سُر می‌خورند و پیدا می‌شوند */
.reveal-in { animation: nav-reveal .32s cubic-bezier(.2, .7, .3, 1) backwards; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes nav-reveal {
  from { opacity: 0; transform: translateY(-6px); max-height: 0; }
  to { opacity: .6; transform: none; max-height: 48px; }
}
@media (prefers-reduced-motion: reduce) { .reveal-in { animation: none; } }
.tpl-pill { gap: 6px; cursor: pointer; border: 0; font: inherit; }
.tpl-count { font-size: 11px; opacity: .7; }
@container (max-width: 760px) {
  .ss-layout { grid-template-columns: minmax(0, 1fr); }
  .ss-side { position: static; }
}

/* «بیشتر»: فهرست‌های بلندتر از هفت مورد */
.fold-more {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 36px;
  padding-inline: var(--s3);
  border: 0;
  border-top: 1px dashed var(--border);
  background: none;
  color: var(--accent-text);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
}
.fold-more:hover { background: var(--hover); }
.fold-in { animation: fold-in .3s cubic-bezier(.2, .7, .3, 1) backwards; animation-delay: calc(var(--i, 0) * 40ms); }
@keyframes fold-in { from { opacity: 0; transform: translateY(-8px); } }
@media (prefers-reduced-motion: reduce) { .fold-in { animation: none; } }

/* بیرون رفتن (پنهان کردن، «کمتر»): محو، کمی بالا، و جمع شدنِ جایش */
.leave-out { overflow: hidden; pointer-events: none; animation: leave-out .24s ease-in forwards; animation-delay: calc(var(--i, 0) * 35ms); }
@keyframes leave-out {
  from { max-height: 64px; }
  to { opacity: 0; transform: translateY(-6px); max-height: 0; min-height: 0; padding-block: 0; margin-block: 0; border-width: 0; }
}

/* تنظیماتِ موجودیت */
.ss-side-stack { display: flex; flex-direction: column; gap: var(--s4); position: sticky; top: var(--s4); }
.range-from { display: flex; flex-direction: column; gap: var(--s3); padding: var(--s3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
@container (max-width: 760px) { .ss-side-stack { position: static; } }

/* منوی ظاهر */
.theme-btn { flex: none; }
.theme-pop .menu-item.on { color: var(--accent-text); font-weight: 600; }
.menu-check { margin-inline-start: auto; display: inline-flex; }

/* ============================================================ رنگِ کارپوشه (مثل رنگِ یادداشت در Keep) */
/* زمینهٔ صفحه وقتی داخلِ یک کارپوشهٔ رنگی هستید؛ رنگ‌ها همان --h-… اند که برای روشن و تیره جدا تعریف شده‌اند */
body[data-tint] { background: color-mix(in srgb, var(--tint) var(--tint-mix), var(--bg)); transition: background-color .25s; }
body[data-tint="red"], .tint-swatch[data-color="red"], .nav-space[data-tint="red"] { --tint: var(--h-red); }
body[data-tint="orange"], .tint-swatch[data-color="orange"], .nav-space[data-tint="orange"] { --tint: var(--h-orange); }
body[data-tint="amber"], .tint-swatch[data-color="amber"], .nav-space[data-tint="amber"] { --tint: var(--h-amber); }
body[data-tint="green"], .tint-swatch[data-color="green"], .nav-space[data-tint="green"] { --tint: var(--h-green); }
body[data-tint="teal"], .tint-swatch[data-color="teal"], .nav-space[data-tint="teal"] { --tint: var(--h-teal); }
body[data-tint="blue"], .tint-swatch[data-color="blue"], .nav-space[data-tint="blue"] { --tint: var(--h-blue); }
body[data-tint="indigo"], .tint-swatch[data-color="indigo"], .nav-space[data-tint="indigo"] { --tint: var(--h-indigo); }
body[data-tint="violet"], .tint-swatch[data-color="violet"], .nav-space[data-tint="violet"] { --tint: var(--h-violet); }
body[data-tint="pink"], .tint-swatch[data-color="pink"], .nav-space[data-tint="pink"] { --tint: var(--h-pink); }
body[data-tint="slate"], .tint-swatch[data-color="slate"], .nav-space[data-tint="slate"] { --tint: var(--h-slate); }
.nav-space[data-tint] > .ico, .nav-space[data-tint] .ent-ico { color: var(--tint); }
.tint-swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.tint-swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--tint, var(--border-strong)) 70%, transparent);
  background: color-mix(in srgb, var(--tint, var(--bg)) calc(var(--tint-mix) * 3), var(--surface));
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--text);
  padding: 0;
  transition: transform .12s, box-shadow .12s;
}
.tint-swatch:hover { transform: scale(1.08); }
.tint-swatch.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--tint, var(--text-2)); }
.tint-swatch.none { --tint: var(--border-strong); background: var(--surface); }
.tint-swatch.none::after { content: ''; width: 22px; height: 2px; background: var(--muted); transform: rotate(-45deg); border-radius: 2px; }
.tint-swatch.none.on::after { display: none; }

/* ============================================================ پهنای سایدبار (دسکتاپ) */
.sidebar-resizer {
  position: fixed;
  top: 0;
  bottom: 0;
  inset-inline-start: calc(var(--sidebar-w, 264px) - 4px);
  width: 8px;
  cursor: col-resize;
  z-index: 30;
  touch-action: none;
}
.sidebar-resizer::after { content: ''; position: absolute; inset-block: 0; inset-inline-start: 3px; width: 2px; background: transparent; transition: background .15s; }
.sidebar-resizer:hover::after, .sidebar-resizer:focus-visible::after, body.resizing-sidebar .sidebar-resizer::after { background: var(--accent); }
.sidebar-resizer:focus-visible { outline: none; }
body.resizing-sidebar { cursor: col-resize; user-select: none; }
body.auth-mode .sidebar-resizer { display: none; }
@media (max-width: 860px) { .sidebar-resizer { display: none; } }

/* ============================================================ گیرنده‌های دعوت (مخاطب‌ها و گروه‌ها) */
.rp { position: relative; flex: 1; min-width: 0; }
.rp-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-height: 38px;
  padding: 3px 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: text;
}
.rp-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.rp-chips { display: contents; }
.rp-chip { display: inline-flex; align-items: center; gap: 2px; height: 26px; padding-inline: 8px 2px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: var(--fs-sm); max-width: 220px; }
.rp-chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-x { display: grid; place-items: center; width: 20px; height: 20px; border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer; }
.rp-x:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.rp-input { flex: 1; min-width: 140px; border: 0; outline: 0; background: none; color: var(--text); font: inherit; padding: 4px; }
.rp-list {
  position: absolute;
  top: calc(100% + 4px);
  inset-inline: 0;
  z-index: 70;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.rp-item { display: flex; align-items: center; gap: var(--s2); padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; min-width: 0; }
.rp-item.active { background: var(--hover); }
.rp-ico { display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 50%; background: var(--fill); color: var(--muted); }
.rp-main { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-sub { margin-inline-start: auto; color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.invite-row .rp + .select { align-self: flex-start; }
.invite-link-row { display: flex; flex-direction: column; gap: 4px; margin-top: var(--s2); }
.invite-email { font-size: var(--fs-sm); font-weight: 600; }
.invite-error { color: var(--h-red); font-size: var(--fs-sm); }

/* گروه‌ها در «مدیریت اعضا» */
.groups-card { padding: var(--s4) var(--s5); display: flex; flex-direction: column; gap: var(--s3); margin-bottom: var(--s4); }
.group-list { display: flex; flex-direction: column; }
.group-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) 0; }
.group-row + .group-row { border-top: 1px solid var(--border); }
.group-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.group-members { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.group-member { height: 22px; display: inline-flex; align-items: center; padding-inline: 8px; border-radius: 999px; background: var(--fill); font-size: var(--fs-xs); }
.rp-hint { padding: 8px 10px; color: var(--muted); font-size: var(--fs-sm); line-height: 1.8; }
.rp-all { display: grid; place-items: center; width: 28px; height: 28px; flex: none; margin-inline-start: auto; border: 0; border-radius: var(--radius-sm); background: none; color: var(--muted); cursor: pointer; }
.rp-all:hover, .rp-all.on { background: var(--hover); color: var(--text); }

/* فایلی که روزبان در گفتگو ساخت */
.msg-file { margin-top: var(--s2); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; white-space: normal; }
.msg-file-preview { display: block; background: #fff; border-bottom: 1px solid var(--border); }
.msg-file-preview img { display: block; width: 100%; height: auto; }
.msg-file-row { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s3); }
.msg-file-ico { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-text); }
.msg-file-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.5; }
.msg-file-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); }
.msg-file-text .muted { font-size: var(--fs-xs); }

/* ============================================================
   تقویم (web/calendar.js): بلوک‌های برنامه زیر، قرارها رو.
   ============================================================ */
.plc-head { margin-bottom: var(--s3); }
.plc-nav { display: flex; align-items: center; gap: var(--s3); flex: 1 1 100%; flex-wrap: wrap; }
.plc-step { display: flex; align-items: center; gap: 2px; }
.plc-title { font-size: var(--fs-lg); font-weight: 700; }
.plc-loading { padding: var(--s8) 0; text-align: center; }

.plc-filters { display: flex; flex-wrap: wrap; gap: var(--s1); margin-bottom: var(--s3); }
.plc-filter {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 var(--s3);
  border: 1px solid var(--border); border-radius: 999px; background: transparent;
  color: var(--muted); font: inherit; font-size: var(--fs-xs); cursor: pointer; text-decoration: line-through;
}
.plc-filter.on { color: var(--text-2); background: var(--surface-2); text-decoration: none; }
.plc-filter:hover { border-color: var(--border-strong); }
.plc-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--hue, var(--h-slate)); flex: none; }

.plc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: var(--s4); align-items: start; }

/* ---- جدولِ روز/هفته ---- */
.plc-grid {
  --gutter: 52px;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface);
  overflow: hidden; min-width: 0;
}
.plc-row { display: grid; grid-template-columns: var(--gutter) repeat(var(--days), minmax(0, 1fr)); }
.plc-days-head { border-bottom: 1px solid var(--border); background: var(--surface-2); }
.plc-corner { font-size: 11px; display: grid; place-items: center; }
.plc-day-head {
  display: flex; flex-direction: column; align-items: center; gap: 0; padding: 6px 0;
  border: 0; border-inline-start: 1px solid var(--border); background: transparent; color: var(--text-2);
  font: inherit; cursor: pointer; min-width: 0;
}
.plc-day-head:hover { background: var(--hover); }
.plc-wd { font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.plc-dn { font-size: 18px; font-weight: 700; line-height: 1.4; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; }
.plc-day-head.holiday .plc-dn, .plc-day-head.holiday .plc-wd { color: var(--h-red); }
.plc-day-head.today .plc-dn { background: var(--accent); color: var(--on-accent); }
.plc-allday { border-bottom: 1px solid var(--border); min-height: 30px; }
.plc-allday-cell { border-inline-start: 1px solid var(--border); padding: 3px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.plc-due {
  display: flex; align-items: center; gap: 4px; min-width: 0; height: 22px; padding: 0 6px;
  border: 0; border-radius: var(--radius-sm); font: inherit; font-size: 11px; cursor: pointer;
  background: color-mix(in srgb, var(--h-amber) 14%, transparent); color: color-mix(in srgb, var(--h-amber) 80%, var(--text));
}
.plc-due.hot { background: color-mix(in srgb, var(--h-red) 14%, transparent); color: color-mix(in srgb, var(--h-red) 80%, var(--text)); }
.plc-due span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plc-due svg { flex: none; }
.plc-more { font-size: 11px; padding-inline-start: 4px; }

.plc-scroll { max-height: calc(100vh - 290px); min-height: 360px; overflow-y: auto; overscroll-behavior: contain; }
.plc-body { position: relative; }
.plc-gutter { position: relative; }
.plc-hour-label {
  position: absolute; inset-inline: 0; transform: translateY(-50%); text-align: center;
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; unicode-bidi: isolate;
}
.plc-col { position: relative; border-inline-start: 1px solid var(--border); touch-action: pan-y; cursor: crosshair; min-width: 0; }
.plc-col.today { background: color-mix(in srgb, var(--accent) 3%, transparent); }
.plc-line { position: absolute; inset-inline: 0; border-top: 1px solid var(--border); pointer-events: none; }

.plc-block {
  position: absolute; inset-inline: 0; overflow: hidden;
  background: color-mix(in srgb, var(--hue) 13%, transparent);
  border-inline-start: 3px solid color-mix(in srgb, var(--hue) 70%, transparent);
  border-top: 1px solid color-mix(in srgb, var(--hue) 22%, transparent);
}
.plc-block.free {
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--hue) 10%, transparent) 0 6px, transparent 6px 12px);
  border-inline-start-style: dashed;
}
.plc-block:hover { background-color: color-mix(in srgb, var(--hue) 19%, transparent); }
.plc-block-title {
  display: flex; flex-direction: column; padding: 3px 6px; font-size: 11px; font-weight: 600; line-height: 1.5;
  color: color-mix(in srgb, var(--hue) 75%, var(--text)); pointer-events: none;
}
.plc-block-time { font-weight: 400; opacity: .8; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }

.plc-lane { position: absolute; inset-block: 0; inset-inline-start: 10px; inset-inline-end: 2px; pointer-events: none; }
.plc-event {
  position: absolute; pointer-events: auto; overflow: hidden; cursor: grab; user-select: none; touch-action: none;
  display: flex; flex-direction: column; gap: 0; padding: 2px 6px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--hue) 88%, var(--surface)); color: #fff;
  box-shadow: 0 0 0 1px var(--surface), 0 1px 3px rgba(0, 0, 0, .15);
  font-size: 12px; line-height: 1.5;
}
.plc-event:hover { filter: brightness(1.06); z-index: 2; }
.plc-event:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.plc-event.dragging { cursor: grabbing; opacity: .85; z-index: 5; box-shadow: var(--shadow); }
.plc-event.done { opacity: .5; text-decoration: line-through; }
.plc-event.conflict { box-shadow: 0 0 0 1px var(--surface), 0 0 0 3px var(--h-red); }
.plc-event.tiny { flex-direction: row; align-items: center; padding-block: 0; }
.plc-event-title { display: flex; align-items: center; gap: 3px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plc-event-title svg { flex: none; }
.plc-event-time, .plc-event-src { font-size: 11px; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plc-event-time { unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.plc-resize { position: absolute; inset-inline: 0; bottom: 0; height: 7px; cursor: ns-resize; }
.plc-resize::after { content: ''; position: absolute; inset-inline: 40%; bottom: 2px; height: 2px; border-radius: 2px; background: rgba(255, 255, 255, .6); }

.plc-now { position: absolute; inset-inline: 0; height: 0; border-top: 2px solid var(--accent); z-index: 3; pointer-events: none; }
.plc-now::before { content: ''; position: absolute; inset-inline-start: -5px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.plc-select {
  position: absolute; inset-inline: 2px; z-index: 4; pointer-events: none; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent) 18%, transparent); border: 1.5px dashed var(--accent);
  color: var(--accent-text); font-size: 11px; font-weight: 700; padding: 2px 6px; unicode-bidi: isolate;
}

/* ---- ستونِ کناری ---- */
.plc-side { display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.plc-side-card { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); padding: var(--s3) var(--s4); }
.plc-side-card.warn { border-color: color-mix(in srgb, var(--h-red) 35%, var(--border)); }
.plc-side-head { display: flex; align-items: center; gap: var(--s2); justify-content: space-between; margin-bottom: var(--s2); }
.plc-side-head h3 { font-size: var(--fs); font-weight: 700; }
.plc-side-card p { font-size: var(--fs-sm); line-height: 1.8; }
.plc-count { min-width: 22px; height: 22px; border-radius: 11px; display: grid; place-items: center; padding: 0 6px; background: var(--h-red); color: #fff; font-size: 12px; font-weight: 700; }
.plc-block-list, .plc-free, .plc-mix-legend, .plc-clashes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.plc-block-list button, .plc-free button, .plc-clashes.small button {
  display: flex; align-items: center; gap: var(--s2); width: 100%; padding: 6px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text); font: inherit; text-align: start; cursor: pointer;
}
.plc-block-list button:hover, .plc-free button:hover, .plc-clashes.small button:hover { background: var(--hover); }
.plc-swatch { width: 12px; height: 28px; border-radius: 4px; background: color-mix(in srgb, var(--hue) 70%, transparent); flex: none; }
.plc-swatch.free { background: repeating-linear-gradient(135deg, var(--hue) 0 3px, transparent 3px 6px); }
.plc-bl-text, .plc-clash-text { display: flex; flex-direction: column; min-width: 0; font-size: var(--fs-sm); line-height: 1.6; }
.plc-bl-text .muted, .plc-clash-text .muted { font-size: var(--fs-xs); }
.plc-free button { justify-content: space-between; font-size: var(--fs-sm); }
.plc-free button svg { color: var(--muted); }
.plc-side-empty .plc-presets { display: flex; flex-wrap: wrap; gap: var(--s1); margin-top: var(--s2); }
.plc-mix-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 1px; background: var(--surface-2); margin-bottom: var(--s2); }
.plc-mix-bar span { background: color-mix(in srgb, var(--hue) 75%, transparent); min-width: 2px; }
.plc-mix-bar span.rest { background: var(--fill); }
.plc-mix-legend li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--s2); font-size: var(--fs-xs); padding: 2px 0; }
.plc-clashes.small svg { color: var(--h-red); flex: none; }

/* ---- نمای ماه ---- */
.plc-month { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.plc-month-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.plc-month-head div { text-align: center; padding: 6px 0; font-size: var(--fs-xs); color: var(--muted); }
.plc-month-head div:last-child { color: var(--h-red); }
.plc-month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(108px, auto); }
.plc-m-cell {
  position: relative; display: flex; flex-direction: column; gap: 3px; padding: 4px 4px 14px; min-width: 0;
  border-inline-start: 1px solid var(--border); border-top: 1px solid var(--border); cursor: pointer;
}
.plc-m-cell:nth-child(7n + 1) { border-inline-start: 0; }
.plc-m-cell:nth-child(-n + 7) { border-top: 0; }
.plc-m-cell:hover { background: var(--hover); }
.plc-m-cell:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.plc-m-cell.out { background: var(--surface-2); }
.plc-m-cell.out .plc-m-num { color: var(--faint); }
.plc-m-cell.holiday .plc-m-num { color: var(--h-red); }
.plc-m-num { font-size: var(--fs-sm); font-weight: 700; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.plc-m-cell.today .plc-m-num { background: var(--accent); color: var(--on-accent); }
.plc-m-items { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.plc-m-event {
  display: flex; align-items: center; gap: 4px; min-width: 0; height: 20px; padding: 0 5px; border: 0; border-radius: 4px;
  background: color-mix(in srgb, var(--hue) 15%, transparent); color: var(--text); font: inherit; font-size: 11px; cursor: pointer;
  border-inline-start: 3px solid var(--hue);
}
.plc-m-event span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plc-m-event .mono { color: var(--muted); }
.plc-m-event.conflict { box-shadow: inset 0 0 0 1px var(--h-red); }
.plc-m-event.done { opacity: .5; text-decoration: line-through; }
.plc-strip { position: absolute; inset-inline: 4px; bottom: 4px; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.plc-strip span, .plc-strip i { position: absolute; top: 0; bottom: 0; }
.plc-strip span { background: color-mix(in srgb, var(--hue) 55%, transparent); }
.plc-strip span.free { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--hue) 55%, transparent) 0 2px, transparent 2px 4px); }
.plc-strip i { background: var(--text); border-radius: 1px; }
.plc-strip i.conflict { background: var(--h-red); }

/* ---- پنجره‌ها ---- */
.plc-slot { display: flex; align-items: center; gap: var(--s2); font-weight: 600; margin-bottom: var(--s3); }
.plc-choices { display: flex; flex-direction: column; gap: var(--s1); margin-bottom: var(--s3); }
.plc-choice {
  display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; text-align: start; cursor: pointer;
}
.plc-choice:hover { background: var(--hover); border-color: var(--border-strong); }
.plc-choice-ico { color: var(--muted); display: grid; place-items: center; }
.plc-choice-text { display: flex; flex-direction: column; line-height: 1.6; }
.plc-choice-text .muted { font-size: var(--fs-xs); }
.plc-clash-head { display: flex; align-items: flex-start; gap: var(--s3); margin-bottom: var(--s3); }
.plc-clash-head > svg { color: var(--h-red); flex: none; margin-top: 3px; }
.plc-clashes:not(.small) li { display: flex; align-items: flex-start; gap: var(--s2); padding: var(--s2); border-radius: var(--radius-sm); background: var(--surface-2); }
.plc-clashes:not(.small) .plc-dot { margin-top: 7px; }

.plc-cats { display: flex; flex-wrap: wrap; gap: var(--s1); }
.plc-cat {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 var(--s3); border-radius: 999px;
  border: 1px solid var(--border); background: transparent; color: var(--text-2); font: inherit; font-size: var(--fs-xs); cursor: pointer;
}
.plc-cat .plc-dot { background: var(--hue); }
.plc-cat.on { background: color-mix(in srgb, var(--hue) 14%, transparent); border-color: color-mix(in srgb, var(--hue) 45%, transparent); color: var(--text); font-weight: 600; }
.plc-swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.plc-swatch-btn { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--surface); background: var(--hue); cursor: pointer; box-shadow: 0 0 0 1px var(--border); }
.plc-swatch-btn.on { box-shadow: 0 0 0 2px var(--text); }
.plc-kind { flex-wrap: wrap; margin-bottom: var(--s2); }
.plc-weekdays { display: flex; gap: 4px; flex-wrap: wrap; }
.plc-wd-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border-strong); background: transparent;
  color: var(--text-2); font: inherit; font-weight: 700; cursor: pointer;
}
.plc-wd-btn.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.plc-busy { align-items: flex-start; margin: var(--s2) 0; line-height: 1.7; }
.plc-busy .muted { font-size: var(--fs-xs); }
.plc-more-opts summary { cursor: pointer; color: var(--text-2); font-size: var(--fs-sm); margin: var(--s2) 0; }

@media (max-width: 1100px) {
  .plc-layout { grid-template-columns: minmax(0, 1fr); }
  .plc-side { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
}
@media (max-width: 720px) {
  .plc-grid { --gutter: 40px; }
  .plc-grid.wide { overflow-x: auto; }
  .plc-grid.wide .plc-row { min-width: 560px; }
  .plc-month-grid { grid-auto-rows: minmax(72px, auto); }
  .plc-m-items .plc-m-event .mono, .plc-m-items .plc-due svg { display: none; }
  .plc-scroll { max-height: calc(100vh - 250px); }
}
/* نمای روز: یک‌چهارمِ کناری خالی می‌ماند تا بلوکِ برنامهٔ زیرِ قرارها دیده شود */
.plc-grid.single .plc-lane { inset-inline-end: 22%; }

/* تقویم و ساعتِ کنارِ لبه: به‌جای بیرون زدن، از سمتِ دیگرِ ورودی باز می‌شوند (keepPopupInside در app.js) */
.time-pop.flip, .calendar.flip { inset-inline-start: auto; inset-inline-end: 0; }

/* ---- تقویم: نوارِ فیلتر و پنلِ «نمایش» ---- */
.plc-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-bottom: var(--s3); }
.plc-view-btn.on { background: var(--accent-soft); color: var(--accent-text); }
.plc-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: inline-grid; place-items: center;
  background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 700;
}
.plc-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 var(--s2) 0 var(--s3);
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: var(--text-2);
  font: inherit; font-size: var(--fs-xs); cursor: pointer; max-width: 240px;
}
.plc-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plc-chip.struck span { text-decoration: line-through; color: var(--muted); }
.plc-chip svg { flex: none; color: var(--muted); }
.plc-chip:hover { border-color: var(--border-strong); color: var(--text); }

.plc-panel {
  position: fixed; z-index: 70; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.plc-panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); }
.plc-panel-body { overflow-y: auto; padding: var(--s2) var(--s3); flex: 1 1 auto; }
.plc-panel-body section + section { border-top: 1px solid var(--border); margin-top: var(--s2); padding-top: var(--s2); }
.plc-panel-body h4 { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; margin: var(--s1) var(--s1) var(--s1); }
.plc-panel-body .hint { padding: 0 var(--s1); }
.plc-panel-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: var(--s2) var(--s4); border-top: 1px solid var(--border); font-size: var(--fs-xs); }
.plc-prow { display: flex; align-items: center; gap: var(--s2); min-height: 34px; padding: 0 var(--s1); border-radius: var(--radius-sm); }
.plc-prow:hover { background: var(--hover); }
.plc-prow.sub { padding-inline-start: var(--s6); }
.plc-prow .check { flex: 1 1 auto; min-width: 0; font-size: var(--fs-sm); }
.plc-prow .check svg { color: var(--muted); flex: none; }
.plc-plabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plc-pcount { font-size: var(--fs-xs); color: var(--muted); min-width: 20px; text-align: center; }
.plc-only {
  border: 0; background: transparent; color: var(--accent-text); font: inherit; font-size: var(--fs-xs); font-weight: 600;
  padding: 2px 6px; border-radius: var(--radius-sm); cursor: pointer; opacity: 0; white-space: nowrap;
}
.plc-prow:hover .plc-only, .plc-only:focus-visible { opacity: 1; }
.plc-only:hover { background: var(--accent-soft); }
@media (hover: none) { .plc-only { opacity: 1; } }

/* ============================================================ قابِ کارپوشه (web/spaceframe.js)
   سرتیترِ ثابتِ هر کارپوشه بالای خانه و صفحهٔ موجودیت‌هایش: مسیر، اسم، اعضا، و تب‌ها.
   صفحهٔ موجودیت زیرش سرتیترِ خودش را دارد، پس قاب کوچک‌تر و آرام‌تر است. */
.space-frame { margin-bottom: var(--s4); }
.space-frame .crumbs { margin-bottom: 2px; font-size: var(--fs-xs); }
.space-frame-title { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.space-frame-name {
  display: inline-flex; align-items: center; gap: var(--s2); min-width: 0;
  border: 0; background: none; padding: 0; color: var(--text); cursor: pointer;
  font: inherit; font-size: var(--fs-lg); font-weight: 700;
}
.space-frame-name .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.space-frame-name:hover .label { color: var(--accent-text); }
.space-frame-icon { display: grid; place-items: center; color: var(--muted); }
.space-frame-title .actions { display: flex; align-items: center; gap: var(--s1); margin-inline-start: auto; flex-wrap: wrap; }
.space-tabs {
  display: flex; align-items: stretch; gap: 2px; margin-top: var(--s2);
  border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: thin;
}
.space-tab {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 7px 10px; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent;
  background: none; color: var(--text-2); font: inherit; font-size: var(--fs-sm); cursor: pointer; white-space: nowrap;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.space-tab:hover { color: var(--text); background: var(--hover); }
.space-tab.on { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.space-tab .ico, .space-tab svg { color: var(--muted); flex: none; }
.space-tab.on svg { color: var(--accent-text); }
.space-tab .count { font-size: var(--fs-xs); color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.space-tab.sub { color: var(--muted); }
.space-tab.add, .space-tab.more { color: var(--muted); padding-inline: 8px; }
.space-tabs-sep { width: 1px; background: var(--border); margin: 8px 4px; flex: none; }

/* سایدبار: سرتیترِ «کارپوشه‌ها» با دکمهٔ + و بخشِ تاشوی «بیشتر» */
.nav-label-row { display: flex; align-items: center; justify-content: space-between; }
.nav-label-add {
  width: 22px; height: 22px; display: grid; place-items: center; border: 0; border-radius: 4px;
  background: none; color: var(--muted); cursor: pointer;
}
.nav-label-add:hover { background: var(--fill-hover); color: var(--text); }
.nav-more { color: var(--text-2); }
.nav-more-list { margin-top: 2px; }
.nav-more-list[hidden] { display: none; }
.nav-more-list .nav-divider.short { margin-block: var(--s1); }
