/* ============================================================
   Saqqar — Chat Page Redesign (v2)
   Token-driven · container-query responsive · 1440 → 393 px
   Loaded AFTER app.css on the chat page so these declarations win.
   Existing JS class names (.conversation-row, .approval-row, etc.)
   are bridged at the bottom of this file.
   ============================================================ */

/* ---------- Tokens (same names as app.css; specs from HANDOFF §2) ---------- */
:root,
html[data-theme="dark"],
html.dark {
  --bg: #0E1322;
  --surface-1: #161C2E;
  --surface-2: #1C2338;
  --surface-3: #11182B;
  --card-bg: rgba(22, 28, 46, 0.80);
  --card-border: rgba(40, 49, 73, 0.85);
  --input-bg: #1C2338;
  --hover-bg: rgba(255, 255, 255, 0.05);
  --text: #EAEDF6;
  --muted: #A2A9C0;
  --muted-2: rgba(234, 237, 246, 0.72);
  --hairline: rgba(55, 65, 92, 0.45);
  --hairline-strong: rgba(55, 65, 92, 0.78);
  --border: #283149;
  --ghost-bg: rgba(255, 255, 255, 0.04);
  --ghost-bg-hover: rgba(255, 255, 255, 0.08);

  --brand-cyan: #43C2C4;
  --brand-cyan-strong: #5BD3D5;
  --brand-cyan-soft: rgba(67, 194, 196, 0.18);
  --brand-purple: #4660B8;
  --brand-purple-soft: rgba(70, 96, 184, 0.20);
  --brand-navy: #4660B8;
  --brand-gradient: linear-gradient(135deg, #36488F 0%, #4660B8 45%, #43C2C4 100%);
  --brand-gradient-vivid: linear-gradient(135deg, #43C2C4 0%, #4660B8 100%);

  --success: #3DBB85;
  --warning: #F59E0B;
  --danger: #E0614F;
  --success-soft: rgba(61, 187, 133, 0.15);
  --warning-soft: rgba(245, 158, 11, 0.12);
  --warning-border: rgba(245, 158, 11, 0.35);
  --danger-soft: rgba(224, 97, 79, 0.13);
  --danger-border: rgba(224, 97, 79, 0.40);
}

html[data-theme="light"],
html.light {
  --bg: #F4F6FB;
  --surface-1: #FFFFFF;
  --surface-2: #F8FAFD;
  --surface-3: #EEF1F8;
  --card-bg: rgba(255, 255, 255, 0.94);
  --card-border: rgba(26, 34, 56, 0.09);
  --input-bg: #FFFFFF;
  --hover-bg: rgba(26, 34, 56, 0.04);
  --text: #1A2238;
  --muted: #545B73;
  --muted-2: rgba(26, 34, 56, 0.68);
  --hairline: rgba(26, 34, 56, 0.09);
  --hairline-strong: rgba(26, 34, 56, 0.17);
  --border: #E5E8F1;
  --ghost-bg: rgba(26, 34, 56, 0.04);
  --ghost-bg-hover: rgba(26, 34, 56, 0.08);

  --brand-cyan: #0E7E81;
  --brand-cyan-strong: #43C2C4;
  --brand-cyan-soft: rgba(67, 194, 196, 0.16);
  --brand-purple: #284080;
  --brand-purple-soft: rgba(40, 64, 128, 0.10);
  --brand-navy: #284080;
  --brand-gradient: linear-gradient(135deg, #1C2E5E 0%, #284080 45%, #0E7E81 100%);
}

/* ---------- Page chrome ---------- */
html, body.chat-page { height: 100%; }
body.chat-page {
  margin: 0;
  background:
    radial-gradient(ellipse at 18% 20%, rgba(6, 182, 212, 0.08) 0%, transparent 55%),
    radial-gradient(ellipse at 82% 12%, rgba(67, 194, 196, 0.05) 0%, transparent 55%),
    radial-gradient(ellipse at 50% 100%, rgba(40, 64, 128, 0.05) 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: 'Hanken Grotesk', 'Tajawal', system-ui, -apple-system, sans-serif;
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.005em;
  overflow: hidden;
}
html[data-theme="light"] body.chat-page,
html.light body.chat-page {
  background:
    radial-gradient(ellipse at 18% 20%, rgba(6, 182, 212, 0.05) 0%, transparent 55%),
    radial-gradient(ellipse at 82% 12%, rgba(139, 92, 246, 0.04) 0%, transparent 55%),
    radial-gradient(ellipse at 50% 100%, rgba(59, 130, 246, 0.03) 0%, transparent 55%),
    var(--bg);
}
body[lang="ar"], [dir="rtl"] body {
  font-family: 'Tajawal', 'Inter', system-ui, sans-serif;
}

.saqqar-frame {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-width: 320px;
  container-type: inline-size;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* Ambient halos */
.saqqar-frame::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 600px 400px at 12% 18%, rgba(6, 182, 212, 0.10), transparent 70%),
    radial-gradient(ellipse 700px 500px at 88% 8%, rgba(139, 92, 246, 0.08), transparent 70%),
    radial-gradient(ellipse 800px 400px at 50% 110%, rgba(31, 60, 136, 0.10), transparent 70%);
  z-index: 0;
}
html[data-theme="light"] .saqqar-frame::before {
  background:
    radial-gradient(ellipse 600px 400px at 12% 18%, rgba(6, 182, 212, 0.06), transparent 70%),
    radial-gradient(ellipse 700px 500px at 88% 8%, rgba(139, 92, 246, 0.05), transparent 70%),
    radial-gradient(ellipse 800px 400px at 50% 110%, rgba(31, 60, 136, 0.05), transparent 70%);
}

/* ---------- Shell grid ---------- */
.shell {
  position: relative;
  z-index: 1;
  height: 100%;
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr) 320px;
  gap: 14px;
  padding: 16px;
  box-sizing: border-box;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(14px);
  border-radius: 18px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
}
.sb-top {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-block: 4px;
}
.sidebar-brand { display: flex; justify-content: center; width: 100%; }
.sb-logo { width: 82%; max-width: 220px; height: auto; opacity: 0.95; }
html[data-theme="dark"] .sb-logo--dark,
html.dark .sb-logo--dark { display: none; }
html[data-theme="light"] .sb-logo--light,
html.light .sb-logo--light { display: none; }

.sb-new {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding-block: 10px; padding-inline: 14px;
  border-radius: 10px;
  background: var(--brand-gradient);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  border: 0;
  box-shadow: 0 2px 8px rgba(31, 60, 136, 0.25);
  cursor: pointer;
}
.sb-new:hover { filter: brightness(1.08); }

.sb-search {
  position: relative;
  display: flex; align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding-block: 7px; padding-inline: 10px;
  gap: 8px;
  color: var(--muted);
}
.sb-search input {
  flex: 1;
  font-size: 12.5px;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
  min-width: 0;
}
.sb-search input::placeholder { color: var(--muted-2); }
.sb-search-clear {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 6px;
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
}
.sb-search-clear:hover { background: var(--ghost-bg-hover); color: var(--text); }
.sb-search-clear.hidden { display: none; }

/* Conversation list scroll area */
.sb-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-inline-end: 2px;
  margin-inline-end: -2px;
}
.sb-section { display: flex; flex-direction: column; gap: 2px; margin-block-start: 6px; }
.sb-section:first-child { margin-block-start: 0; }
.sb-section-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--muted-2);
  padding-block: 6px 4px;
  padding-inline: 6px;
}
[dir="rtl"] .sb-section-label { text-transform: none; letter-spacing: 0; font-size: 11px; }

.convo {
  display: flex; align-items: center; gap: 8px;
  padding-block: 7px;
  padding-inline-start: 10px;
  padding-inline-end: 8px;
  border-radius: 8px;
  cursor: pointer;
  position: relative;
  text-align: start;
  background: transparent;
  border: 1px solid transparent;
  color: inherit;
}
.convo:hover { background: var(--hover-bg); }
.convo.is-active,
.convo[aria-current="true"] {
  background: var(--brand-cyan-soft);
  border-color: rgba(6, 182, 212, 0.30);
}
.convo-body { flex: 1; min-width: 0; }
.convo-title {
  font-size: 13px; font-weight: 500;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.convo.is-active .convo-title { font-weight: 600; }
.convo-meta {
  font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-block-start: 1px;
}
.convo-badge {
  font-size: 10px; font-weight: 700;
  min-width: 18px; height: 18px;
  padding-inline: 5px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px;
  background: var(--warning); color: #1A1300;
}
.convo-menu {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: transparent;
  border: 0;
  color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.convo:hover .convo-menu,
.convo:focus-within .convo-menu { opacity: 1; }
.convo-menu:hover { background: var(--ghost-bg-hover); color: var(--text); }

/* Empty state in list */
.sb-empty {
  padding: 18px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}
.sb-empty strong { color: var(--text); display: block; margin-block-end: 4px; font-weight: 600; }

/* Sidebar foot — vault opener */
.sb-foot {
  margin-block-start: auto;
  display: flex; flex-direction: column; gap: 6px;
  padding-block-start: 8px;
  border-block-start: 1px solid var(--hairline);
}
.sb-foot-btn {
  display: flex; align-items: center; gap: 10px;
  padding-block: 9px; padding-inline: 10px;
  border-radius: 8px;
  font-size: 12.5px; font-weight: 500;
  color: var(--text);
  background: var(--ghost-bg);
  border: 1px solid var(--hairline);
  cursor: pointer;
  text-align: start;
}
.sb-foot-btn:hover { background: var(--ghost-bg-hover); }
.sb-foot-ic {
  width: 24px; height: 24px;
  border-radius: 7px;
  background: var(--brand-cyan-soft);
  color: var(--brand-cyan);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sb-foot-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-foot-count {
  margin-inline-start: auto;
  font-size: 10.5px; font-weight: 600;
  background: var(--brand-cyan); color: #fff;
  padding-block: 1px; padding-inline: 7px;
  border-radius: 999px;
}
.sb-foot-count[hidden],
.sb-foot-count:empty { display: none; }

/* ============================================================
   STAGE (center)
   ============================================================ */
.stage {
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  gap: 10px;
}

/* Chat header — title + two pickers + responsive triggers */
.ch-header {
  display: flex; align-items: center; gap: 12px;
  padding-block: 10px; padding-inline: 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(14px);
  border-radius: 14px;
  flex-shrink: 0;
  /* Lift the whole header (and its dropdowns) above the message area, which
     otherwise paints over the env panel because backdrop-filter on this
     header creates its own stacking context. */
  position: relative;
  z-index: 40;
}
.ch-trigger {
  display: none;
  align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--hairline);
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
}
.ch-trigger:hover { background: var(--ghost-bg-hover); }
.ch-trigger-badge {
  position: absolute;
  top: -4px; inset-inline-end: -4px;
  min-width: 16px; height: 16px;
  padding-inline: 4px;
  background: var(--warning); color: #1A1300;
  font-size: 10px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px;
  border: 2px solid var(--bg);
}
.ch-trigger-badge:empty,
.ch-trigger-badge[hidden] { display: none; }

.ch-titlewrap { flex: 1; min-width: 0; max-width: 100%; }
.ch-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14.5px; font-weight: 700;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin: 0;
  justify-content: flex-start;
  text-align: start;
  max-width: 100%;
}
.ch-title-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  display: inline-block;
  min-width: 0;
  text-align: start;
}
.ch-title-edit {
  width: 22px; height: 22px;
  border-radius: 6px;
  color: var(--muted-2);
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 0;
  cursor: pointer;
  opacity: 0.55;
}
.ch-streaming-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding-block: 2px; padding-inline: 8px;
  margin-inline-start: 4px;
  font-size: 11px; font-weight: 600;
  color: var(--brand-cyan);
  background: var(--brand-cyan-soft);
  border-radius: 999px;
  flex-shrink: 0;
}
.ch-streaming-pill[hidden] { display: none; }
.ch-streaming-dot {
  width: 6px; height: 6px;
  border-radius: 999px;
  background: var(--brand-cyan);
  animation: ch-streaming-pulse 1.2s ease-in-out infinite;
}
@keyframes ch-streaming-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}
.ch-title-edit:hover { background: var(--ghost-bg-hover); color: var(--text); opacity: 1; }
.ch-title-edit[hidden] { display: none; }

.ch-pickers { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }

.project-list {
  display: flex; flex-direction: column; gap: 8px;
  margin-block-start: 12px;
}
.project-list-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 10px;
}
.project-list-open {
  flex: 1;
  display: flex; flex-direction: column; gap: 2px;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: start;
  min-width: 0;
  padding: 0;
}
.project-list-name {
  font-size: 13.5px; font-weight: 600;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.project-list-meta {
  font-size: 11.5px; color: var(--muted);
}
.project-list-open:hover .project-list-name { color: var(--brand-cyan); }
.ch-picker {
  display: inline-flex; align-items: center; gap: 8px;
  padding-block: 6px;
  padding-inline-start: 12px;
  padding-inline-end: 10px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
.ch-picker:hover { border-color: var(--brand-cyan); background: var(--ghost-bg-hover); }
.ch-picker-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.10em;
  color: var(--muted-2);
  padding-inline-end: 4px;
  border-inline-end: 1px solid var(--hairline);
}
[dir="rtl"] .ch-picker-label { text-transform: none; letter-spacing: 0; font-size: 11px; }
.ch-picker-value {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.ch-picker svg { color: var(--muted); }
.ch-picker-dot {
  width: 7px; height: 7px; border-radius: 999px;
  flex-shrink: 0;
}
.ch-picker[data-env-state="live"] .ch-picker-dot,
.ch-picker--live .ch-picker-dot {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.18);
  animation: ch-picker-pulse 2.4s ease-in-out infinite;
}
.ch-picker[data-env-state="staging"] .ch-picker-dot,
.ch-picker--staging .ch-picker-dot { background: var(--brand-purple); }
.ch-picker[data-env-state="dev"] .ch-picker-dot,
.ch-picker--dev .ch-picker-dot { background: var(--brand-cyan); }
.ch-picker[data-env-state="auto"] .ch-picker-dot,
.ch-picker--auto .ch-picker-dot { background: var(--success); }
@keyframes ch-picker-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(16,185,129,0.18); }
  50%      { box-shadow: 0 0 0 5px rgba(16,185,129,0.04); }
}
/* Hidden native selects under each picker (a11y + form submission) */
.ch-picker select {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 14px;
}

/* Multi-select environment picker — checkbox dropdown panel */
.ch-picker--multi { cursor: pointer; }
.env-multi-panel {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-end: 0;
  z-index: 60;
  min-width: 240px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(14px);
}
.env-multi-panel.hidden { display: none; }
.env-multi-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px; cursor: pointer;
  font-size: 13px; color: var(--text);
}
.env-multi-item:hover { background: var(--ghost-bg-hover); }
.env-multi-item input { accent-color: var(--brand-cyan); width: 15px; height: 15px; flex-shrink: 0; cursor: pointer; }
.env-multi-item span { white-space: nowrap; }
.env-multi-live { margin-inline-start: auto; font-size: 10px; font-weight: 700; color: var(--warning); text-transform: uppercase; letter-spacing: 0.06em; }
.env-multi-empty { padding: 12px; font-size: 12.5px; color: var(--muted); }

/* "Detect databases" control inside the credential form's db field */
.db-detect-btn { margin-top: 8px; align-self: flex-start; }
.db-detect-box { margin-top: 8px; }
.db-detect-box .field-help { display: block; }
.db-detect-select { width: 100%; margin-top: 4px; padding: 8px 10px; border-radius: 8px; }

/* Inline red alert under a field (e.g. invalid URL on blur) */
.field-error { display: block; margin-top: 6px; color: #dc2626; font-size: 0.82rem; }

/* Chat log — full-bleed, no card */
.ch-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-block: 20px;
  padding-inline: 14px;
  display: flex; flex-direction: column; gap: 18px;
  position: relative;
}
/* "Load earlier messages" pill — sits at the top of the windowed stack. */
.load-earlier-btn {
  display: block;
  align-self: center;            /* if .msg-stack is ever flex */
  width: fit-content;
  margin-block: 4px 10px;
  margin-inline: auto;           /* centers in the default block .msg-stack */
  padding: 6px 16px;
  font: inherit;
  font-size: 12.5px;
  color: var(--brand-cyan);
  background: var(--surface-2);
  border: 1px solid rgba(6, 182, 212, 0.30);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.load-earlier-btn:hover {
  background: var(--brand-cyan-soft);
  border-color: rgba(6, 182, 212, 0.55);
}
/* Loading state: the button turns into a spinner + label for the duration of
   the fetch, so it never vanishes abruptly on scroll-to-top. */
.load-earlier-btn.is-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: default;
}
.load-earlier-btn.is-loading:hover {
  background: var(--surface-2);
  border-color: rgba(6, 182, 212, 0.30);
}
.load-earlier-spinner {
  flex: none;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(6, 182, 212, 0.28);
  border-top-color: var(--brand-cyan);
  border-radius: 50%;
  animation: load-earlier-spin 0.7s linear infinite;
}
@keyframes load-earlier-spin {
  to { transform: rotate(360deg); }
}
/* Welcome / empty state: a centred card instead of a full-width banner. */
.ch-log > .empty-state {
  margin: auto;
  max-width: 520px;
  width: 100%;
  padding: 30px 28px;
  border-style: solid;
  border-color: var(--card-border);
  background: var(--card-bg);
  border-radius: 16px;
}

