@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
/* the reference design's typeface; Latin only, Persian text falls back to Vazirmatn */
@font-face {
  font-family: "Urbanist";
  src: url("fonts/urbanist.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

/* ------------------------------------------------------------------ tokens
 * Black (default) and white themes; the brand colour is #272757 in both. */
:root, :root[data-theme="dark"] {
  --brand: #272757;
  --brand-2: #34347a;
  --brand-ink: #ffffff;
  --brand-text: #a9a9f5;       /* brand colour readable on black */
  --brand-soft: rgba(124, 124, 230, 0.16);
  --bg: #000000;
  --surface: #0c0c0e;
  --card: #1a1a1d;
  --card-2: #242428;
  --card-3: #2e2e33;
  --line: #2c2c31;
  --line-2: #3a3a40;
  --text: #ffffff;
  --muted: #8d8d96;
  --hover: rgba(255, 255, 255, 0.06);
  --on: #ffffff;                /* selected chip */
  --on-ink: #000000;
  --cyan: #66ffed;
  --ok: #6ee7a0;
  --warn: #ffc457;
  --danger: #f04949;
  --pending: #9a9aa3;
  --progress: #66ffed;
  --done: #6ee7a0;
  --chat-bg: #000000;
  --bubble-in: #1f1f23;
  --bubble-out: #272757;
  --bubble-out-ink: #ffffff;
  --bubble-out-meta: #b4b4f0;
  --panel-light: #f4f4f6;       /* the "Summary" drawer stays light, as in the design */
  --panel-light-ink: #0d0d12;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --brand-text: #272757;
  --brand-soft: rgba(39, 39, 87, 0.09);
  --bg: #ececef;
  --surface: #f6f6f8;
  --card: #ffffff;
  --card-2: #f1f1f4;
  --card-3: #e7e7ec;
  --line: #e1e1e7;
  --line-2: #d2d2da;
  --text: #0d0d12;
  --muted: #6c6c78;
  --hover: rgba(13, 13, 18, 0.05);
  --on: #272757;
  --on-ink: #ffffff;
  --cyan: #0fb5a3;
  --ok: #1f9d55;
  --warn: #c98400;
  --danger: #d93636;
  --pending: #8a8a95;
  --progress: #0b9e8f;
  --done: #1f9d55;
  --chat-bg: #ececef;
  --bubble-in: #ffffff;
  --bubble-out: #272757;
  --bubble-out-meta: #b9b9ee;
  --panel-light: #ffffff;
  --shadow: 0 1px 2px rgba(13, 13, 18, 0.08);
  --shadow-lg: 0 24px 60px rgba(13, 13, 18, 0.18);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="system"] {
    --brand-text: #272757; --brand-soft: rgba(39, 39, 87, 0.09);
    --bg: #ececef; --surface: #f6f6f8; --card: #ffffff; --card-2: #f1f1f4; --card-3: #e7e7ec;
    --line: #e1e1e7; --line-2: #d2d2da; --text: #0d0d12; --muted: #6c6c78; --hover: rgba(13, 13, 18, 0.05);
    --on: #272757; --on-ink: #ffffff; --cyan: #0fb5a3; --ok: #1f9d55; --warn: #c98400; --danger: #d93636;
    --pending: #8a8a95; --progress: #0b9e8f; --done: #1f9d55; --chat-bg: #ececef; --bubble-in: #ffffff;
    --bubble-out-meta: #b9b9ee; --panel-light: #ffffff;
    --shadow: 0 1px 2px rgba(13, 13, 18, 0.08); --shadow-lg: 0 24px 60px rgba(13, 13, 18, 0.18);
    color-scheme: light;
  }
}

:root {
  --font: "Urbanist", "Vazirmatn", system-ui, sans-serif;
  --r-sm: 12px;
  --r: 20px;
  --r-lg: 28px;
}

:root[dir="rtl"] { --font: "Vazirmatn", Tahoma, system-ui, sans-serif; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.65 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; opacity: 0.5; }
a { color: var(--brand-text); }
[hidden] { display: none !important; }
::selection { background: var(--brand); color: #fff; }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.grow { flex: 1; }
.num { font-feature-settings: "tnum"; }
.boot { display: grid; place-items: center; height: 100vh; }
.boot img { animation: breathe 1.4s ease-in-out infinite; border-radius: 18px; }
@keyframes breathe { 50% { transform: scale(0.92); opacity: 0.7; } }

.ico { width: 22px; height: 22px; fill: currentColor; flex: none; }
/* icons are drawn for left-to-right; mirror the directional ones in Persian */
[dir="rtl"] .ico-back, [dir="rtl"] .ico-arrow, [dir="rtl"] .ico-send, [dir="rtl"] .ico-forward { transform: scaleX(-1); }
/* the prev/next chevrons are swapped on purpose for RTL; un-swap them for LTR */
[dir="ltr"] .ico-prev, [dir="ltr"] .ico-next { transform: scaleX(-1); }

/* ------------------------------------------------------------------ form controls */
input:not([type=checkbox]):not([type=color]):not([type=radio]), select, textarea {
  width: 100%;
  min-width: 0;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card-2);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { border-radius: 18px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-text); box-shadow: 0 0 0 3px var(--brand-soft); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); margin: 0; flex: none; }
