/* =========================================================
   پینگتر — چت هوش مصنوعی (چیدمان ChatGPT)
   ========================================================= */

:root {
  --bg: #ffffff;
  --surface: #f9f9f9;
  --surface-2: #f4f4f4;
  --surface-3: #ececec;
  --ink: #0d0d0d;
  --ink-soft: #3f3f3f;
  --muted: #6f6f6f;
  --muted-2: #9a9a9a;
  --line: #e6e6e6;
  --line-soft: #efefef;
  --accent: #0b8f6d;
  --accent-2: #14b88a;
  --accent-soft: #e8f7f2;
  --accent-ink: #ffffff;
  --danger: #d92d20;
  --danger-soft: #fdecea;
  --user-bubble: #f4f4f4;
  --code-bg: #0d1117;
  --code-ink: #e6edf3;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05);
  --shadow: 0 8px 30px rgba(0, 0, 0, .09);
  --shadow-lg: 0 18px 60px rgba(0, 0, 0, .16);
  --radius: 16px;
  --font: "Vazirmatn", "IRANSans", system-ui, -apple-system, "Segoe UI", Tahoma, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

html[data-theme="dark"] {
  --bg: #212121;
  --surface: #171717;
  --surface-2: #2a2a2a;
  --surface-3: #343434;
  --ink: #ededed;
  --ink-soft: #d4d4d4;
  --muted: #a3a3a3;
  --muted-2: #7d7d7d;
  --line: #383838;
  --line-soft: #2e2e2e;
  --accent: #2ecfa2;
  --accent-2: #43e0b4;
  --accent-soft: #16322b;
  --accent-ink: #08221c;
  --danger: #ff7b72;
  --danger-soft: #3a1d1a;
  --user-bubble: #2f2f2f;
  --code-bg: #0b0e14;
  --code-ink: #e6edf3;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 8px 30px rgba(0, 0, 0, .45);
  --shadow-lg: 0 18px 60px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  direction: rtl;
  font-size: 14.5px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }

button { background: none; border: 0; cursor: pointer; }

a { color: var(--accent); }

::selection { background: var(--accent); color: var(--accent-ink); }

/* ---------- اسکرول‌بار ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--muted-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted-2) 55%, transparent);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--muted-2); background-clip: content-box; }

/* ---------- چیدمان ---------- */
.app { display: flex; height: 100dvh; overflow: hidden; }

.sidebar {
  width: 268px;
  flex: 0 0 268px;
  background: var(--surface);
  border-inline-end: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  transition: width .18s ease, flex-basis .18s ease;
}

.sidebar.collapsed { width: 0; flex-basis: 0; overflow: hidden; border: 0; }

.side-head { padding: 12px 12px 6px; display: flex; flex-direction: column; gap: 8px; }

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 6px 10px;
  text-decoration: none;
  color: var(--ink);
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 800; font-size: 14px;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.brand-text strong { font-size: 13.5px; font-weight: 700; }
.brand-text span { font-size: 11px; color: var(--muted); }

.btn-new {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  font-weight: 600; font-size: 13.5px;
  box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s, transform .1s;
}
.btn-new:hover { background: var(--surface-2); }
.btn-new:active { transform: scale(.99); }
.btn-new svg { width: 17px; height: 17px; }

.search-wrap { position: relative; }
.search-wrap svg {
  position: absolute; inset-inline-start: 10px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--muted); pointer-events: none;
}
.search {
  width: 100%; padding: 8px 34px 8px 12px;
  border-radius: 10px; border: 1px solid transparent;
  background: var(--surface-3);
  font-size: 12.5px;
}
.search:focus { outline: none; border-color: var(--line); background: var(--bg); }

.conv-scroll { flex: 1; overflow-y: auto; padding: 6px 8px 12px; min-height: 0; }

.conv-group-label {
  font-size: 10.5px; font-weight: 700; color: var(--muted-2);
  padding: 12px 8px 5px; letter-spacing: .2px;
}