/* Empty state inside log */
.ch-empty {
  margin: auto;
  text-align: center;
  max-width: 460px;
  padding: 28px 18px;
  color: var(--muted);
}
.ch-empty-icon {
  display: inline-flex;
  width: 56px; height: 56px;
  border-radius: 16px;
  background: var(--brand-cyan-soft);
  color: var(--brand-cyan);
  align-items: center; justify-content: center;
  margin-block-end: 14px;
}
.ch-empty h3 {
  font-size: 18px; font-weight: 700; color: var(--text);
  margin: 0 0 6px;
}
.ch-empty p { font-size: 13px; line-height: 1.55; }

/* ============================================================
   MESSAGES
   ============================================================ */
.msg {
  display: flex;
  max-width: 100%;
  min-width: 0;
  flex-direction: column;
}
.msg--user, .msg.user { align-items: flex-end; }
.msg--agent, .msg.assistant, .msg.agent { align-items: flex-start; }

.msg-card {
  background: var(--brand-cyan-soft);
  border: 1px solid rgba(6, 182, 212, 0.30);
  max-width: 640px;
  padding-block: 11px;
  padding-inline: 16px;
  border-radius: 14px;
}
.msg--user .msg-card,
.msg.user .msg-card {
  border-start-end-radius: 4px;
}
.msg-meta {
  font-size: 11px; font-weight: 500;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}
.msg-meta--user,
.msg-meta-user {
  margin-block-start: 5px;
  padding-inline-end: 6px;
  text-align: end;
}
.msg-body {
  font-size: 13.5px; color: var(--text);
  line-height: 1.55;
  min-width: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.msg-body p { margin: 0; }
.msg-body p + p { margin-block-start: 6px; }
.msg-body strong { font-weight: 600; }
.msg-body pre, .msg-body code {
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12.5px;
}
.msg-body pre {
  background: var(--surface-3);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  margin-block: 8px;
}
.msg-body code {
  padding-inline: 6px; padding-block: 1px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--brand-cyan);
  /* A technical name or a number inside an Arabic sentence is laid out by the
     bidi algorithm with the text around it, which reorders "Customer Code 1"
     into nonsense. Isolating it keeps the token exactly as written. */
  direction: ltr;
  unicode-bidi: isolate;
}
.msg-body pre code { background: transparent; padding: 0; color: inherit; }
.msg-body a {
  color: var(--brand-cyan);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-word;
}
.msg-body a:hover { opacity: 0.82; }
.md-table-wrap {
  overflow-x: auto;
  margin-block: 10px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
}
.md-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12.5px;
}
.md-table th,
.md-table td {
  padding: 7px 10px;
  text-align: start;
  border-block-end: 1px solid var(--hairline);
  border-inline-end: 1px solid var(--hairline);
  vertical-align: top;
  white-space: nowrap;
}
.md-table th:last-child,
.md-table td:last-child { border-inline-end: none; }
.md-table tbody tr:last-child td { border-block-end: none; }
.md-table thead th {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--text);
}
.md-table tbody tr:nth-child(even) td { background: var(--surface-2); }

/* Agent message — no bubble, no border */
.msg-agent {
  max-width: 760px;
  width: 100%;
}
.msg-meta--agent,
.msg-meta-agent {
  display: inline-flex; align-items: baseline; gap: 6px;
  font-size: 12px; color: var(--muted);
  margin-block-end: 6px;
}
.msg-agent-name {
  font-weight: 700;
  font-size: 13px;
  background-image: var(--brand-gradient);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.msg-sep { color: var(--muted-2); }
/* Per-message token chip — small, muted, lives in .msg-meta next to the date.
   Tooltip (native title) shows the input/cached/output breakdown. */
.msg-tokens {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  color: var(--muted-2);
  cursor: help;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.msg-tokens svg { opacity: 0.7; }
.msg-tokens:hover { color: var(--text); }
.msg-tokens:hover svg { opacity: 1; }
/* Daily/weekly/monthly cap banner, rendered above the composer.
   Driven by conversation.quota.kind from the API. RTL flips automatically. */
.limit-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 16px 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.12), rgba(239, 68, 68, 0.10));
  border: 1px solid rgba(245, 158, 11, 0.42);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.4;
}
.limit-banner.hidden { display: none; }
.limit-banner-text {
  flex: 1;
  min-width: 0;
}
.limit-banner-cta {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 8px;
  background: linear-gradient(135deg, #06B6D4, #8B5CF6);
  color: #fff !important;
  text-decoration: none !important;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  transition: filter 0.15s ease, transform 0.15s ease;
}
.limit-banner-cta:hover { filter: brightness(1.08); transform: translateY(-1px); }
/* Disabled composer while the cap is hit. */
.composer.is-locked { opacity: 0.55; pointer-events: none; user-select: none; }
.composer.is-locked .composer-input { cursor: not-allowed; }
.msg-agent-body {
  display: flex; flex-direction: column; gap: 10px;
  min-width: 0; max-width: 100%;
  overflow-wrap: break-word;
  font-size: 13.5px; color: var(--text); line-height: 1.6;
}

/* Thinking fold (collapsible reasoning, no bg, no border) */
.think-fold {
  display: block;
}
/* Fold inherits direction from the document (<html dir=...>), so it sits
   on the website's natural assistant side: LTR site → left, RTL site →
   right. `width: fit-content` shrinks the box so the inherited
   `margin-inline: 0 auto` from .msg-thinking actually has room to push. */
.think-fold.msg-thinking { width: fit-content; max-width: 100%; }
.think-fold-head {
  list-style: none;
  display: flex; align-items: center; gap: 6px;
  font-size: 13px;
  color: var(--brand-cyan);
  cursor: pointer;
  user-select: none;
  font-weight: 600;
}
.think-fold-head::-webkit-details-marker { display: none; }
.think-fold-pulse {
  width: 8px; height: 8px; border-radius: 999px;
  background: var(--brand-cyan);
  box-shadow: 0 0 0 3px var(--brand-cyan-soft);
  flex-shrink: 0;
}
.think-fold-label { color: var(--brand-cyan); }
.think-fold-time { color: var(--muted); font-size: 12px; font-weight: 500; }
.think-fold-head svg {
  color: var(--brand-cyan);
  transition: transform 0.15s;
  margin-inline-start: 4px;
}
.think-fold[open] .think-fold-head svg { transform: rotate(180deg); }
.think-fold-body {
  display: none;
  padding-block: 8px 0;
  padding-inline-start: 14px;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
}
.think-fold[open] .think-fold-body { display: flex; }
.think-fold-line {
  position: relative;
  font-style: normal;
}
.think-fold-line::before {
  content: '•';
  position: absolute;
  inset-inline-start: -14px;
  color: var(--muted-2);
}

/* Server activity row */
.server-act {
  margin-block-start: 6px;
  border-radius: 10px;
  background: var(--surface-3);
  border: 1px dashed rgba(139, 92, 246, 0.40);
  overflow: hidden;
}
.server-act-head {
  display: flex; align-items: center; gap: 8px;
  padding-block: 7px; padding-inline: 12px;
  font-size: 11.5px;
  color: var(--muted);
  background: transparent;
  border: 0;
  width: 100%;
  text-align: start;
  cursor: pointer;
}
.server-act-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--brand-purple); flex-shrink: 0; }
.server-act-dot--ok { background: var(--success); }
.server-act-title { color: var(--text); font-weight: 600; }
.server-act-time { margin-inline-start: auto; }
.server-act-body {
  display: none;
  padding: 10px 12px;
  border-block-start: 1px solid var(--hairline);
  font-family: 'SF Mono', ui-monospace, monospace;
  font-size: 12px;
  color: var(--muted);
  white-space: pre-wrap;
}
.server-act[open] .server-act-body,
.server-act.is-open .server-act-body { display: block; }

/* Building report (progress bar) */
.building-card {
  margin-block-start: 4px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.building-head { display: flex; align-items: center; gap: 10px; }
.building-ic {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--brand-cyan-soft);
  color: var(--brand-cyan);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.building-label {
  font-size: 13px; font-weight: 600; color: var(--text);
  flex: 1; min-width: 0;
}
.building-file {
  font-family: 'SF Mono', ui-monospace, monospace;
  font-size: 12px;
  color: var(--brand-cyan);
}
.building-pct {
  font-size: 12.5px; font-weight: 700;
  color: var(--brand-cyan);
  font-variant-numeric: tabular-nums;
  font-family: 'SF Mono', ui-monospace, monospace;
}
.progress {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.progress-bar {
  position: absolute; top: 0; bottom: 0;
  inset-inline-start: 0;
  background: var(--brand-gradient);
  border-radius: 999px;
  transition: width 0.3s ease;
  background-size: 200% 100%;
  animation: progress-shine 2.2s linear infinite;
}
@keyframes progress-shine {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.building-meta {
  display: flex; flex-wrap: wrap; gap: 14px;
  font-size: 11.5px; color: var(--muted-2);
}
.building-step {
  display: inline-flex; align-items: center; gap: 5px;
}
.building-step--done { color: var(--success); }
.building-step--active { color: var(--brand-cyan); font-weight: 600; }

/* Ready artifact one-liner (replaces progress on complete) */
.ready-art {
  display: flex; align-items: center; gap: 12px;
  padding-block: 10px; padding-inline: 14px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  margin-block-start: 4px;
}
.ready-art-ic {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: var(--success-soft);
  color: var(--success);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ready-art-body { flex: 1; min-width: 0; }
.ready-art-name {
  font-size: 13.5px; font-weight: 700;
  color: var(--text);
  font-family: 'SF Mono', ui-monospace, monospace;
}
.ready-art-meta { font-size: 11.5px; color: var(--muted); margin-block-start: 1px; }

/* Working message — pulse + label */
.msg--working .msg-agent-body,
.msg-working .msg-agent-body {
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(6,182,212,0.08), rgba(139,92,246,0.04));
  border: 1px solid var(--brand-cyan-soft);
  padding: 10px 14px;
}
.working { display: inline-flex; align-items: center; gap: 10px; }
.working-pulse {
  width: 11px; height: 11px; border-radius: 999px;
  background: var(--brand-cyan);
  box-shadow: 0 0 0 0 var(--brand-cyan-soft);
  animation: working-pulse 1.6s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes working-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(6,182,212,0.4); }
  50%      { box-shadow: 0 0 0 6px rgba(6,182,212,0); }
}
.working-label { font-weight: 600; font-size: 13.5px; color: var(--text); }
.working-sub { color: var(--muted); font-size: 12px; }

/* ============================================================
   COMPOSER
   ============================================================ */
.composer {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(14px);
  border-radius: 16px;
  padding: 4px;
  flex-shrink: 0;
  position: relative;
}
/* Pending-approval strip pinned just above the composer. Reuses the rail's
   .approval-row cards; caps its own height and scrolls so a big delete card
   (with its record list) never pushes the composer off-screen. */
.inline-approvals {
  flex-shrink: 0;
  margin-block-end: 8px;
  max-height: 42vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--warning, #b45309);
  border-radius: 14px;
  background: var(--warning-soft, rgba(180, 83, 9, 0.08));
}
.inline-approvals[hidden] { display: none; }
.inline-approvals-title {
  margin: 0;
  font-weight: 700;
  font-size: 13px;
  color: var(--warning, #b45309);
}
.composer-input {
  padding: 6px 12px;
}
.composer-input textarea {
  width: 100%;
  /* Resting height = one line. This is also the floor autoGrowComposer() can
     shrink back to: it sets height:auto and reads scrollHeight, which never
     reports below min-height — so min-height and height must move together. */
  min-height: 25px;
  /* JS auto-grow sets the height up to this cap; past it the textarea scrolls
     internally instead of pushing the message list further up. Fullscreen mode
     (below) overrides the cap when the user wants to see everything at once. */
  max-height: 340px;
  height: 25px;
  resize: none;
  /* Hidden at rest: at one line the placeholder is taller than the box, and
     `auto` would show a scrollbar on an empty composer. autoGrowComposer()
     switches this back to `auto` once the content passes the cap. */
  overflow-y: hidden;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
  font-family: inherit;
  unicode-bidi: plaintext;
  text-align: start;
}

/* Expand/collapse control: show the "open" glyph normally, swap to the
   "close" glyph while the composer is expanded. */
.composer-expand-icon.composer-expand-close { display: none; }
.composer.is-composer-expanded .composer-expand-icon.composer-expand-open { display: none; }
.composer.is-composer-expanded .composer-expand-icon.composer-expand-close { display: inline; }

/* Fullscreen / large compose mode: the textarea takes most of the viewport so
   the user can read everything they've written at once. The toolbar stays
   pinned below (the composer is a flex column), and the message list shrinks. */
.composer.is-composer-expanded .composer-input textarea {
  height: 62vh !important;
  max-height: 62vh;
}

/* ---- Interactive report-builder card (show_report_builder) ---- */
.rb-card {
  margin-top: 6px;
  padding: 16px;
  border-radius: 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text);
}
.rb-helper {
  margin: 4px 0 10px;
  max-width: min(760px, 100%);
  line-height: 1.8;
}
.rb-intro {
  margin: 0 0 14px;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.7;
  color: var(--text);
}
.rb-group { margin-bottom: 14px; }
.rb-label {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.rb-req { color: var(--brand-cyan); }
.rb-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.rb-chip {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: var(--ghost-bg);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.rb-chip:hover { background: var(--hover-bg); }
.rb-chip.is-active {
  background: var(--brand-cyan);
  border-color: var(--brand-cyan);
  color: #fff;
}
.rb-chip:disabled { opacity: .55; cursor: default; }
.rb-dates {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 9px;
}
.rb-dates label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}
.rb-dates input {
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid var(--card-border);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
}
.rb-submit {
  width: 100%;
  margin-top: 4px;
  padding: 11px;
  border-radius: 10px;
  border: 0;
  background: var(--brand-gradient, var(--brand-cyan));
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.rb-submit:hover:not(:disabled) { filter: brightness(1.05); }
.rb-submit:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Report builder: entity (customers/vendors/employees) filter ---- */
.rb-entity-search {
  width: 100%;
  margin-bottom: 8px;
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid var(--card-border);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
}
.rb-entity-selected { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.rb-entity-selected:empty { display: none; }
.rb-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--brand-cyan);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.rb-tag b { font-weight: 800; opacity: .85; }
.rb-entity-list {
  max-height: 168px;
  overflow-y: auto;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: var(--ghost-bg);
}
.rb-entity-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  border-bottom: 1px solid var(--card-border);
}
.rb-entity-item:last-child { border-bottom: 0; }
.rb-entity-item:hover { background: var(--hover-bg); }
.rb-entity-hint { padding: 12px; text-align: center; color: var(--muted); font-size: 12px; }
.composer-input textarea::placeholder { color: var(--muted-2); }

.composer-tray {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding-block: 4px 8px;
  padding-inline: 16px;
}
.composer-tray:empty,
.composer-tray.hidden { display: none; }

.composer-bar {
  display: flex; align-items: center; gap: 8px;
  padding-block: 8px; padding-inline: 10px;
  border-block-start: 1px solid var(--hairline);
}
.composer-attach {
  width: 34px; height: 34px;
  border-radius: 9px;
  color: var(--muted);
  background: var(--ghost-bg);
  border: 1px solid var(--hairline);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}
.composer-attach:hover {
  color: var(--brand-cyan);
  background: var(--brand-cyan-soft);
  border-color: rgba(6,182,212,0.30);
}
.composer-divider {
  display: inline-block;
  width: 1px; height: 20px;
  background: var(--hairline);
  margin-inline: 2px;
  flex-shrink: 0;
}
.composer-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text);
  padding-block: 4px; padding-inline: 6px;
  cursor: pointer;
  user-select: none;
  margin: 0;
}
.composer-toggle input { display: none; }
.composer-toggle-label { font-weight: 500; }
.composer-toggle-icon {
  display: inline-flex;
  width: 18px; height: 18px;
  align-items: center; justify-content: center;
  color: var(--muted);
  border-radius: 6px;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.deep-think-toggle input:checked ~ .composer-toggle-label,
.deep-think-toggle input:checked + .composer-toggle-icon {
  color: var(--brand-cyan);
}
.deep-think-toggle input:checked + .composer-toggle-icon {
  background: var(--brand-cyan-soft);
}
.composer-toggle-track {
  width: 32px; height: 18px; border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.composer-toggle input:checked + .composer-toggle-track,
.composer-toggle.is-on .composer-toggle-track {
  background: var(--brand-gradient);
  border-color: transparent;
  box-shadow: 0 0 0 1px rgba(6,182,212,0.20);
}
.composer-toggle-thumb {
  position: absolute; top: 1px;
  inset-inline-start: 1px;
  width: 14px; height: 14px;
  border-radius: 999px;
  background: var(--muted);
  transition: inset-inline-start 0.2s, background 0.2s;
}
.composer-toggle input:checked + .composer-toggle-track .composer-toggle-thumb,
.composer-toggle.is-on .composer-toggle-track .composer-toggle-thumb {
  inset-inline-start: 15px;
  background: #fff;
}
.composer-spacer { flex: 1; }

.composer-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(31, 60, 136, 0.30);
  flex-shrink: 0;
  margin-inline-start: auto;
  border: 0;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s, background 0.15s;
}
.composer-send:hover { filter: brightness(1.08); transform: translateY(-1px); }
.composer-send[data-state="busy"],
.composer-send[data-state="running"] {
  background: var(--danger);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.35);
}
.composer-send[data-state="busy"]:hover,
.composer-send[data-state="running"]:hover {
  filter: brightness(1.05);
  background: var(--danger);
}
.composer-send-icon { display: none; }
.composer-send[data-state="idle"] .composer-send-icon-send,
.composer-send:not([data-state]) .composer-send-icon-send { display: inline-flex; }
.composer-send[data-state="busy"] .composer-send-icon-stop,
.composer-send[data-state="running"] .composer-send-icon-stop { display: inline-flex; }

/* -------------------- Voice (mic) record button + recording UI -------------------- */
.composer-voice {
  width: 38px; height: 38px;
  border-radius: 50%;
  color: var(--muted);
  background: var(--ghost-bg);
  border: 1px solid var(--hairline);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s, transform 0.1s;
}
.composer-voice:hover {
  color: var(--brand-cyan);
  background: var(--brand-cyan-soft);
  border-color: rgba(6,182,212,0.30);
}
.composer-voice[disabled] { opacity: 0.5; cursor: not-allowed; }
.composer-voice .voice-icon { display: none; }
.composer-voice[data-state="idle"] .voice-icon-mic { display: inline-flex; }
.composer-voice[data-state="recording"] {
  color: #fff;
  background: var(--danger, #ef4444);
  border-color: transparent;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.18);
  animation: voice-btn-pulse 1.2s ease-in-out infinite;
}
.composer-voice[data-state="recording"] .voice-icon-stop { display: inline-flex; }
.composer-voice[data-state="transcribing"] {
  color: var(--brand-cyan);
  background: var(--brand-cyan-soft);
  border-color: rgba(6,182,212,0.30);
  cursor: progress;
}
.composer-voice[data-state="transcribing"] .voice-icon-mic { display: inline-flex; opacity: 0.5; }
@keyframes voice-btn-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.18); }
  50%      { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0.08); }
}