input[type=color] { width: 56px; height: 38px; border: 1px solid var(--line); border-radius: 12px; padding: 3px; background: var(--card-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 20px; border-radius: 999px; font-weight: 600;
  background: transparent; color: var(--text); white-space: nowrap;
  box-shadow: inset 0 0 0 1px var(--line-2);
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}
.btn:hover:not(:disabled) { background: var(--hover); }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn.primary { background: var(--brand); color: var(--brand-ink); box-shadow: none; }
.btn.primary:hover:not(:disabled) { background: var(--brand-2); }
.btn.light { background: var(--on); color: var(--on-ink); box-shadow: none; }
.btn.danger { color: var(--danger); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 55%, transparent); }
.btn.sm { padding: 6px 14px; font-size: 13px; }
.btn.sm .ico { width: 18px; height: 18px; }
.btn.block { width: 100%; padding: 12px; }
.btn .plus { width: 28px; height: 28px; margin-inline-start: -10px; border-radius: 50%; display: grid; place-items: center; box-shadow: inset 0 0 0 1px var(--line-2); }
.link { color: var(--brand-text); font-weight: 600; padding: 4px 0; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border-radius: 50%; color: var(--muted); transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.ring { box-shadow: inset 0 0 0 1px var(--line-2); color: var(--text); }
.icon-btn.solid { background: var(--on); color: var(--on-ink); }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm .ico { width: 16px; height: 16px; }
.icon-btn.danger:hover { color: var(--danger); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 16px; border-radius: 999px; font-size: 13px;
  color: var(--text); white-space: nowrap; box-shadow: inset 0 0 0 1px var(--line-2);
  transition: background 0.15s;
}
button.chip:hover, a.chip:hover { background: var(--hover); }
a.chip { text-decoration: none; }
.chip.sm { padding: 2px 10px; font-size: 12px; }
.chip.on, .chip.toggle.on { background: var(--on); color: var(--on-ink); box-shadow: none; }
.chip .ico { width: 16px; height: 16px; }
.chip.soft { background: var(--card-3); box-shadow: none; }
.ws-chip { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 60%, transparent); }
.tag { font-size: 11px; font-weight: 700; padding: 0 7px; margin-inline-start: 6px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-text); }
.tag.soft { background: var(--card-3); color: var(--muted); }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--danger); color: #fff; font-size: 11.5px; font-weight: 700;
  display: inline-grid; place-items: center; line-height: 1;
}
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }

.avatar {
  --c: var(--brand);
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(150deg, color-mix(in srgb, var(--c) 70%, #fff), var(--c));
  color: #fff; font-weight: 700; font-size: 15px; user-select: none;
  box-shadow: 0 0 0 2px var(--card);
}
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.avatar.xs { width: 22px; height: 22px; font-size: 9.5px; }
.avatar.bot { --c: var(--brand); }
.avatar.bot .ico { width: 20px; height: 20px; }
.avatar.role { --c: #6c6c78; }
.stack { display: inline-flex; }
.stack .avatar + .avatar { margin-inline-start: -8px; }

/* platform & status markers */
.pf { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px 2px 8px; border-radius: 999px; font-size: 12px; background: var(--card-3); white-space: nowrap; }
.pf i { width: 8px; height: 8px; border-radius: 50%; background: var(--pc); }
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.st::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--sc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sc) 25%, transparent); }
.st.pending { --sc: var(--pending); }
.st.progress { --sc: var(--progress); }
.st.done { --sc: var(--done); }
.st.late { --sc: var(--danger); color: var(--danger); }
.code { font: 600 12px/1 var(--font); direction: ltr; unicode-bidi: isolate; padding: 3px 8px; border-radius: 8px; background: var(--card-3); color: var(--muted); }

/* ------------------------------------------------------------------ login */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 16px; overflow: auto;
  background: radial-gradient(1200px 600px at 80% -10%, color-mix(in srgb, var(--brand) 55%, transparent), transparent 60%), var(--bg);
}
.login-card {
  width: min(400px, 100%); background: var(--card); border-radius: var(--r-lg); padding: 36px 28px;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 12px; text-align: center;
}
.login-card h1 { margin: 0; font-size: 30px; font-weight: 300; letter-spacing: 1px; }
.login-card p { margin: 0 0 8px; }
.login-logo { width: 84px; height: 84px; margin: 0 auto 6px; border-radius: 24px; }
.login-err { color: var(--danger); min-height: 20px; font-size: 13px; }

/* ------------------------------------------------------------------ layout */
.layout { display: grid; grid-template-columns: 84px 1fr; height: 100vh; height: 100dvh; background: var(--bg); }
.rail {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 0;
  overflow-y: auto; scrollbar-width: none;
}
.rail-logo { width: 44px; height: 44px; margin-bottom: 18px; border-radius: 14px; }
.rail-nav { display: flex; flex-direction: column; gap: 12px; align-items: center; flex: 1; }
.rail-btn {
  position: relative; width: 48px; height: 48px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line-2); transition: background 0.2s, color 0.2s;
}
.rail-btn .ico { width: 21px; height: 21px; }
.rail-btn:hover { background: var(--hover); }
.rail-btn.active { background: var(--on); color: var(--on-ink); box-shadow: none; }
.rail-btn .badge { position: absolute; top: -3px; inset-inline-end: -3px; box-shadow: 0 0 0 2px var(--bg); }
.rail-sep { width: 28px; height: 1px; background: var(--line); margin: 4px 0; }
.me-btn { box-shadow: none; }
.me-btn.active { box-shadow: 0 0 0 2px var(--text); background: none; }

.shell { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 14px 14px 14px 0; gap: 14px; }
.workarea { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr; gap: 14px; }
.layout.v-chat .workarea { grid-template-columns: 300px 1fr; }