.conv {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; margin-bottom: 1px;
  border-radius: 9px;
  font-size: 13px; color: var(--ink-soft);
  cursor: pointer;
  transition: background .14s;
}
.conv:hover { background: var(--surface-3); }
.conv.active { background: var(--surface-3); color: var(--ink); font-weight: 600; }
.conv-title {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-menu-btn {
  width: 24px; height: 24px; border-radius: 6px; flex: none;
  display: grid; place-items: center;
  color: var(--muted); opacity: 0;
}
.conv:hover .conv-menu-btn, .conv.active .conv-menu-btn { opacity: 1; }
.conv-menu-btn:hover { background: var(--line); color: var(--ink); }
.conv-menu-btn svg { width: 15px; height: 15px; }

.conv-empty { padding: 18px 10px; text-align: center; color: var(--muted-2); font-size: 12px; }

.side-foot {
  border-top: 1px solid var(--line);
  padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
}

.quota-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 11px;
  background: var(--bg);
  font-size: 11.5px;
}
.quota-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.quota-row b { font-size: 11.5px; }
.quota-row span { color: var(--muted); }
.quota-bar { height: 5px; border-radius: 99px; background: var(--surface-3); margin-top: 7px; overflow: hidden; }
.quota-bar i {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .4s ease;
}
.quota-card.full .quota-bar i { background: var(--danger); }

.user-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: 10px;
}
.user-row:hover { background: var(--surface-3); }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 800; font-size: 12px;
}
.user-meta { flex: 1; min-width: 0; line-height: 1.4; }
.user-meta b { display: block; font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta span { font-size: 10.5px; color: var(--muted); }
.icon-mini {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  display: grid; place-items: center; color: var(--muted);
}
.icon-mini:hover { background: var(--line); color: var(--ink); }
.icon-mini svg { width: 16px; height: 16px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }

.topbar {
  height: 56px; flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  z-index: 20;
}
.topbar .spacer { flex: 1; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center; color: var(--ink-soft);
  transition: background .14s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:disabled { opacity: .4; cursor: default; }

.title-mini {
  font-size: 13.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw;
}

.mode-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 11px; border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 12.5px; font-weight: 600;
  color: var(--ink-soft);
  transition: background .14s, border-color .14s;
}
.mode-btn:hover { background: var(--surface-2); }
.mode-btn .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.mode-btn svg { width: 13px; height: 13px; color: var(--muted); }

.chip-desktop {
  display: none; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 11px; font-weight: 700;
}
body.is-desktop .chip-desktop { display: inline-flex; }

/* ---------- منوی حالت ---------- */
.popover {
  position: absolute; z-index: 60;
  min-width: 250px; padding: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  animation: pop .12s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.99); } }

.mode-item {
  display: flex; align-items: flex-start; gap: 9px;
  width: 100%; padding: 9px 10px; border-radius: 10px; text-align: start;
}
.mode-item:hover { background: var(--surface-2); }
.mode-item.active { background: var(--accent-soft); }
.mode-item .mi-text { flex: 1; min-width: 0; }
.mode-item b { display: block; font-size: 12.5px; font-weight: 600; }
.mode-item span { font-size: 11px; color: var(--muted); }
.mode-item .check { width: 15px; height: 15px; color: var(--accent); margin-top: 2px; }
.mode-item .mi-note {
  font-size: 9.5px; padding: 1px 6px; border-radius: 99px;
  background: var(--surface-3); color: var(--muted); align-self: center;
}

.menu-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 9px 11px; border-radius: 9px;
  font-size: 12.5px; text-align: start;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-item svg { width: 15px; height: 15px; }

/* ---------- رشته‌ی گفتگو ---------- */
.thread { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 22px 0 6px; scroll-behavior: smooth; }
.thread-inner { max-width: 780px; margin: 0 auto; padding: 0 20px; }

.msg { display: flex; gap: 13px; padding: 15px 0; animation: fadeIn .18s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } }

.msg.user { justify-content: flex-end; }
.msg.user .bubble {
  max-width: min(78%, 620px);
  background: var(--user-bubble);
  border-radius: 20px;
  padding: 10px 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg.ai { align-items: flex-start; }
.msg.ai > .wrap { flex: 1; min-width: 0; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 12px; font-weight: 800;
  box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 30%, transparent);
}

.md { overflow-wrap: anywhere; }
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md p { margin: 0 0 10px; }
.md h2, .md h3, .md h4 { margin: 18px 0 8px; font-size: 15px; font-weight: 700; line-height: 1.5; }
.md h2 { font-size: 17px; }
.md ul, .md ol { margin: 4px 0 12px; padding-inline-start: 22px; }
.md li { margin-bottom: 4px; }
.md li::marker { color: var(--muted); }
.md blockquote {
  border-inline-start: 3px solid var(--line);
  padding: 2px 12px; margin: 10px 0; color: var(--muted);
}
.md hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.md a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.md strong { font-weight: 700; }
.md em { font-style: italic; }
.md code.inline {
  background: var(--surface-3); padding: 1.5px 5px; border-radius: 5px;
  font-family: var(--mono); font-size: 12.3px; direction: ltr; unicode-bidi: embed;
}
.md table {
  width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px;
  display: block; overflow-x: auto;
}
.md th, .md td { border: 1px solid var(--line); padding: 7px 10px; text-align: start; }
.md th { background: var(--surface-2); font-weight: 700; }