.composer-input { position: relative; }
.composer-input.is-recording textarea { visibility: hidden; }
.voice-recording-ui {
  position: absolute;
  /* Sits exactly where the textarea sits, so these track .composer-input's
     padding (6px 12px) — they are not independent values. */
  inset-block-start: 6px;
  inset-inline-start: 12px;
  inset-inline-end: 12px;
  /* Stands in for the textarea while recording, so it tracks the textarea's
     resting height — at 48px it would spill past the composer and cover the
     button row below. */
  min-height: 25px;
  display: flex; align-items: center; gap: 12px;
  pointer-events: none;
}
.voice-recording-ui.hidden { display: none; }
.voice-rec-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--danger, #ef4444);
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
  animation: voice-dot-pulse 1s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes voice-dot-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(239, 68, 68, 0.55); }
  70%  { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);   }
  100% { box-shadow: 0 0 0 0   rgba(239, 68, 68, 0);   }
}
.voice-waveform {
  display: inline-flex; align-items: center; gap: 3px;
  height: 22px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.voice-waveform > span {
  display: inline-block;
  width: 3px;
  background: linear-gradient(180deg, var(--brand-cyan, #06b6d4), var(--brand-blue, #3b82f6));
  border-radius: 2px;
  height: 8px;
  animation: voice-wave 0.9s ease-in-out infinite alternate;
}
.voice-waveform > span:nth-child(1) { animation-delay: 0.00s; }
.voice-waveform > span:nth-child(2) { animation-delay: 0.10s; }
.voice-waveform > span:nth-child(3) { animation-delay: 0.20s; }
.voice-waveform > span:nth-child(4) { animation-delay: 0.05s; }
.voice-waveform > span:nth-child(5) { animation-delay: 0.30s; }
.voice-waveform > span:nth-child(6) { animation-delay: 0.15s; }
.voice-waveform > span:nth-child(7) { animation-delay: 0.25s; }
.voice-waveform > span:nth-child(8) { animation-delay: 0.05s; }
.voice-waveform > span:nth-child(9) { animation-delay: 0.20s; }
@keyframes voice-wave {
  0%   { height: 6px;  opacity: 0.55; }
  100% { height: 20px; opacity: 1;    }
}
.voice-timer {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  flex-shrink: 0;
  min-width: 36px;
  text-align: end;
}
.voice-recording-ui.is-transcribing .voice-rec-dot,
.voice-recording-ui.is-transcribing .voice-waveform,
.voice-recording-ui.is-transcribing .voice-timer { display: none; }
.voice-status {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px;
  color: var(--brand-cyan);
  font-weight: 600;
}
.voice-status.hidden { display: none; }
.voice-status::before {
  content: "";
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--brand-cyan);
  border-block-start-color: transparent;
  animation: voice-spin 0.8s linear infinite;
}
@keyframes voice-spin { to { transform: rotate(360deg); } }

/* Drag overlay on composer (legacy fallback) */
.composer-drop-zone.is-drag-target {
  outline: 2px dashed var(--brand-cyan);
  outline-offset: -6px;
  border-radius: 12px;
}

/* Attachment chips (rendered by app.js into #attachmentTray, which we wrap in
   .composer-tray) */
.attachment-tray:not(.hidden) { display: flex; flex-wrap: wrap; gap: 6px; }
.attachment-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding-block: 4px; padding-inline-start: 10px; padding-inline-end: 6px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  font-size: 11.5px; color: var(--text);
  max-width: 220px;
}
.attachment-chip-name {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-weight: 500;
}
.attachment-chip-size,
.attachment-chip-kind { color: var(--muted); font-size: 11px; }
.attachment-chip-thumb {
  width: 24px; height: 24px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-1);
}
.attachment-chip-thumb img {
  width: 100%; height: 100%; object-fit: cover;
}
.attachment-chip.uploading .attachment-chip-thumb {
  animation: chip-pulse 1.4s ease-in-out infinite;
}
@keyframes chip-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
.attachment-chip-remove {
  width: 18px; height: 18px;
  border-radius: 999px;
  background: transparent;
  border: 0;
  color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.attachment-chip-remove:hover { background: var(--ghost-bg-hover); color: var(--danger); }

/* ============================================================
   RIGHT RAIL
   ============================================================ */
.rail {
  display: flex; flex-direction: column; gap: 12px;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
}
.rail-top {
  display: flex; align-items: center; gap: 6px;
  padding-block: 8px; padding-inline: 12px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  backdrop-filter: blur(14px);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 5;
}
.rail-iconbtn {
  width: 30px; height: 30px;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.rail-iconbtn:hover { background: var(--hover-bg); color: var(--text); }
.rail-lang-toggle {
  display: inline-flex; align-items: center;
  height: 28px;
  padding: 2px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  gap: 2px;
}
.rail-top .rail-lang-toggle .lang-flag,
html .rail-lang-toggle .lang-flag {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  color: var(--muted);
  border-radius: 999px;
  padding-inline: 8px;
  height: 22px;
  min-width: 22px;
  transition: color 0.15s, background 0.15s;
  background: transparent;
}
html[lang="ar"] .rail-lang-toggle .lang-flag-ar,
[dir="rtl"] .rail-lang-toggle .lang-flag-ar {
  color: #fff;
  background: var(--brand-gradient);
}
html:not([lang="ar"]) .rail-lang-toggle .lang-flag-en {
  color: #fff;
  background: var(--brand-gradient);
}

.rail-user {
  margin-inline-start: auto;
}
.rail-user-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  padding-block: 4px;
  padding-inline-end: 10px;
  padding-inline-start: 4px;
  border-radius: 999px;
  background: var(--ghost-bg);
  border: 1px solid var(--hairline);
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
}
.rail-user-trigger:hover { background: var(--ghost-bg-hover); }
.rail-user-avatar {
  width: 24px; height: 24px; border-radius: 999px;
  background: var(--brand-gradient-vivid); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 11px;
  box-shadow: 0 4px 10px rgba(139, 92, 246, 0.25);
}
.rail-user-name {
  max-width: 110px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Rail cards */
.rcard {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(14px);
  border-radius: 16px;
  padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
}
.rcard[data-hidden="1"] { display: none; }

.rcard-head { display: flex; align-items: center; gap: 8px; }
.rcard-head h3, .rcard-head h2 {
  font-size: 13px; font-weight: 700; color: var(--text);
  margin: 0;
}
.rcard-icon {
  width: 26px; height: 26px;
  border-radius: 8px;
  background: var(--brand-cyan-soft);
  color: var(--brand-cyan);
  display: inline-flex; align-items: center; justify-content: center;
}
.rcard-icon--warn { background: var(--warning-soft); color: var(--warning); }
.rcard-icon--purple { background: var(--brand-purple-soft); color: var(--brand-purple); }
.rcard-count {
  margin-inline-start: auto;
  font-size: 11px; font-weight: 700;
  padding-block: 2px; padding-inline: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}
.rcard-count--warn { background: var(--warning); color: #1A1300; }
.rcard-count:empty { display: none; }

/* Approvals (highest priority — warning-tinted) */
.rcard--approvals {
  border-color: var(--warning-border);
  background: linear-gradient(180deg, var(--warning-soft), var(--card-bg) 70%);
}
.approval {
  border-radius: 12px;
  background: var(--surface-1);
  border: 1px solid var(--warning-border);
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.approval-row-top { display: flex; align-items: center; gap: 8px; }
.approval-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  padding-block: 3px; padding-inline: 8px;
  border-radius: 6px;
  background: var(--danger-soft);
  color: var(--danger);
}
[dir="rtl"] .approval-pill { text-transform: none; letter-spacing: 0; }
.approval-pill--mini { background: var(--surface-2); color: var(--muted); }
.approval-meta { font-size: 11px; color: var(--muted); margin-inline-start: auto; }
.approval-body { font-size: 12.5px; color: var(--text); line-height: 1.5; }
.approval-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.approval--collapsed {
  display: flex; align-items: center; gap: 8px;
  padding-block: 8px; padding-inline: 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
}
.approval-title {
  font-size: 12.5px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Activity card with tabs */
.rcard--activity .rcard-head {
  border-block-end: 1px solid var(--hairline);
  padding-block-end: 10px;
}
.rcard-tabs {
  display: inline-flex; gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1px solid var(--hairline);
  width: 100%;
}
.rcard-tab {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding-block: 6px; padding-inline: 10px;
  font-size: 12px; font-weight: 600;
  color: var(--muted);
  border-radius: 7px;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.rcard-tab.is-active {
  background: var(--surface-1);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.rcard-tab-count {
  font-size: 10px;
  padding-block: 0; padding-inline: 6px;
  border-radius: 999px;
  background: var(--brand-cyan-soft);
  color: var(--brand-cyan);
}
.rcard-tab.is-active .rcard-tab-count { background: var(--brand-cyan); color: #fff; }
.rcard-tab-count:empty { display: none; }
.rcard-panel { display: none; }
.rcard-panel.is-active { display: flex; flex-direction: column; gap: 4px; }

/* Activity list */
.activity { display: flex; flex-direction: column; gap: 4px; }
.activity-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  background: transparent;
  border: 0;
  text-align: start;
  width: 100%;
  color: inherit;
}
.activity-item:hover { background: var(--hover-bg); }
.activity-ic {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.activity-ic--ok { background: var(--success-soft); color: var(--success); }
.activity-ic--cyan { background: var(--brand-cyan-soft); color: var(--brand-cyan); }
.activity-ic--purple { background: var(--brand-purple-soft); color: var(--brand-purple); }
.activity-ic--warn { background: var(--warning-soft); color: var(--warning); }
.activity-body { flex: 1; min-width: 0; }
.activity-title {
  font-size: 12.5px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.activity-meta { font-size: 11px; color: var(--muted); margin-block-start: 1px; }
.activity-empty {
  padding: 18px 8px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.rcard-foot {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px;
  border-radius: 8px;
  font-size: 12px; font-weight: 600;
  color: var(--brand-cyan);
  background: transparent;
  border-block-start: 1px solid var(--hairline);
  margin-block-start: 2px;
  border-inline: 0; border-block-end: 0;
  cursor: pointer;
}
.rcard-foot:hover { background: var(--brand-cyan-soft); }
[dir="rtl"] .rcard-foot svg { transform: scaleX(-1); }

/* ============================================================
   BUTTONS (chat-page palette — coexist with admin .btn-* in app.css)
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding-block: 6px; padding-inline: 12px;
  border-radius: 8px;
  font-size: 12px; font-weight: 600;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.15s, background 0.15s, color 0.15s, border-color 0.15s;
}
.btn--sm { padding-block: 7px; padding-inline: 12px; font-size: 12px; }
.btn--xs { padding-block: 4px; padding-inline: 10px; font-size: 11px; border-radius: 6px; }
.btn:hover { filter: brightness(1.05); }
.btn--primary {
  background: var(--brand-gradient);
  color: #fff;
  box-shadow: 0 1px 3px rgba(31, 60, 136, 0.18);
}
.btn--primary:hover { filter: brightness(1.08); }
.btn--danger-outline {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger-border);
}
.btn--danger-outline:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}
.btn--info {
  background: var(--brand-cyan-soft);
  color: var(--brand-cyan);
  border-color: rgba(6,182,212,0.30);
}
.btn--info:hover { background: rgba(6,182,212,0.25); }
.btn--ghost { background: var(--ghost-bg); color: var(--muted); border-color: var(--hairline); }
.btn--ghost:hover { color: var(--text); background: var(--ghost-bg-hover); }

/* ============================================================
   DRAWER (sidebar / rail collapse pattern, ≤1024)
   ============================================================ */
.drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.55);
  backdrop-filter: blur(4px);
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease-out;
}
html[data-theme="light"] .drawer-scrim,
html.light .drawer-scrim { background: rgba(15, 23, 42, 0.35); }
.drawer-scrim.is-open {
  opacity: 1;
  pointer-events: auto;
}

.drawer-sheet {
  position: fixed;
  top: 0; bottom: 0;
  width: min(360px, 86vw);
  background: var(--surface-1);
  border-inline-end: 1px solid var(--card-border);
  z-index: 81;
  display: flex; flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.22s ease-out;
  box-shadow: 24px 0 80px rgba(2, 6, 23, 0.55);
  overflow: hidden;
}
.drawer-sheet--start { inset-inline-start: 0; }
.drawer-sheet--end {
  inset-inline-end: 0;
  inset-inline-start: auto;
  transform: translateX(100%);
  border-inline-end: 0;
  border-inline-start: 1px solid var(--card-border);
  box-shadow: -24px 0 80px rgba(2, 6, 23, 0.55);
}
[dir="rtl"] .drawer-sheet--start { transform: translateX(100%); }
[dir="rtl"] .drawer-sheet--end { transform: translateX(-100%); }

.drawer-sheet::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  inset-inline-start: 0;
  width: 3px;
  background: var(--brand-gradient);
}
.drawer-sheet--end::before {
  inset-inline-start: auto;
  inset-inline-end: 0;
}
.drawer-sheet.is-open { transform: translateX(0); }
[dir="rtl"] .drawer-sheet.is-open { transform: translateX(0); }

.drawer-head {
  display: flex; align-items: center; gap: 10px;
  padding-block: 14px; padding-inline: 16px;
  border-block-end: 1px solid var(--hairline);
  background: var(--card-bg);
  flex-shrink: 0;
}
.drawer-title { font-size: 14px; font-weight: 700; margin: 0; flex: 1; }
.drawer-close {
  width: 32px; height: 32px;
  border-radius: 9px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.drawer-close:hover { color: var(--text); background: var(--ghost-bg-hover); }
.drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
}

/* ============================================================
   STACKED TOASTS (replaces single .toast)
   ============================================================ */
.toast-stack {
  position: fixed;
  inset-block-end: 18px;
  inset-inline-end: 18px;
  display: flex; flex-direction: column-reverse;
  gap: 8px;
  z-index: 9999;
  max-width: min(360px, 86vw);
  pointer-events: none;
}
.toast-stack .toast {
  position: static;
  pointer-events: auto;
  background: var(--surface-1);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 18px 50px rgba(2, 6, 23, 0.45);
  display: flex; align-items: center; gap: 10px;
  animation: toast-in 0.2s ease-out;
  border-inline-start: 3px solid var(--brand-cyan);
}
.toast-stack .toast--success { border-inline-start-color: var(--success); }
.toast-stack .toast--error,
.toast-stack .toast--danger { border-inline-start-color: var(--danger); }
.toast-stack .toast--warning { border-inline-start-color: var(--warning); }
.toast-stack .toast-message { flex: 1; min-width: 0; }
.toast-stack .toast-undo {
  font-size: 12px; font-weight: 600; color: var(--brand-cyan);
  background: transparent; border: 0; cursor: pointer; padding-inline: 4px;
}
.toast-stack .toast-undo:hover { text-decoration: underline; }
.toast-stack .toast-close {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: transparent;
  border: 0;
  color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.toast-stack .toast-close:hover { background: var(--ghost-bg-hover); color: var(--text); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   DRAG-AND-DROP WINDOW OVERLAY (full-window cyan target)
   ============================================================ */
.dnd-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 182, 212, 0.10);
  backdrop-filter: blur(3px);
  z-index: 150;
  display: none;
  align-items: center; justify-content: center;
  pointer-events: none;
}
html[data-theme="light"] .dnd-overlay,
html.light .dnd-overlay { background: rgba(6, 182, 212, 0.06); }
.dnd-overlay.is-active { display: flex; }
.dnd-target {
  width: min(640px, 90vw);
  padding: 48px 40px;
  background: var(--card-bg);
  border: 2px dashed var(--brand-cyan);
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(6, 182, 212, 0.20);
  backdrop-filter: blur(14px);
}
.dnd-ic {
  display: inline-flex;
  width: 80px; height: 80px;
  border-radius: 50%;
  align-items: center; justify-content: center;
  background: var(--brand-cyan-soft);
  color: var(--brand-cyan);
  margin-block-end: 18px;
  animation: dnd-float 2.4s ease-in-out infinite;
}
@keyframes dnd-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
.dnd-title {
  font-size: 22px; font-weight: 700;
  color: var(--text);
  margin-block-end: 6px;
  letter-spacing: -0.01em;
}
.dnd-sub { font-size: 13px; color: var(--muted); margin-block-end: 14px; }
.dnd-formats { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.dnd-fmt {
  display: inline-flex;
  font-size: 11px; font-weight: 600;
  color: var(--muted);
  padding-block: 4px; padding-inline: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  font-family: 'SF Mono', ui-monospace, monospace;
}

/* ============================================================
   CREDENTIAL VAULT — per-env tabbed modal (v2)
   ============================================================ */
.modal-shell.vault-v2 {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(2, 6, 23, 0.55);
  backdrop-filter: blur(4px);
}
.modal-shell.vault-v2:not(.hidden) { display: flex; }
html[data-theme="light"] .modal-shell.vault-v2,
html.light .modal-shell.vault-v2 { background: rgba(15, 23, 42, 0.30); }

.vault-v2 .vault-card {
  position: relative;
  width: min(760px, 94vw);
  max-height: 90vh;
  background: var(--surface-1);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  box-shadow: 0 22px 60px rgba(2, 6, 23, 0.55);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.vault-v2 .vault-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--brand-gradient);
  z-index: 1;
}
.vault-v2 .vault-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 18px;
  padding-block: 22px 18px;
  padding-inline: 26px;
  border-block-end: 1px solid var(--hairline);
}
.vault-v2 .vault-titlewrap {
  text-align: start;
  flex: 1;
  min-width: 0;
}
.vault-v2 .vault-breadcrumb {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.10em;
  color: var(--muted);
  margin-block-end: 4px;
}
[dir="rtl"] .vault-v2 .vault-breadcrumb { text-transform: none; letter-spacing: 0; font-size: 11.5px; }
.vault-v2 .vault-breadcrumb strong { color: var(--brand-cyan); font-weight: 700; }
.vault-v2 .vault-bc-sep { color: var(--muted-2); }
.vault-v2 .vault-title { font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; margin: 0; }
.vault-v2 .vault-close {
  width: 32px; height: 32px;
  border-radius: 9px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.vault-v2 .vault-close:hover { color: var(--text); background: var(--ghost-bg-hover); }

.vault-v2 .vault-kind-tabs {
  display: flex; gap: 0;
  padding-block: 14px 0;
  padding-inline: 26px;
  border-block-end: 1px solid var(--hairline);
  overflow-x: auto;
}
.vault-v2 .vault-kind-tab {
  position: relative;
  display: inline-flex; align-items: center; gap: 7px;
  padding-block: 10px 14px;
  padding-inline: 16px;
  font-size: 13px; font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-block-end: 2px solid transparent;
  margin-block-end: -1px;
  cursor: pointer;
  white-space: nowrap;
}
.vault-v2 .vault-kind-tab:hover { color: var(--text); }
.vault-v2 .vault-kind-tab.is-active {
  color: var(--text);
  border-block-end-color: var(--brand-cyan);
}
.vault-kind-tab-state {
  width: 16px; height: 16px;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.vault-kind-tab-state.is-set {
  background: var(--brand-cyan);
  color: #fff;
}
.vault-kind-tab-state.is-empty {
  background: transparent;
  border: 1.5px dashed var(--hairline-strong);
}

.vault-v2 .vault-form {
  padding-block: 22px;
  padding-inline: 26px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.vault-v2 .vault-form > p.muted-line {
  text-align: center;
  padding: 32px 8px;
  color: var(--muted);
}
.vault-v2 .vault-field {
  display: flex; flex-direction: column; gap: 7px;
}
.vault-v2 .vault-field--full { grid-column: 1 / -1; }
.vault-v2 .vault-field-label {
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.10em;
  color: var(--muted);
}
[dir="rtl"] .vault-v2 .vault-field-label { text-transform: none; letter-spacing: 0; font-size: 11.5px; }
.vault-v2 .vault-field-input,
.vault-v2 .vault-field select,
.vault-v2 .vault-field input {
  width: 100%;
  padding-block: 11px; padding-inline: 14px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  color: var(--text);
  font-size: 13.5px;
  font-family: 'SF Mono', ui-monospace, monospace;
  outline: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.vault-v2 .vault-field select {
  font-family: inherit;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.vault-v2 .vault-field-input:focus,
.vault-v2 .vault-field-input:hover,
.vault-v2 .vault-field select:focus,
.vault-v2 .vault-field input:focus {
  border-color: var(--brand-cyan);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}
.vault-v2 .vault-field-help {
  font-size: 11px;
  color: var(--muted);
  margin-block-start: 4px;
}

.vault-v2 .vault-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px;
  padding-block: 16px;
  padding-inline: 26px;
  border-block-start: 1px solid var(--hairline);
  background: var(--surface-2);
  flex-shrink: 0;
}
.vault-v2 .vault-foot-meta {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11.5px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.vault-v2 .vault-foot-dot {
  width: 7px; height: 7px; border-radius: 999px;
  background: var(--success);
}
.vault-v2 .vault-foot-actions { display: inline-flex; gap: 8px; }
.vault-v2 .vault-empty {
  grid-column: 1 / -1;
  padding: 32px 8px;
  text-align: center;
  color: var(--muted);
}

/* Bridge: app.js renders tabs as .env-tab-button and form as
   .env-credential-form. Give them the vault-v2 look. */
.vault-kind-tabs .env-tab-button {
  position: relative;
  display: inline-flex; align-items: center; gap: 7px;
  padding-block: 10px 14px;
  padding-inline: 16px;
  font-size: 13px; font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-block-end: 2px solid transparent;
  margin-block-end: -1px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}
.vault-kind-tabs .env-tab-button:hover { color: var(--text); }
.vault-kind-tabs .env-tab-button.active,
.vault-kind-tabs .env-tab-button.is-active {
  color: var(--text);
  border-block-end-color: var(--brand-cyan);
}

.env-tab-panels.vault-form { /* contains the form once rendered */ }
.env-credential-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 18px;
  width: 100%;
}
.env-credential-form > .field:first-child {
  grid-column: 1 / -1;
}
.odoo-connect-guide {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid rgba(34, 211, 238, 0.26);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.12), rgba(37, 99, 235, 0.08));
  color: var(--text);
}
.odoo-connect-guide strong {
  display: block;
  font-size: 14px;
  line-height: 1.35;
}
.odoo-connect-guide p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}
.odoo-connect-guide ol {
  margin: 0;
  padding-inline-start: 20px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.75;
}
.odoo-connect-guide li + li { margin-block-start: 2px; }
.env-credential-form > .field-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 18px;
}
.env-credential-form > .modal-actions {
  grid-column: 1 / -1;
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 0 0;
  margin-block-start: 6px;
  border-block-start: 1px solid var(--hairline);
  background: transparent;
  border-block-end: 0;
}
.env-credential-form > .muted-line {
  grid-column: 1 / -1;
  font-size: 11.5px;
  color: var(--muted);
  display: inline-flex; align-items: center; gap: 7px;
}
.env-credential-form > .muted-line::before {
  content: '';
  width: 7px; height: 7px; border-radius: 999px;
  background: var(--success);
}
.env-credential-form .field input,
.env-credential-form .field select,
.env-credential-form .field textarea {
  font-family: 'SF Mono', ui-monospace, monospace;
  padding-block: 11px; padding-inline: 14px;
  border-radius: 12px;
}
.env-credential-form .field select { font-family: inherit; }

/* Persona switch (I'm a user / I'm a developer) above the kind tabs. */
.vault-v2 .vault-persona-tabs {
  display: inline-flex;
  gap: 4px;
  align-self: flex-start;
  margin: 16px 26px 0;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 999px;
}
.vault-v2 .vault-persona-tab {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  padding: 7px 16px;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.vault-v2 .vault-persona-tab:hover { color: var(--text); }
.vault-v2 .vault-persona-tab.is-active {
  background: var(--surface-1);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(2, 6, 23, 0.18);
}

/* Per-field (i) info button + click-to-open explanation bubble. */
.field-label-row {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.field-info {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--hairline-strong);
  background: transparent;
  color: var(--muted);
  font-family: Georgia, 'Times New Roman', serif;
  font-style: italic;
  font-weight: 700;
  font-size: 10px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.field-info:hover,
.field-info:focus-visible {
  color: var(--brand-cyan);
  border-color: var(--brand-cyan);
  outline: 0;
}
.field-info-bubble {
  position: absolute;
  z-index: 60;
  inset-inline-start: 0;
  inset-block-start: calc(100% + 6px);
  width: max-content;
  max-width: 260px;
  padding: 9px 11px;
  background: var(--surface-1);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.4);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  white-space: normal;
  text-transform: none;
  letter-spacing: 0;
}

@media (max-width: 600px) {
  .env-credential-form,
  .env-credential-form > .field-grid,
  .vault-v2 .vault-form {
    grid-template-columns: 1fr;
  }
  .vault-v2 .vault-card { border-radius: 14px; }
  .vault-v2 .vault-head,
  .vault-v2 .vault-kind-tabs,
  .vault-v2 .vault-form,
  .vault-v2 .vault-foot {
    padding-inline: 16px;
  }
  .vault-v2 .vault-persona-tabs { margin-inline: 16px; }
}

/* ============================================================
   BRIDGES — keep existing JS-rendered class names rendering well.
   ============================================================ */
/* The legacy app shell mapped to new shell so the chat page still works
   if someone forgets to update the template. Real markup uses .shell. */
.app-shell { display: contents; }
.chat-stage, .chat-shell { display: contents; }
.chat-header { display: contents; }
.chat-header-main, .chat-header-aside, .chat-body { display: contents; }

/* Old conversation list scroll wrapper */
.conversation-list { display: flex; flex-direction: column; gap: 4px; }
.conversation-group { display: flex; flex-direction: column; gap: 2px; margin-block-start: 6px; }
.conversation-group-label {
  font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.10em;
  color: var(--muted-2);
  padding-block: 6px 4px;
  padding-inline: 6px;
}
[dir="rtl"] .conversation-group-label { text-transform: none; letter-spacing: 0; font-size: 11px; }

.conversation-row {
  display: flex; align-items: stretch;
  border-radius: 8px;
  cursor: pointer;
  position: relative;
  background: transparent;
  border: 1px solid transparent;
  padding: 0;
}
.conversation-row:hover { background: var(--hover-bg); }
.conversation-card {
  display: flex; gap: 8px;
  flex: 1;
  padding-block: 7px;
  padding-inline-start: 10px;
  padding-inline-end: 8px;
  background: transparent;
  border: 0;
  text-align: start;
  cursor: pointer;
  color: inherit;
  min-width: 0;
}
.conversation-card.active,
.conversation-card[aria-current="true"],
.conversation-row.active {
  background: var(--brand-cyan-soft);
  border-radius: 8px;
}
.conversation-row.active { border-color: rgba(6, 182, 212, 0.30); }
.conversation-card.active .conversation-title,
.conversation-card[aria-current="true"] .conversation-title { font-weight: 600; }
.conversation-title {
  font-size: 13px; font-weight: 500;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-align: start;
}
.conversation-meta {
  font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-block-start: 1px;
}
.conversation-rename-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  border-radius: 6px;
  padding-block: 4px; padding-inline: 8px;
  color: var(--text);
  font-size: 12.5px;
  outline: 0;
}
.row-menu-button {
  width: 24px; height: 24px;
  border-radius: 6px;
  background: transparent;
  border: 0;
  color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
  align-self: center;
}
.conversation-row:hover .row-menu-button,
.conversation-row:focus-within .row-menu-button,
.row-menu-button[aria-expanded="true"] { opacity: 1; }
.row-menu-button:hover,
.row-menu-button[aria-expanded="true"] { background: var(--ghost-bg-hover); color: var(--text); }
.row-menu {
  position: fixed;
  z-index: 95;
  background: var(--surface-1);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.45);
  min-width: 180px;
  padding: 6px;
  display: flex; flex-direction: column;
}
.row-menu button {
  display: flex; align-items: center; gap: 8px;
  padding-block: 7px; padding-inline: 10px;
  border-radius: 6px;
  background: transparent;
  border: 0;
  text-align: start;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
}
.row-menu button:hover { background: var(--hover-bg); }
.row-menu button.danger,
.row-menu button[data-action="delete"] { color: var(--danger); }

.archived-toggle {
  display: flex; align-items: center; gap: 6px;
  padding-block: 7px; padding-inline: 10px;
  border-radius: 8px;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
[dir="rtl"] .archived-toggle { text-transform: none; letter-spacing: 0; }
.archived-toggle:hover { background: var(--hover-bg); color: var(--text); }
.archived-count {
  margin-inline-start: auto;
  font-size: 10px;
  background: var(--surface-2);
  color: var(--muted);
  padding-block: 1px; padding-inline: 6px;
  border-radius: 999px;
  text-transform: none;
  letter-spacing: 0;
}

/* Approvals legacy → new look */
.approval-row {
  border-radius: 12px;
  background: var(--surface-1);
  border: 1px solid var(--warning-border);
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.approval-row + .approval-row { margin-block-start: 8px; }
.approval-row-label {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  padding-block: 3px; padding-inline: 8px;
  border-radius: 6px;
  background: var(--danger-soft);
  color: var(--danger);
  align-self: flex-start;
}
[dir="rtl"] .approval-row-label { text-transform: none; letter-spacing: 0; }
.approval-row-meta { font-size: 11px; color: var(--muted); margin-inline-start: auto; }
.approval-row-body { font-size: 12.5px; color: var(--text); line-height: 1.5; }
.approval-row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.approval-row-actions button {
  display: inline-flex; align-items: center; gap: 6px;
  padding-block: 6px; padding-inline: 12px;
  border-radius: 8px;
  font-size: 12px; font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--ghost-bg);
  color: var(--text);
  font-family: inherit;
}
.approval-row-actions .approval-approve,
.approval-row-actions .approval-batch { background: var(--brand-gradient); color: #fff; border-color: transparent; }
.approval-row-actions .approval-reject {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger-border);
}
.approval-row-actions .approval-reject:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}
/* Permanent-deletion card: every record named, each confirmed by typing it. */
.approval-row--danger { border-color: var(--danger); background: var(--danger-soft); }
.approval-row-label--danger { background: var(--danger); color: #fff; }
.approval-confirm-hint { font-size: 11.5px; color: var(--danger); font-weight: 600; line-height: 1.45; }
/* Read-only list of what is about to be deleted. Long lists scroll inside the
   card so a 47-record delete can't push the confirm control off-screen. */
.approval-confirm-listlabel {
  margin: 10px 0 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.approval-confirm-list {
  display: block;
  margin: 0 0 10px;
  padding: 8px 10px;
  max-height: 168px;
  overflow-y: auto;
  list-style: none;
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.07);
  border: 1px solid var(--border);
}
.approval-confirm-item {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text);
  overflow-wrap: anywhere;
}
.approval-confirm-row { display: flex; flex-direction: column; gap: 4px; }
.approval-confirm-name {
  font-size: 12px; font-weight: 600; color: var(--text);
  word-break: break-word;
}
.approval-confirm-input {
  padding-block: 6px; padding-inline: 10px;
  border-radius: 8px;
  border: 1px solid var(--danger-border);
  background: var(--surface-1);
  color: var(--text);
  font-size: 12.5px;
  font-family: inherit;
  width: 100%;
}
.approval-confirm-input { width: 100%; box-sizing: border-box; margin-bottom: 10px; font-family: var(--font-mono, monospace); }
.approval-confirm-input:focus { outline: none; border-color: var(--danger); }
.approval-confirm-input[data-state="ok"] { border-color: var(--success, #16a34a); }
.approval-confirm-input[data-state="bad"] { border-color: var(--danger); }
.approval-row-actions .approval-approve--danger { background: var(--danger); color: #fff; }
.approval-row-actions .approval-approve--danger:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.4);
}
.approval-row-actions .approval-show-individual {
  background: var(--brand-cyan-soft);
  color: var(--brand-cyan);
  border-color: rgba(6,182,212,0.30);
}
.approval-individual-row {
  margin-block-start: 8px;
  padding: 10px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
}
.approval-individual-prompt {
  font-size: 12px;
  color: var(--text);
  margin-block-end: 8px;
}

/* Actions / Artifacts legacy → activity-style */
.action-row, .artifact-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: 10px;
  background: transparent;
  border: 0;
  text-align: start;
  cursor: pointer;
  color: inherit;
}
.action-row:hover, .artifact-row:hover { background: var(--hover-bg); }
.action-row-icon, .artifact-row-glyph {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--brand-cyan-soft);
  color: var(--brand-cyan);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.artifact-row-glyph { background: var(--brand-purple-soft); color: var(--brand-purple); }
.action-row-text, .artifact-row-text { flex: 1; min-width: 0; }
.action-row-title, .artifact-row-title {
  font-size: 12.5px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.action-row-title .artifact-name, .artifact-row-title .artifact-name {
  font-family: 'SF Mono', ui-monospace, monospace;
  font-size: 12px;
  color: var(--text);
}
.action-row-sub, .artifact-row-meta {
  font-size: 11px; color: var(--muted);
  margin-block-start: 1px;
}
.action-row-btn {
  width: 24px; height: 24px;
  border-radius: 6px;
  background: transparent;
  border: 0;
  color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.action-row-btn:hover { background: var(--ghost-bg-hover); color: var(--text); }

/* Rail-card empty-states */
.rail-card[data-empty="1"] .rail-body { padding: 12px 4px; text-align: center; color: var(--muted); font-size: 12px; }
.rail-card .rail-body:empty::after {
  content: '';
  display: block;
}

/* Rail header bridge */
.rail-card .rail-head {
  display: flex; align-items: center; gap: 8px;
  padding-block-end: 8px;
  border-block-end: 1px solid var(--hairline);
  margin-block-end: 4px;
}
.rail-card .rail-head h2 {
  font-size: 13px; font-weight: 700;
  margin: 0;
}
.rail-card .rail-head-icon {
  width: 26px; height: 26px;
  border-radius: 8px;
  background: var(--brand-cyan-soft);
  color: var(--brand-cyan);
  display: inline-flex; align-items: center; justify-content: center;
}
.rail-card-approvals[data-empty="0"] .rail-head-icon { background: var(--warning-soft); color: var(--warning); }
.rail-card-actions[data-empty="0"] .rail-head-icon { background: var(--brand-cyan-soft); color: var(--brand-cyan); }
.rail-card-artifacts[data-empty="0"] .rail-head-icon { background: var(--brand-purple-soft); color: var(--brand-purple); }
.rail-card .rail-count {
  margin-inline-start: auto;
  font-size: 11px; font-weight: 700;
  padding-block: 2px; padding-inline: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}
.rail-card[data-empty="1"] .rail-count { display: none; }

/* Promote chat-header from JS-emitted env-badges/header-pill back to picker look */
.env-badges:not(:empty) {
  display: inline-flex;
  gap: 4px;
}
.env-badges .env-badge {
  font-size: 9.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  padding-block: 2px; padding-inline: 7px;
  border-radius: 999px;
  background: var(--warning-soft);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}
[dir="rtl"] .env-badges .env-badge { text-transform: none; letter-spacing: 0; }
.env-badges .env-badge.env-badge-staging { background: var(--brand-purple-soft); color: var(--brand-purple); border-color: rgba(139, 92, 246, 0.35); }
.env-badges .env-badge.env-badge-dev { background: var(--brand-cyan-soft); color: var(--brand-cyan); border-color: rgba(6, 182, 212, 0.35); }
.env-badges .env-badge.env-badge-auto-approve,
.env-badges .env-badge.env-badge-autoapprove,
.env-badges .env-badge.env-badge-live { background: var(--success-soft); color: var(--success); border-color: rgba(16, 185, 129, 0.30); }
.header-divider { display: none; }

/* Hidden helper */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
[hidden] { display: none !important; }

/* ============================================================
   USER MENU dropdown (bridges existing .user-menu chrome to the
   new rail-top look)
   ============================================================ */
.rail-top .user-menu { margin: 0; position: relative; }
.rail-top .user-menu summary { padding: 0; }
.rail-top .user-menu-trigger {
  min-height: 32px !important;
  padding: 2px !important;
  padding-inline-start: 2px !important;
  padding-inline-end: 10px !important;
  gap: 8px !important;
}
.rail-top .user-menu-avatar { width: 26px !important; height: 26px !important; font-size: 11px !important; }
.rail-top .user-menu-name { font-size: 12.5px !important; max-width: 90px !important; }
.rail-top .user-menu-panel {
  position: absolute;
  z-index: 9999;
  min-width: 220px;
  max-width: min(280px, calc(100vw - 16px));
  top: calc(100% + 8px);
  inset-inline-end: 0;
  inset-inline-start: auto;
}
.rail-top .user-menu-trigger {
  padding-block: 4px;
  padding-inline-end: 10px;
  padding-inline-start: 4px;
  border-radius: 999px;
  background: var(--ghost-bg);
  border: 1px solid var(--hairline);
}
.rail-top .user-menu-trigger:hover,
.rail-top .user-menu[open] .user-menu-trigger { background: var(--ghost-bg-hover); }

/* Settings gear (mobile fallback for theme/lang/user) */
.settings-menu { position: relative; }
.settings-menu > summary { list-style: none; cursor: pointer; }
.settings-menu > summary::-webkit-details-marker { display: none; }
.settings-menu .settings-toggle:hover { background: var(--hover-bg); color: var(--text); }
.settings-menu[open] .settings-toggle { background: var(--ghost-bg-hover); color: var(--text); }
.settings-panel {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  z-index: 9999;
  min-width: 200px;
  max-width: min(280px, calc(100vw - 16px));
  padding: 6px;
  background: var(--surface-1, var(--card-bg));
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(2, 6, 23, 0.30);
  display: flex; flex-direction: column;
}
.settings-item {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-align: start;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
.settings-item:hover { background: var(--hover-bg); }
.settings-item-danger { color: var(--danger); }
.settings-divider { height: 1px; background: var(--hairline); margin: 4px 0; }
.settings-form { margin: 0; }

/* ============================================================
   MODAL — small confirm dialog (used by openConfirmDialog)
   Keep visual consistency for legacy modal-shell/modal-card.
   ============================================================ */
.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center; justify-content: center;
  background: rgba(2, 6, 23, 0.55);
  backdrop-filter: blur(4px);
  padding: 16px;
}
.modal-shell.hidden { display: none; }
html[data-theme="light"] .modal-shell,
html.light .modal-shell { background: rgba(15, 23, 42, 0.30); }
.modal-card {
  background: var(--surface-1);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  box-shadow: 0 22px 60px rgba(2, 6, 23, 0.55);
  width: min(520px, 100%);
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px;
  padding-block: 18px 12px;
  padding-inline: 22px;
  border-block-end: 1px solid var(--hairline);
}
.modal-head h3 { font-size: 16px; font-weight: 700; margin: 0; color: var(--text); }
.modal-head .eyebrow {
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.10em;
  color: var(--brand-cyan);
  margin-block-end: 4px;
}
.modal-close-button {
  width: 32px; height: 32px;
  border-radius: 9px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 12px;
}
.modal-close-button:hover { background: var(--ghost-bg-hover); color: var(--text); }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  padding-block: 12px 16px;
  padding-inline: 22px;
  border-block-start: 1px solid var(--hairline);
  background: var(--surface-2);
}
.muted-line { color: var(--muted); font-size: 13px; line-height: 1.55; margin: 0; }
.eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--brand-cyan);
  margin: 0 0 4px;
}
[dir="rtl"] .eyebrow { text-transform: none; letter-spacing: 0; }

/* Confirm dialog body */
.confirm-body {
  padding: 18px 22px;
  font-size: 13px; color: var(--text);
  line-height: 1.55;
}

/* Buttons re-used in modals (admin templates also use these) */
.primary-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding-block: 9px; padding-inline: 16px;
  border-radius: 10px;
  background: var(--brand-gradient);
  color: #fff;
  font-weight: 600; font-size: 13px;
  border: 0;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(31, 60, 136, 0.25);
}
.primary-button:hover { filter: brightness(1.08); }
.primary-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}
.ghost-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding-block: 9px; padding-inline: 16px;
  border-radius: 10px;
  background: var(--ghost-bg);
  border: 1px solid var(--hairline);
  color: var(--text);
  font-weight: 500; font-size: 13px;
  cursor: pointer;
}
.ghost-button:hover { background: var(--ghost-bg-hover); }
.danger-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding-block: 9px; padding-inline: 16px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid var(--danger-border);
  color: var(--danger);
  font-weight: 600; font-size: 13px;
  cursor: pointer;
}
.danger-button:hover { background: var(--danger-soft); border-color: var(--danger); }

