/* Memarik theme: deep navy + warm cream + white, frosted glass surfaces, Vazirmatn (layout from the iTeam demo).
   Tokens in :root below; colour overrides in the THEME LAYER further down. Logical properties only; no inline styles.
   Status colours (green/yellow/red) only as a small dot or a very faint tint. */

@font-face {
  font-family: "Vazirmatn";
  src: url("/fonts/Vazirmatn-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  /* THEME TOKENS (deep navy + warm cream + white, frosted glass; the single place to re-theme the app) */
  --ink: #1a2238;            /* text, ink navy */
  --paper: #fff;
  --bg: #f6f1e7;             /* app background (warm cream) */
  --bg-glow: rgba(30, 42, 74, .08);     /* navy blob in the background gradient */
  --bg-warm: rgba(224, 196, 142, .30);  /* warm sand blob */
  --card: #fff;              /* opaque raised surfaces: sheets, dialogs, menus */
  --surface: #ece6d8;        /* quiet fills: search, hover, segmented, table head (cream, deeper) */
  --sidebar: #efe9db;        /* opaque fallback for the sidebar */
  --line: #ddd5c3;           /* borders */
  --mute: #555b6b;           /* secondary text */
  --accent: #1e2a4a;         /* brand accent: deep navy */
  --accent-hover: #141e38;
  --accent-soft: #e4e7f1;    /* active rows, soft highlights */
  --accent-contrast: #fff;   /* text on accent */
  --bubble-user: var(--accent);
  --bubble-user-text: #fff;
  --bubble-worker: rgba(255, 255, 255, .78);
  --tabbar: rgba(24, 36, 66, .86);      /* floating pill tab bar, frosted navy */
  --tabbar-fg: #e6e9f3;
  --tab-on-bg: #f6f1e7;
  --tab-on-fg: #1e2a4a;
  --focus: #1e2a4a;          /* focus ring */
  /* glass recipe: translucent white + blur + 1px light edge + soft shadow */
  --glass: rgba(255, 255, 255, .62);
  --glass-strong: rgba(255, 255, 255, .8);
  --glass-edge: rgba(255, 255, 255, .75);
  --glass-shadow: 0 8px 32px rgba(30, 42, 74, .12);
  --glass-blur: blur(18px) saturate(165%);
  --font: "Vazirmatn", Tahoma, sans-serif;  /* Vazirmatn is self-hosted; Tahoma only if the file fails to load */
  --r-card: 12px;            /* cards, sheets, bubbles' big corners */
  --r-ctl: 8px;              /* buttons */
  --r-input: 10px;           /* inputs, search, composer */
  --nav-h: 56px;
  --side-w: 300px;
  --blur: blur(20px) saturate(160%);
  --st-green: #1f8a4c;
  --st-yellow: #d9a400;
  --st-red: #c0392b;
  --st-red-bg: #fbeceb;
  --st-yellow-bg: #fbf3dc;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
button, input, select, textarea { font-family: var(--font); }
body { color: var(--ink); font-family: var(--font); font-weight: 400; line-height: 1.8; font-kerning: normal; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; min-height: 100vh; background: #fff; }
[hidden] { display: none !important; }
bdi.ltr, .ltr { unicode-bidi: isolate; direction: ltr; display: inline-block; }
* { scrollbar-width: thin; scrollbar-color: #c8c8c8 transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #c8c8c8; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }
.skip { position: absolute; inset-inline-start: 16px; top: -100px; background: #fff; padding: 8px 12px; }
.skip:focus { top: 8px; z-index: 60; }

/* ---------- top bar of the agent list ---------- */
.nav {
  position: sticky; top: 0; z-index: 10; height: var(--nav-h); color: var(--ink); background: #fff;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 8px;
  padding-inline: max(8px, calc((100vw - 712px) / 2));
}
.nav .brand { grid-column: 2; font-weight: 800; font-size: 16px; letter-spacing: -.01em; }
.icon-btn {
  grid-column: 1; justify-self: start; width: 42px; height: 42px; border-radius: 999px; color: inherit; cursor: pointer;
  display: grid; place-items: center; background: transparent; border: 0; transition: background .15s, transform .15s;
}
.icon-btn:hover { background: rgba(0, 0, 0, .06); }
.icon-btn:active { transform: scale(.94); }
.icon-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.icon-btn svg { width: 22px; height: 22px; }
.logout-btn {
  grid-column: 1; justify-self: start; min-height: 40px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent;
  color: var(--st-red); font: 700 14px "Vazirmatn", sans-serif; cursor: pointer; transition: background .15s, transform .15s;
}
.logout-btn:hover { background: rgba(198, 40, 40, .08); }
.logout-btn:active { transform: scale(.96); }
.logout-btn:focus-visible { outline: 2px solid var(--st-red); outline-offset: 2px; }
body.in-agent .nav { display: none; }

/* ---------- side drawer (previous chats) ---------- */
.scrim { position: fixed; inset: 0; z-index: 29; background: rgba(0, 0, 0, .4); opacity: 0; pointer-events: none; transition: opacity .25s; }
.scrim.show { opacity: 1; pointer-events: auto; }
.side {
  position: fixed; z-index: 30; inset-block: 0; inset-inline-end: 0; width: min(320px, 86vw); display: flex; flex-direction: column;
  overflow: hidden; color: var(--ink); background: #f9f9f9; border-inline-start: 1px solid var(--line);
  transform: translateX(-100%); transition: transform .3s cubic-bezier(.2, .8, .2, 1);
  padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
}
body:not(.in-agent) .side { display: none; }
.side.open { transform: none; }
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }
.side-top { padding: 6px 6px 10px; font-size: 15px; font-weight: 800; }
.side-new {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; margin: 4px 0 16px; border: 0; border-radius: 14px;
  background: var(--ink); color: #fff; font: 600 14px "Vazirmatn", sans-serif; cursor: pointer; transition: transform .15s;
}
.side-new:active { transform: scale(.98); }
.side-new svg { width: 18px; height: 18px; }
.side-h { margin: 0 6px 6px; font-size: 12px; font-weight: 700; color: var(--mute); }
.side-list { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -4px; }
.side-empty { margin: 6px; font-size: 12.5px; line-height: 1.9; color: var(--mute); }
.session { display: flex; align-items: center; gap: 4px; margin: 0; padding-inline-end: 2px; border-radius: 12px; }
.session { max-height: 72px; transition: opacity .2s, max-height .26s, transform .26s; }
.session.leaving { opacity: 0; max-height: 0; overflow: hidden; transform: scale(.96); }
@media (prefers-reduced-motion: reduce) { .session { transition: none; } }
.session:hover { background: #efefef; }
.session.on { background: #e6e6e6; }
.session-open {
  flex: 1; min-width: 0; display: block; padding: 8px 10px; min-height: 44px; border: 0; border-radius: 16px; background: transparent;
  cursor: pointer; text-align: start; color: var(--ink); font-family: "Vazirmatn", sans-serif;
}
.session-open b { display: block; font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-open span { display: block; font-size: 12px; color: #8a8a8a; margin-top: 2px; }
.session-open:focus-visible, .del:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.del { width: 40px; height: 40px; flex: none; border: 0; border-radius: 50%; background: transparent; color: #8a8a8a; cursor: pointer; display: grid; place-items: center; opacity: .6; }
.del:hover { background: rgba(0, 0, 0, .06); color: var(--ink); }
.session:hover .del, .session.on .del, .del:focus-visible { opacity: 1; }
.del svg { width: 19px; height: 19px; }

/* ---------- glass tab bar (only inside an agent) ---------- */
.glass-ink { color: #fff; background: var(--ink); border: 0; box-shadow: 0 8px 28px rgba(0, 0, 0, .2); }
.tabbar {
  position: fixed; z-index: 10; inset-inline: 0; margin-inline: auto; bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex; gap: 2px; padding: 5px; border-radius: 999px; width: min(320px, calc(100vw - 24px));
}
body:not(.in-agent) .tabbar { display: none; }
.tab {
  flex: 1; min-height: 54px; border: 0; border-radius: 999px; background: transparent; color: rgba(255, 255, 255, .72);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font: 600 10.5px "Vazirmatn", sans-serif; cursor: pointer; transition: background .2s, color .2s, transform .15s;
}
.tab svg { width: 22px; height: 22px; }
.tab:hover { color: #fff; }
.tab:active { transform: scale(.94); }
.tab.on { background: #fff; color: var(--ink); }
.tab:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }

/* ---------- page ---------- */
main { max-width: 680px; margin: 0 auto; padding: 20px 14px calc(116px + env(safe-area-inset-bottom)); font-size: 13px; }
body:not(.in-agent) main { padding-bottom: 40px; }
body.in-agent main { padding-bottom: calc(110px + env(safe-area-inset-bottom)); padding-top: 12px; }
body.on-chat main { padding-bottom: calc(var(--composer-h, 62px) + 92px + 28px + env(safe-area-inset-bottom)); }
.page-title { margin: 0 8px; font-size: 21px; font-weight: 800; }
.empty { padding: 20px 0; text-align: center; color: #8a8a8a; }
.btn {
  min-height: 36px; padding: 0 18px; border-radius: 999px; cursor: pointer; font: 600 13px "Vazirmatn", sans-serif; color: var(--ink);
  background: #fff; border: 1px solid #cfcfcf; transition: transform .15s, background .15s; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { background: var(--surface); }
.btn:active { transform: scale(.96); }
.btn.primary { color: #fff; background: var(--ink); border-color: var(--ink); }
.btn.primary:hover { background: #2a2a2a; }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: 12.5px; }
.btn[disabled] { opacity: .4; cursor: default; }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- agent list, like a messenger ---------- */
.search {
  display: flex; align-items: center; gap: 8px; margin: 8px 0 6px; padding: 0 14px; height: 44px; border-radius: 999px; color: #8a8a8a;
  background: var(--surface); border: 1px solid transparent;
}
.search svg { width: 18px; height: 18px; flex: none; }
.search input { flex: 1; border: 0; background: transparent; font: 400 14px "Vazirmatn", sans-serif; color: var(--ink); outline: none; min-width: 0; }
.search:focus-within { background: #fff; border-color: var(--ink); }
.dept-title { position: sticky; top: var(--nav-h); z-index: 2; margin: 0 -14px; padding: 14px 14px 6px; font-size: 13px; font-weight: 700; color: var(--ink); background: #fff; }
.chat-row {
  width: calc(100% + 16px); margin: 0 -8px; display: flex; align-items: center; gap: 12px; padding: 8px; min-height: 72px; border: 0;
  background: transparent; cursor: pointer; text-align: start; color: var(--ink); font-family: "Vazirmatn", sans-serif; border-radius: 16px; transition: background .15s;
}
.chat-row:hover { background: var(--surface); }
.chat-row:active { background: rgba(0, 0, 0, .08); }
.chat-row:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.pic { position: relative; width: 54px; height: 54px; border-radius: 50%; flex: none; display: grid; place-items: center; }
.pic .online { position: absolute; bottom: 1px; inset-inline-start: 1px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 3.5px #fff, inset 0 0 0 10px var(--ink); }
.av { width: var(--s); height: var(--s); border-radius: 50%; display: grid; place-items: center; flex: none; color: #fff; font-weight: 700; font-size: calc(var(--s) * .36); line-height: 1; user-select: none; }
.av-54 { --s: 54px; } .av-40 { --s: 40px; } .av-28 { --s: 28px; } .av-72 { --s: 72px; }
.av-0 { background: linear-gradient(135deg, #82b1ff, #665fff); }
.av-1 { background: linear-gradient(135deg, #a0de7e, #54cb68); }
.chat-text { flex: 1; min-width: 0; }
.chat-top { display: flex; align-items: center; gap: 8px; }
.chat-name { flex: 1; min-width: 0; font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-time { font-size: 11px; color: var(--ink); font-weight: 500; flex: none; }
.chat-desc { font-size: 12.5px; color: #8a8a8a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.no-result { padding: 40px 0; text-align: center; color: #8a8a8a; }

/* ---------- agent header ---------- */
.agent-bar {
  position: sticky; top: 0; z-index: 11; display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin: 0;
  padding-inline: max(12px, calc((100vw - 680px) / 2)); background: rgba(255, 255, 255, .94);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
body:not(.in-agent) .agent-bar { display: none; }
.agent-bar .back, .agent-bar .hist {
  width: 42px; height: 42px; border: 0; border-radius: 50%; background: transparent; color: var(--ink); display: grid; place-items: center; cursor: pointer; flex: none; transition: background .15s, transform .15s;
}
.agent-bar .back:hover, .agent-bar .hist:hover { background: var(--surface); }
.agent-bar .hist:active, .agent-bar .back:active { transform: scale(.94); }
.agent-bar button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.agent-bar .title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.agent-bar .who { flex: 1; min-width: 0; }
.agent-bar .who b { display: block; font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-bar .who span { display: block; font-size: 11px; color: var(--mute); }

/* ---------- chat ---------- */
.msgs.loading { opacity: .55; transition: opacity .2s; }
.msgs { display: flex; flex-direction: column; gap: 18px; padding: 4px 0 0; }
/* new chat and conversation are the same top-down list with one gap; the wrapper adds no box of its own */
.chat-home { display: contents; }
.demo-note { align-self: center; margin: 0; padding: 4px 12px; border-radius: 999px; background: var(--surface); font-size: 11.5px; line-height: 1.8; color: var(--mute); text-align: center; }
.sug { display: flex; flex-wrap: wrap; gap: 8px; }
.sug-chip { min-height: 40px; padding: 0 16px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); font: 500 13px "Vazirmatn", sans-serif; cursor: pointer; transition: border-color .15s, background .15s; }
.sug-chip:hover { border-color: var(--ink); }
.sug-chip:active { background: var(--surface); }
.sug-chip:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.bubble { max-width: 84%; padding: 10px 16px 6px; border-radius: 22px; font-size: 14px; line-height: 1.9; white-space: pre-line; position: relative; overflow-wrap: anywhere; }
.bubble.me { align-self: flex-start; background: var(--ink); color: #fff; }
.bubble.me.tail { border-end-start-radius: 4px; }
.bot-row { display: flex; align-self: flex-end; max-width: 92%; align-items: flex-end; gap: 14px; }
.bot-av { flex: none; margin-top: 2px; }
.bot-b { position: relative; min-width: 0; padding: 10px 16px 6px; border-radius: 22px; background: #eee; color: var(--ink); }
.bot-b.tail { border-end-end-radius: 4px; }
.bot-row.mid .bot-av { visibility: hidden; }
.bot-row.err .bot-b { background: #fff; border: 1px solid var(--ink); }
.bubble .t, .bot-b .t { display: block; margin-top: 2px; font-size: 10.5px; line-height: 1.6; text-align: end; }
.bubble.me .t { color: rgba(255, 255, 255, .6); }
.bot-b .t { color: var(--mute); }
.md { font-size: 14px; line-height: 2; overflow-wrap: anywhere; }
.md p { margin: 0 0 8px; }
.md p:last-child { margin: 0; }
.md ul, .md ol { margin: 0 0 8px; padding-inline-start: 22px; }
.md li { margin: 2px 0; }
.md a { color: var(--ink); font-weight: 600; }
.att-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.att-pill { display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; border-radius: 12px; background: #fff; color: var(--ink); border: 1px solid var(--line); font-size: 12px; }
.att-pill { max-inline-size: 100%; min-inline-size: 0; }
.att-name { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-pill .ci { flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--ink); color: #fff; }
.att-pill .ci svg { width: 15px; height: 15px; }
.queue-note { display: block; font-size: 11.5px; color: var(--mute); }
.dots { display: inline-flex; gap: 4px; padding: 12px 0; }
.bot-b .dots { padding: 6px 0; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink); animation: dot 1s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .2; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
/* live work steps in the wait bubble */
.live { display: flex; flex-direction: column; gap: 6px; padding: 4px 0; min-width: 180px; }
.live-step { display: flex; align-items: center; gap: 8px; font-size: 13px; line-height: 1.7; }
.live-step.past { color: var(--mute); font-size: 12px; }
.live-step.now { font-weight: 600; }
.live-step svg { width: 14px; height: 14px; flex: none; }
.spin { width: 14px; height: 14px; flex: none; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--ink); animation: spin .8s linear infinite; }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }
@media (prefers-reduced-motion: reduce) { .dots i { animation: none; } }

/* tool results: quiet chips under the answer, files last */
.tc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pill, .pill.st { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 11.5px; line-height: 1.6; color: var(--mute); font-weight: 500; white-space: normal; }
.pill.st::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; }
.pill.bad { color: var(--ink); border-color: var(--ink); }
.st-green::before { background: var(--st-green) !important; }
.st-yellow::before { background: var(--st-yellow) !important; }
.st-red::before { background: var(--st-red) !important; }
.tc-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.tc-dl svg { width: 15px; height: 15px; flex: none; }
.tc-acts .tc-dl { flex: 1 1 130px; min-width: 0; }
.tc-dl .fn { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; unicode-bidi: plaintext; }
.tc-acts .btn:not(.tc-dl) { flex: none; }
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.st::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }

/* ---------- composer ---------- */
.composer {
  position: fixed; z-index: 11; inset-inline: 0; margin-inline: auto; bottom: calc(92px + env(safe-area-inset-bottom));
  width: min(680px, calc(100vw - 24px)); padding: 8px; border-radius: 28px; background: #fff; border: 1px solid #d0d0d0; box-shadow: 0 6px 24px rgba(0, 0, 0, .1);
}
body:not(.on-chat) .composer { display: none; }
.c-row { display: flex; align-items: flex-end; gap: 6px; }
.c-btn { width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; display: grid; place-items: center; background: transparent; color: var(--ink); cursor: pointer; padding: 0; line-height: 0; transition: background .15s, transform .15s; }
.c-btn:hover { background: var(--surface); }
.c-btn:active { transform: scale(.92); }
.c-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.c-btn svg, .send svg { display: block; width: 22px; height: 22px; }
.send { background: var(--ink); color: #fff; }
.send:hover { background: var(--ink); }
.composer textarea { flex: 1; min-width: 0; height: 44px; max-height: 140px; padding: 7px 12px; overflow-y: hidden; border: 0; background: transparent; color: var(--ink); resize: none; outline: none; font: 400 16px/1.8 "Vazirmatn", sans-serif; }
.composer textarea::placeholder { color: #8e8e8e; }
.composer .send { display: none; }
.composer.has-text .send, .composer.busy .send { display: grid; }
.c-plus-wrap { position: relative; flex: none; }
.c-menu { position: absolute; bottom: calc(100% + 12px); inset-inline-start: 0; min-width: 190px; padding: 6px; border-radius: 20px; background: #fff; border: 1px solid var(--line); box-shadow: 0 12px 32px rgba(0, 0, 0, .16); z-index: 5; }
.c-menu button { width: 100%; min-height: 46px; display: flex; align-items: center; gap: 12px; padding: 0 12px; border: 0; border-radius: 14px; background: transparent; color: var(--ink); cursor: pointer; text-align: start; font: 500 14px "Vazirmatn", sans-serif; }
.c-menu button[hidden] { display: none; }
.c-menu button:hover { background: var(--surface); }
.c-menu svg { width: 21px; height: 21px; flex: none; }
.c-att { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 4px 8px; }
.c-att.grid { display: block; }
.att-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-block-end: 8px; font-size: 12.5px; font-weight: 600; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; max-height: 188px; overflow-y: auto; }
.thumb { position: relative; width: 72px; height: 72px; flex: none; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .x { position: absolute; inset-block-start: 2px; inset-inline-end: 2px; width: 28px; height: 28px; border: 0; border-radius: 50%; background: var(--ink); color: #fff; cursor: pointer; display: grid; place-items: center; }
.thumb .x { overflow: visible; }
.thumb .x svg { width: 13px; height: 13px; }

.chip { display: flex; align-items: center; gap: 8px; max-width: 100%; padding: 4px 4px 4px 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.chip .ci { width: 34px; height: 34px; flex: none; border-radius: 9px; display: grid; place-items: center; background: var(--ink); color: #fff; overflow: hidden; }
.chip .ci svg { width: 18px; height: 18px; }
.chip .ci img { width: 100%; height: 100%; object-fit: cover; }
.chip .cn { min-width: 0; }
.chip b { display: block; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; font-weight: 600; }
.chip small { display: block; font-size: 11px; color: var(--mute); }
.chip .x { position: relative; width: 32px; height: 32px; flex: none; border: 0; border-radius: 50%; background: transparent; color: var(--mute); cursor: pointer; display: grid; place-items: center; }
.chip .x:hover { background: #e4e4e4; color: var(--ink); }
.chip .x svg { width: 14px; height: 14px; }
.chip .x::after, .thumb .x::after { content: ""; position: absolute; inset: -6px; }
.composer.drag { border-color: var(--ink); background: var(--surface); }

/* ---------- review sheet ---------- */
.pg { min-width: 40px; height: 40px; padding: 0; border: 0; border-radius: 999px; cursor: pointer; display: grid; place-items: center; color: var(--ink); background: var(--surface); }
.pg svg { width: 18px; height: 18px; }
.pg:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.rp-modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgba(0, 0, 0, .4); }
.rp-sheet { width: min(640px, 100%); max-height: 90dvh; overflow-y: auto; padding: 20px 20px calc(28px + env(safe-area-inset-bottom)); border-radius: 24px 24px 0 0; background: #fff; }
.rp-sheet.wide { width: min(1100px, 100%); }
.rp-sh-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.rp-sh-top h2 { margin: 0; font-size: 18px; font-weight: 800; line-height: 1.8; color: var(--ink); }
.rp-sh-top .sub { display: block; margin-top: 2px; font-size: 12px; color: var(--mute); }
.rp-sh-top .pg { flex: none; }
@media (min-width: 700px) { .rp-modal { align-items: center; padding: 20px; } .rp-sheet { border-radius: 24px; } }

/* ---------- job description tab ---------- */
.jd-title { margin: 4px 8px 0; font-size: 21px; font-weight: 800; }
.jd { margin: 8px 0 0; }
.jd-row { padding: 22px 8px; border-top: 1px solid var(--line); }
.jd-row:first-child { border-top: 0; }
.jd-row dt { margin-bottom: 8px; font-size: 12.5px; font-weight: 700; color: var(--mute); }
.jd-row dd { margin: 0; font-size: 14px; line-height: 2; }
.jd-row dd p { margin: 0 0 6px; }
.jd-row dd p small { display: block; font-size: 12px; color: var(--mute); }
.jd-list { margin: 0; padding-inline-start: 22px; }
.jd-list li { padding: 2px 0; }
.jd-steps { margin: 0; padding-inline-start: 24px; list-style-type: persian; }
.jd-steps li { padding: 3px 0; }
.jd-duty { font-weight: 700; font-size: 15px; }
.au-g small { display: block; margin-bottom: 4px; font-size: 12px; color: var(--mute); }
.au-g { margin-top: 14px; }
.au-g:first-child { margin-top: 0; }
.au-g h5 { margin: 0 0 6px; font-size: 13px; font-weight: 800; }

/* ---------- review table (inside the sheet) ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 14px 0 10px; }
.toolbar .spacer { flex: 1; }
.count-line { color: var(--mute); font-size: 12px; }
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface); overflow-x: auto; }
.seg button { min-height: 40px; padding: 0 12px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 10px; background: transparent; color: var(--mute); font: 600 12.5px "Vazirmatn", sans-serif; cursor: pointer; white-space: nowrap; }
.seg button[aria-pressed=true] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table.tbl { border-collapse: collapse; width: 100%; font-size: 12.5px; min-width: 820px; }
.tbl th { background: var(--surface); text-align: start; padding: 8px 10px; font-weight: 700; white-space: nowrap; position: sticky; top: 0; }
.tbl td { padding: 7px 10px; border-top: 1px solid var(--line); vertical-align: top; }
.tbl td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl td.reason { min-width: 220px; color: #444; }
.tbl td.reason div + div { margin-top: 2px; }
.tbl td.edit { cursor: text; min-width: 110px; }
.tbl td.edit input, .tbl td.edit select { width: 100%; min-width: 100px; border: 1px solid var(--ink); border-radius: 8px; padding: 4px 6px; background: #fff; }
.tbl td.empty { color: #aaa; }
.note { color: var(--mute); font-size: 12px; margin: 8px 2px 0; }

body.on-chat .flash { bottom: calc(var(--composer-h, 62px) + 92px + 14px + env(safe-area-inset-bottom)); }
/* in-app dialog */
.dlg-modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .4); }
.dlg { width: min(380px, 100%); padding: 22px 20px 16px; border-radius: 24px; background: #fff; box-shadow: 0 24px 60px rgba(0, 0, 0, .25); }
.dlg-t { margin: 0 0 8px; font-size: 17px; font-weight: 800; line-height: 1.8; }
.dlg-d { font-size: 14px; line-height: 1.9; color: var(--mute); }
.dlg-d p { margin: 0; }
.dlg-name { display: block; margin-bottom: 4px; color: var(--ink); font-weight: 700; overflow-wrap: anywhere; }
.dlg-err { margin: 12px 0 0; padding: 8px 12px; border: 1px solid var(--ink); border-radius: 12px; font-size: 13px; line-height: 1.8; }
.dlg-acts { display: flex; gap: 8px; margin-top: 18px; }
.dlg-acts .btn { flex: 1; min-height: 44px; font-size: 14px; }
.btn .spin { border-color: rgba(128, 128, 128, .4); border-top-color: currentColor; }
.tbl td.saving { opacity: .5; pointer-events: none; }
.flash {
  position: fixed; z-index: 80; inset-inline: 0; margin-inline: auto; width: fit-content; max-width: 90vw; bottom: calc(100px + env(safe-area-inset-bottom));
  padding: 10px 18px; border-radius: 999px; color: #fff; font-size: 13px; background: var(--ink); box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}

/* ---------- login ---------- */
body.login { display: grid; place-items: center; min-height: 100vh; background: var(--surface); }
.login-wrap { display: grid; justify-items: center; gap: 16px; }
.login-brand { margin: 0; font-size: 20px; font-weight: 700; text-align: center; }
.login-card { width: min(360px, calc(100vw - 32px)); background: #fff; border: 1px solid var(--line); border-radius: 24px; padding: 28px 24px; display: grid; gap: 8px; }
.login-card h1 { margin: 0 0 8px; font-size: 22px; }
.login-card label { font-size: 12px; color: var(--mute); }
.login-card input { height: 44px; border: 1px solid #cfcfcf; border-radius: 12px; padding: 0 12px; background: #fff; }
.login-card .err { color: var(--st-red); margin: 0; font-size: 13px; }
.login-card .btn { margin-top: 8px; min-height: 44px; }

/* ---------- desktop: fixed drawer on the side, content in the middle ---------- */
@media (min-width: 900px) {
  main { max-width: 760px; font-size: 14px; }
  .nav { padding-inline: max(16px, calc((100vw - 760px) / 2)); }
  body.in-agent { padding-inline-start: var(--side-w); }
  body.in-agent .side { z-index: 12; inset-inline-start: 0; inset-inline-end: auto; width: var(--side-w); transform: none; border-inline-start: 0; border-inline-end: 1px solid var(--line); }
  body.in-agent .scrim, body.in-agent .hist { display: none; }
  body.in-agent .agent-bar { padding-inline: max(20px, calc((100vw - var(--side-w) - 760px) / 2)); }
  body.in-agent .composer { inset-inline-start: var(--side-w); inset-inline-end: 0; width: min(760px, calc(100vw - var(--side-w) - 48px)); }
  body.in-agent .tabbar { inset-inline-start: var(--side-w); inset-inline-end: 0; }
  body.in-agent .flash { inset-inline-start: var(--side-w); inset-inline-end: 0; }
  body.in-agent .rp-modal { padding-inline-start: calc(var(--side-w) + 16px); }
  .bubble, .md { font-size: 15px; }
  .bubble { max-width: 72%; }
  .bot-row { max-width: 80%; }
  .side-top { font-size: 16px; }
}

/* ======================= QA round: structure, a11y, review sheet, job tab ======================= */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
main:focus { outline: none; }
html.scroll-locked, html.scroll-locked body { overflow: hidden; }
.rp-modal, .dlg-modal, .rp-sheet, .tbl-wrap, .side-list { overscroll-behavior: contain; }

/* toast: one persistent live region, above dialogs */
.flash { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .2s, visibility .2s; }
.flash.show { opacity: 1; visibility: visible; }
@media (prefers-reduced-motion: reduce) { .flash { transition: none; } }

/* agent list */
.search-x { width: 36px; height: 36px; flex: none; margin-inline-end: -8px; border: 0; border-radius: 50%; background: transparent; color: var(--mute); display: grid; place-items: center; cursor: pointer; }
.search-x svg { width: 16px; height: 16px; }
.search-x:hover { background: rgba(0, 0, 0, .06); color: var(--ink); }
.search-x:focus-visible { outline: 2px solid var(--ink); outline-offset: 0; }
.search input::-webkit-search-cancel-button, .search input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
.chat-row .chat-top { display: block; }

/* drawer */
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-close { min-height: 40px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--ink); font: 600 13px "Vazirmatn", sans-serif; cursor: pointer; }
.side-close:hover { background: #ececec; }
.side-close:focus-visible, .side-new:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
@media (min-width: 900px) { .side-close { display: none; } }

/* composer: short screens, keyboard open */
/* --dock = space the composer reserves under itself: tab bar offset + tab bar height + gap (5px padding x2 + 54px tab) */
:root { --tabbar-h: 64px; --dock: calc(14px + var(--tabbar-h) + 14px); }
.composer textarea { max-height: min(140px, 25vh); }
.send[aria-disabled="true"] { opacity: .22; cursor: default; }
/* the tab bar steps aside while typing only on phones, so the composer drops only where the bar is really hidden */
@media (max-width: 899px) { body.typing .tabbar { display: none; } body.typing, body.in-agent.typing { --dock: 12px; } }
@media (max-height: 520px) { body.in-agent .tabbar { display: none; } body.in-agent { --dock: 12px; } }
.composer { bottom: calc(var(--dock) + env(safe-area-inset-bottom)); }
body.on-chat main { padding-bottom: calc(var(--composer-h, 62px) + var(--dock) + 28px + env(safe-area-inset-bottom)); }
body.on-chat .flash { bottom: calc(var(--composer-h, 62px) + var(--dock) + 14px + env(safe-area-inset-bottom)); }
.new-pill { position: fixed; z-index: 12; inset-inline: 0; margin-inline: auto; width: fit-content; bottom: calc(var(--composer-h, 62px) + var(--dock) + 12px + env(safe-area-inset-bottom)); min-height: 40px; padding: 0 18px; border: 0; border-radius: 999px; background: var(--ink); color: #fff; font: 600 13px "Vazirmatn", sans-serif; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); cursor: pointer; }
.new-pill:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
body:not(.on-chat) .new-pill { display: none; }
@media (min-width: 900px) { body.in-agent .new-pill { inset-inline-start: var(--side-w); inset-inline-end: 0; } }

/* black and white avatars */
.av, .av-0, .av-1 { background: var(--ink); }
.av svg { display: block; }
.nav .brand { margin: 0; }

/* thumbnails */
.thumb .x { inset-block-start: 4px; inset-inline-end: 4px; width: 32px; height: 32px; }
.chip .x::after, .thumb .x::after { inset: -4px; }
.thumbs { max-height: min(188px, 30vh); padding-bottom: 2px; }
.thumb-fb { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 4px; color: var(--mute); background: var(--surface); }
.thumb-fb svg { width: 22px; height: 22px; }
.thumb-fb small { max-width: 100%; font-size: 9.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* markdown inside bubbles */
.bot-row { min-width: 0; }
.bot-b { max-width: 100%; }
.md-tbl { max-width: 100%; overflow-x: auto; margin: 6px 0; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.md-tbl table { border-collapse: collapse; width: max-content; min-width: 100%; font-size: 12.5px; line-height: 1.7; }
.md-tbl th, .md-tbl td { min-width: 64px; padding: 6px 10px; text-align: start; vertical-align: top; white-space: nowrap; word-break: keep-all; }
.md-tbl th { background: var(--surface); font-weight: 700; }
.md-tbl td { border-top: 1px solid var(--line); }
.md i { font-style: italic; }

/* send error */
.err-box .err-line { display: flex; align-items: flex-start; gap: 8px; line-height: 1.9; }
.err-box .err-line svg { width: 18px; height: 18px; flex: none; margin-top: 4px; }

/* dialog: danger is solid black, never red text */
.btn.danger { color: #fff; background: var(--ink); border-color: var(--ink); }
.dlg:focus { outline: none; }

/* review sheet */
.rp-sheet.wide { display: flex; flex-direction: column; overflow: hidden; }
.rp-sheet.wide .rp-sh-top { flex: none; }
#rv-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.review { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.review .toolbar { flex: none; }
.review .tbl-wrap { flex: 1; min-height: 0; max-height: min(62dvh, 560px); overflow: auto; }
.review .note { flex: none; }
.tbl th { z-index: 2; }
.tbl tr.row-saved td { background: #f1f1f1; }
.rv-loading { display: flex; align-items: center; gap: 10px; padding: 36px 0; justify-content: center; color: var(--mute); font-size: 14px; }
.rv-fail { padding: 28px 0; text-align: center; display: grid; gap: 12px; justify-items: center; }
.rv-fail p { margin: 0; }
.dl-area { flex: none; margin: 0 0 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); outline: none; }
.dl-area:focus-visible { border-color: var(--ink); }
.tbl td.reason .rs { line-height: 1.8; }
.tbl td.reason .rs.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tbl td.reason .rs { line-height: 1.6; }
.review .tbl td, .review .tbl th { padding-inline: 8px; }
.review .tbl td.reason { min-width: 170px; max-width: 260px; }
.rs-more { min-height: 24px; padding: 0 2px; border: 0; background: none; color: var(--ink); font: 600 12px "Vazirmatn", sans-serif; text-decoration: underline; cursor: pointer; }
.tbl td.edit { text-decoration: underline dotted #bdbdbd; text-underline-offset: 5px; }
.tbl td.edit input, .tbl td.edit select { font: 400 14px "Vazirmatn", sans-serif; min-height: 36px; text-decoration: none; }
.tbl td.saving { display: flex; align-items: center; gap: 8px; }
.cell-err { display: block; margin-top: 4px; font-size: 11.5px; line-height: 1.7; color: var(--ink); font-weight: 600; }
.cell-err::before { content: "! "; }
.tbl td .spin { width: 13px; height: 13px; }
@media (hover: hover) { .tbl td.edit:hover { background: #fafafa; outline: 1px dashed #cfcfcf; outline-offset: -2px; } }
@media (max-width: 699px) {
  .rp-sheet { padding-inline: 14px; }
  .review .tbl-wrap { border: 0; border-radius: 0; max-height: min(60dvh, 560px); }
  table.tbl { min-width: 0; display: block; }
  .tbl thead { display: none; }
  .tbl tbody { display: flex; flex-direction: column; gap: 10px; }
  .tbl tr { display: flex; flex-wrap: wrap; gap: 4px 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
  .tbl td { display: block; flex: 1 1 calc(50% - 10px); min-width: 0; padding: 0; border: 0; font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
  .tbl td::before { content: attr(data-label); display: block; color: var(--mute); font-size: 11px; line-height: 1.5; }
  .rs-more { min-height: 32px; }
  .tbl td.k-row_no, .tbl td.k-status { flex: 0 0 auto; order: -3; font-weight: 700; }
  .tbl td.k-status { order: -2; }
  .tbl td.k-reasons { flex-basis: 100%; order: -1; padding-block-end: 6px; border-block-end: 1px solid var(--line); }
  .tbl td.k-row_no::before { display: inline; content: "ردیف "; font-size: 13px; color: var(--ink); }
  .tbl td.k-status::before { content: none; }
  .tbl td.k-reasons::before { display: none; }
  .tbl td.reason { min-width: 0; }
  .tbl td.edit { min-height: 48px; }
  .tbl td.edit input, .tbl td.edit select { width: 100%; min-width: 0; }
  .tbl td.saving { display: block; }
  .tbl tr.row-saved { background: #f1f1f1; }
  .tbl tr.row-saved td { background: none; }
}

/* job description tab */
.jd-sum { padding: 4px 8px 14px; }
.jd-sum .jd-title { margin: 0 0 6px; }
.jd-role { margin: 0; font-size: 12.5px; color: var(--mute); }
.jd-sum .jd-duty { margin: 4px 0 6px; font-size: 16px; font-weight: 800; line-height: 1.9; }
.jd-meta { margin: 0; font-size: 13px; line-height: 1.9; color: var(--mute); }
.jd-sec { border-top: 1px solid var(--line); }
.jd-sec summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 52px; padding: 0 8px; cursor: pointer; list-style: none; font-size: 14.5px; font-weight: 700; }
.jd-sec summary::-webkit-details-marker { display: none; }
.jd-sec summary::after { content: "+"; flex: none; width: 28px; text-align: center; font-size: 22px; font-weight: 400; line-height: 1; }
.jd-sec[open] summary::after { content: "−"; }
.jd-sec summary:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; border-radius: 10px; }
.jd-body { padding: 0 8px 18px; font-size: 14px; line-height: 2; }
.jd-body p { margin: 0 0 6px; }
.jd-body p small { display: block; font-size: 12px; color: var(--mute); }

/* desktop: narrower pill tab bar */
@media (min-width: 900px) { body.in-agent .tabbar { width: 280px; } }

/* login */
.login-card .login-note, .login-card .err { display: flex; align-items: baseline; gap: 8px; margin: 0; padding: 8px 12px; border: 0; border-radius: 8px; background: var(--surface); color: var(--ink); font-size: 12.5px; font-weight: 400; line-height: 1.8; }
.login-card .login-note[hidden], .login-card .err[hidden] { display: none; }
.login-card .login-note::before, .login-card .err::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--st-yellow); }
.login-card .err::before { background: var(--st-red); }
.login-card input:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.login-card input[aria-invalid="true"] { border-color: var(--ink); }
.login-card input[disabled], .login-card .btn:disabled { opacity: .6; cursor: progress; }
.login-card label { margin-block-start: 6px; }
.pw-wrap { position: relative; display: grid; }
/* the input is dir=ltr while the wrapper is rtl: its inline-start side is the same physical side as the wrapper's inline-end */
.pw-wrap input { padding-inline-start: 44px; }
.pw-toggle { position: absolute; inset-block: 0; inset-inline-end: 0; width: 44px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 12px; background: transparent; color: var(--ink); cursor: pointer; }
.pw-toggle:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.pw-toggle svg[hidden] { display: none; }

/* ======================= THEME LAYER: colour pass (tokens at the top of this file) ======================= */
body { background-color: var(--bg); background-image: radial-gradient(820px 520px at 100% -6%, var(--bg-glow), transparent 70%), radial-gradient(760px 520px at -6% 104%, var(--bg-warm), transparent 70%), radial-gradient(520px 380px at 55% 48%, rgba(255, 255, 255, .55), transparent 72%); background-attachment: fixed; }
body.login { background-color: var(--bg); }
.skip { background: var(--card); color: var(--ink); }
.nav, .dept-title { background: rgba(246, 241, 231, .9); }
.agent-bar { background: var(--glass-strong); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); border-bottom-color: var(--glass-edge); box-shadow: 0 4px 20px rgba(20, 30, 56, .06); }
body :is(button, a, input, textarea, summary, .btn, .session-open, .chat-row):focus-visible { outline-color: var(--focus); }
body .tab:focus-visible { outline-color: #fff; }
body .logout-btn:focus-visible { outline-color: var(--st-red); }
.icon-btn:hover { background: var(--accent-soft); }
.logout-btn { color: var(--st-red); }
.logout-btn:hover { background: var(--st-red-bg); }
.scrim, .rp-modal, .dlg-modal { background: rgba(20, 30, 56, .45); }

/* sidebar */
.side { background: rgba(255, 255, 255, .58); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); border-inline-color: var(--glass-edge); box-shadow: var(--glass-shadow); }
.side-new { background: var(--accent); color: var(--accent-contrast); }
.side-new:hover { background: var(--accent-hover); }
.session:hover { background: rgba(255, 255, 255, .6); }
.session.on { background: rgba(255, 255, 255, .88); box-shadow: 0 0 0 1px var(--glass-edge), 0 2px 8px rgba(20, 30, 56, .08); }
.session.on .session-open b { color: var(--accent); }
.session-open span, .del, .chat-desc, .empty, .no-result { color: var(--mute); }
.del:hover { background: var(--accent-soft); color: var(--ink); }
.side-close:hover { background: var(--accent-soft); }

/* avatars */
.av, .av-0, .av-1 { background: linear-gradient(145deg, #34457a, var(--accent)); color: var(--accent-contrast); box-shadow: 0 0 0 2px rgba(255, 255, 255, .85); }
.pic .online { background: var(--st-green); box-shadow: 0 0 0 2.5px var(--bg); }
.chat-row { background: var(--glass); border: 1px solid var(--glass-edge); margin-block: 3px; -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); box-shadow: 0 2px 12px rgba(20, 30, 56, .06); }
.chat-row:hover { background: var(--glass-strong); }
.chat-row:active { background: var(--accent-soft); }
.chat-time { color: var(--mute); }
.search { background: var(--surface); color: var(--mute); }
.search:focus-within { background: var(--card); border-color: var(--accent); }

/* tab bar */
.glass-ink { background: var(--tabbar); color: var(--tabbar-fg); border: 1px solid rgba(255, 255, 255, .22); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); box-shadow: 0 12px 32px rgba(20, 30, 56, .3), inset 0 1px 0 rgba(255, 255, 255, .18); }
.tab { color: var(--tabbar-fg); }
.tab:hover { color: #fff; }
.tab.on { background: var(--tab-on-bg); color: var(--tab-on-fg); }

/* buttons and links */
.btn { background: var(--glass-strong); border-color: rgba(30, 42, 74, .22); }
.btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { background: var(--st-red); border-color: var(--st-red); color: #fff; }
.btn.danger:hover { background: #a93226; border-color: #a93226; }
.md a, .rp-src, .rs-more { color: var(--accent); }
.sug-chip { background: var(--glass-strong); border-color: var(--glass-edge); box-shadow: 0 2px 10px rgba(20, 30, 56, .06); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); }
.sug-chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.new-pill { background: var(--accent); color: var(--accent-contrast); }
.flash { background: #182442; }

/* chat bubbles */
.bubble.me { background: var(--bubble-user); color: var(--bubble-user-text); box-shadow: 0 1px 2px rgba(20, 30, 56, .12); }
.bubble.me .t { color: rgba(255, 255, 255, .9); }
.bot-b { background: var(--bubble-worker); color: var(--ink); border: 1px solid var(--glass-edge); box-shadow: 0 4px 18px rgba(20, 30, 56, .08); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); }
.bot-row.err .bot-b { background: var(--st-red-bg); border-color: #e3b4af; }
.dots i, .spin { --dot: var(--accent); }
.dots i { background: var(--accent); }
.spin { border-top-color: var(--accent); }
.att-pill { background: var(--card); }
.att-pill .ci, .chip .ci { background: var(--accent); color: var(--accent-contrast); }
.pill, .pill.st { background: var(--card); }
.demo-note { background: var(--surface); }
.md-tbl { background: var(--card); }

/* composer */
.composer { background: rgba(255, 255, 255, .82); border: 1px solid var(--glass-edge); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); box-shadow: 0 10px 34px rgba(20, 30, 56, .16); }
.composer:focus-within { border-color: var(--accent); }
.composer.drag { border-color: var(--accent); background: var(--accent-soft); }
.c-btn { color: var(--accent); }
.c-btn:hover { background: var(--accent-soft); }
.send, .send:hover { background: var(--accent); color: var(--accent-contrast); }
.send:hover { background: var(--accent-hover); }
.composer textarea::placeholder { color: #666b7a; }
.c-menu { background: rgba(255, 255, 255, .9); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); border-color: var(--glass-edge); }
.rp-sheet, .dlg { background: rgba(255, 255, 255, .92); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); }
.c-menu button:hover { background: var(--surface); }
.chip { background: var(--surface); }
.chip .x:hover { background: var(--accent-soft); }

/* review table and misc surfaces */
.seg button[aria-pressed=true] { background: var(--card); color: var(--accent); }
.tbl th, .md-tbl th { background: var(--surface); }
.tbl tr.row-saved td { background: var(--accent-soft); }
.tbl tr.row-saved { background: var(--accent-soft); }
.tbl tr { background: var(--card); }
.tbl td.empty { color: var(--mute); }
.tbl td.reason { color: var(--ink); }
.tbl td.edit input, .tbl td.edit select { background: var(--card); border-color: var(--accent); }
@media (hover: hover) { .tbl td.edit:hover { background: var(--accent-soft); outline-color: var(--accent); } }
.dl-area:focus-visible { border-color: var(--accent); }
.dlg-err, .cell-err { color: var(--ink); }
.dlg-err { background: var(--st-red-bg); border-color: #e3b4af; }

/* login */
.login-card { background: var(--glass-strong); border-color: var(--glass-edge); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); box-shadow: 0 18px 48px rgba(20, 30, 56, .14); }
.login-card input { background: rgba(255, 255, 255, .9); border-color: #b8bccb; }
.login-card input:focus-visible { outline-color: var(--accent); }
.login-card input[aria-invalid="true"] { border-color: var(--st-red); }
.login-card .login-note { background: var(--st-yellow-bg); }
.login-card .err { background: var(--st-red-bg); color: var(--ink); }
.login-card .err::before { background: var(--st-red); }
.pw-toggle { color: var(--mute); }
.login-brand { color: var(--accent); }

/* ======================= REFINEMENT LAYER: restrained, product-like (overrides the glass pass above) =======================
   Rules: glass only on the floating tab bar and the sidebar; solid surfaces for cards, inputs, bubbles, sheets.
   Radii 8 (buttons) / 10 (inputs) / 12 (cards). 4/8px spacing. Weights: 400 body, 500 labels, 600 names, 700 titles only. */
body { background-image: linear-gradient(180deg, #f8f4ec 0%, var(--bg) 60%); background-attachment: fixed; }
.nav, .dept-title { background: var(--bg); }
.agent-bar { background: rgba(246, 241, 231, .96); -webkit-backdrop-filter: none; backdrop-filter: none; border-bottom: 1px solid var(--line); box-shadow: none; }
.side { background: rgba(250, 247, 240, .82); border-inline-color: var(--line); box-shadow: none; }
.session { border-radius: var(--r-ctl); }
.session-open { border-radius: var(--r-ctl); }
.session.on { background: var(--card); box-shadow: 0 0 0 1px var(--line); }
.side-new { border-radius: var(--r-ctl); }
.av, .av-0, .av-1 { background: var(--accent); box-shadow: none; }
.pic .online { box-shadow: 0 0 0 2px var(--bg); }

/* cards and rows: solid, thin border, no shadow */
.chat-row { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); margin-block: 4px; -webkit-backdrop-filter: none; backdrop-filter: none; box-shadow: none; }
.chat-row:hover { background: var(--card); border-color: #b9bfd0; }
.search { border-radius: var(--r-input); background: var(--card); border: 1px solid var(--line); }
.sug-chip { border-radius: var(--r-ctl); background: var(--card); border-color: var(--line); box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.btn, .btn.sm, .rp-more, .seg button { border-radius: var(--r-ctl); }
.btn { background: var(--card); border-color: #c9cddb; }
.new-pill, .flash { border-radius: var(--r-ctl); }

/* chat */
.msgs { gap: 16px; }
.bubble { border-radius: 16px; }
.bot-b { border-radius: 16px; background: var(--card); border: 1px solid var(--line); box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.bubble.me { box-shadow: none; }
.att-pill, .pill, .pill.st { border-radius: var(--r-ctl); }
.demo-note { border-radius: var(--r-ctl); }

/* composer */
.composer { border-radius: 14px; background: var(--card); border: 1px solid #c9cddb; box-shadow: 0 2px 12px rgba(20, 30, 56, .08); -webkit-backdrop-filter: none; backdrop-filter: none; }
.send, .c-btn { border-radius: 10px; }
.c-menu { border-radius: var(--r-card); background: var(--card); box-shadow: 0 6px 20px rgba(20, 30, 56, .14); -webkit-backdrop-filter: none; backdrop-filter: none; }
.c-menu button { border-radius: var(--r-ctl); }
.chip, .thumb { border-radius: var(--r-ctl); }
.rp-sheet, .dlg { background: var(--card); -webkit-backdrop-filter: none; backdrop-filter: none; }
.dlg { border-radius: var(--r-card); box-shadow: 0 12px 32px rgba(20, 30, 56, .2); }
.rp-sheet { border-radius: 16px 16px 0 0; }
@media (min-width: 700px) { .rp-sheet { border-radius: var(--r-card); } }
.tbl-wrap, .md-tbl, .dl-area, .dlg-err { border-radius: var(--r-ctl); }

/* type scale: 12 meta / 13 secondary / 14 body / 16 input / 18 sheet title / 20 page title */
.page-title, .jd-title, .dlg-t, .rp-sh-top h2, .nav .brand, .side-top { font-weight: 700; }
.chat-name, .agent-bar .who b, .dept-title, .rp-s, .jd-sec summary, .jd-duty, .jd-sum .jd-duty, .au-g h5, .dlg-name { font-weight: 600; }
.side-h, .jd-row dt, .login-card label { font-weight: 500; }
.page-title, .jd-title { font-size: 20px; }
.rp-sh-top h2 { font-size: 17px; }
.chat-time, .tbl td.num, .rp-item time { font-variant-numeric: tabular-nums; }
.tab { font-weight: 500; }
.tab.on { font-weight: 600; }

/* login: modest, start-aligned, thin border, no heavy shadow */
body.login { align-content: center; }
.login-wrap { width: min(360px, calc(100vw - 32px)); padding: 0; justify-items: stretch; gap: 12px; }
body.login main.login-wrap { padding: 0; margin: 0; }
.login-brand { font-size: 14px; font-weight: 600; text-align: start; color: var(--mute); }
.login-card { width: 100%; padding: 24px; gap: 4px; border-radius: var(--r-card); background: var(--card); border: 1px solid var(--line); box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.login-card h1 { margin: 0 0 12px; font-size: 18px; font-weight: 700; }
.login-card label { margin-block-start: 8px; font-size: 13px; color: var(--mute); }
.login-card input { height: 44px; border-radius: var(--r-ctl); background: var(--card); border: 1px solid #b8bccb; font-size: 14px; }
.login-card .btn { margin-top: 16px; min-height: 44px; border-radius: var(--r-ctl); font-size: 14px; }
.login-card .login-note, .login-card .err { border-radius: var(--r-ctl); margin-bottom: 4px; }
.pw-toggle { border-radius: var(--r-ctl); }

/* reports tab */
.rp-list2 { display: grid; gap: 10px; }
.rp-item { display: grid; gap: 4px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--card); box-shadow: none; }
.rp-s { margin: 0; font-size: 14px; font-weight: 700; line-height: 1.9; overflow-wrap: anywhere; }
.rp-item time { font-size: 12px; color: var(--mute); }
.rp-more { justify-self: start; min-height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--accent); font: 600 12px "Vazirmatn", sans-serif; cursor: pointer; }
.rp-more:hover { background: var(--accent-soft); border-color: var(--accent); }
.rp-more:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.rp-detail { display: grid; gap: 8px; margin-block-start: 6px; padding-block-start: 8px; border-block-start: 1px solid var(--line); }
.rp-detail[hidden] { display: none; }
.rp-clamp { margin: 0; font-size: 13px; line-height: 1.9; white-space: pre-line; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.rp-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.rp-src { color: var(--accent); text-decoration: underline; }

/* glass fallback: no backdrop-filter, so the translucent surfaces become opaque */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --glass: #fbf9f3; --glass-strong: #fff; --bubble-worker: #fff; --tabbar: #182442; }
  .nav, .dept-title, .agent-bar { background: var(--bg); }
  .side { background: var(--sidebar); }
  .composer, .c-menu, .rp-sheet, .dlg, .login-card { background: #fff; }
}