/* ---------- بلوک کد ---------- */
.code {
  margin: 12px 0; border-radius: 12px; overflow: hidden;
  background: var(--code-bg); border: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  direction: ltr;
}
.code-head {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 11px;
  background: rgba(255, 255, 255, .055);
  color: #b9c2cc; font-size: 11px;
}
.code-lang { font-family: var(--mono); letter-spacing: .3px; text-transform: lowercase; }
.code-head .grow { flex: 1; }
.code-act {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 7px; border-radius: 6px;
  color: #c8d1da; font-size: 10.5px; font-weight: 600;
  transition: background .12s, color .12s;
}
.code-act:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.code-act svg { width: 12px; height: 12px; }
.code-act.run { color: #7ee2c0; }
.code pre {
  margin: 0; padding: 13px 14px; overflow: auto;
  font-family: var(--mono); font-size: 12.4px; line-height: 1.65;
  color: var(--code-ink); direction: ltr; text-align: left;
  max-height: 460px;
}
.code pre code { font-family: inherit; white-space: pre; }

/* ---------- اکشن پیام ---------- */
.msg-actions { display: flex; align-items: center; gap: 2px; margin-top: 6px; }
.msg-actions button {
  width: 27px; height: 27px; border-radius: 7px;
  display: grid; place-items: center; color: var(--muted);
  opacity: .55;
}
.msg-actions button svg { width: 15px; height: 15px; }
.msg:hover .msg-actions button { opacity: 1; }
.msg-actions button:hover { background: var(--surface-2); color: var(--ink); }
.msg-actions button.on { color: var(--accent); opacity: 1; }

/* ---------- تایپ ---------- */
.typing { display: inline-flex; gap: 4px; align-items: center; height: 22px; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--muted-2);
  animation: blink 1.2s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: .16s; }
.typing i:nth-child(3) { animation-delay: .32s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }

.caret {
  display: inline-block; width: 7px; height: 15px; margin-inline-start: 2px;
  background: var(--accent); border-radius: 2px; vertical-align: -2px;
  animation: blinkCaret .9s steps(2, start) infinite;
}
@keyframes blinkCaret { 50% { opacity: 0; } }

/* ---------- صفحه‌ی خالی ---------- */
.hero {
  max-width: 780px; margin: 0 auto;
  padding: clamp(28px, 9vh, 96px) 20px 20px;
  display: flex; flex-direction: column; align-items: center;
}
.hero-mark {
  width: 52px; height: 52px; border-radius: 16px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 800; font-size: 20px;
  box-shadow: 0 12px 34px color-mix(in srgb, var(--accent) 34%, transparent);
  margin-bottom: 18px;
}
.hero h1 { font-size: clamp(20px, 3.4vw, 27px); font-weight: 700; text-align: center; line-height: 1.5; }
.hero p.sub { color: var(--muted); font-size: 13px; text-align: center; margin-top: 7px; }