.wide-button { width: 100%; }
.field {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12.5px;
  color: var(--text);
}
.field > span {
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.10em;
  color: var(--muted);
}
[dir="rtl"] .field > span { text-transform: none; letter-spacing: 0; font-size: 11.5px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding-block: 10px; padding-inline: 12px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand-cyan);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.toggle-field {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text);
}

/* ============================================================
   RESPONSIVE (container-query keyed off .saqqar-frame width)
   ============================================================ */
.ch-trigger { /* hidden by default; only shown by container queries */ }

@container (max-width: 1280px) {
  .shell {
    grid-template-columns: 264px minmax(0, 1fr) 296px;
    gap: 12px;
    padding: 12px;
  }
  .sidebar, .rcard, .composer, .ch-header, .rail-top { border-radius: 14px; }
  .ch-title { font-size: 14px; }
}

@container (max-width: 1024px) {
  .shell {
    grid-template-columns: 1fr;
    padding: 12px;
    gap: 12px;
  }
  .sidebar { display: none; }
  .ch-trigger--menu { display: inline-flex; }
  /* Keep the rail in DOM flow but only surface its top cluster (theme /
     lang / user menu) as a floating top-right group. The cards drop into
     the drawer triggered by the inbox bell. */
  .rail {
    display: block;
    position: fixed;
    top: 72px;
    inset-inline-end: 14px;
    z-index: 80;
    background: transparent;
    overflow: visible;
    width: auto;
    height: auto;
    padding: 0;
    border: 0;
    pointer-events: none;
    gap: 0;
  }
  .rail > * { pointer-events: auto; }
  .rail > #approvalsCard,
  .rail > #activityCard { display: none; }
  /* Rail-top hidden by default at this breakpoint; the ch-header gear
     (#railTopTrigger) toggles it as a floating top-end pill. */
  .rail-top { display: none; }
  body.is-rail-top-open .rail-top {
    display: flex;
    box-shadow: 0 8px 24px rgba(15,23,42,0.18);
    z-index: 90;
  }
  .ch-trigger--inbox,
  .ch-trigger--settings { display: inline-flex; }
  .ch-header { gap: 8px; }
  .ch-pickers { gap: 6px; }
  .ch-picker { padding-inline: 10px 8px; }
  .ch-picker-label { font-size: 10px; padding-inline-end: 6px; }
}

