/* =========================================================================
   מרכז הסוכנים — Modern Dark, dense dashboard, RTL
   ========================================================================= */

:root {
  --bg:        #0B0F17;
  --bg-soft:   #0E1420;
  --surface:   #121826;
  --surface-2: #172033;
  --surface-3: #1E2940;
  --border:    #232C3F;
  --border-2:  #2E3A52;

  --text:      #E6EAF2;
  --text-2:    #B4BECF;
  --muted:     #7E8AA3;
  --faint:     #5A6478;

  --brand:     #6366F1;
  --brand-2:   #818CF8;
  --brand-dim: #6366F11f;
  --accent:    #22C55E;
  --accent-dim:#22C55E1f;
  --warn:      #F59E0B;
  --warn-dim:  #F59E0B1f;
  --danger:    #EF4444;
  --danger-dim:#EF44441f;
  --info:      #38BDF8;

  --r-xs: 6px;  --r-sm: 9px;  --r-md: 13px; --r-lg: 18px; --r-xl: 24px;
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;

  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 6px 20px -6px rgba(0,0,0,.6);
  --shadow-3: 0 24px 60px -18px rgba(0,0,0,.75);

  --rail-w: 268px;
  --ease: cubic-bezier(.22,.61,.36,1);
  --dur: 200ms;

  --font: "Heebo", -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

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

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
h1,h2,h3,h4 { margin: 0; line-height: 1.3; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
::selection { background: var(--brand); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--faint); background-clip: content-box; }

:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; border-radius: var(--r-xs); }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono  { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.nowrap{ white-space: nowrap; }
[hidden] { display: none !important; }

/* ------------------------------- icons ---------------------------------- */
i[data-icon] { display: inline-flex; width: 1.15em; height: 1.15em; flex: none; }
i[data-icon] svg { width: 100%; height: 100%; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------- boot ----------------------------------- */
.boot, .login {
  position: fixed; inset: 0; display: grid; place-content: center; justify-items: center;
  gap: var(--sp-4); background: radial-gradient(1000px 600px at 70% -10%, #1a2340 0%, var(--bg) 62%);
  z-index: 50;
}
.boot p { color: var(--muted); font-size: 14px; }
.boot-mark, .login-mark, .rail-mark {
  width: 46px; height: 46px; border-radius: 14px;
  background: linear-gradient(140deg, var(--brand) 0%, #4F46E5 45%, var(--accent) 130%);
  box-shadow: 0 8px 26px -8px var(--brand);
  position: relative;
}
.boot-mark::after, .login-mark::after, .rail-mark::after {
  content: ""; position: absolute; inset: 13px; border-radius: 5px;
  border: 2.5px solid rgba(255,255,255,.9); border-bottom-color: transparent; border-left-color: transparent;
}
.boot-mark { animation: pulse 1.4s var(--ease) infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1 } 50% { transform: scale(.9); opacity: .6 } }

/* ------------------------------- login ---------------------------------- */
.login-card {
  width: min(400px, calc(100vw - 32px));
  display: grid; gap: var(--sp-4); justify-items: stretch; text-align: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-6); box-shadow: var(--shadow-3);
}
.login-card .login-mark { justify-self: center; }
.login-card h1 { font-size: 22px; }
.login-card p { font-size: 14px; }
.login-error { color: var(--danger); font-size: 14px; }

/* ------------------------------- shell ---------------------------------- */
.shell { display: grid; grid-template-columns: var(--rail-w) 1fr; height: 100vh; height: 100dvh; }

.rail {
  background: var(--bg-soft); border-inline-start: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0; padding: var(--sp-4) var(--sp-3);
  gap: var(--sp-4);
}
.rail-brand { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-1) var(--sp-2); }
.rail-brand-text { display: grid; }
.rail-brand-text strong { font-size: 15px; font-weight: 600; }
.rail-brand-text small { font-size: 12px; color: var(--faint); font-family: var(--mono); }
.rail-mark { width: 34px; height: 34px; border-radius: 11px; }
.rail-mark::after { inset: 10px; border-width: 2px; }

.rail-nav { display: grid; gap: 2px; }
.rail-link {
  display: flex; align-items: center; gap: var(--sp-3); padding: 9px var(--sp-3);
  border-radius: var(--r-sm); color: var(--text-2); font-size: 14.5px; font-weight: 500;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.rail-link i { color: var(--muted); transition: color var(--dur) var(--ease); }
.rail-link:hover { background: var(--surface); color: var(--text); }
.rail-link.active { background: var(--brand-dim); color: var(--brand-2); }
.rail-link.active i { color: var(--brand-2); }
.rail-badge {
  margin-inline-start: auto; font-style: normal; font-size: 11.5px; font-weight: 600;
  background: var(--surface-3); color: var(--text-2); border-radius: 99px; padding: 1px 7px;
}

.rail-agents { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.rail-section-title {
  font-size: 11.5px; font-weight: 600; letter-spacing: .06em; color: var(--faint);
  text-transform: uppercase; padding: 0 var(--sp-3);
}
.rail-live { overflow-y: auto; display: grid; gap: 4px; align-content: start; }
.rail-empty { padding: var(--sp-3); font-size: 13px; color: var(--faint); }
.rail-live-item {
  display: flex; align-items: center; gap: var(--sp-2); padding: 7px var(--sp-3);
  border-radius: var(--r-sm); font-size: 13.5px; background: var(--surface); cursor: pointer;
  border: 1px solid transparent; text-align: start; width: 100%;
}
.rail-live-item:hover { border-color: var(--border-2); }
.rail-live-item .ttl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rail-foot { display: flex; align-items: center; gap: var(--sp-2); border-top: 1px solid var(--border); padding-top: var(--sp-3); }
.conn { display: flex; align-items: center; gap: var(--sp-2); font-size: 12.5px; color: var(--muted); flex: 1; }
.conn .dot { width: 8px; height: 8px; border-radius: 99px; background: var(--faint); flex: none; }
.conn.on .dot { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-dim); }
.conn.off .dot { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-dim); }
.rail-icon-btn {
  background: transparent; border: 1px solid transparent; color: var(--muted); cursor: pointer;
  width: 34px; height: 34px; border-radius: var(--r-sm); display: grid; place-items: center;
}
.rail-icon-btn:hover { background: var(--surface); color: var(--text); border-color: var(--border); }

/* ------------------------------- main ----------------------------------- */
.main { min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }

.page { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.page-head {
  display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-5) var(--sp-6) var(--sp-4);
  border-bottom: 1px solid var(--border); flex: none;
}
.page-head .titles { flex: 1; min-width: 0; }
.page-head h1 { font-size: 21px; }
.page-head .sub { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.page-head .actions { display: flex; gap: var(--sp-2); align-items: center; }
.page-body { flex: 1; min-height: 0; overflow-y: auto; padding: var(--sp-5) var(--sp-6) var(--sp-7); }
.page-body.flush { padding: 0; overflow: hidden; }

/* ------------------------------ buttons --------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 38px; padding: 0 14px; border-radius: var(--r-sm); cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border-2); color: var(--text);
  font-size: 14px; font-weight: 500; white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform 90ms var(--ease);
}
.btn:hover { background: var(--surface-3); border-color: var(--faint); }
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #04210f; font-weight: 600; }
.btn-accent:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-danger { background: var(--danger-dim); border-color: transparent; color: #FCA5A5; }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 13px; border-radius: var(--r-xs); }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn-block { width: 100%; }

/* ------------------------------- chips ---------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px;
  border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12px; font-weight: 500; color: var(--text-2); white-space: nowrap;
}
.chip i { width: 13px; height: 13px; }
.chip-accent { background: var(--accent-dim); color: var(--accent); border-color: transparent; }
.chip-brand  { background: var(--brand-dim);  color: var(--brand-2); border-color: transparent; }
.chip-warn   { background: var(--warn-dim);   color: var(--warn);   border-color: transparent; }
.chip-danger { background: var(--danger-dim); color: #FCA5A5;       border-color: transparent; }

.dot-live { width: 7px; height: 7px; border-radius: 99px; background: var(--accent); flex: none;
  box-shadow: 0 0 0 0 var(--accent); animation: ring 1.8s var(--ease) infinite; }
@keyframes ring { 70% { box-shadow: 0 0 0 7px transparent } 100% { box-shadow: 0 0 0 0 transparent } }

/* ------------------------------ agent grid ------------------------------ */
.agent-grid {
  display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(auto-fill, minmax(266px, 1fr));
}
.agent-card {
  position: relative; display: flex; flex-direction: column; gap: var(--sp-3);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: var(--sp-4); cursor: pointer; text-align: start; min-height: 172px;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.agent-card::before {
  content: ""; position: absolute; inset-inline: 0; top: 0; height: 3px;
  border-radius: var(--r-md) var(--r-md) 0 0; background: var(--ac, var(--brand)); opacity: .85;
}
.agent-card:hover { transform: translateY(-2px); border-color: var(--border-2); box-shadow: var(--shadow-2); }
.agent-card:focus-visible { outline-offset: 3px; }
.agent-card .ac-top { display: flex; align-items: flex-start; gap: var(--sp-3); }
.agent-avatar {
  width: 44px; height: 44px; border-radius: var(--r-sm); display: grid; place-items: center;
  background: color-mix(in srgb, var(--ac, var(--brand)) 16%, transparent);
  color: var(--ac, var(--brand)); flex: none; font-size: 21px;
}
.agent-avatar i { width: 22px; height: 22px; }
.agent-avatar.sm { width: 30px; height: 30px; border-radius: var(--r-xs); font-size: 15px; }
.agent-avatar.sm i { width: 16px; height: 16px; }
.agent-avatar.lg { width: 56px; height: 56px; border-radius: var(--r-md); }
.agent-avatar.lg i { width: 28px; height: 28px; }
.ac-name { flex: 1; min-width: 0; }
.ac-name h3 { font-size: 16px; }
.ac-name .id { font-family: var(--mono); font-size: 11.5px; color: var(--faint); }
.ac-desc { font-size: 13.5px; color: var(--text-2); flex: 1;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ac-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.ac-foot { display: flex; gap: var(--sp-2); align-items: center; }
.ac-foot .btn { flex: 1; }
.ac-foot .btn-icon { flex: none; }
.ac-live { position: absolute; top: var(--sp-4); inset-inline-end: var(--sp-4); }

.card-new {
  display: grid; place-content: center; justify-items: center; gap: var(--sp-2);
  border: 1.5px dashed var(--border-2); background: transparent; color: var(--muted);
  border-radius: var(--r-md); cursor: pointer; min-height: 172px; padding: var(--sp-4);
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.card-new:hover { border-color: var(--brand); color: var(--brand-2); background: var(--brand-dim); }
.card-new i { width: 26px; height: 26px; }
.card-new strong { font-size: 15px; font-weight: 600; }
.card-new small { font-size: 12.5px; }

/* ------------------------------- panels --------------------------------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); }
.panel + .panel { margin-top: var(--sp-4); }
.panel-head {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.panel-head h3 { font-size: 15px; flex: 1; }
.panel-body { padding: var(--sp-4); }
.panel-body.tight { padding: 0; }

.stat-row { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-4);
}
.stat .k { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 25px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 13px; color: var(--muted); font-weight: 400; }

/* ------------------------------- empty ---------------------------------- */
.empty {
  display: grid; justify-items: center; gap: var(--sp-3); text-align: center;
  padding: var(--sp-7) var(--sp-4); color: var(--muted);
}
.empty .ic {
  width: 56px; height: 56px; border-radius: var(--r-md); display: grid; place-items: center;
  background: var(--surface-2); color: var(--faint);
}
.empty .ic i { width: 26px; height: 26px; }
.empty h3 { font-size: 16px; color: var(--text); }
.empty p { font-size: 13.5px; max-width: 46ch; }

/* ------------------------------- chat ----------------------------------- */
.chat { display: grid; grid-template-columns: 1fr 264px; min-height: 0; height: 100%; }
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-side {
  border-inline-start: 1px solid var(--border); background: var(--bg-soft);
  display: flex; flex-direction: column; min-height: 0;
}
.chat-side-head { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); display: flex; gap: var(--sp-2); align-items: center; }
.chat-side-head h3 { font-size: 13px; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; flex: 1; }
.session-list { overflow-y: auto; padding: var(--sp-2); display: grid; gap: 3px; align-content: start; flex: 1; }
.session-item {
  display: grid; gap: 2px; padding: 9px var(--sp-3); border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid transparent; background: transparent; text-align: start; width: 100%; position: relative;
}
.session-item:hover { background: var(--surface); }
.session-item.active { background: var(--surface-2); border-color: var(--border-2); }
.session-item .t { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-item .m { font-size: 11.5px; color: var(--faint); display: flex; gap: 8px; }
.session-item .del {
  position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%);
  opacity: 0; background: var(--surface-3); border: none; color: var(--muted); cursor: pointer;
  width: 26px; height: 26px; border-radius: var(--r-xs); display: grid; place-items: center;
}
.session-item:hover .del { opacity: 1; }
.session-item .del:hover { background: var(--danger); color: #fff; }

/* projects rail — inside the chat sidebar, above the conversations */
.chat-projects { flex: none; display: flex; flex-direction: column; max-height: 46%; min-height: 0; }
.project-list { overflow-y: auto; padding: var(--sp-2); display: grid; gap: 4px; align-content: start; }
.project-item {
  display: grid; gap: 5px; padding: 8px var(--sp-3); border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid transparent;
}
.project-item:hover { background: var(--surface); }
.project-item.active { background: var(--surface-2); border-color: var(--ac, var(--brand)); }
.project-item .t { display: flex; gap: var(--sp-2); align-items: baseline; }
.project-item .t .name { font-size: 13.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-item .t .cnt { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.project-item .bar { height: 3px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.project-item .bar i { display: block; height: 100%; background: var(--ac, var(--brand)); }
.project-item .acts { display: flex; gap: 2px; opacity: .35; transition: opacity .15s ease; }
.project-item:hover .acts, .project-item.active .acts { opacity: 1; }
.project-item .acts .btn { width: 26px; height: 26px; padding: 0; }

.chat-head {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--border); flex: none; background: var(--bg-soft);
}
.chat-head .who { flex: 1; min-width: 0; }
.chat-head .who h2 { font-size: 16px; display: flex; align-items: center; gap: var(--sp-2); }
.chat-head .who .sub { font-size: 12.5px; color: var(--muted); }

.msgs { flex: 1; overflow-y: auto; padding: var(--sp-5) var(--sp-5) var(--sp-4); scroll-behavior: smooth; }
.msgs-inner { max-width: 900px; margin: 0 auto; display: grid; gap: var(--sp-4); }

.msg { display: flex; gap: var(--sp-3); align-items: flex-start; }
.msg-av {
  width: 30px; height: 30px; border-radius: var(--r-xs); display: grid; place-items: center; flex: none;
  font-size: 13px; font-weight: 600;
}
.msg-user .msg-av { background: var(--surface-3); color: var(--text-2); }
.msg-assistant .msg-av { background: color-mix(in srgb, var(--ac, var(--brand)) 18%, transparent); color: var(--ac, var(--brand)); }
.msg-av i { width: 16px; height: 16px; }
.msg-body { min-width: 0; flex: 1; }
.msg-name { font-size: 12.5px; color: var(--muted); margin-bottom: 3px; display: flex; gap: var(--sp-2); align-items: center; }
.bubble {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4); font-size: 14.5px; overflow-wrap: anywhere;
}
.msg-user .bubble { background: var(--surface-2); border-color: var(--border-2); }
.bubble > *:first-child { margin-top: 0 }
.bubble > *:last-child { margin-bottom: 0 }
.bubble p { margin: 0 0 .6em; }
.bubble ul, .bubble ol { margin: 0 0 .6em; padding-inline-start: 1.4em; }
.bubble li { margin-bottom: .2em; }
.bubble h1, .bubble h2, .bubble h3 { font-size: 15.5px; margin: .9em 0 .4em; }
.bubble code {
  font-family: var(--mono); font-size: .89em; background: var(--surface-3);
  padding: 1px 5px; border-radius: var(--r-xs); direction: ltr; unicode-bidi: embed;
}
.bubble pre {
  background: #0A0E17; border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: var(--sp-3); overflow-x: auto; direction: ltr; text-align: left; margin: 0 0 .6em;
}
.bubble pre code { background: none; padding: 0; font-size: 12.8px; line-height: 1.55; }
.bubble a { color: var(--brand-2); text-decoration: underline; text-underline-offset: 2px; }
.bubble blockquote { margin: 0 0 .6em; padding-inline-start: var(--sp-3);
  border-inline-start: 3px solid var(--border-2); color: var(--text-2); }
.bubble table { border-collapse: collapse; width: 100%; font-size: 13px; margin-bottom: .6em; }
.bubble th, .bubble td { border: 1px solid var(--border); padding: 5px 8px; text-align: start; }
.bubble th { background: var(--surface-2); font-weight: 600; }

.think {
  border-inline-start: 2px solid var(--border-2); padding-inline-start: var(--sp-3);
  color: var(--faint); font-size: 13.5px; font-style: italic; white-space: pre-wrap;
}
.think-head { display: flex; align-items: center; gap: 6px; font-style: normal;
  font-size: 12px; color: var(--muted); cursor: pointer; margin-bottom: 4px; }

.tool {
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--bg-soft);
  font-size: 13px; overflow: hidden;
}
.tool-head {
  display: flex; align-items: center; gap: var(--sp-2); padding: 7px var(--sp-3); cursor: pointer;
  color: var(--text-2);
}
.tool-head:hover { background: var(--surface); }
.tool-head .nm { font-weight: 600; font-size: 12.5px; }
.tool-head .arg { color: var(--faint); font-family: var(--mono); font-size: 11.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; direction: ltr; text-align: left; }
.tool-head .st { flex: none; }
.tool-body { border-top: 1px solid var(--border); padding: var(--sp-3); }
.tool-body pre {
  margin: 0; background: #0A0E17; border-radius: var(--r-xs); padding: var(--sp-3);
  overflow: auto; max-height: 340px; font-family: var(--mono); font-size: 12px;
  direction: ltr; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere;
}
.tool-body .lbl { font-size: 11.5px; color: var(--faint); margin-bottom: 4px; }
.tool.err { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
/* A call whose result never came back — interrupted, or the stream dropped.
   Dimmed rather than red: nothing failed, we just do not know the outcome. */
.tool.unanswered { border-style: dashed; opacity: 0.75; }

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

.run-note {
  display: flex; align-items: center; gap: var(--sp-2); font-size: 13px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: var(--sp-2) var(--sp-3);
}
.denial {
  border: 1px solid var(--warn); background: var(--warn-dim); border-radius: var(--r-sm);
  padding: var(--sp-3); display: grid; gap: var(--sp-2); font-size: 13.5px;
}
.denial h4 { font-size: 13.5px; color: var(--warn); display: flex; align-items: center; gap: 6px; }
.denial .rule { font-family: var(--mono); font-size: 12.5px; background: #0A0E17;
  padding: 5px 9px; border-radius: var(--r-xs); direction: ltr; text-align: left; }
.denial .row { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.denial-explain:not(:empty) {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: var(--sp-3); font-size: 12.5px;
}

.composer { flex: none; border-top: 1px solid var(--border); padding: var(--sp-3) var(--sp-5) var(--sp-4); background: var(--bg-soft); }
.composer-inner { max-width: 900px; margin: 0 auto; }
.composer-box {
  display: flex; align-items: flex-end; gap: var(--sp-2); background: var(--surface);
  border: 1px solid var(--border-2); border-radius: var(--r-md); padding: var(--sp-2);
  transition: border-color var(--dur) var(--ease);
}
.composer-box:focus-within { border-color: var(--brand); }
.composer textarea {
  flex: 1; background: transparent; border: none; resize: none; outline: none;
  padding: 8px var(--sp-2); font-size: 15px; line-height: 1.55; max-height: 220px; min-height: 24px;
}
.composer textarea::placeholder { color: var(--faint); }
.composer-hint { font-size: 11.5px; color: var(--faint); margin-top: 6px; display: flex; gap: var(--sp-3); }
.composer-hint kbd {
  font-family: var(--mono); font-size: 10.5px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 4px; padding: 0 4px;
}
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: var(--sp-2); }
.quick button {
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
  border-radius: 99px; padding: 4px 11px; font-size: 12.5px; cursor: pointer;
}
.quick button:hover { border-color: var(--brand); color: var(--brand-2); }

/* ------------------------------ forms ----------------------------------- */
.field { display: grid; gap: 6px; text-align: start; }
.field > span, .field-label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.field .hint { font-size: 12.5px; color: var(--faint); line-height: 1.5; }
input[type=text], input[type=password], input[type=number], input[type=search], textarea, select {
  background: var(--bg); border: 1px solid var(--border-2); border-radius: var(--r-sm);
  padding: 9px var(--sp-3); font-size: 14.5px; width: 100%; outline: none;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
input:focus, textarea:focus, select:focus { border-color: var(--brand); background: var(--bg-soft); }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { resize: vertical; min-height: 84px; line-height: 1.6; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: left 16px top 55%, left 11px top 55%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.form-grid { display: grid; gap: var(--sp-4); }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.inline { display: flex; gap: var(--sp-2); align-items: center; }

.check {
  display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--r-sm); cursor: pointer; background: var(--surface);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.check:hover { border-color: var(--border-2); }
.check.on { border-color: var(--brand); background: var(--brand-dim); }
.check input { margin: 3px 0 0; accent-color: var(--brand); width: 16px; height: 16px; flex: none; }
.check .t { font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.check .h { font-size: 12.5px; color: var(--muted); margin-top: 2px; line-height: 1.45; }
.check.locked { cursor: default; opacity: .82; border-style: dashed; }
.check.locked:hover { border-color: var(--brand); }
.check-grid { display: grid; gap: var(--sp-2); grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

.radio-cards { display: grid; gap: var(--sp-2); }
.radio-cards.cols { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* ------------------------------ modal ----------------------------------- */
.modal-root {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(4,7,13,.72); backdrop-filter: blur(6px); padding: var(--sp-4);
  animation: fadeIn 160ms var(--ease);
}
@keyframes fadeIn { from { opacity: 0 } }
.modal {
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-lg);
  box-shadow: var(--shadow-3); width: min(720px, 100%); max-height: min(88vh, 900px);
  display: flex; flex-direction: column; min-height: 0; animation: rise 220ms var(--ease);
}
@keyframes rise { from { transform: translateY(14px) scale(.985); opacity: 0 } }
.modal.wide { width: min(1000px, 100%); }
.modal.narrow { width: min(480px, 100%); }
.modal-head {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border); flex: none;
}
.modal-head h2 { font-size: 17px; flex: 1; }
.modal-head .sub { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.modal-body { padding: var(--sp-5); overflow-y: auto; flex: 1; min-height: 0; }
.modal-foot {
  display: flex; gap: var(--sp-2); justify-content: flex-end; padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--border); flex: none; background: var(--bg-soft);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.modal-foot .spread { margin-inline-end: auto; }

/* ------------------------------ tabs ------------------------------------ */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 var(--sp-5); flex: none; overflow-x: auto; }
.tab {
  background: none; border: none; cursor: pointer; padding: 11px var(--sp-3); font-size: 14px;
  color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
  display: flex; align-items: center; gap: 6px; font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand-2); border-bottom-color: var(--brand); }

/* --------------------------- file guidance ------------------------------ */
.files-layout { display: grid; grid-template-columns: 250px 1fr; gap: 0; min-height: 0; height: 100%; }
.files-list { border-inline-start: 1px solid var(--border); overflow-y: auto; padding: var(--sp-2); display: grid; gap: 2px; align-content: start; }
.files-group-title { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--faint);
  padding: var(--sp-3) var(--sp-3) 4px; font-weight: 600; }
.file-item {
  display: flex; align-items: center; gap: var(--sp-2); padding: 8px var(--sp-3); border-radius: var(--r-sm);
  cursor: pointer; background: none; border: 1px solid transparent; width: 100%; text-align: start; font-size: 13.5px;
}
.file-item:hover { background: var(--surface); }
.file-item.active { background: var(--surface-2); border-color: var(--border-2); }
.file-item i { color: var(--muted); }
.file-item .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .badge { font-size: 10.5px; color: var(--faint); font-family: var(--mono); }
.file-item.missing .nm { color: var(--faint); }

.file-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.guide {
  background: var(--bg-soft); border-bottom: 1px solid var(--border); padding: var(--sp-4) var(--sp-5);
  flex: none; max-height: 42vh; overflow-y: auto;
}
.guide h3 { font-size: 15.5px; display: flex; align-items: center; gap: var(--sp-2); }
.guide .tagline { font-size: 13px; color: var(--brand-2); margin-top: 2px; }
.guide .role { font-size: 13.5px; color: var(--text-2); margin-top: var(--sp-3); }
.guide-cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); margin-top: var(--sp-3); }
.guide-box { border-radius: var(--r-sm); padding: var(--sp-3); font-size: 13px; }
.guide-box.yes { background: var(--accent-dim); border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent); }
.guide-box.no  { background: var(--danger-dim); border: 1px solid color-mix(in srgb, var(--danger) 32%, transparent); }
.guide-box h4 { font-size: 12.5px; display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.guide-box.yes h4 { color: var(--accent); }
.guide-box.no h4 { color: #FCA5A5; }
.guide-box ul { margin: 0; padding-inline-start: 1.15em; display: grid; gap: 3px; }
.guide-box li { color: var(--text-2); }
.guide-example {
  margin-top: var(--sp-3); background: #0A0E17; border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: var(--sp-3); font-family: var(--mono); font-size: 12px; white-space: pre-wrap;
  max-height: 190px; overflow: auto; color: var(--text-2);
}
.guide-toggle { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 12.5px;
  display: flex; align-items: center; gap: 5px; padding: 0; }

.editor { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.editor textarea {
  flex: 1; border: none; border-radius: 0; background: var(--bg); padding: var(--sp-4) var(--sp-5);
  font-family: var(--mono); font-size: 13.2px; line-height: 1.7; resize: none; min-height: 0;
}
.editor textarea:focus { background: var(--bg); }
.editor-bar {
  display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-5);
  border-top: 1px solid var(--border); background: var(--bg-soft); flex: none;
}
.editor-bar .st { flex: 1; font-size: 12.5px; color: var(--faint); }
.editor-bar .st.dirty { color: var(--warn); }

/* ---------------------------- icon picker ------------------------------- */
.icon-picker { display: grid; gap: var(--sp-3); }
.icon-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px;
  max-height: 320px; overflow-y: auto; padding: 2px;
}
.icon-cell {
  aspect-ratio: 1; display: grid; place-items: center; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid transparent; cursor: pointer; color: var(--text-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-cell:hover { background: var(--surface-3); color: var(--text); }
.icon-cell.on { background: var(--brand-dim); border-color: var(--brand); color: var(--brand-2); }
.icon-cell i { width: 21px; height: 21px; }
.color-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 99px; cursor: pointer; border: 2px solid transparent; }
.swatch.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg); }

/* ------------------------------ tables ---------------------------------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: start; font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase;
  color: var(--faint); font-weight: 600; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.tbl td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .act { text-align: end; white-space: nowrap; }
.tbl-wrap { overflow-x: auto; }

/* ------------------------------ rules ----------------------------------- */
.rule-row {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.rule-row:last-child { border-bottom: none; }
.rule-row .code { font-family: var(--mono); font-size: 13px; direction: ltr; }
.rule-row .exp { font-size: 12.5px; color: var(--muted); flex: 1; }

/* ------------------------------ toasts ---------------------------------- */
.toasts {
  position: fixed; bottom: var(--sp-5); inset-inline-start: var(--sp-5); z-index: 80;
  display: grid; gap: var(--sp-2); max-width: 380px;
}
.toast {
  display: flex; align-items: flex-start; gap: var(--sp-3); background: var(--surface-2);
  border: 1px solid var(--border-2); border-radius: var(--r-sm); padding: var(--sp-3) var(--sp-4);
  box-shadow: var(--shadow-3); font-size: 13.5px; animation: toastIn 240ms var(--ease);
}
@keyframes toastIn { from { transform: translateY(10px); opacity: 0 } }
.toast.out { animation: toastOut 200ms var(--ease) forwards; }
@keyframes toastOut { to { transform: translateY(8px); opacity: 0 } }
.toast i { flex: none; margin-top: 2px; }
.toast.ok i { color: var(--accent); }
.toast.err i { color: var(--danger); }
.toast.info i { color: var(--info); }
.toast .msg { flex: 1; }

/* ------------------------------ misc ------------------------------------ */
.spin { animation: spin 900ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%; animation: sheen 1.3s linear infinite; border-radius: var(--r-sm);
}
@keyframes sheen { to { background-position: -200% 0 } }
.divider { height: 1px; background: var(--border); margin: var(--sp-4) 0; }
.stack { display: grid; gap: var(--sp-3); }
.stack-sm { display: grid; gap: var(--sp-2); }
.row { display: flex; gap: var(--sp-3); align-items: center; }
.row-between { display: flex; gap: var(--sp-3); align-items: center; justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.callout {
  display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-sm);
  background: var(--brand-dim); border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent);
  font-size: 13.5px; color: var(--text-2);
}
.callout i { color: var(--brand-2); flex: none; margin-top: 3px; }
.callout.warn { background: var(--warn-dim); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.callout.warn i { color: var(--warn); }

/* ------------------------ settings modal shell --------------------------- */
/* The settings modal hosts a full-height file editor, so its body gives up the
   usual padding and lets the tab panel own the scrolling. */
.modal-body:has(> .settings-wrap) { padding: 0; display: flex; }
.settings-wrap { display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0; }
.settings-wrap > .tabs { padding-inline: var(--sp-4); }
.settings-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.settings-panel > * { flex: 1; min-height: 0; }
.settings-scroll {
  overflow-y: auto; padding: var(--sp-5); display: flex; flex-direction: column;
  gap: var(--sp-4); min-height: 0;
}
.settings-scroll.tight { padding: 0; gap: 0; }
.settings-foot {
  display: flex; align-items: center; gap: var(--sp-2); flex: none;
  padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); background: var(--bg-soft);
}
.settings-foot .spread { margin-inline-end: auto; }
@media (max-width: 900px) {
  .settings-scroll { padding: var(--sp-4); }
  .settings-foot { padding-inline: var(--sp-4); }
}

/* --------------------------- create wizard ------------------------------- */
.wizard { display: flex; flex-direction: column; gap: var(--sp-4); min-height: 320px; }
.wizard-head h3 { font-size: 16px; margin-bottom: 4px; }
.wizard-head p { font-size: 13px; color: var(--muted); line-height: 1.6; }
.wizard-dots { display: flex; gap: 6px; align-items: center; margin-inline-end: auto; }
.wdot {
  width: 22px; height: 4px; border-radius: 99px; background: var(--border-2);
  transition: background var(--dur) var(--ease), width var(--dur) var(--ease);
}
.wdot.done { background: color-mix(in srgb, var(--accent) 55%, transparent); }
.wdot.on { background: var(--accent); width: 34px; }

/* --------------------------- agent id field ----------------------------- */
.id-state { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.id-state.ok  { color: var(--accent); }
.id-state.bad { color: var(--danger); }
.id-dot { width: 7px; height: 7px; border-radius: 99px; background: var(--faint); flex: none; }
.id-dot.ok  { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.id-dot.bad { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-dim); }

.id-preview {
  display: grid; gap: 6px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: var(--sp-3);
}
.id-preview-row { display: flex; align-items: center; gap: var(--sp-3); font-size: 13px; }
.id-preview-row .k { color: var(--muted); min-width: 120px; }
.id-preview-row code {
  font-family: var(--mono); font-size: 12.5px; direction: ltr; unicode-bidi: isolate;
  background: #0A0E17; border-radius: var(--r-xs); padding: 2px 7px; color: var(--accent);
}

.id-explain { border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); }
.id-explain > summary {
  cursor: pointer; list-style: none; padding: 9px var(--sp-3); font-size: 13.5px; color: var(--text-2);
  display: flex; align-items: center; gap: var(--sp-2);
}
.id-explain > summary::-webkit-details-marker { display: none; }
.id-explain > summary:hover { color: var(--text); }
.id-explain[open] > summary { border-bottom: 1px solid var(--border); color: var(--text); }
.id-explain > div { padding: var(--sp-3); display: grid; gap: var(--sp-2); font-size: 13px; color: var(--text-2); }
.id-explain code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: var(--r-xs); }
.id-examples { display: grid; gap: 5px; margin-top: 2px; }
.id-examples > div { display: flex; align-items: center; gap: var(--sp-2); font-size: 12.5px; }
.id-examples .was { color: var(--muted); min-width: 140px; }
.id-examples i { color: var(--faint); width: 14px; height: 14px; }

/* ------------------------------ mcp connect ----------------------------- */
.probe-wait, .probe-ok, .probe-bad {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  border-radius: var(--r-sm); padding: var(--sp-3) var(--sp-4); font-size: 13.5px;
  border: 1px solid var(--border);
}
.probe-wait { background: var(--surface-2); color: var(--text-2); }
.probe-wait i { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.probe-ok  { background: var(--accent-dim); border-color: var(--accent); color: var(--text); }
.probe-ok i  { color: var(--accent); }
.probe-bad { background: var(--danger-dim); border-color: var(--danger); color: var(--text); }
.probe-bad i { color: var(--danger); }
.probe-err {
  margin-top: var(--sp-2); max-height: 150px; overflow: auto; direction: ltr; text-align: left;
  font-family: var(--mono); font-size: 11.5px; color: var(--text-2);
  background: #0A0E17; border-radius: var(--r-xs); padding: var(--sp-2); white-space: pre-wrap;
}

/* -------------------------------- tooltips ------------------------------ */
/* Renders into a body-level portal, so it escapes every scrolling panel. */
.tip {
  position: fixed; z-index: 200; max-width: min(400px, calc(100vw - 24px));
  background: var(--surface-3); border: 1px solid var(--border-2);
  border-radius: var(--r-md); box-shadow: var(--shadow-3);
  padding: var(--sp-3) var(--sp-4); font-size: 13px; line-height: 1.65;
  color: var(--text); pointer-events: auto;
  opacity: 0; transform: translateY(-4px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.tip.above { transform: translateY(4px); }
.tip.in { opacity: 1; transform: none; }
.tip-card { display: flex; flex-direction: column; gap: 7px; }
.tip-top { display: flex; align-items: center; gap: var(--sp-2); justify-content: space-between; }
.tip-rule {
  font-family: var(--mono); font-size: 12px; direction: ltr; unicode-bidi: isolate;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-xs);
  padding: 2px 6px; color: var(--text); word-break: break-all;
}
.tip-row { color: var(--text-2); }
.tip-row b { color: var(--text); font-weight: 600; }
.tip-row.muted { color: var(--muted); font-size: 12.5px; }
.tip-effect {
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  border-inline-start: 2px solid var(--brand);
  border-radius: var(--r-xs); padding: 6px 9px; font-size: 12.5px; color: var(--text-2);
}
.tip-ex { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 5px; align-items: baseline; }
.tip-ex code {
  font-family: var(--mono); direction: ltr; unicode-bidi: isolate;
  background: var(--surface-2); border-radius: var(--r-xs); padding: 1px 5px; font-size: 11.5px;
}
.tip-warn {
  font-size: 12.5px; color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent);
  border-radius: var(--r-xs); padding: 6px 9px;
}
.tip-body { color: var(--text-2); }

.risk { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.risk.ok   { color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, transparent); }
.risk.warn { color: var(--warn);   background: color-mix(in srgb, var(--warn) 15%, transparent); }
.risk.bad  { color: #FB923C;       background: color-mix(in srgb, #FB923C 15%, transparent); }
.risk.crit { color: var(--danger); background: color-mix(in srgb, var(--danger) 16%, transparent); }

.tip-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; flex: none; border-radius: 50%; cursor: pointer;
  background: transparent; border: 1px solid var(--border-2); color: var(--muted);
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.tip-btn svg { width: 13px; height: 13px; }
.tip-anchor { cursor: help; border-bottom: 1px dashed var(--border-2); }
.tip-anchor:hover { border-bottom-color: var(--brand); }
.tip-btn:hover, .tip-btn:focus-visible { color: var(--brand); border-color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent); }

/* --------------------------- responsive --------------------------------- */
@media (max-width: 1180px) {
  .chat { grid-template-columns: 1fr 220px; }
  .files-layout { grid-template-columns: 210px 1fr; }
}
@media (max-width: 900px) {
  :root { --rail-w: 0px; }
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: fixed; inset-block: 0; inset-inline-end: 0; width: 272px; z-index: 40;
    transform: translateX(100%); transition: transform var(--dur) var(--ease); box-shadow: var(--shadow-3);
  }
  .rail.open { transform: none; }
  .page-head, .page-body, .chat-head, .composer { padding-inline: var(--sp-4); }
  .chat { grid-template-columns: 1fr; }
  .chat-side { position: fixed; inset-block: 0; inset-inline-start: 0; width: 84vw; max-width: 320px; z-index: 35;
    transform: translateX(-100%); transition: transform var(--dur) var(--ease); }
  html[dir=rtl] .chat-side { transform: translateX(-100%); }
  .chat-side.open { transform: none; }
  .form-grid.two, .guide-cols { grid-template-columns: 1fr; }
  .files-layout { grid-template-columns: 1fr; }
  .files-list { max-height: 190px; border-inline-start: none; border-bottom: 1px solid var(--border); }
  .agent-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
}
.only-mobile { display: none; }
@media (max-width: 900px) { .only-mobile { display: inline-flex; } }

/* ------------------------------- hiring ---------------------------------- */
/* Two ways to create an agent — an interview or the wizard — and the panel
   where an interview turns into something you can approve. */

.callout.danger { background: var(--danger-dim); border-color: color-mix(in srgb, var(--danger) 34%, transparent); }
.callout.danger i { color: var(--danger); }
.callout strong { display: block; color: var(--text); margin-bottom: 3px; }
.callout p { margin: 0; }
.callout ul { margin: 4px 0 0; padding-inline-start: 18px; }

.hire-choice { display: grid; gap: var(--sp-3); }
.hire-option {
  display: flex; gap: var(--sp-4); align-items: flex-start; width: 100%; text-align: start;
  padding: var(--sp-4); border-radius: var(--r-md); cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.hire-option:hover { transform: translateY(-1px); border-color: var(--border-2); background: var(--surface-2); }
.hire-option.primary { border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: var(--accent-dim); }
.hire-option.primary:hover { border-color: var(--accent); }
.hire-option .ic {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px;
  border-radius: var(--r-sm); background: var(--surface-2); color: var(--text-2);
}
.hire-option.primary .ic { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
.hire-option .ic i { width: 20px; height: 20px; }
.hire-option .txt { flex: 1; min-width: 0; }
.hire-option strong { display: block; font-size: 15px; margin-bottom: 2px; }
.hire-option p { margin: 0 0 var(--sp-2); font-size: 13px; color: var(--text-2); }
.hire-option ul { margin: 0; padding-inline-start: 16px; display: grid; gap: 3px; }
.hire-option li { font-size: 12.5px; color: var(--faint); }
.hire-option .go { flex: none; color: var(--faint); align-self: center; }
.hire-option:hover .go { color: var(--text-2); }

/* The draft panel, above the session list while talking to the CEO. */
.chat:has(.chat-side.with-hiring) { grid-template-columns: 1fr 344px; }
.chat-side.with-hiring .session-list { max-height: 30vh; }

.hire-panel { display: flex; flex-direction: column; min-height: 0; border-bottom: 1px solid var(--border); }
.hire-panel.filled { flex: 1 1 auto; }
.hire-head {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border);
}
.hire-head .ic { color: var(--warn); flex: none; margin-top: 2px; }
.hire-head h3 { font-size: 13.5px; }
.hire-head p { margin: 2px 0 0; font-size: 11.5px; color: var(--faint); line-height: 1.5; }
.hire-body { overflow-y: auto; padding: var(--sp-3) var(--sp-4); flex: 1; min-height: 0; }
.hire-foot { display: grid; gap: 6px; padding: var(--sp-3); border-top: 1px solid var(--border); }
.hire-panel:not(.filled) .hire-foot { display: none; }

.hire-draft { display: grid; gap: var(--sp-3); }
.hire-id { display: flex; gap: var(--sp-3); align-items: center; }
.hire-id strong { display: block; font-size: 14.5px; }
.hire-id code { font-size: 11.5px; color: var(--faint); }
.hire-desc { margin: 0; font-size: 13px; color: var(--text-2); line-height: 1.6; }

.hire-rows { display: grid; gap: 6px; margin: 0; }
.hire-rows > div { display: flex; gap: var(--sp-3); align-items: baseline; font-size: 12.5px; }
.hire-rows dt { display: flex; gap: 5px; align-items: center; color: var(--faint); flex: none; min-width: 84px; }
.hire-rows dt i { width: 13px; height: 13px; }
.hire-rows dd { margin: 0; color: var(--text-2); min-width: 0; overflow-wrap: anywhere; }

.hire-tools { display: grid; gap: 6px; }
.hire-tools dt { display: flex; gap: 5px; align-items: center; font-size: 12.5px; color: var(--faint); }
.hire-tools dt i { width: 13px; height: 13px; }

.hire-why {
  margin: 0; padding: var(--sp-3); border-radius: var(--r-sm); background: var(--surface);
  border-inline-start: 2px solid var(--brand); font-size: 12.5px; color: var(--text-2); line-height: 1.65;
}
.hire-why span { display: block; font-size: 11px; color: var(--faint); margin-bottom: 3px; }

.hire-sched {
  display: flex; gap: var(--sp-3); align-items: center; padding: var(--sp-3);
  border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--border);
}
.hire-sched i { color: var(--brand-2); flex: none; }
.hire-sched strong { display: block; font-size: 13px; }
.hire-sched code { font-size: 11.5px; color: var(--faint); }

/* The CEO's own card leads the grid, and says why it is different. */
.agent-card.is-ceo { background: linear-gradient(180deg, color-mix(in srgb, var(--ac) 8%, transparent), transparent 42%), var(--surface); }
.agent-card.is-ceo::before { opacity: 1; height: 4px; }
.ac-badge {
  position: absolute; inset-block-start: var(--sp-3); inset-inline-end: var(--sp-3);
  display: inline-flex; gap: 4px; align-items: center; padding: 2px 8px; border-radius: 99px;
  background: color-mix(in srgb, var(--ac) 18%, transparent); color: var(--ac);
  font-size: 10.5px; font-weight: 600; white-space: nowrap;
}
.ac-badge i { width: 12px; height: 12px; }

@media (max-width: 1200px) { .chat:has(.chat-side.with-hiring) { grid-template-columns: 1fr 300px; } }
@media (max-width: 900px) {
  .chat:has(.chat-side.with-hiring) { grid-template-columns: 1fr; }
  .chat-side.with-hiring .session-list { max-height: 24vh; }
}
/* Both markers live in the same corner; the live dot moves aside for the badge. */
.agent-card.is-ceo .ac-live { inset-inline-end: auto; inset-inline-start: var(--sp-4); }

/* ------------------------- connections & secrets ------------------------- */
/* A card per service. Connected ones carry an accent edge, so the answer to
   "what is actually wired up" is readable from across the room. */
.svc-grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.svc-card {
  display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-4);
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface);
  transition: border-color var(--dur) var(--ease);
}
.svc-card:hover { border-color: var(--border-2); }
.svc-card.on { border-color: color-mix(in srgb, var(--accent) 38%, var(--border)); }
.svc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-2); }
.svc-title { display: grid; gap: 2px; min-width: 0; }
.svc-title strong { font-size: 15px; }
.svc-title code { font-size: 11.5px; direction: ltr; font-family: var(--mono); }
.svc-what { margin: 0; font-size: 13px; color: var(--text-2); line-height: 1.5; }
.svc-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--muted); direction: ltr; }
.svc-meta .mono { font-family: var(--mono); }
.svc-actions { display: flex; gap: var(--sp-2); margin-top: auto; padding-top: var(--sp-2); }
.svc-actions .btn { flex: none; }
/* A token nobody holds is not a problem, but it is worth noticing. */
.warn-inline { color: var(--warn); }
.row-inline { display: flex; gap: var(--sp-2); align-items: center; }
.row-inline input { flex: 1; min-width: 0; }
@media (max-width: 560px) { .svc-grid { grid-template-columns: 1fr; } }