.suggests {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  width: 100%; margin-top: 28px;
}
.suggest {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 13px 14px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--bg); text-align: start;
  transition: background .15s, border-color .15s, transform .1s;
}
.suggest:hover { background: var(--surface-2); border-color: var(--muted-2); transform: translateY(-1px); }
.suggest .s-ico {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.suggest .s-ico svg { width: 16px; height: 16px; }
.suggest b { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 2px; }
.suggest span { font-size: 11px; color: var(--muted); line-height: 1.6; }

/* ---------- نوار نوشتن ---------- */
.composer-wrap { flex: none; padding: 6px 20px 14px; }
.composer {
  max-width: 780px; margin: 0 auto;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 24px;
  padding: 10px 10px 8px;
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.composer textarea {
  width: 100%; border: 0; background: transparent; resize: none;
  padding: 6px 8px; max-height: 200px; min-height: 26px;
  font-size: 14.5px; line-height: 1.7; color: var(--ink);
}
.composer textarea:focus { outline: none; }
.composer textarea::placeholder { color: var(--muted-2); }

.tools-row { display: flex; align-items: center; gap: 4px; padding: 2px 2px 0; }
.tools-row .grow { flex: 1; }

.tool-btn {
  display: inline-flex; align-items: center; gap: 5px;
  height: 32px; padding: 0 9px; border-radius: 9px;
  color: var(--muted); font-size: 11.5px; font-weight: 600;
  transition: background .13s, color .13s;
}
.tool-btn:hover { background: var(--surface-3); color: var(--ink); }
.tool-btn svg { width: 16px; height: 16px; }
.tool-btn.armed { background: var(--accent-soft); color: var(--accent); }
.tool-btn:disabled { opacity: .4; cursor: default; }

.send-btn {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--ink); color: var(--bg);
  transition: opacity .15s, transform .1s, background .15s;
}
.send-btn:hover:not(:disabled) { transform: scale(1.05); }
.send-btn:disabled { opacity: .3; cursor: default; }
.send-btn svg { width: 17px; height: 17px; }
.send-btn.stop { background: var(--danger); color: #fff; }

.hint-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; max-width: 780px; margin: 7px auto 0;
  font-size: 10.5px; color: var(--muted-2);
  padding: 0 6px;
}
.hint-row .kbd {
  font-family: var(--font); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 5px;
  padding: 1px 5px; font-size: 10px; color: var(--muted);
}

.file-chip {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 0 8px 6px; padding: 4px 9px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 8px; font-size: 11.5px; font-weight: 600;
}
.file-chip button { color: inherit; display: grid; place-items: center; }
.file-chip svg { width: 13px; height: 13px; }

/* ---------- دکمه‌ی پایین ---------- */
.scroll-down {
  position: absolute; inset-inline-end: 24px; bottom: 108px;
  width: 34px; height: 34px; border-radius: 50%;
  display: none; place-items: center;
  background: var(--bg); border: 1px solid var(--line);
  box-shadow: var(--shadow); color: var(--ink-soft); z-index: 15;
}
.scroll-down.show { display: grid; }
.scroll-down svg { width: 16px; height: 16px; }

/* ---------- مودال ---------- */
.modal-root { position: fixed; inset: 0; z-index: 200; display: none; }
.modal-root.open { display: block; }
.modal-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, .5); backdrop-filter: blur(2px); }
.modal {
  position: relative; z-index: 1;
  width: min(920px, calc(100vw - 32px));
  max-height: calc(100dvh - 60px);
  margin: 30px auto 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: pop .16s ease-out;
}
.modal.small { width: min(440px, calc(100vw - 32px)); }
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-bottom: 1px solid var(--line);
}
.modal-head b { font-size: 13px; flex: 1; }
.modal-body { padding: 14px; overflow: auto; }
.modal-body iframe { width: 100%; height: min(60vh, 560px); border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.modal-body pre {
  background: var(--code-bg); color: var(--code-ink);
  padding: 12px; border-radius: 10px; overflow: auto;
  font-family: var(--mono); font-size: 12px; direction: ltr; text-align: left;
  max-height: 320px; white-space: pre-wrap;
}
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.input {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg);
  font-size: 13px;
}
.input:focus { outline: none; border-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 15px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg);
  font-size: 12.5px; font-weight: 600;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-block { width: 100%; }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn-danger:hover { background: var(--danger-soft); }
.row { display: flex; gap: 8px; align-items: center; }

/* ---------- توست ---------- */
.toasts {
  position: fixed; inset-inline-start: 50%; transform: translateX(-50%);
  bottom: 22px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--ink); color: var(--bg);
  padding: 9px 16px; border-radius: 10px;
  font-size: 12.5px; box-shadow: var(--shadow-lg);
  animation: toastIn .2s ease-out;
  max-width: 90vw;
}
.toast.error { background: var(--danger); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ---------- ورود ---------- */
.auth {
  position: fixed; inset: 0;
  display: none; place-items: center;
  padding: 20px; overflow: auto;
  background:
    radial-gradient(1000px 520px at 50% -12%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%),
    var(--bg);
  z-index: 100;
}
body.logged-out .auth { display: grid; }
body.logged-out .app { display: none; }
.auth-card {
  width: 100%; max-width: 390px;
  border: 1px solid var(--line); border-radius: 20px;
  background: var(--bg); box-shadow: var(--shadow-lg);
  padding: 26px 24px;
}
.auth-card .brand { justify-content: center; padding: 0 0 16px; }
.auth-card h2 { font-size: 16px; text-align: center; margin-bottom: 4px; }
.auth-card p.sub { font-size: 12px; color: var(--muted); text-align: center; margin-bottom: 18px; }
.auth-tabs {
  display: flex; gap: 4px; padding: 3px;
  background: var(--surface-2); border-radius: 11px; margin-bottom: 16px;
}
.auth-tabs button {
  flex: 1; padding: 7px; border-radius: 9px;
  font-size: 12.5px; font-weight: 600; color: var(--muted);
}
.auth-tabs button.active { background: var(--bg); color: var(--ink); box-shadow: var(--shadow-sm); }
.auth-note { font-size: 11px; color: var(--muted-2); text-align: center; margin-top: 14px; line-height: 1.9; }

/* ---------- اسکلت ---------- */
.skeleton { border-radius: 8px; background: var(--surface-2); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .5; } }