/* top bar: workspace switcher + "your schedule" timeline + bell + avatar */
.topbar { display: flex; align-items: center; gap: 12px; flex: none; }
.ws-switch {
  display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 8px; border-radius: 999px; flex: none;
  background: var(--card); max-width: 240px;
}
.ws-switch .ws-mark { width: 30px; height: 30px; border-radius: 50%; background: var(--c); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 13px; flex: none; }
.ws-switch .ws-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-switch .ico { width: 18px; height: 18px; color: var(--muted); }
.schedule {
  flex: 1; min-width: 0; height: 56px; display: flex; align-items: center; gap: 10px;
  background: var(--panel-light); color: var(--panel-light-ink); border-radius: 999px; padding: 6px 6px 6px 8px;
}
.schedule-label { font-weight: 600; padding-inline: 12px 4px; white-space: nowrap; }
.schedule-date { display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 999px; box-shadow: inset 0 0 0 1px #d6d6dd; white-space: nowrap; font-size: 13px; }
.schedule-date .ico { width: 30px; height: 30px; padding: 6px; border-radius: 50%; background: #e7e7ec; }
.timeline { position: relative; flex: 1; min-width: 0; height: 44px; border-radius: 999px; background: #e9e9ee; overflow: hidden; }
.timeline .tl-item {
  position: absolute; top: 4px; height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 14px 0 6px;
  border-radius: 999px; background: #fff; color: #0d0d12; font-size: 12.5px; white-space: nowrap; max-width: 260px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); cursor: pointer;
}
.timeline .tl-item.st-done { opacity: 0.55; }
.timeline .tl-item.st-progress { background: #272757; color: #fff; }
.timeline .tl-item b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.timeline .tl-now { position: absolute; top: 0; bottom: 0; width: 2px; background: #272757; }
.timeline .tl-now span { position: absolute; top: 2px; transform: translateX(50%); background: #272757; color: #fff; font-size: 10.5px; padding: 0 6px; border-radius: 999px; white-space: nowrap; }
.timeline .tl-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #8a8a95; font-size: 13px; }
.schedule .icon-btn { color: #0d0d12; box-shadow: inset 0 0 0 1px #d6d6dd; }
.topbar .bell { position: relative; background: var(--card); color: var(--text); width: 48px; height: 48px; }
.topbar .bell .pip { position: absolute; top: 12px; inset-inline-end: 13px; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--card); }

.sidebar { background: var(--card); border-radius: var(--r-lg); display: none; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.layout.v-chat .sidebar { display: flex; }
.sb-head { padding: 18px 20px 14px; display: flex; align-items: flex-start; gap: 10px; }
.sb-head > div { flex: 1; min-width: 0; }
.sb-title { font-weight: 300; font-size: 24px; line-height: 1.3; }
.sb-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.sb-roles { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.sb-list { overflow-y: auto; padding: 4px 10px 12px; flex: 1; }
.sb-label { font-size: 12px; color: var(--muted); padding: 12px 10px 6px; font-weight: 600; }
.sb-item {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 18px;
  text-align: start; transition: background 0.12s;
}
.sb-item:hover { background: var(--hover); }
.sb-item.active { background: var(--on); color: var(--on-ink); }
.sb-item.active .sb-desc { color: inherit; opacity: 0.7; }
.sb-item.active .chan-ico { background: var(--brand); color: #fff; box-shadow: none; }
.sb-item.active .badge { background: var(--brand); }
.sb-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sb-name { font-weight: 600; display: flex; align-items: center; gap: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-name .ico { width: 14px; height: 14px; opacity: 0.6; }
.sb-desc { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chan-ico {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none;
  color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2);
}
.chan-ico .ico { width: 20px; height: 20px; }
.chan-ico.sm { width: 32px; height: 32px; }
.chan-ico.sm .ico { width: 16px; height: 16px; }
.chan-ico.k-plan { color: var(--brand-text); }
.chan-ico.k-final { color: var(--ok); }
.chan-ico.k-content { color: var(--cyan); }

.main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); border-radius: var(--r-lg); overflow: hidden; }
.main.drop::after {
  content: attr(data-drop); position: absolute; inset: 12px; border: 2px dashed var(--brand-text);
  border-radius: var(--r); display: grid; place-items: center; background: color-mix(in srgb, var(--surface) 85%, transparent);
  font-size: 18px; font-weight: 700; color: var(--brand-text); z-index: 5; pointer-events: none;
}
.main-head {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px; min-height: 68px;
  border-bottom: 1px solid var(--line); flex: none; z-index: 2;
}
.head-text { flex: 1; min-width: 0; }
.head-title { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back-btn { display: none; }

.offline-bar {
  position: fixed; top: 0; inset-inline: 0; margin: auto; width: max-content; z-index: 50;
  background: var(--warn); color: #1c1f23; font-size: 12.5px; font-weight: 600;
  padding: 3px 14px; border-radius: 0 0 10px 10px; display: none;
}
body.offline .offline-bar { display: block; }

.empty { margin: auto; padding: 40px 20px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 14px; align-items: center; max-width: 440px; }
.loading { text-align: center; color: var(--muted); padding: 14px; font-size: 13px; }

/* ------------------------------------------------------------------ dashboard */
.dash { flex: 1; overflow-y: auto; padding: 22px 26px 30px; display: flex; flex-direction: column; gap: 26px; }
.hero { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.hero h1 { margin: 0; font-size: clamp(30px, 4vw, 48px); font-weight: 300; letter-spacing: 0.5px; line-height: 1.1; display: flex; align-items: center; gap: 12px; }
.hero h1 img { width: 0.9em; height: 0.9em; border-radius: 28%; }
.stats { display: flex; gap: 28px; margin-inline-start: auto; flex-wrap: wrap; }
.stat { display: flex; align-items: baseline; gap: 6px; position: relative; }
.stat b { font-size: clamp(30px, 3.4vw, 44px); font-weight: 300; line-height: 1; }
.stat span { color: var(--muted); font-size: 14px; }
.stat .delta { position: absolute; top: -8px; inset-inline-end: -14px; font-size: 10.5px; font-weight: 700; padding: 0 6px; border-radius: 6px; background: var(--ok); color: #000; }
.stat .delta.bad { background: var(--danger); color: #fff; }
.sec-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sec-head h2 { margin: 0; font-size: 22px; font-weight: 400; }
.sec-head .count { font-size: 13px; text-decoration: underline; text-underline-offset: 5px; color: var(--text); }
.sec-head .count b { font-size: 18px; font-weight: 600; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-inline-start: auto; }
.row-scroll { display: flex; gap: 16px; overflow-x: auto; padding: 4px 2px 10px; scroll-snap-type: x proximity; }
.row-scroll > * { scroll-snap-align: start; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }

/* notched card: a round button sits in a bite out of the top corner */
.nwrap { position: relative; flex: none; width: 290px; }
.grid-cards .nwrap { width: auto; }
.ncard {
  position: relative; border-radius: var(--r-lg); background: var(--card); padding: 18px 18px 16px;
  min-height: 210px; display: flex; flex-direction: column; gap: 10px; cursor: pointer;
  -webkit-mask: radial-gradient(circle 31px at 25px 25px, #0000 30px, #000 31px);
  mask: radial-gradient(circle 31px at 25px 25px, #0000 30px, #000 31px);
  transition: background 0.15s, transform 0.15s;
}
.ncard:hover { background: var(--card-2); }
.nwrap .corner { position: absolute; top: 3px; left: 3px; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; box-shadow: inset 0 0 0 1px var(--line-2); color: var(--text); background: transparent; }
.nwrap .corner .ico { width: 20px; height: 20px; }
.nwrap .corner:hover { background: var(--hover); }
.nwrap.hot .ncard { background: var(--brand); color: #fff; }
.nwrap.hot .ncard .muted, .nwrap.hot .ncard .st { color: rgba(255, 255, 255, 0.75); }
.nwrap.hot .ncard .pf { background: rgba(255, 255, 255, 0.14); }
.nwrap.hot .ncard .chip { color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35); }
.nwrap.hot .ncard .code { background: rgba(255, 255, 255, 0.14); color: #fff; }
.nc-top { display: flex; align-items: center; gap: 10px; padding-inline-end: 0; padding-inline-start: 0; margin-inline-end: 0; min-height: 34px; padding-left: 44px; }
.nc-top .who { min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.nc-top .who b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nc-top .who span { font-size: 11.5px; color: var(--muted); }
.nc-title { font-size: 20px; font-weight: 500; line-height: 1.35; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.nc-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.nc-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; }
.nc-status { flex: 1; display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--line-2); min-width: 0; }
.nwrap.hot .nc-status { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3); }
.nc-status small { display: block; font-size: 10.5px; color: var(--muted); line-height: 1.1; }
.nc-cover { height: 96px; border-radius: 18px; background: var(--card-3) center / cover no-repeat; overflow: hidden; }
.nc-cover video { width: 100%; height: 100%; object-fit: cover; display: block; }
.progress-dots { display: flex; gap: 4px; }
.progress-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--card-3); }
.progress-dots i.on { background: var(--progress); }
.progress-dots i.on.d { background: var(--done); }

/* ------------------------------------------------------------------ drawer (content template / "Summary") */
.drawer-bg { position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, 0.35); animation: fade 0.15s; }
.drawer {
  position: fixed; top: 14px; bottom: 14px; left: 14px; width: min(520px, calc(100vw - 28px)); z-index: 95;
  background: var(--panel-light); color: var(--panel-light-ink); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; animation: slide 0.22s ease-out;
  --text: #0d0d12; --muted: #6c6c78; --card: #ffffff; --card-2: #f1f1f4; --card-3: #e7e7ec; --line: #e1e1e7; --line-2: #d2d2da;
  --hover: rgba(13, 13, 18, 0.05); --on: #0d0d12; --on-ink: #ffffff; --brand-text: #272757; --brand-soft: rgba(39, 39, 87, 0.09);
  --progress: #0b9e8f; --done: #1f9d55; --pending: #8a8a95; --ok: #1f9d55; --danger: #d93636; --cyan: #0fb5a3;
  color-scheme: light;
}
@keyframes slide { from { transform: translateX(-24px); opacity: 0; } }
.drawer input:not([type=checkbox]), .drawer select, .drawer textarea { background: #fff; }
.dr-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 10px; }
.dr-head .dr-ico { width: 48px; height: 48px; border-radius: 50%; background: #0d0d12; color: #fff; display: grid; place-items: center; flex: none; }
.dr-head h2 { margin: 0; flex: 1; min-width: 0; font-size: 24px; font-weight: 400; line-height: 1.3; overflow-wrap: anywhere; }
.dr-body { flex: 1; overflow-y: auto; padding: 4px 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.dr-body > * { flex-shrink: 0; }
.dr-block { background: var(--card-2); border-radius: 22px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.dr-block h4 { margin: 0; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.dr-block h4 .grow + * { margin-inline-start: auto; }
.dr-block .val { white-space: pre-wrap; overflow-wrap: anywhere; }
.dr-block .val.empty-val { color: var(--muted); font-size: 13px; }
.dr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dr-kv { background: var(--card-2); border-radius: 18px; padding: 10px 14px; }
.dr-kv small { display: block; color: var(--muted); font-size: 11.5px; }
.dr-kv b { font-weight: 600; }
.stepper { display: flex; align-items: center; gap: 0; }
.stepper .step { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); position: relative; }
.stepper .step::before { content: ""; position: absolute; top: 11px; left: -50%; width: 100%; height: 2px; background: var(--line-2); z-index: 0; }
/* each step draws the line toward the next one (leftwards in RTL) */
.stepper .step:last-child::before { display: none; }
.stepper .step i { width: 24px; height: 24px; border-radius: 50%; background: var(--card-3); position: relative; z-index: 1; display: grid; place-items: center; }
.stepper .step.on { color: var(--text); font-weight: 600; }
.stepper .step.on i { background: #0d0d12; color: #fff; }
.stepper .step.on:has(+ .step.on)::before { background: #0d0d12; }
.stepper .step i .ico { width: 14px; height: 14px; }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.file-tile { position: relative; aspect-ratio: 1; border-radius: 16px; background: #fff; overflow: hidden; display: grid; place-items: center; box-shadow: inset 0 0 0 1px var(--line); text-decoration: none; color: inherit; }
.file-tile img, .file-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-tile .fname { position: absolute; inset-inline: 0; bottom: 0; padding: 14px 8px 6px; font-size: 11px; color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, 0.65)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-tile .doc { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px; text-align: center; font-size: 11px; color: var(--muted); }
.file-tile .doc .ico { width: 30px; height: 30px; color: var(--text); }
.file-tile .rm { position: absolute; top: 6px; inset-inline-start: 6px; width: 26px; height: 26px; border-radius: 50%; background: rgba(0, 0, 0, 0.55); color: #fff; display: none; place-items: center; }
.file-tile:hover .rm { display: grid; }
.file-tile .rm .ico { width: 15px; height: 15px; }
.file-tile.add { box-shadow: inset 0 0 0 2px dashed var(--line-2); border: 2px dashed var(--line-2); background: transparent; color: var(--muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; }
.file-tile.add .ico { width: 26px; height: 26px; }
.file-tile .play { position: absolute; width: 34px; height: 34px; border-radius: 50%; background: rgba(0, 0, 0, 0.55); color: #fff; display: grid; place-items: center; }
.activity { display: flex; flex-direction: column; gap: 8px; }
.act { display: flex; gap: 8px; align-items: flex-start; }
.act .bub { background: #fff; border-radius: 16px; padding: 7px 12px; flex: 1; min-width: 0; box-shadow: inset 0 0 0 1px var(--line); }
.act .bub .who { font-size: 12px; font-weight: 700; }
.act .bub .text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; }
.act .bub .when { font-size: 11px; color: var(--muted); }
.comment-box { display: flex; gap: 8px; align-items: flex-end; }
.comment-box textarea { flex: 1; min-height: 42px; border-radius: 22px; resize: none; }
.inline-edit { cursor: text; border-radius: 12px; padding: 2px 4px; margin: -2px -4px; }
.inline-edit:hover { background: var(--hover); }
.metric-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.metric-row:first-of-type { border-top: 0; }
.metric-nums { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--muted); }
.metric-nums b { color: var(--text); font-weight: 600; }
.score-pill { min-width: 48px; text-align: center; padding: 3px 10px; border-radius: 999px; font-weight: 700; background: var(--gc, var(--card-3)); color: #000; }
.g-Aplus { --gc: #6ee7a0; } .g-A { --gc: #a6f0c6; } .g-B { --gc: #66ffed; } .g-C { --gc: #ffd27a; } .g-D { --gc: #ff9a9a; }

/* ------------------------------------------------------------------ messages */
.messages {
  flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 14px 6% 18px;
  background: var(--surface); display: flex; flex-direction: column;
}
.messages > :first-child { margin-top: auto; }
.day-sep { text-align: center; margin: 12px 0 8px; position: sticky; top: 4px; z-index: 1; }
.day-sep span { background: var(--card-2); color: var(--muted); padding: 3px 14px; border-radius: 999px; font-size: 12px; font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
.msg-row { display: flex; align-items: flex-end; gap: 8px; margin-top: 8px; max-width: 100%; }
.msg-row.grouped { margin-top: 2px; }
.msg-row.out { justify-content: flex-end; }
.avatar-space { width: 42px; flex: none; }
.bubble {
  position: relative; max-width: min(580px, 78%); min-width: 72px;
  background: var(--bubble-in); border-radius: 20px; padding: 8px 14px 5px;
  overflow-wrap: anywhere;
}
.msg-row.in:not(.grouped) .bubble { border-end-start-radius: 6px; }
.msg-row.out .bubble { background: var(--bubble-out); color: var(--bubble-out-ink); border-end-end-radius: 6px; }
.msg-row.out.grouped .bubble { border-end-end-radius: 20px; }
.author { font-weight: 700; font-size: 13px; margin-bottom: 1px; display: flex; align-items: center; }
.fwd { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; margin-bottom: 2px; }
.fwd .ico { width: 14px; height: 14px; }
.msg-row.out .fwd { color: var(--bubble-out-meta); }
.ref-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 10px 2px 4px; border-radius: 999px; background: rgba(127, 127, 160, 0.2); margin-bottom: 4px; max-width: 100%; }
.ref-chip .code { background: rgba(0, 0, 0, 0.25); color: inherit; }
.ref-chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text { white-space: pre-wrap; }
.text.folded { max-height: 16em; overflow: hidden; -webkit-mask: linear-gradient(#000 70%, #0000); mask: linear-gradient(#000 70%, #0000); }
.more-btn { display: block; margin-top: 2px; }
.msg-row.out .more-btn { color: #c9c9ff; }
.mention { color: var(--brand-text); font-weight: 600; }
.msg-row.out .mention { color: #c9c9ff; }
/* "@reza" inside Persian text must not turn into "reza@" */
.mention, .chip, .sb-desc, .head-sub, .ev-title, .agenda-title, .nc-title, .tl-item b { unicode-bidi: plaintext; }
.mention.me { background: var(--brand-soft); border-radius: 4px; padding: 0 2px; }
.meta { display: flex; justify-content: flex-end; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.msg-row.out .meta { color: var(--bubble-out-meta); }
.edited { font-style: italic; }
.ev-badge { display: inline-flex; align-items: center; gap: 3px; padding: 1px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-text); font-weight: 600; font-size: 11.5px; }
.msg-row.out .ev-badge { background: rgba(255, 255, 255, 0.15); color: #fff; }
.ev-badge .ico { width: 14px; height: 14px; }
.att-img { display: block; margin: 2px -10px 4px; }
.att-img img { display: block; max-width: 100%; max-height: 360px; border-radius: 16px; }
.att-video { display: block; width: 100%; max-height: 420px; border-radius: 16px; margin: 2px 0 4px; background: #000; }
.att-audio { width: 260px; max-width: 100%; margin: 4px 0; }
.att-file { display: flex; align-items: center; gap: 10px; padding: 4px 0; text-decoration: none; color: inherit; }
.att-ico { width: 44px; height: 44px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; flex: none; }
.msg-row.out .att-ico { background: rgba(255, 255, 255, 0.18); }
.att-info { display: flex; flex-direction: column; min-width: 0; }
.att-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-size { font-size: 12px; color: var(--muted); }
.msg-row.out .att-size { color: var(--bubble-out-meta); }

.bubble.note { cursor: pointer; }
.bubble.note.unread { box-shadow: inset -3px 0 0 var(--brand-text); }
.note-kind { font-size: 12px; font-weight: 700; color: var(--brand-text); }
.bubble.note.k-reminder .note-kind { color: var(--warn); }
.bubble.note.k-mention .note-kind { color: var(--cyan); }
.bubble.note.k-overdue .note-kind { color: var(--danger); }
.bubble.note.k-report .note-kind { color: var(--ok); }

.help-card { margin: auto; max-width: 480px; background: var(--card); border-radius: var(--r); padding: 16px 18px; }
.help-card p { margin: 6px 0; }
.help-card pre, pre.cred {
  background: var(--card-2); border-radius: 14px; padding: 10px 12px; margin: 8px 0; white-space: pre-wrap;
  font: 13.5px/1.8 var(--font);
}

/* ------------------------------------------------------------------ composer */
.composer { position: relative; padding: 10px 14px 12px; flex: none; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.composer.readonly { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); padding: 16px; }
.composer.readonly .ico { width: 18px; height: 18px; }
.composer-row { display: flex; align-items: flex-end; gap: 8px; background: var(--card); border-radius: 26px; padding: 6px; }
.composer textarea {
  flex: 1; resize: none; min-height: 42px; max-height: 200px; overflow-y: auto; line-height: 1.55; border-radius: 20px; padding: 9px 8px;
  background: transparent; border-color: transparent; box-shadow: none !important;
}
.send-btn { width: 42px; height: 42px; border-radius: 50%; background: var(--on); color: var(--on-ink); display: grid; place-items: center; flex: none; }
.composer-hint { font-size: 11.5px; color: var(--muted); padding: 6px 54px 0; }
.att-bar { display: flex; flex-direction: column; gap: 6px; }
.att-bar:not(:empty) { margin-bottom: 8px; }
.att-chip {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 16px;
  background: var(--card); font-size: 13px; box-shadow: inset 0 0 0 1px var(--line-2);
}
.att-chip .ico { width: 18px; height: 18px; color: var(--brand-text); }
.att-chip.ready .ico:first-child { color: var(--ok); }
.att-chip-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mention-box {
  position: absolute; bottom: 100%; inset-inline: 14px; max-width: 380px; margin-bottom: 4px;
  background: var(--card-2); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 4px; z-index: 10;
}
.mention-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 14px; text-align: start; }
.mention-item > span:nth-child(2) { flex: 1; font-weight: 600; }
.mention-item.on, .mention-item:hover { background: var(--hover); }

/* ------------------------------------------------------------------ calendar */
.cal-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line); flex: none; }
.cal-nav, .cal-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-title { font-weight: 400; font-size: 18px; margin-inline-start: 6px; }
.segs { display: inline-flex; border-radius: 999px; padding: 3px; box-shadow: inset 0 0 0 1px var(--line-2); }
.seg { padding: 5px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg.on { background: var(--on); color: var(--on-ink); }
.cal-body { flex: 1; overflow: auto; padding: 16px 18px 26px; }

.week { display: grid; grid-template-columns: repeat(7, minmax(130px, 1fr)); gap: 10px; min-height: 100%; }
.day { position: relative; background: var(--card); border-radius: 22px; padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 240px; }
.day.today { box-shadow: inset 0 0 0 2px var(--brand-text); }
.day.past { opacity: 0.7; }
.day-head { display: flex; flex-direction: column; align-items: flex-start; text-align: start; padding: 2px 6px; }
.day-head .wd { font-weight: 700; }
.day-head .dn { font-size: 12px; color: var(--muted); }
.day-evs { display: flex; flex-direction: column; gap: 6px; }
.add-day { position: absolute; top: 8px; inset-inline-end: 8px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); opacity: 0; transition: opacity 0.15s; box-shadow: inset 0 0 0 1px var(--line-2); }
.add-day .ico { width: 18px; height: 18px; }
.day:hover .add-day, .add-day:focus { opacity: 1; }

.ev {
  --c: var(--brand-text);
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; width: 100%; text-align: start;
  padding: 7px 10px; border-radius: 14px; font-size: 12.5px; line-height: 1.45;
  background: var(--card-2); box-shadow: inset -3px 0 0 var(--c); /* the start edge in RTL */
}
.ev:hover { background: var(--card-3); }
.ev.mine { font-weight: 700; }
.ev.st-done { opacity: 0.6; }
.ev.st-done .ev-title { text-decoration: line-through; }
.ev .st { font-size: 0; gap: 0; }
.ev-time { font-weight: 700; color: var(--c); }
.ev-title { flex: 1 1 100%; min-width: 0; overflow-wrap: anywhere; }
.ev-people { display: flex; gap: 2px; }

.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.mh { text-align: center; color: var(--muted); font-weight: 700; font-size: 13px; padding: 4px 0; }
.mc { background: var(--card); border-radius: 18px; padding: 8px; min-height: 116px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
.mc.blank { background: transparent; cursor: default; }
.mc.today { box-shadow: inset 0 0 0 2px var(--brand-text); }
.mc.past { opacity: 0.7; }
.mn { font-weight: 700; font-size: 13px; }
.mc-evs { display: flex; flex-direction: column; gap: 3px; }
.mc .ev { padding: 3px 8px; font-size: 11.5px; border-radius: 10px; }
.mc .ev .ev-people { display: none; }
.more { font-size: 11.5px; color: var(--muted); padding: 0 4px; }
.dots { display: none; gap: 3px; justify-content: center; }
.dots i { width: 6px; height: 6px; border-radius: 50%; }

.agenda-day { max-width: 820px; margin: 0 auto 20px; }
.agenda-date { font-weight: 600; margin-bottom: 8px; color: var(--muted); }
.agenda-day.today .agenda-date { color: var(--brand-text); }
.agenda-ev, .day-list .agenda-ev {
  --c: var(--brand-text);
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
  background: var(--card); border-radius: 22px;
}
.agenda-ev:hover { background: var(--card-2); }
.agenda-ev.st-done .agenda-title { text-decoration: line-through; color: var(--muted); }
.agenda-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.agenda-title { font-weight: 600; overflow-wrap: anywhere; }
.agenda-sub { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.done-box { width: 26px; height: 26px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--line-2); display: grid; place-items: center; flex: none; color: var(--on-ink); }
.done-box.on { background: var(--done); box-shadow: none; color: #000; }
.done-box .ico { width: 16px; height: 16px; }
.agenda-ev .thumb { width: 54px; height: 54px; border-radius: 16px; background: var(--card-3) center / cover; flex: none; }

.people-list { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.person { display: inline-flex; align-items: center; gap: 5px; }

/* day template ("final template of the day") */
.tpl { background: var(--card-2); border-radius: 22px; padding: 12px; display: grid; grid-template-columns: 120px 1fr; gap: 12px; cursor: pointer; }
.tpl + .tpl { margin-top: 10px; }
.tpl .tpl-media { aspect-ratio: 4 / 5; border-radius: 16px; background: var(--card-3) center / cover; display: grid; place-items: center; color: var(--muted); overflow: hidden; }
.tpl .tpl-media video { width: 100%; height: 100%; object-fit: cover; }
.tpl .tpl-body { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.tpl .tpl-body b { font-size: 16px; }
.tpl .cap { font-size: 13px; color: var(--muted); white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ------------------------------------------------------------------ library */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.lib-item { background: var(--card); border-radius: 22px; overflow: hidden; display: flex; flex-direction: column; }
.lib-item .lib-media { aspect-ratio: 1; background: var(--card-2) center / cover; display: grid; place-items: center; color: var(--muted); position: relative; }
.lib-item .lib-media img, .lib-item .lib-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-item .lib-media .ico { width: 40px; height: 40px; }
.lib-item .lib-info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lib-item .lib-info b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-item .lib-info span { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-item .lib-actions { display: flex; gap: 4px; margin-top: 6px; }

/* ------------------------------------------------------------------ analytics */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kpi { background: var(--card); border-radius: 22px; padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.kpi small { color: var(--muted); font-size: 12.5px; }
.kpi b { font-size: 30px; font-weight: 300; line-height: 1.2; }
.kpi .trend { font-size: 12px; font-weight: 700; }
.kpi .trend.up { color: var(--ok); }
.kpi .trend.down { color: var(--danger); }
.rank { background: var(--card); border-radius: 22px; overflow: hidden; }
.rank-row { display: grid; grid-template-columns: 34px 52px minmax(0, 1fr) repeat(3, 84px) 120px; gap: 12px; align-items: center; padding: 10px 16px; border-top: 1px solid var(--line); cursor: pointer; }
.rank-row:hover { background: var(--hover); }
.rank-row.head { cursor: default; color: var(--muted); font-size: 12px; font-weight: 600; border-top: 0; background: transparent; }
.rank-row .pos { font-size: 18px; font-weight: 300; text-align: center; }
.rank-row .pos.top { color: var(--brand-text); font-weight: 700; }
.rank-row .thumb { width: 52px; height: 52px; border-radius: 14px; background: var(--card-3) center / cover; }
.rank-row .t b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .t span { font-size: 12px; color: var(--muted); }
.rank-row .n { font-feature-settings: "tnum"; font-size: 13.5px; }
.bar { height: 8px; border-radius: 999px; background: var(--card-3); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--gc, var(--brand-text)); }
.score-cell { display: flex; align-items: center; gap: 8px; }
.score-cell .bar { flex: 1; }
.pf-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.pf-card { background: var(--card); border-radius: 22px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.metric-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }

/* ------------------------------------------------------------------ ads */
.ad-card { background: var(--card); border-radius: var(--r-lg); padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.ad-head { display: flex; align-items: center; gap: 12px; }
.ad-head .avatar { width: 48px; height: 48px; }
.ad-head b { font-size: 17px; display: block; }
.ad-followers { display: flex; align-items: baseline; gap: 6px; }
.ad-followers b { font-size: 30px; font-weight: 300; line-height: 1; }
.ad-contact { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--line-2); font-size: 13px; }
.ad-contact .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pkg { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; border-radius: 14px; background: var(--card-2); font-size: 13px; }
.pkg b { white-space: nowrap; }
.pkg-rows { display: flex; flex-direction: column; gap: 8px; }
.pkg-row { display: grid; grid-template-columns: 1.2fr 1fr 1.4fr auto; gap: 8px; align-items: center; }

/* ------------------------------------------------------------------ modal, menu, toast */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); display: grid; place-items: center; padding: 16px; z-index: 100; animation: fade 0.15s; }
.modal {
  width: min(560px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column;
  background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); animation: pop 0.18s;
}
.modal.wide { width: min(760px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 12px 6px; padding-inline: 22px 12px; }
.modal-title { font-weight: 500; font-size: 19px; }
.modal-body { padding: 8px 22px 18px; overflow-y: auto; }
.modal-body > p { margin: 4px 0 8px; }
.modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 12px 22px 18px; border-top: 1px solid var(--line); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } }

.menu { position: fixed; z-index: 120; background: var(--card-2); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 5px; min-width: 170px; animation: fade 0.1s; max-height: 70vh; overflow-y: auto; }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: start; padding: 9px 14px; border-radius: 13px; }
.menu button:hover { background: var(--hover); }
.menu button.danger { color: var(--danger); }
.menu button.on { font-weight: 700; }

.toasts { position: fixed; bottom: 24px; inset-inline: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 200; pointer-events: none; padding: 0 16px; }
.toast {
  background: var(--on); color: var(--on-ink); padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow-lg);
  max-width: 520px; font-size: 13.5px; transition: opacity 0.4s, transform 0.4s; animation: pop 0.2s;
}
.toast.error { background: var(--danger); color: #fff; }
.toast.note { background: var(--brand); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ------------------------------------------------------------------ forms & pages */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.hint, .counter { font-size: 12px; color: var(--muted); }
.counter.warn { color: var(--warn); }
.att-ico .ext, .file-tile .doc .ext { font: 700 11px/1 var(--font); letter-spacing: 0.3px; direction: ltr; }
.file-tile .doc .ext { font-size: 15px; color: var(--text); }
.lib-item .lib-media .ext.big { font-size: 26px; font-weight: 800; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.checks .chip { cursor: pointer; }
.checks input { display: none; }
.inline { display: flex; align-items: center; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.jdate { display: flex; gap: 6px; align-items: center; }
.jdate select { width: auto; flex: 1; padding-inline: 10px; }
.jdate .muted { min-width: 70px; text-align: center; }
.assignees { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow-y: auto; padding: 6px; border: 1px solid var(--line); border-radius: 18px; }
.person-check { padding: 6px 8px; border-radius: 12px; }
.person-check:hover { background: var(--hover); }
.role-picks { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 4px 6px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.mem-list { display: flex; flex-direction: column; gap: 8px; }
.mem-row { display: grid; grid-template-columns: minmax(130px, 1fr) 1.4fr 1fr; gap: 8px; align-items: center; }
.row > .level-select { flex: 1 1 220px; width: auto; }
.perm-row .muted.small { align-self: center; }
.fieldset { border: 1px solid var(--line); border-radius: 20px; padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }
.fieldset > b { font-size: 13px; color: var(--muted); }

.page { flex: 1; overflow-y: auto; padding: 22px 26px 30px; display: flex; flex-direction: column; gap: 16px; width: 100%; }
/* scrolling columns: children keep their height instead of being squeezed to fit */
.page > *, .dash > * { flex-shrink: 0; }
.pf, .chip, .st, .code { width: fit-content; }
.page.narrow { max-width: 1000px; margin: 0 auto; }
.page-title { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.page-title h1 { margin: 0; font-size: clamp(26px, 3vw, 38px); font-weight: 300; }
.page-title .filters { margin-inline-start: auto; }
.panel { background: var(--card); border-radius: var(--r-lg); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.panel h3 { margin: 0; font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.panel p { margin: 0; }
.panel .help-card { padding: 0; margin: 0; max-width: none; background: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--line); }
.row > input:not([type=checkbox]), .row > select { flex: 1 1 140px; width: auto; }
.row-name { display: flex; flex-direction: column; min-width: 130px; flex: 0 1 180px; font-weight: 600; line-height: 1.35; }
.add-row { background: var(--card-2); border-radius: 20px; padding: 10px; border-top: 0; margin-top: 6px; }
.ch-row .check { white-space: nowrap; }
.perm-row { display: flex; flex-wrap: wrap; gap: 6px; flex-basis: 100%; padding-inline-start: 38px; }
.perm-row .chip { font-size: 12px; padding: 3px 12px; }

.admin-toolbar { display: flex; align-items: center; justify-content: space-between; }
.cards { display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--card); border-radius: var(--r); padding: 14px 16px; }
.user-card { display: flex; align-items: center; gap: 12px; }
.uc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.uc-name { font-weight: 700; display: flex; align-items: center; }
.uc-ws { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.uc-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ws-admin { display: grid; grid-template-columns: 230px 1fr; gap: 16px; align-items: start; }
.ws-list { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; }
.ws-item { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 16px; text-align: start; font-weight: 600; }
.ws-item:hover { background: var(--hover); }
.ws-item.on { background: var(--on); color: var(--on-ink); }
.ws-list .btn { margin-top: 8px; }
.ws-detail { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.theme-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-pick button { border-radius: 18px; padding: 10px; box-shadow: inset 0 0 0 1px var(--line-2); display: flex; flex-direction: column; gap: 8px; align-items: center; font-weight: 600; font-size: 13px; }
.theme-pick button.on { box-shadow: inset 0 0 0 2px var(--text); }
.theme-pick .sw { width: 100%; height: 54px; border-radius: 12px; display: grid; grid-template-columns: 1fr 2fr; overflow: hidden; }
.theme-pick .sw i:first-child { background: #272757; }
.theme-pick .sw.dark i:last-child { background: #000; }
.theme-pick .sw.light i:last-child { background: #fff; box-shadow: inset 0 0 0 1px #ddd; }
.theme-pick .sw.system i:last-child { background: linear-gradient(135deg, #000 50%, #fff 50%); }

/* ------------------------------------------------------------------ left-to-right (English)
 * Most rules use logical properties; these are the ones tied to a physical side. The
 * reference design is LTR: the notch and its ↗ button sit at the top right, the summary panel
 * slides in from the right. */
[dir="ltr"] .ncard {
  -webkit-mask: radial-gradient(circle 31px at calc(100% - 25px) 25px, #0000 30px, #000 31px);
  mask: radial-gradient(circle 31px at calc(100% - 25px) 25px, #0000 30px, #000 31px);
}
[dir="ltr"] .nwrap .corner { left: auto; right: 3px; }
[dir="ltr"] .nc-top { padding-left: 0; padding-right: 44px; }
[dir="ltr"] .drawer { left: auto; right: 14px; animation-name: slide-ltr; }
@keyframes slide-ltr { from { transform: translateX(24px); opacity: 0; } }
[dir="ltr"] .ev { box-shadow: inset 3px 0 0 var(--c); }
[dir="ltr"] .bubble.note.unread { box-shadow: inset 3px 0 0 var(--brand-text); }
[dir="ltr"] .stepper .step::before { left: 50%; }
[dir="ltr"] .timeline .tl-now span { transform: translateX(-50%); }
.ws-switch { padding: 6px; padding-inline: 8px 14px; }
.schedule { padding: 6px; padding-inline: 8px 6px; }
.schedule-date { padding: 6px; padding-inline: 6px 14px; }
.pf { padding: 2px; padding-inline: 8px 10px; }
.nc-status { padding: 6px; padding-inline: 6px 14px; }
.ad-contact { padding: 6px; padding-inline: 12px 6px; }
.ref-chip { padding: 2px; padding-inline: 4px 10px; }
.lang-switch { position: absolute; top: 16px; inset-inline-end: 16px; }
.login-wrap { position: relative; }
.panel .lang-switch { position: static; width: fit-content; }

/* ------------------------------------------------------------------ narrow screens */
@media (max-width: 1180px) {
  .layout.v-chat .workarea { grid-template-columns: 260px 1fr; }
  .messages { padding-inline: 3%; }
  .rank-row { grid-template-columns: 28px 44px minmax(0, 1fr) 70px 70px 110px; }
  .rank-row .n.hide-md { display: none; }
}

@media (max-width: 760px) {
  body { font-size: 14px; }
  .layout { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .rail {
    order: 2; flex-direction: row; justify-content: space-around; padding: 8px 6px; padding-bottom: max(8px, env(safe-area-inset-bottom));
    gap: 4px; overflow-x: auto; background: var(--bg); border-top: 1px solid var(--line);
  }
  .rail-logo, .rail-sep, .rail .hide-sm { display: none; }
  .rail-nav { flex-direction: row; flex: none; gap: 6px; }
  .rail-btn { width: 44px; height: 44px; box-shadow: none; }
  .shell { padding: 8px; padding-top: max(8px, env(safe-area-inset-top)); gap: 8px; }
  .topbar { gap: 8px; }
  .schedule { height: 48px; }
  .schedule-label, .schedule-date span { display: none; }
  .schedule-date { padding: 4px; box-shadow: none; }
  .ws-switch .ws-name { display: none; }
  .ws-switch { padding: 6px; }
  .topbar .bell { width: 44px; height: 44px; }
  .layout.v-chat .workarea { grid-template-columns: 1fr; }
  .layout.v-chat .main { display: none; }
  .layout.v-chat.show-main .sidebar { display: none; }
  .layout.v-chat.show-main .main { display: flex; }
  .layout.show-main .rail, .layout.v-chat.show-main .topbar { display: none; }
  .main-head { padding: 8px 10px; gap: 8px; min-height: 58px; }
  .back-btn { display: inline-grid; }
  .messages { padding: 8px 8px 12px; }
  .bubble { max-width: 86%; }
  .avatar-space, .msg-row.in > .avatar { width: 32px; height: 32px; font-size: 12px; }
  .composer-hint { display: none; }
  .composer textarea { font-size: 16px; }
  .dash, .page { padding: 14px; gap: 18px; }
  .stats { gap: 18px; margin-inline-start: 0; }
  .cal-bar { padding: 8px 10px; }
  .cal-body { padding: 10px; }
  .week { grid-template-columns: 1fr; }
  .day { min-height: 0; }
  .day .add-day { opacity: 1; }
  .month { gap: 4px; }
  .mc { min-height: 54px; padding: 4px; align-items: center; border-radius: 12px; }
  .mc-evs { display: none; }
  .dots { display: flex; }
  .grid2, .grid3, .mem-row, .dr-grid { grid-template-columns: 1fr; }
  .ws-admin { grid-template-columns: 1fr; }
  .ws-list { position: static; }
  .user-card { flex-wrap: wrap; }
  .drawer, [dir="ltr"] .drawer { inset: 0; width: 100%; border-radius: 0; }
  .rank-row { grid-template-columns: 24px 40px minmax(0, 1fr) 96px; }
  .rank-row .n { display: none; }
  .tpl { grid-template-columns: 90px 1fr; }
  .pkg-row { grid-template-columns: 1fr 1fr; }
  .modal-bg { place-items: end center; padding: 0; }
  .modal { width: 100%; border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); }
  input:not([type=checkbox]):not([type=color]), select, textarea { font-size: 16px; }
}