@container (max-width: 768px) {
  .shell {
    padding: 10px;
    gap: 10px;
  }
  .ch-header {
    padding: 8px 10px;
    gap: 8px;
    border-radius: 12px;
  }
  .ch-title { font-size: 14px; }
  .ch-pickers { display: none; }
  .composer { border-radius: 12px; }
  .composer-input { padding-block: 10px 4px; padding-inline: 14px; }
  .composer-bar { padding-inline: 8px; gap: 6px; flex-wrap: wrap; }
  .composer-toggle { padding-inline: 4px; }
  .composer-attach { width: 40px; height: 40px; }
  .composer-voice { width: 40px; height: 40px; }
  .composer-send { width: 40px; height: 40px; margin-inline-start: auto; }
  .rail-iconbtn, .ch-trigger { width: 40px; height: 40px; }
  .ch-log { padding-block: 14px; padding-inline: 6px; gap: 14px; }
  .msg--user .msg-card, .msg.user .msg-card { max-width: 80%; }
  .msg-agent, .msg--agent, .msg.assistant { max-width: 92%; }
}

@container (max-width: 600px) {
  .ch-header { padding-block: 6px; padding-inline: 8px; }
  .ch-title { font-size: 13.5px; }
  .ch-title-edit { display: none; }
  .ch-log { padding-inline: 4px; }
  .composer-toggle-label { display: none; }
  .composer-enter-hint { display: none; }
  .composer-bar { gap: 4px; }
  .msg--user .msg-card, .msg.user .msg-card { max-width: 88%; }
  .msg-agent, .msg--agent, .msg.assistant { max-width: 96%; }
}

@container (max-width: 480px) {
  .shell { padding: 8px; gap: 8px; }
  .ch-header { gap: 6px; }
  .ch-trigger { width: 32px; height: 32px; }
  .ch-trigger-badge { min-width: 14px; height: 14px; font-size: 9px; }
  .ch-title { font-size: 13px; }
  .msg-card { padding-inline: 13px; }
  .composer-input textarea { font-size: 13.5px; }
  .composer-send { width: 34px; height: 34px; }
  .composer-attach { width: 30px; height: 30px; }
  .rail-top { padding-inline: 8px; }
}

/* ============================================================
   TOUCH TARGETS — global viewport media query so pages without a
   .saqqar-frame container (login / register / aid pages) also get
   the >=40px tap area on narrow viewports.
   ============================================================ */
@media (max-width: 768px) {
  .rail-iconbtn,
  .rail-lang-toggle,
  .ch-trigger,
  .row-menu-button,
  .settings-toggle {
    min-width: 40px;
    min-height: 40px;
  }
  .rail-iconbtn { width: 40px; height: 40px; }
  .rail-lang-toggle { height: 40px; }
  .row-menu-button { width: 40px; height: 40px; }
}

/* enter hint */
.composer-enter-hint {
  font-size: 11px;
  color: var(--muted-2);
  margin-inline-end: 6px;
  font-variant-numeric: tabular-nums;
}

/* spacer between bar items */
.composer-actions-spacer { flex: 1; }
.composer-actions-divider {
  display: inline-block;
  width: 1px; height: 20px;
  background: var(--hairline);
  margin-inline: 2px;
  flex-shrink: 0;
}
.composer-icon-btn {
  width: 34px; height: 34px;
  border-radius: 9px;
  color: var(--muted);
  background: var(--ghost-bg);
  border: 1px solid var(--hairline);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}
.composer-icon-btn:hover { color: var(--brand-cyan); background: var(--brand-cyan-soft); border-color: rgba(6,182,212,0.30); }

/* Auto-approve toggle bridge (legacy) */
.auto-approve-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text);
  padding-block: 4px; padding-inline: 6px;
  cursor: pointer;
  user-select: none;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  height: auto !important;
}
.auto-approve-toggle:has(input:checked) {
  background: transparent !important;
  border: 0 !important;
}
.auto-approve-toggle:has(input:checked) .auto-approve-label,
.auto-approve-toggle .auto-approve-label {
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
}
.auto-approve-toggle input { display: none; }
.auto-approve-label { font-weight: 500; }
.auto-approve-track {
  width: 32px; height: 18px; border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.auto-approve-toggle input:checked + .auto-approve-track {
  background: rgb(27, 80, 148);
  border-color: transparent;
  box-shadow: 0 0 0 1px rgba(6,182,212,0.20);
}
.auto-approve-thumb {
  position: absolute; top: 1px;
  inset-inline-start: 1px;
  width: 14px; height: 14px;
  border-radius: 999px;
  background: var(--muted);
  transition: inset-inline-start 0.2s, background 0.2s;
}
.auto-approve-toggle input:checked + .auto-approve-track .auto-approve-thumb {
  inset-inline-start: 15px !important;
  background: #fff;
  transform: none !important;
}
.auto-approve-toggle .auto-approve-thumb {
  transform: none !important;
}
[dir="rtl"] .auto-approve-toggle input:checked + .auto-approve-track .auto-approve-thumb {
  transform: none !important;
  inset-inline-start: 15px !important;
}
@container (max-width: 600px) {
  .auto-approve-label { display: none; }
}

/* Env-not-bound hint bar (shown in chat while no project/environment is bound) */
.env-hint-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 16px 0;
  padding: 5px 10px;
  background: #eef4ff;
  border: 1px solid #c9ddff;
  border-radius: 10px;
  font-size: 13px;
  color: #1f3b6e;
}
.env-hint-bar .env-hint-text { flex: 1; line-height: 1.4; }
.env-hint-bar .env-hint-action {
  flex: none;
  border: 0;
  border-radius: 7px;
  padding: 6px 12px;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.env-hint-bar .env-hint-action:hover { background: #1d4ed8; }
.env-hint-bar .env-hint-dismiss {
  flex: none;
  border: 0;
  background: transparent;
  color: #5b6b8c;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
}
.env-hint-bar .env-hint-dismiss:hover { background: #dce8ff; }
.env-select-attention {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
  border-radius: 6px;
  animation: envSelectPulse 0.9s ease-in-out 2;
}
@keyframes envSelectPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.0); }
  50% { box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.25); }
}

/* My Database quick-connect button (sidebar foot, above the vault) */
.sb-mydb { margin-bottom: 8px; }

/* Near-limit usage warning (amber variant of the hint bar) */
.env-hint-bar.is-warn {
  background: #fff7ed;
  border-color: #fdba74;
  color: #7c2d12;
}
.env-hint-bar.is-warn .env-hint-action {
  background: #ea580c;
  text-decoration: none;
}
.env-hint-bar.is-warn .env-hint-action:hover { background: #c2410c; }
.env-hint-bar.is-warn .env-hint-dismiss:hover { background: #ffedd5; }

/* Approval card mirrored inline under the last message */
.inline-approvals .approval-row { margin-top: 10px; }
.inline-approvals .approval-row:first-of-type { margin-top: 6px; }

/* ===== Norhan tool-UI styles (feature-extracted, additive) ===== */
/* ============================================================================
 * css_additions.css — Norhan tool-UI CSS to APPEND to prod chat-v2.css:
 *   /home/bolshuq/saqqar-integration/integration/odoo_agent/static/odoo_agent/chat-v2.css
 * APPEND-ONLY. Every selector below was verified ABSENT from prod chat-v2.css.
 * Selectors prod already defines are intentionally OMITTED:
 *   - .composer-toggle / .composer-toggle-icon / .composer-toggle-label /
 *     .composer-toggle-track / .composer-attach / .composer-divider
 *   - .deep-think-toggle:checked rules
 *   - .rb-entity-* family (prod chat-v2.css already ships these)
 * Source: nourhan-run/odoo_agent/static/odoo_agent/chat-v2.css
 * ============================================================================ */


/* ---- Radar / tools menu anchor + panel (#shadowMenu carries .radar-menu) ---- */
.radar-menu-anchor {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}
.radar-menu {
  position: absolute;
  z-index: 60;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  width: min(380px, calc(100vw - 24px));
  min-width: min(250px, calc(100vw - 24px));
  max-width: 380px;
  max-height: min(72vh, 640px);
  overflow: auto;
  padding: 10px;
  color: var(--text);
  background: var(--surface-1, var(--card-bg));
  border: 1px solid var(--hairline-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-card, 0 22px 60px rgba(2, 6, 23, 0.38));
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
}
.radar-menu.prompt-bank-menu-card {
  width: min(420px, calc(100vw - 24px));
  max-width: 420px;
}
html[data-theme="light"] .radar-menu,
html.light .radar-menu {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(26, 34, 56, 0.13);
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.14);
}
.radar-menu-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 2px;
  color: var(--brand-cyan);
}
.radar-menu-title {
  font-size: 13px;
  color: var(--text);
}
.radar-menu-subtext {
  margin: 0 0 10px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.6;
}
.radar-menu-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px;
  border-radius: 10px;
  border: 0;
  background: var(--brand-gradient);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.radar-menu-action:hover { filter: brightness(1.05); }