/* ----------------------------- work plans ------------------------------- */

.bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .3s ease-out; }

.steps { display: grid; gap: 6px; border-top: 1px solid var(--border); padding-top: var(--sp-3); }
.step { border: 1px solid var(--border); border-radius: var(--r-xs); background: var(--bg); }
.step.blocked { border-color: var(--warn); }
.step-head {
  display: flex; gap: var(--sp-3); align-items: center; cursor: pointer;
  padding: 9px 10px; min-height: 42px;
}
.step-head:hover { background: var(--surface-2); }
.step-head input { accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.step-head .num {
  font-family: var(--mono); font-size: 11.5px; font-weight: 600; color: var(--brand-2);
  background: var(--brand-dim); padding: 3px 7px; border-radius: 999px; flex: none;
}
.step-head .t {
  font-size: 13.5px; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.step-head > i:last-child { width: 15px; height: 15px; color: var(--faint); flex: none; transition: transform .18s; }
.step-head > i.flip { transform: rotate(180deg); }
.step-body {
  margin: 0; padding: 0 12px 12px 12px; font-size: 13px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word; color: var(--text-2);
  font-family: inherit; border-top: 1px solid var(--border); padding-top: 10px;
}
.step .n {
  font-size: 12.5px; color: var(--accent); white-space: pre-wrap; line-height: 1.5;
  padding: 8px 12px; border-top: 1px dashed var(--border); background: var(--surface-2);
}
.step.blocked .n { color: var(--warn); }
.step.done .step-head .t { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }

.parse-preview { display: grid; gap: 4px; border: 1px solid var(--border); border-radius: var(--r-xs); padding: 8px; max-height: 220px; overflow-y: auto; }
.pp-row { display: flex; gap: var(--sp-3); align-items: center; font-size: 12.5px; }
.pp-row .num {
  font-family: var(--mono); font-weight: 600; color: var(--brand-2); background: var(--brand-dim);
  min-width: 26px; text-align: center; padding: 2px 6px; border-radius: 999px; flex: none;
}
.pp-row .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.pp-row .len { color: var(--faint); font-family: var(--mono); font-size: 11.5px; flex: none; }

.quick button.on { border-color: var(--brand); background: var(--brand-dim); color: var(--brand-2); }

.secret-value {
  display: block; padding: var(--sp-3); border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--border-2);
  font-size: 14px; word-break: break-all; user-select: all; direction: ltr; text-align: start;
}