/* ---------- موبایل ---------- */
.scrim {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .45);
  z-index: 90; display: none;
}
.scrim.show { display: block; }

@media (max-width: 880px) {
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 100;
    width: 282px; flex-basis: 282px;
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  html[dir="rtl"] .sidebar { transform: translateX(100%); }
  html[dir="rtl"] .sidebar.open { transform: translateX(0); }
  .sidebar.collapsed { width: 282px; flex-basis: 282px; transform: translateX(100%); }
  .sidebar.collapsed.open { transform: translateX(0); }
  .suggests { grid-template-columns: 1fr; }
  .thread-inner, .composer-wrap { padding-inline: 14px; }
  .msg.user .bubble { max-width: 88%; }
  .title-mini { display: none; }
  .hero { padding-top: 26px; }
  .hint-row .kbd-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  .thread { scroll-behavior: auto; }
}

/* ---------- تکمیل‌های پیام ---------- */
.msg.user .u-wrap {
  display: flex; flex-direction: column; align-items: flex-end;
  max-width: min(78%, 620px); min-width: 0;
}
.msg.user .u-wrap .bubble { max-width: 100%; }
.msg.user .msg-actions { justify-content: flex-end; }
.md.stream { white-space: pre-wrap; overflow-wrap: anywhere; }
.md img { max-width: 100%; border-radius: 12px; margin: 10px 0; border: 1px solid var(--line); display: block; }

/* ---------- کارت پکیج و دسترسی‌ها ---------- */
.plan-card {
  display: block; width: 100%; text-align: start;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--bg); padding: 10px 11px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.plan-card:hover { border-color: var(--muted-2); background: var(--surface-2); }
.plan-card.full { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }

.plan-head { display: flex; align-items: center; gap: 7px; }
.plan-ico {
  width: 24px; height: 24px; border-radius: 7px; flex: none;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.plan-ico svg { width: 14px; height: 14px; }
.plan-name {
  flex: 1; min-width: 0; font-size: 11.5px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.plan-badge {
  font-size: 9.5px; font-weight: 700; padding: 1px 7px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent); flex: none;
}
.plan-badge.off { background: var(--surface-3); color: var(--muted); }
.plan-badge.warn { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

.plan-quota { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 7px; }
.pq-main { font-size: 10.5px; color: var(--muted); }
.pq-main b { font-size: 12px; color: var(--ink); font-weight: 700; }
.pq-left { font-size: 10px; color: var(--muted-2); }

.plan-feats { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.feat {
  font-size: 9.5px; font-weight: 700; padding: 2px 7px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; gap: 3px;
}
.feat.off { background: var(--surface-3); color: var(--muted-2); text-decoration: line-through; }
.feat .fnum { font-weight: 600; opacity: .8; }

/* ابزار قفل‌شده در کامپوزر */
.tool-btn.locked { opacity: .45; }
.tool-btn.locked:hover { background: var(--surface-3); color: var(--muted); }

/* شیت جزئیات پکیج */
.plan-sheet { display: flex; flex-direction: column; gap: 10px; }
.plan-section {
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.plan-section > h4 {
  font-size: 11px; color: var(--muted); font-weight: 700; margin-bottom: 7px;
}
.plan-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 12px; padding: 4px 0;
}
.plan-row + .plan-row { border-top: 1px dashed var(--line-soft); }
.plan-row span { color: var(--muted); }
.plan-row b { font-weight: 700; font-size: 12px; }
.plan-row b.ok { color: var(--accent); }
.plan-row b.no { color: var(--danger); }
.plan-row b.muted { color: var(--muted-2); font-weight: 600; }
.plan-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }

/* ---------- کنسول مدیر ---------- */
body[data-scope="admin"] #btnLogout { display: none; }
body[data-embed="1"] .hint-row .kbd-hint { display: none; }