.radar-menu-action--ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--hairline);
  box-shadow: none;
}
.radar-menu-action--ghost:hover {
  color: var(--brand-cyan);
  background: var(--brand-cyan-soft);
  border-color: rgba(6,182,212,0.28);
}
.radar-menu-divider {
  height: 1px;
  margin: 10px 2px;
  background: var(--hairline);
}

/* ---- Tools menu (sections + items + pills) ---- */
.tools-menu-section {
  padding: 4px 0;
}
.tools-menu-section + .tools-menu-section {
  border-block-start: 1px solid var(--hairline);
}
.tools-menu-section-toggle {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 8px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.tools-menu-section-toggle:hover,
.tools-menu-section.is-open .tools-menu-section-toggle {
  background: var(--surface-2);
  border-color: var(--hairline);
}
.tools-menu-section-icon,
.tools-menu-section-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-cyan);
}
.tools-menu-section-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--brand-cyan-soft);
}
.tools-menu-section-title {
  color: var(--text);
  font-size: 12.8px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.3;
}
.tools-menu-section-caret {
  transition: transform 0.16s ease;
}
.tools-menu-section.is-open .tools-menu-section-caret {
  transform: rotate(180deg);
}
.tools-menu-stack {
  display: grid;
  gap: 6px;
  padding: 7px 0 2px;
}
.tools-menu-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 9px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: start;
  cursor: pointer;
  margin-inline-start: 8px;
  width: calc(100% - 8px);
}
.tools-menu-item:hover {
  background: var(--surface-2);
  border-color: var(--hairline);
}
.tools-menu-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  color: var(--brand-cyan);
  background: var(--brand-cyan-soft);
  flex-shrink: 0;
}
.tools-menu-item-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.tools-menu-item-title {
  color: var(--text);
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1.3;
}
.tools-menu-item-sub {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}
.tools-menu-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 4px 7px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  font-size: 10.5px;
  font-weight: 800;
  white-space: nowrap;
}
.tools-menu-pill.is-on {
  color: #fff;
  background: var(--brand-gradient);
  border-color: transparent;
}

/* ---- Prompt-bank (rendered inside .radar-menu by app.js) ---- */
.prompt-bank-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 10px;
}
.prompt-bank-cat {
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 9px;
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}
.prompt-bank-cat.is-active {
  color: #fff;
  border-color: transparent;
  background: var(--brand-gradient);
}
.prompt-bank-query {
  display: grid;
  gap: 7px;
  margin: 8px 0 10px;
}
.prompt-bank-query label,
.prompt-bank-section-title {
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}
.prompt-bank-query textarea {
  width: 100%;
  min-height: 74px;
  resize: vertical;
  border: 1px solid var(--hairline-strong);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  padding: 9px 10px;
  font: inherit;
  font-size: 12.5px;
  line-height: 1.55;
  outline: 0;
}
.prompt-bank-query textarea:focus {
  border-color: rgba(6, 182, 212, 0.52);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.13);
}
.prompt-bank-section-title {
  margin: 8px 2px 7px;
  color: var(--muted);
}
.prompt-bank-list {
  display: grid;
  gap: 7px;
  max-height: min(360px, calc(100vh - 240px));
  overflow: auto;
  padding-inline-end: 2px;
}
.prompt-bank-item {
  display: grid;
  gap: 4px;
  text-align: start;
  width: 100%;
  padding: 10px;
  border-radius: 11px;
  border: 1px solid var(--hairline);
  background: var(--card-bg);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.prompt-bank-item strong {
  font-size: 13px;
  line-height: 1.35;
}
.prompt-bank-item span {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}
.prompt-bank-item:hover {
  border-color: rgba(6,182,212,0.34);
  background: var(--brand-cyan-soft);
}
.prompt-bank-item--draft {
  border-color: rgba(6,182,212,0.34);
  background: linear-gradient(135deg, rgba(6,182,212,0.12), rgba(65,84,200,0.10));
}
.prompt-bank-empty {
  padding: 14px 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  border: 1px dashed var(--hairline-strong);
  border-radius: 10px;
  background: var(--surface-2);
}
.prompt-bank-limit-hint {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
  padding: 3px 2px 1px;
}
.prompt-bank-back {
  width: 100%;
  margin-top: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.prompt-bank-back:hover { color: var(--brand-cyan); }

/* ---- Prompt-suggestions strip (#promptSuggestions) ---- */
.prompt-suggestions {
  display: block;
  margin: 0 16px 8px;
  padding: 0;
}
.prompt-suggestions.hidden { display: none; }
.prompt-suggestions-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: min(280px, 100%);
  border: 1px solid var(--hairline);
  background: var(--card-bg);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 10px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(2, 6, 23, 0.08);
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.prompt-suggestions-trigger:hover {
  color: var(--brand-cyan);
  background: var(--brand-cyan-soft);
  border-color: rgba(6,182,212,0.30);
  transform: translateY(-1px);
}
.prompt-suggestions-icon {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-cyan);
  background: var(--brand-cyan-soft);
  flex: 0 0 auto;
}
.prompt-suggestions-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prompt-suggestions-count {
  min-width: 20px;
  height: 20px;
  padding-inline: 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--brand-cyan);
  font-size: 11px;
  font-weight: 800;
  flex: 0 0 auto;
}

/* ---- Task wording card (rendered inside #promptSuggestions / chat log) ---- */
.msg-task-prompt {
  max-width: 820px;
}
.task-prompt-dock {
  width: 100%;
}
.task-prompt-card {
  width: min(820px, 100%);
  max-height: min(48vh, 560px);
  overflow: auto;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text);
  box-shadow: 0 14px 36px rgba(2, 6, 23, 0.12);
}
.prompt-suggestions .task-prompt-card {
  width: 100%;
  max-width: 100%;
}
.task-prompt-head {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-bottom: 12px;
}
.task-prompt-close {
  margin-inline-start: auto;
  width: 30px;
  height: 30px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}
.task-prompt-close:hover {
  color: var(--text);
  border-color: rgba(6, 182, 212, 0.32);
  background: var(--brand-cyan-soft);
}
.task-prompt-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-cyan);
  background: var(--brand-cyan-soft);
  flex: 0 0 auto;
}
.task-prompt-head strong {
  display: block;
  font-size: 15px;
  line-height: 1.35;
}
.task-prompt-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
}
.task-prompt-panel {
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  border-radius: 12px;
  padding: 11px;
}
.task-prompt-panel + .task-prompt-panel {
  margin-top: 10px;
}
.task-prompt-label {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.task-prompt-original p {
  margin: 0;
  color: var(--text);
  font-size: 12.8px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}
.task-prompt-original textarea,
.task-prompt-draft textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid rgba(6, 182, 212, 0.28);
  border-radius: 10px;
  background: var(--surface-1, var(--card-bg));
  color: var(--text);
  padding: 10px 11px;
  font: inherit;
  font-size: 13px;
  line-height: 1.75;
  outline: 0;
}
.task-prompt-original textarea {
  min-height: 96px;
}
.task-prompt-draft textarea {
  min-height: 124px;
}
.task-prompt-original textarea:focus,
.task-prompt-draft textarea:focus {
  border-color: rgba(6, 182, 212, 0.58);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.12);
}
.task-prompt-inline-action {
  margin-top: 8px;
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  background: var(--brand-gradient);
  color: #fff;
  font: inherit;
  font-weight: 850;
  cursor: pointer;
}
.task-prompt-inline-action:hover {
  filter: brightness(1.04);
}
.task-prompt-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.task-prompt-loading {
  display: flex; align-items: center; gap: 9px;
  padding: 14px 12px; color: var(--muted, #7a8699); font-size: 13.5px; font-weight: 600;
}
.task-prompt-spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--card-border, #d7deea); border-top-color: var(--brand-accent, #43C2C4);
  animation: task-prompt-spin 0.7s linear infinite; flex: 0 0 auto;
}
@keyframes task-prompt-spin { to { transform: rotate(360deg); } }
.task-prompt-btn:disabled { opacity: .5; cursor: default; }
.task-prompt-btn {
  min-height: 42px;
  border-radius: 10px;
  border: 1px solid var(--hairline);
  font: inherit;
  font-weight: 850;
  cursor: pointer;
}
.task-prompt-btn-primary {
  color: var(--text);
  background: var(--surface-2);
}
.task-prompt-btn-strong {
  color: #fff;
  border-color: transparent;
  background: var(--brand-gradient);
}
.task-prompt-btn:hover,
.task-prompt-match:hover {
  filter: brightness(1.04);
}
.task-prompt-similar {
  margin-top: 13px;
}
.task-prompt-matches {
  display: grid;
  gap: 7px;
}
.task-prompt-match {
  display: grid;
  gap: 4px;
  width: 100%;
  text-align: start;
  border: 1px solid var(--hairline);
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 11px;
  font: inherit;
  cursor: pointer;
}
.task-prompt-match strong {
  font-size: 13px;
  line-height: 1.35;
}
.task-prompt-match span {
  color: var(--muted);
  font-size: 11.8px;
  line-height: 1.5;
}
.task-prompt-hint {
  margin: 7px 2px 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}
.task-prompt-hintbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: var(--card-bg);
  color: var(--text);
  box-shadow: 0 10px 26px rgba(2, 6, 23, 0.10);
}
.task-prompt-hintbar-text {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.5;
}
.task-prompt-hintbar-actions {
  display: inline-flex;
  gap: 7px;
  flex: 0 0 auto;
}
.task-prompt-mini-btn {
  min-height: 32px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  padding: 0 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.task-prompt-mini-btn-primary {
  border-color: transparent;
  background: var(--brand-gradient);
  color: #fff;
}
html[data-theme="light"] .task-prompt-card,
html.light .task-prompt-card,
html[data-theme="light"] .task-prompt-hintbar,
html.light .task-prompt-hintbar {
  box-shadow: 0 16px 42px rgba(15, 23, 42, 0.08);
}
@media (max-width: 640px) {
  .task-prompt-card { padding: 13px; border-radius: 14px; }
  .task-prompt-actions { grid-template-columns: 1fr; }
  .task-prompt-hintbar { align-items: stretch; flex-direction: column; }
  .task-prompt-hintbar-actions { width: 100%; }
  .task-prompt-mini-btn { flex: 1 1 0; }
}

/* ---- Prompt-suggestion card (.ps-*) ---- */
.ps-card { margin-top: 10px; padding: 14px; border-radius: 14px; background: var(--card-bg); border: 1px solid var(--card-border); }
.ps-label { font-size: 12px; font-weight: 800; color: var(--brand-accent); margin-bottom: 8px; }
.ps-text { width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--card-border); background: var(--input-bg); color: var(--text); font: inherit; font-size: 13.5px; line-height: 1.7; resize: vertical; min-height: 260px; max-height: 60vh; }
.ps-note { margin-top: 7px; font-size: 12px; color: var(--muted); }
.ps-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.ps-use { padding: 9px 16px; border-radius: 10px; border: 0; background: var(--brand-gradient, var(--brand-primary)); color: #fff; font: inherit; font-weight: 800; cursor: pointer; }
.ps-use:hover:not(:disabled) { filter: brightness(1.06); }
.ps-keep { padding: 9px 14px; border-radius: 10px; border: 1px solid var(--card-border); background: var(--ghost-bg); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.ps-use:disabled, .ps-keep:disabled { opacity: .5; cursor: default; }

/* ---- Clarifying-questions card (.pq-*) ---- */
.pq-card { margin-top: 10px; padding: 14px; border-radius: 14px; background: var(--card-bg); border: 1px solid var(--card-border); }
.pq-q { padding: 12px 0; border-bottom: 1px solid var(--card-border); }
.pq-q:first-child { padding-top: 2px; }
.pq-q:last-of-type { border-bottom: 0; }
.pq-qtext { font-size: 13.5px; font-weight: 800; color: var(--text); margin-bottom: 9px; line-height: 1.6; }
.pq-opts { display: flex; gap: 8px; flex-wrap: wrap; }
.pq-opt { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--card-border); background: var(--ghost-bg); color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: all .12s; }
.pq-opt:hover { border-color: var(--brand-accent); }
.pq-opt.is-on { background: var(--brand-gradient, var(--brand-primary)); border-color: transparent; color: #fff; font-weight: 800; }
.pq-other { width: 100%; box-sizing: border-box; margin-top: 8px; padding: 8px 12px; border-radius: 10px; border: 1px dashed var(--card-border); background: var(--input-bg); color: var(--text); font: inherit; font-size: 13px; }
.pq-other:focus { outline: none; border-style: solid; border-color: var(--brand-accent); }
.pq-hint { margin-top: 11px; font-size: 12px; font-weight: 600; color: var(--brand-accent, #43C2C4); }
.pq-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.pq-prepare { padding: 10px 18px; border-radius: 10px; border: 0; background: var(--brand-gradient, var(--brand-primary)); color: #fff; font: inherit; font-weight: 800; cursor: pointer; }
.pq-prepare:hover:not(:disabled) { filter: brightness(1.06); }
.pq-prepare:disabled { opacity: .5; cursor: default; }
.pq-review { padding: 10px 16px; border-radius: 10px; border: 1px solid var(--card-border); background: var(--ghost-bg); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.pq-review:hover:not(:disabled) { border-color: var(--brand-accent); }
.pq-review:disabled { opacity: .5; cursor: default; }

/* ---- Radar-menu footnote ---- */
.radar-menu-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 2px;
  padding: 0 8px;
  color: var(--muted-2);
  font-size: 10px;
  line-height: 1.6;
}

/* ---- Task-prep toggle (composer). Only the .task-prep-toggle-specific rules;
 *      prod already defines the shared .composer-toggle* + .deep-think-toggle. ---- */
.task-prep-toggle input:checked ~ .composer-toggle-label,
.task-prep-toggle input:checked + .composer-toggle-icon {
  color: var(--brand-cyan);
}
.task-prep-toggle input:checked + .composer-toggle-icon {
  background: var(--brand-cyan-soft);
}

/* ── Factory card (مصنعك) ─────────────────────────────────────────────────
   Same visual family as the report/approval cards: a quiet panel, numbers
   first, and one action row per threatened order. */
.fc-card { margin-top: 10px; padding: 14px; border-radius: 14px; background: var(--card-bg); border: 1px solid var(--card-border); }
.fc-head { font-weight: 700; font-size: 13.5px; margin-bottom: 10px; }
.fc-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(124px, 1fr)); gap: 8px; margin-bottom: 12px; }
.fc-stat { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--card-border); background: var(--input-bg); }
.fc-stat-value { font-size: 19px; font-weight: 700; line-height: 1.1; }
.fc-stat-label { font-size: 11.5px; line-height: 1.25; opacity: .72; margin-top: 2px; }
.fc-stat--warn .fc-stat-value { color: #d97706; }
.fc-stat--danger .fc-stat-value { color: #dc2626; }
.fc-risk { padding: 10px 0; border-top: 1px solid var(--card-border); }
.fc-risk-main { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 13px; }
.fc-risk-customer { opacity: .7; font-size: 12px; }
.fc-risk-cause { font-size: 12.5px; opacity: .85; margin: 3px 0 8px; }
.fc-risk-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.fc-btn { border: 1px solid var(--card-border); background: transparent; color: inherit; border-radius: 9px; padding: 6px 12px; font-size: 12.5px; cursor: pointer; }
.fc-btn:hover { border-color: var(--brand-cyan, #22d3ee); }
.fc-btn--primary { background: var(--brand-gradient-vivid, linear-gradient(135deg, #22d3ee, #2563eb)); color: #fff; border: 0; font-weight: 600; }
.fc-empty, .fc-note { font-size: 12.5px; opacity: .78; padding-top: 8px; border-top: 1px solid var(--card-border); }
.crew-subtitle { margin: -4px 0 12px; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.crew-mode-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; margin: 0 0 12px; }
.crew-mode { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 9px; align-items: start; min-height: 112px; padding: 11px; border: 1px solid rgba(34, 211, 238, .22); border-radius: 12px; background: linear-gradient(135deg, rgba(34, 211, 238, .09), rgba(70, 96, 184, .05)); color: var(--text); text-align: start; cursor: pointer; }
.crew-mode:hover { border-color: var(--brand-cyan, #22d3ee); background: linear-gradient(135deg, rgba(34, 211, 238, .14), rgba(70, 96, 184, .08)); }
.crew-mode-icon { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; background: rgba(34, 211, 238, .13); color: var(--brand-cyan, #22d3ee); font-size: 15px; }
.crew-mode-copy { min-width: 0; display: grid; gap: 3px; }
.crew-mode-copy strong { font-size: 13px; line-height: 1.3; color: var(--text); }
.crew-mode-copy span { color: var(--muted); font-size: 11.5px; line-height: 1.45; }
.crew-mode-action { grid-column: 1 / -1; justify-self: end; min-height: 26px; display: inline-flex; align-items: center; padding: 4px 9px; border-radius: 8px; background: var(--brand-gradient-vivid, linear-gradient(135deg, #22d3ee, #2563eb)); color: #fff; font-size: 11.5px; font-weight: 800; }
.crew-section-label { margin: 8px 0 7px; color: var(--text); font-size: 12.5px; font-weight: 800; }
.crew-grid { display: grid; gap: 8px; }
.crew-people-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(238px, 1fr)); gap: 10px; margin-bottom: 10px; overflow: visible; }
.crew-person-card {
  /* The native clock popup is drawn outside the field: a clipping ancestor
     cuts it off, which is what made it look misplaced. */
  overflow: visible;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--card-bg) 88%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .03);
}
.crew-person-card:hover { border-color: rgba(67, 194, 196, .46); }
.crew-person-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.crew-person-avatar {
  --crew-accent: var(--brand-cyan, #22d3ee);
  position: relative;
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  overflow: hidden;
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 22%, rgba(255,255,255,.22), transparent 34%),
    linear-gradient(145deg, color-mix(in srgb, var(--crew-accent) 48%, #111827), color-mix(in srgb, var(--crew-accent) 16%, #111827));
  border: 1px solid color-mix(in srgb, var(--crew-accent) 45%, transparent);
}
.crew-person-face {
  position: absolute;
  top: 13px;
  left: 50%;
  width: 20px;
  height: 20px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: #f4c29b;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .16);
}
.crew-person-face::after {
  content: "";
  position: absolute;
  top: 26px;
  left: 50%;
  width: 34px;
  height: 20px;
  transform: translateX(-50%);
  border-radius: 16px 16px 8px 8px;
  background: rgba(255, 255, 255, .88);
}
.crew-person-avatar--female .crew-person-face::before {
  content: "";
  position: absolute;
  inset: -5px -5px 6px;
  border-radius: 50% 50% 48% 48%;
  background: #2f2545;
  z-index: -1;
}
.crew-person-title { display: grid; gap: 1px; min-width: 0; }
.crew-person-title strong { font-size: 16px; line-height: 1.15; color: var(--text); }
.crew-person-title span { color: var(--muted); font-size: 12px; line-height: 1.35; }
.crew-person-role { font-size: 12.5px; color: var(--text); opacity: .9; line-height: 1.45; }
.crew-saved-task {
  display: grid;
  gap: 4px;
  padding: 8px 9px;
  border: 1px solid rgba(67, 194, 196, .28);
  border-radius: 10px;
  background: rgba(67, 194, 196, .08);
}
.crew-saved-task strong {
  color: var(--brand-cyan, #22d3ee);
  font-size: 11.5px;
  line-height: 1.25;
}
.crew-saved-task span {
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.crew-saved-task em {
  color: var(--brand-cyan, #22d3ee);
  font-style: normal;
  font-size: 11.5px;
  font-weight: 800;
  line-height: 1.35;
}
.crew-task-box { display: grid; gap: 5px; }
.crew-task-box span { color: var(--muted); font-size: 11.5px; font-weight: 700; }
.crew-task-box textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  box-sizing: border-box;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  padding: 9px 10px;
  font: inherit;
  line-height: 1.45;
  outline: 0;
}
.crew-task-box textarea:focus { border-color: var(--brand-cyan, #22d3ee); box-shadow: 0 0 0 2px rgba(67, 194, 196, .14); }
.crew-person-actions { align-items: center; }
.crew-person-quick { padding-inline: 9px; }
.crew-period-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.crew-period {
  min-height: 34px;
  border: 1px solid var(--card-border);
  border-radius: 9px;
  background: var(--surface-1);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.crew-period:hover { border-color: rgba(67, 194, 196, .44); color: var(--text); }
.crew-period.is-on {
  border-color: var(--brand-cyan, #22d3ee);
  background: rgba(67, 194, 196, .14);
  color: var(--text);
}
.crew-time-box {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
}
.crew-time-box select,
.crew-time-box input {
  /* A time is read left-to-right even in an Arabic card, and the browser's own
     clock popup follows the field's color-scheme — without it the picker comes
     out white on a dark card. */
  direction: ltr;
  text-align: start;
  color-scheme: light dark;
  width: 100%;
  min-height: 38px;
  box-sizing: border-box;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
  outline: 0;
}
.crew-time-box select {
  /* A dropdown list the user can scroll and search, instead of the browser's
     cramped clock column. */
  appearance: auto;
  cursor: pointer;
}
.crew-time-box select:focus,
.crew-time-box input:focus {
  border-color: var(--brand-cyan, #22d3ee);
  box-shadow: 0 0 0 2px rgba(67, 194, 196, .14);
}
.crew-book-btn {
  flex: 1 1 100%;
  min-height: 42px;
  justify-content: center;
  font-size: 13px;
}
.crew-person-card--blue .crew-person-avatar { --crew-accent: #60a5fa; }
.crew-person-card--amber .crew-person-avatar { --crew-accent: #f59e0b; }
.crew-person-card--green .crew-person-avatar { --crew-accent: #22c55e; }
.crew-person-card--purple .crew-person-avatar { --crew-accent: #a855f7; }
.crew-add-card {
  min-height: 100%;
  border: 1px dashed rgba(67, 194, 196, .42);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(67, 194, 196, .08), rgba(70, 96, 184, .06));
}
.crew-add-open {
  width: 100%;
  min-height: 220px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 18px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: center;
}
.crew-add-open:hover .crew-add-plus { transform: scale(1.04); }
.crew-add-plus {
  width: 58px;
  height: 58px;
  display: inline-grid;
  place-items: center;
  border-radius: 18px;
  background: var(--brand-gradient-vivid, linear-gradient(135deg, #22d3ee, #2563eb));
  color: #fff;
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
  transition: transform .12s ease;
}
.crew-add-open strong { font-size: 15px; color: var(--text); }
.crew-add-open span:not(.crew-add-plus) { max-width: 230px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.crew-add-form {
  display: grid;
  gap: 9px;
  padding: 12px;
}
.crew-add-form[hidden],
.crew-add-open[hidden] { display: none; }
.crew-add-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
}
.crew-add-form input,
.crew-add-form textarea,
.crew-add-form select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
  outline: 0;
}
.crew-add-form input:focus,
.crew-add-form textarea:focus,
.crew-add-form select:focus {
  border-color: var(--brand-cyan, #22d3ee);
  box-shadow: 0 0 0 2px rgba(67, 194, 196, .14);
}
.crew-add-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.crew-add-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.crew-person-delete { color: var(--danger, #E0614F); }
.crew-worker { display: flex; align-items: flex-start; gap: 10px; padding: 11px; border: 1px solid var(--card-border); border-radius: 12px; background: color-mix(in srgb, var(--card-bg) 84%, transparent); }
.crew-worker-avatar { width: 38px; height: 38px; flex: 0 0 38px; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; background: rgba(34, 211, 238, .12); color: var(--brand-cyan, #22d3ee); font-size: 17px; font-weight: 800; letter-spacing: 0; }
.crew-worker-body { min-width: 0; flex: 1 1 auto; }
.crew-assignment-line { margin-top: 4px; font-size: 12.5px; color: var(--text); opacity: .88; }
.crew-limit-line { margin: 2px 0 9px; font-size: 12px; color: var(--muted); line-height: 1.45; }
.crew-worker--blue .crew-worker-avatar { background: rgba(37, 99, 235, .14); color: #60a5fa; }
.crew-worker--amber .crew-worker-avatar { background: rgba(245, 158, 11, .16); color: #f59e0b; }
.crew-worker--green .crew-worker-avatar { background: rgba(34, 197, 94, .14); color: #22c55e; }
.crew-worker--purple .crew-worker-avatar { background: rgba(168, 85, 247, .14); color: #a855f7; }
.crew-card .fc-stats { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.crew-card .crew-steps .fc-stat-value { font-size: 13px; line-height: 1.25; }
.crew-card .fc-risk-actions .fc-btn { padding-inline: 10px; }
@media (max-width: 720px) {
  .crew-people-grid { grid-template-columns: 1fr; }
  .crew-person-actions .fc-btn { flex: 1 1 auto; }
}

/* Cards that are data, not prose, use the full chat column. */
.msg--wide { max-width: 100%; width: 100%; }
.msg--wide .fc-card { width: 100%; }
.fc-card .fc-risk-main { justify-content: flex-start; }
.fc-subhead { font-size: 12px; opacity: .68; margin: -6px 0 10px; }
.fc-section-title { font-size: 12px; font-weight: 700; opacity: .82; margin: 14px 0 4px; }
.fc-list { margin: 8px 0 12px; padding-inline-start: 22px; font-size: 12.5px; line-height: 1.65; }
.fc-list li { margin: 2px 0; }

.addon-catalog {
  margin: 14px 0 4px;
  padding: 12px;
  border: 1px solid rgba(34, 211, 238, .22);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(34, 211, 238, .07), rgba(15, 23, 42, .18));
}
.addon-catalog-head {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}
.addon-catalog-head strong {
  color: var(--text);
  font-size: 13px;
}
.addon-catalog-head span {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
}
.addon-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}
.addon-catalog-item {
  min-width: 0;
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid rgba(148, 163, 184, .24);
  border-radius: 10px;
  background: rgba(2, 6, 23, .22);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.035);
}
.addon-catalog-item strong {
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.addon-catalog-item span {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
}
.addon-catalog-tag {
  justify-self: start;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 7px;
  background: rgba(34, 211, 238, .11);
  color: #67e8f9;
  border: 1px solid rgba(34, 211, 238, .22);
  font-size: 10.5px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.addon-catalog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.addon-flow {
  margin: 14px 0 12px;
  padding: 12px;
  border: 1px solid rgba(34, 211, 238, .22);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(34, 211, 238, .07), rgba(168, 85, 247, .04)),
    var(--input-bg);
}
.addon-flow-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.addon-flow-head strong { font-size: 13px; color: var(--text); }
.addon-flow-head span {
  font-size: 11.5px;
  color: var(--muted);
  text-align: end;
}
.addon-flow-track {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}
.addon-flow-step {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
}
.addon-flow-box {
  position: relative;
  width: min(520px, 100%);
  min-height: 112px;
  padding: 12px 14px 12px 54px;
  border: 1px solid rgba(148, 163, 184, .28);
  border-radius: 10px;
  background: rgba(15, 23, 42, .46);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
[dir="rtl"] .addon-flow-box { padding: 12px 54px 12px 14px; }
.addon-flow-step--decision .addon-flow-box {
  border-color: rgba(245, 158, 11, .42);
  background: linear-gradient(135deg, rgba(245, 158, 11, .14), rgba(15, 23, 42, .42));
}
.addon-flow-step--output .addon-flow-box {
  border-color: rgba(34, 197, 94, .42);
  background: linear-gradient(135deg, rgba(34, 197, 94, .12), rgba(15, 23, 42, .42));
}
.addon-flow-num {
  position: absolute;
  top: 12px;
  left: 12px;
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: 8px;
  background: rgba(34, 211, 238, .16);
  color: #67e8f9;
  font-size: 12px;
  font-weight: 800;
}
[dir="rtl"] .addon-flow-num { left: auto; right: 12px; }
.addon-flow-step--decision .addon-flow-num {
  background: rgba(245, 158, 11, .18);
  color: #fbbf24;
}
.addon-flow-step--output .addon-flow-num {
  background: rgba(34, 197, 94, .18);
  color: #4ade80;
}
.addon-flow-title {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.addon-flow-model {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11.5px;
  overflow-wrap: anywhere;
}
.addon-screen-preview {
  margin-top: 12px;
  border: 1px solid rgba(148, 163, 184, .26);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(2, 6, 23, .28);
}
.addon-screen-topbar {
  min-height: 28px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 9px;
  border-bottom: 1px solid rgba(148, 163, 184, .18);
  background: rgba(15, 23, 42, .72);
}
.addon-screen-topbar span {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: rgba(148, 163, 184, .58);
}
.addon-screen-topbar span:first-child { background: rgba(34, 211, 238, .8); }
.addon-screen-topbar strong {
  min-width: 0;
  margin-inline-start: 6px;
  font-size: 11px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.addon-screen-body {
  display: grid;
  gap: 7px;
  padding: 10px;
}
.addon-screen-row {
  display: grid;
  grid-template-columns: minmax(74px, 36%) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}
.addon-screen-row label {
  min-width: 0;
  color: var(--muted);
  font-size: 10.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.addon-screen-row i {
  height: 20px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, .18);
  background: rgba(15, 23, 42, .58);
}
.addon-screen-row--strong i {
  background: linear-gradient(90deg, rgba(34, 211, 238, .20), rgba(37, 99, 235, .12));
}
.addon-screen-footer {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px 10px 10px;
}
.addon-screen-footer span {
  max-width: 120px;
  padding: 5px 9px;
  border-radius: 7px;
  border: 1px solid rgba(148, 163, 184, .20);
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.addon-screen-footer span.primary {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #22d3ee, #2563eb);
}
.addon-screen-preview--output .addon-screen-footer span.primary {
  background: linear-gradient(135deg, #22c55e, #14b8a6);
}
.addon-screen-preview--decision {
  min-height: 120px;
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 18px 14px;
  border-color: rgba(245, 158, 11, .35);
  background:
    radial-gradient(circle at center, rgba(245, 158, 11, .13), transparent 62%),
    rgba(2, 6, 23, .26);
}
.addon-decision-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid rgba(245, 158, 11, .55);
  background: rgba(245, 158, 11, .14);
  color: #fbbf24;
  font-size: 18px;
  font-weight: 900;
}
.addon-screen-question {
  max-width: 100%;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 800;
  text-align: center;
  overflow-wrap: anywhere;
}
.addon-screen-branches {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 6px;
}
.addon-screen-branches span {
  min-width: 0;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(245, 158, 11, .10);
  border: 1px solid rgba(245, 158, 11, .22);
  color: var(--muted);
  font-size: 10.5px;
  text-align: center;
  overflow-wrap: anywhere;
}
.addon-flow-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.addon-flow-chips span,
.addon-branch {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 5px 8px;
  border: 1px solid rgba(148, 163, 184, .22);
  border-radius: 8px;
  background: rgba(2, 6, 23, .24);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.3;
}
.addon-flow-chips b,
.addon-branch strong { color: var(--text); font-weight: 700; }
.addon-flow-note {
  margin-top: 10px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.55;
}
.addon-flow-branches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.addon-branch {
  justify-content: space-between;
  color: var(--text);
}
.addon-branch span {
  color: var(--muted);
  text-align: end;
  overflow-wrap: anywhere;
}
.addon-flow-arrow {
  height: 30px;
  display: grid;
  place-items: center;
  color: #22d3ee;
  font-size: 19px;
  font-weight: 800;
}
.addon-operator {
  margin: 12px 0;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(34, 197, 94, .24);
  background: linear-gradient(135deg, rgba(34, 197, 94, .10), rgba(20, 184, 166, .06));
}
.addon-operator-head {
  display: grid;
  gap: 3px;
  margin-bottom: 10px;
}
.addon-operator-head strong {
  color: var(--text);
  font-size: 13px;
}
.addon-operator-head span {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
}
.addon-operator-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}
.addon-op-btn {
  min-height: 38px;
  border: 1px solid rgba(34, 197, 94, .25);
  border-radius: 9px;
  background: rgba(2, 6, 23, .22);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.addon-op-btn:hover {
  border-color: rgba(34, 197, 94, .62);
  background: rgba(34, 197, 94, .14);
}
.addon-details {
  margin-top: 12px;
  border-top: 1px solid var(--card-border);
  padding-top: 10px;
}
.addon-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
}

/* ---- Simple addon guide card ---- */
.addon-simple {
  display: grid;
  gap: 12px;
}
.addon-simple-section {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, .20);
  background: rgba(2, 6, 23, .16);
}
.addon-simple-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.addon-simple-title strong {
  color: var(--text);
  font-size: 13px;
}
.addon-simple-title span {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
  text-align: end;
}
.addon-simple-summary {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.7;
}
.addon-permission-list {
  display: grid;
  gap: 8px;
}
.addon-permission-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  padding: 11px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, .18);
  background: rgba(15, 23, 42, .24);
}
.addon-permission-main {
  min-width: 0;
  display: grid;
  gap: 7px;
}
.addon-permission-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.addon-permission-title strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}
.addon-permission-title span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  text-align: end;
  overflow-wrap: anywhere;
}
.addon-permission-row p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}
.addon-permission-points {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
}
.addon-permission-points span {
  overflow-wrap: anywhere;
}
.addon-permission-points b {
  color: var(--text);
  font-weight: 800;
}
.addon-permission-risk {
  color: #fbbf24;
}
.addon-simple-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.addon-guide-strips {
  display: grid;
  gap: 8px;
}
.addon-guide-strip {
  display: grid;
  grid-template-columns: minmax(180px, .9fr) minmax(0, 1.4fr);
  gap: 10px;
  align-items: center;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid rgba(34, 211, 238, .22);
  background: linear-gradient(135deg, rgba(34, 211, 238, .09), rgba(37, 99, 235, .04));
}
.addon-guide-strip-copy {
  display: grid;
  gap: 3px;
}
.addon-guide-strip-copy strong {
  color: var(--text);
  font-size: 13px;
}
.addon-guide-strip-copy span {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
}
.addon-guide-strip-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.addon-simple-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}
.addon-simple-tile {
  min-width: 0;
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, .22);
  background: rgba(15, 23, 42, .30);
}
.addon-simple-tile-head {
  display: grid;
  gap: 2px;
}
.addon-simple-tile-head strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.addon-simple-tile-head span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.addon-simple-tile p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}
.addon-simple-meta {
  color: var(--brand-cyan, #22d3ee);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
}
.addon-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.addon-chip-row span {
  max-width: 160px;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid rgba(34, 211, 238, .20);
  background: rgba(34, 211, 238, .08);
  color: var(--text);
  font-size: 10.5px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.addon-screen-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.addon-field-mini {
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
}
.addon-field-mini b {
  color: var(--text);
  font-size: 11px;
}
@media (max-width: 720px) {
  .addon-guide-strip {
    grid-template-columns: 1fr;
  }
  .addon-guide-strip-actions {
    justify-content: stretch;
  }
  .addon-guide-strip-actions .fc-btn {
    flex: 1 1 140px;
  }
  .addon-simple-title {
    align-items: flex-start;
    flex-direction: column;
  }
  .addon-simple-title span {
    text-align: start;
  }
  .addon-permission-row {
    grid-template-columns: 1fr;
  }
  .addon-permission-row .fc-btn {
    width: 100%;
  }
  .addon-permission-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }
  .addon-permission-title span {
    text-align: start;
  }
  .addon-simple-actions .fc-btn {
    flex: 1 1 130px;
  }
  .addon-screen-actions .fc-btn {
    flex: 1 1 130px;
  }
}

/* ---- Studio Score card ---- */
/* The Studio card is the app's whole interface, so it takes the full chat
   column instead of sitting in a narrow bubble beside it. */
.msg:has(.studio-score-card) {
  width: 100%;
  max-width: 100%;
}
.msg:has(.studio-score-card) .msg-card,
.msg:has(.studio-score-card) .msg-body {
  width: 100%;
  max-width: 100%;
}
/* The card is painted from theme tokens, not from fixed dark rgba values:
   the first version was unreadable in light mode (grey tiles on a white page)
   and the selected option did not read as selected in either theme. */
.studio-score-card {
  --sq-tint: color-mix(in srgb, var(--brand-cyan) 10%, transparent);
  --sq-line: color-mix(in srgb, var(--brand-cyan) 32%, transparent);
  --sq-line-strong: color-mix(in srgb, var(--brand-cyan) 72%, transparent);
  --sq-pick: color-mix(in srgb, var(--brand-cyan) 18%, var(--surface-1));
  width: 100%;
  margin-top: 10px;
  padding: 18px;
  border-radius: 14px;
  border: 1px solid var(--sq-line);
  background: var(--card-bg);
  color: var(--text);
}
.studio-score-hero {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.studio-score-kicker {
  color: var(--brand-cyan);
  font-size: 11px;
  font-weight: 900;
  margin-bottom: 4px;
}
.studio-score-hero h3 {
  margin: 0 0 5px;
  color: var(--text);
  font-size: 19px;
  line-height: 1.25;
}
.studio-score-hero > span {
  flex: 0 0 auto;
  max-width: 180px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--sq-line);
  background: var(--sq-tint);
  color: var(--brand-cyan);
  font-size: 11.5px;
  font-weight: 800;
  text-align: center;
}
.studio-score-section {
  margin-top: 10px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--hairline);
  background: var(--surface-3);
}
.studio-score-section-head {
  display: grid;
  gap: 3px;
  margin-bottom: 10px;
}
.studio-score-section-head strong {
  font-size: 13px;
  color: var(--text);
}
.studio-score-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
  align-items: stretch;
}
.studio-score-action {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-height: 84px;
  padding: 10px 12px;
  border: 1px solid var(--hairline-strong);
  border-radius: 10px;
  background: var(--surface-1);
  color: var(--text);
  font: inherit;
  text-align: start;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.studio-score-action:hover {
  border-color: var(--sq-line-strong);
  background: var(--sq-tint);
}
.studio-score-action-label {
  font-size: 12.5px;
  font-weight: 850;
  line-height: 1.3;
  color: var(--text);
}
.studio-score-action-hint {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--muted);
}
.studio-score-action-example {
  margin-top: 2px;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--brand-cyan);
}
/* Selected: a filled tile with a thick accent edge and a tick, so the pick is
   obvious at a glance in both themes. */
.studio-score-action.is-on {
  border-color: var(--brand-cyan);
  background: var(--sq-pick);
  box-shadow: inset 0 0 0 1px var(--brand-cyan);
}
.studio-score-action.is-on .studio-score-action-label {
  color: var(--brand-cyan);
}
.studio-score-action.is-on .studio-score-action-label::before {
  content: "✓ ";
  font-weight: 900;
}
.studio-score-action.is-on .studio-score-action-hint { color: var(--text); }
.studio-score-compose {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--sq-line);
  background: var(--sq-tint);
}
.studio-score-compose-hint {
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}
.studio-score-compose-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}
.studio-score-field {
  display: grid;
  gap: 4px;
  font-size: 11.5px;
  color: var(--muted);
}
.studio-score-field select,
.studio-score-field input,
.studio-score-compose-input {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--hairline-strong);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
}
.studio-score-field select,
.studio-score-field input {
  min-height: 38px;
  padding: 0 10px;
}
.studio-score-field select:focus,
.studio-score-field input:focus,
.studio-score-compose-input:focus {
  outline: none;
  border-color: var(--brand-cyan);
}
.studio-score-details > summary {
  cursor: pointer;
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 6px;
}
.studio-score-details[open] > summary { color: var(--text); }
.studio-score-compose-input {
  resize: vertical;
  padding: 9px 11px;
}
.studio-score-compose-go {
  justify-self: start;
  min-height: 40px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  background: var(--brand-cyan);
  color: #FFFFFF;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}
.studio-score-compose-go:hover { filter: brightness(1.08); }
/* Older stored cards (before the picker) still render this row. */
.studio-score-calc {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--sq-line);
  background: var(--sq-tint);
}
.studio-score-calc div { display: grid; gap: 3px; }
.studio-score-calc strong { font-size: 13px; color: var(--text); }
.studio-score-calc span { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.studio-score-calc button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: var(--brand-cyan);
  color: #FFFFFF;
  font: inherit;
  font-size: 12.5px;
  font-weight: 900;
  cursor: pointer;
}
.studio-score-footer {
  margin-top: 10px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.55;
}
@media (max-width: 640px) {
  .studio-score-hero {
    flex-direction: column;
    align-items: stretch;
  }
  .studio-score-hero > span {
    max-width: none;
    width: 100%;
  }
}
.addon-details[open] summary { color: var(--text); margin-bottom: 8px; }

/* "This chat stopped mid-task" — same shape as the cap banner, calmer colours:
   nothing is wrong with the account, the run just needs a push. */
.resume-banner {
  background: linear-gradient(90deg, rgba(6, 182, 212, 0.12), rgba(139, 92, 246, 0.10));
  border-color: rgba(6, 182, 212, 0.42);
}
.resume-banner-text { flex: 1; min-width: 0; }
.resume-banner-cta { border: 0; cursor: pointer; font-family: inherit; }
.resume-banner-cta[disabled] { opacity: 0.6; cursor: default; }
/* Breakdown under a merged stat tile — the counters that used to be tiles of
   their own, when they were all the same four cases seen from four angles. */
.fc-stat-hint { font-size: 11px; opacity: .72; margin-top: 4px; line-height: 1.5; }

/* مدير حساباتك — each tile carries its number and the way to look into it, so the
   card never grows a separate row of six buttons under six numbers. */
.ac-stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.ac-tile { display: flex; flex-direction: column; gap: 6px; }
.ac-tile-btn { margin-top: auto; width: 100%; justify-content: center; }
.ac-explain { display: flex; gap: 8px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.ac-explain-input {
    flex: 1 1 220px; min-width: 0; padding: 7px 10px; border-radius: 9px;
    border: 1px solid var(--card-border); background: var(--input-bg);
    color: inherit; font: inherit; font-size: 12.5px;
}
.ac-explain-input:focus { outline: none; border-color: var(--accent, #0ea5e9); }
.ac-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 12px; }
.ac-chip { font-size: 12px; padding: 5px 11px; }

/* ============================================================
   SCHEDULED TASK REMINDER — one small strip beside the chat list
   ============================================================ */
.sched-strip {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 6px 10px 4px;
  padding: 5px 6px 5px 8px;
  min-height: 32px;
  background: rgba(245, 158, 11, 0.10);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 10px;
  font-size: 12px;
  color: var(--text);
  animation: sched-strip-in 0.22s ease-out;
}
.sched-strip--chat { margin: 8px auto 0; width: min(520px, calc(100% - 28px)); }
.sched-strip--ok { background: rgba(61, 187, 133, 0.10); border-color: rgba(61, 187, 133, 0.38); }
.sched-strip--error { background: rgba(224, 97, 79, 0.10); border-color: rgba(224, 97, 79, 0.40); }
.sched-strip-dot {
  flex: none;
  width: 20px; height: 20px;
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--warning);
  background: rgba(245, 158, 11, 0.16);
}
.sched-strip--ok .sched-strip-dot { color: var(--success); background: rgba(61, 187, 133, 0.16); }
.sched-strip--error .sched-strip-dot { color: var(--danger); background: rgba(224, 97, 79, 0.16); }
.sched-strip-text {
  flex: 1; min-width: 0;
  font: inherit; font-size: 12px; color: inherit; text-align: start;
  background: transparent; border: 0; padding: 0; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sched-strip-text strong { font-weight: 700; color: var(--warning); }
.sched-strip--ok .sched-strip-text strong { color: var(--success); }
.sched-strip--error .sched-strip-text strong { color: var(--danger); }
.sched-strip-text:hover { text-decoration: underline; }
.sched-strip-more { color: var(--muted); font-size: 11px; }
.sched-strip-close {
  flex: none; width: 20px; height: 20px; border-radius: 6px;
  background: transparent; border: 0; color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.sched-strip-close:hover { background: var(--ghost-bg-hover); color: var(--text); }
@keyframes sched-strip-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) { .sched-strip { animation: none; } }
.sched-strip--running { background: rgba(67, 194, 196, 0.10); border-color: rgba(67, 194, 196, 0.40); }
.sched-strip--running .sched-strip-dot { color: var(--brand-cyan); background: rgba(67, 194, 196, 0.16); animation: sched-strip-pulse 1.4s ease-in-out infinite; }
.sched-strip--running .sched-strip-text strong { color: var(--brand-cyan); }
@keyframes sched-strip-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .sched-strip--running .sched-strip-dot { animation: none; } }
.sched-strips { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 4px; }
.sched-strips .sched-strip { margin: 0 10px; }
.sched-strips--chat { margin: 8px auto 0; width: min(520px, calc(100% - 28px)); }
.sched-strips--chat .sched-strip { margin: 0; }
.sched-strip--steady { animation: none; }
.sched-strip--meeting { background: rgba(139, 92, 246, 0.10); border-color: rgba(139, 92, 246, 0.40); }
.sched-strip--meeting .sched-strip-dot { color: #8B5CF6; background: rgba(139, 92, 246, 0.16); }
.sched-strip--meeting .sched-strip-text strong { color: #8B5CF6; }
.sched-strip--expanded { flex-wrap: wrap; }
.sched-strip-panel { flex-basis: 100%; padding: 4px 2px 2px 27px; }
[dir="rtl"] .sched-strip-panel { padding: 4px 27px 2px 2px; }
.sched-strip-facts { font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.sched-strip-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.sched-strip-action {
  font: inherit; font-size: 11.5px; font-weight: 600; cursor: pointer;
  padding: 4px 9px; border-radius: 7px;
  border: 1px solid var(--card-border); background: var(--surface-1); color: var(--text);
}
.sched-strip-action:hover { filter: brightness(1.1); }
.sched-strip-action--primary { background: #8B5CF6; border-color: #8B5CF6; color: #fff; }

/* بوت صقّار — وردية خلصت. Separate from scheduled-task strips on purpose:
   this is a person coming back from a shift, not a system reminder. */
.crew-shift-notices {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 7px 10px 8px;
  pointer-events: none;
}
.crew-shift-bubble {
  position: relative;
  min-height: 40px;
  flex: 1 1 auto;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border: 1px solid rgba(67, 194, 196, .42);
  border-radius: 11px;
  background: linear-gradient(135deg, rgba(67, 194, 196, .16), rgba(70, 96, 184, .12));
  color: var(--text);
  box-shadow: none;
  cursor: pointer;
  pointer-events: auto;
  animation: crew-shift-pop .22s ease-out;
}
[dir="rtl"] .crew-shift-bubble { padding: 7px 10px; }
.crew-shift-bubble::after {
  content: none;
}
.crew-shift-avatar {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--brand-gradient-vivid, linear-gradient(135deg, #22d3ee, #2563eb));
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}
.crew-shift-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
  text-align: start;
  line-height: 1.2;
}
.crew-shift-copy strong {
  max-width: 175px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
}
.crew-shift-copy span {
  max-width: 175px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 11px;
}
.crew-shift-more {
  min-width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(67, 194, 196, .14);
  color: var(--brand-cyan);
  font-size: 11px;
  font-weight: 900;
}
.crew-shift-close {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid var(--card-border);
  border-radius: 50%;
  background: var(--surface-1);
  color: var(--muted);
  cursor: pointer;
  pointer-events: auto;
  box-shadow: none;
}
.crew-shift-close:hover { color: var(--text); border-color: rgba(67, 194, 196, .52); }
@keyframes crew-shift-pop {
  from { opacity: 0; transform: translateY(8px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (max-width: 720px) {
  .crew-shift-copy strong,
  .crew-shift-copy span { max-width: 190px; }
}

/* عين صقّار — the screen read, as one card instead of a paragraph. */
.eye-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  font-size: 12.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--hairline);
}
.eye-row:last-child { border-bottom: 0; }
.eye-row strong { color: var(--text); font-weight: 800; direction: ltr; unicode-bidi: isolate; }
.eye-text { font-size: 12.5px; line-height: 1.65; color: var(--text); }
.eye-risk { border-color: color-mix(in srgb, #F59E0B 45%, transparent); }
.eye-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.eye-chips span {
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--hairline-strong);
  background: var(--surface-1);
  font-size: 11.5px;
  color: var(--text);
}
.eye-actions { margin-top: 12px; }
.eye-actions .studio-score-action { min-height: 44px; }
.eye-age { margin: -4px 0 10px; font-size: 11.5px; color: var(--muted); }

/* ── Financial-health card ─────────────────────────────────────────────
   Tables reuse .md-table / .md-table-wrap (theme hairline, surface-2 header,
   zebra rows). Everything here is theme-token based so it reads in dark and
   light; direction follows the card's dir attribute. */
.fh-card { font-size: 13px; color: var(--text); }
.fh-head { font-weight: 600; color: var(--text); margin-block-end: 10px; }
.fh-gt { font-weight: 600; color: var(--text); margin: 14px 0 4px; font-size: 12.5px; }
.fh-card .md-table td.fh-k { color: var(--text); white-space: normal; }
.fh-card .md-table td.fh-v { font-variant-numeric: tabular-nums; text-align: end; white-space: nowrap; }
.fh-card .md-table td.fh-range { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.fh-det summary { cursor: pointer; list-style: none; display: inline-flex; }
.fh-det summary::-webkit-details-marker { display: none; }
.fh-detb { font-size: 11px; color: var(--muted); padding-block: 4px; font-weight: 400; white-space: normal; }
.fh-note { color: var(--muted); font-size: 11px; font-style: italic; margin-block-start: 8px; }

/* Status chips — semantic colours that hold on both themes. */
.fh-chip {
  display: inline-block; padding: 1px 8px; border-radius: 9px;
  font-size: 11px; font-weight: 600; color: #fff; white-space: nowrap;
}
.fh-chip--healthy { background: #16a34a; }
.fh-chip--watch { background: #d97706; }
.fh-chip--critical { background: #dc2626; }
.fh-chip--unreliable { background: #6b7280; }
.fh-chip--unavailable { background: #9ca3af; }
.fh-chip--info { background: #64748b; }

/* Data-quality warnings — themed danger surface, no hard-coded light hex. */
.fh-warn {
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--text); border-radius: 8px; padding: 8px 10px;
  margin-block: 10px; font-size: 12px;
}
.fh-warn strong { display: block; margin-block-end: 4px; color: var(--danger); }

/* Company picker: segmented chips (≤5) or a styled select (>5). */
.fh-seg { display: flex; flex-wrap: wrap; gap: 6px; margin-block: 8px; }
.fh-seg-btn {
  padding: 4px 12px; border-radius: 999px; font-size: 12px; cursor: pointer;
  border: 1px solid var(--hairline); background: transparent; color: var(--text);
}
.fh-seg-btn:hover { background: var(--ghost-bg-hover); }
.fh-seg-btn.is-active {
  background: var(--brand-cyan); border-color: var(--brand-cyan); color: #fff; font-weight: 600;
}
.fh-picker { display: inline-flex; align-items: center; gap: 8px; margin-block: 8px; font-size: 12px; }
.fh-picker .fh-company { padding: 4px 8px; }
