/* Bipper web UI v2 — core design system.
 * Palette + primitives shared by every page. Page-specific layout lives
 * in pages/<page>.css and is loaded on demand by js/router.js. */

:root {
  --bg:        #0b0f16;
  --bg-1:      #11161f;
  --bg-2:      #161c27;
  --bg-3:      #1c2331;
  --border:    #232b3a;
  --border-soft:#1a2030;
  --text:      #d6dde8;
  --text-mute: #7e899e;
  --text-dim:  #4f586a;
  --accent:    #44e020;
  --accent-soft:rgba(68,224,32,0.12);
  --warn:      #f0b429;
  --warn-soft: rgba(240,180,41,0.14);
  --danger:    #ef4444;
  --danger-soft:rgba(239,68,68,0.14);
  --info:      #6aa9ff;
  --info-soft: rgba(106,169,255,0.14);
  --bot:       #d97aff;
  --bot-soft:  rgba(217,122,255,0.14);

  --radius:    8px;
  --radius-lg: 12px;
  --radius-sm: 4px;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;

  --topbar-h: 44px;
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.55);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  overflow: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* ── SVG icon helper ───────────────────────────────────────────────────── */
.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  vertical-align: middle;
}
.icon--lg { width: 22px; height: 22px; }
.icon--sm { width: 14px; height: 14px; }

/* ── Phase 6.10d — Canonical status dot system ───────────────────────── */
/* Used everywhere: dashboard fleet, bot list, team rail, workstation
 * left rail, settings runners, busy bar. One source of truth so every
 * page renders the same "is this bot working?" indicator. */
.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-dim);
}
.dot.online   { background: #4ade80; }
.dot.working  { background: #1FD2FF; animation: dot-pulse 1.5s infinite; }
.dot.idle     { background: var(--warn); }
.dot.offline  { background: var(--text-dim); }
.dot.stuck    { background: var(--danger); animation: dot-shake 0.6s infinite; }
@keyframes dot-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}
@keyframes dot-shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-1px); }
  40%      { transform: translateX(1px); }
  60%      { transform: translateX(-1px); }
  80%      { transform: translateX(1px); }
}

/* ── Layout shell ──────────────────────────────────────────────────────── */
/* Phase 6.10a — canonical topbar matching mockups/dashboard.html. */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
.topbar__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s;
}
.topbar__brand:hover { background: var(--bg-2); text-decoration: none; }
.topbar__brand.is-active {
  background: var(--bg-2);
  border-bottom: 2px solid var(--accent);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.topbar__brand img { height: 22px; display: block; }
.topbar__spacer { flex: 1; }
.topbar__actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.topbar__icon-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-mute);
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  text-decoration: none;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.topbar__icon-btn:hover {
  background: var(--bg-2);
  color: var(--text);
  text-decoration: none;
}
.topbar__icon-btn.is-active {
  background: var(--bg-2);
  border-bottom: 2px solid var(--accent);
  color: var(--text);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.topbar__icon-btn.ws-btn {
  background: var(--accent-soft);
  border: 1px solid rgba(68, 224, 32, 0.2);
  color: var(--accent);
}
.topbar__icon-btn.ws-btn:hover {
  background: rgba(68, 224, 32, 0.18);
  border-color: var(--accent);
  color: var(--accent);
}
.topbar__icon-btn.ws-btn.is-active {
  background: var(--accent);
  color: #0b0f16;
  border-color: var(--accent);
}
.topbar__sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  align-self: center;
  margin: 0 4px;
}
.topbar__badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 8px;
  min-width: 14px;
  text-align: center;
  line-height: 1.3;
  pointer-events: none;
}
/* Live (WS) connection indicator. Sits at the right edge of the topbar.
   Tiny dot — green = connected, amber = reconnecting, red = closed. */
.topbar__ws {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-mute, #7e899e);
  align-self: center;
  margin-left: 6px;
  margin-right: 4px;
  flex: 0 0 auto;
  opacity: 0.7;
}
.topbar__ws.is-ok   { background: var(--ok, #44e020);   opacity: 1; box-shadow: 0 0 6px rgba(68, 224, 32, 0.55); }
.topbar__ws.is-warn { background: var(--warn, #f0b429); opacity: 1; box-shadow: 0 0 6px rgba(240, 180, 41, 0.55); animation: ws-pulse 1.4s ease-in-out infinite; }
.topbar__ws.is-err  { background: var(--danger, #f5563b); opacity: 1; box-shadow: 0 0 6px rgba(245, 86, 59, 0.55); }
@keyframes ws-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }

.app {
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0; bottom: 0;
  overflow: auto;
}

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--text);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { background: var(--bg-3); border-color: var(--border); }
.btn-primary {
  background: var(--accent);
  color: #0b0f16;
  border-color: var(--accent);
  font-weight: 600;
}
.btn-primary:hover { background: #5bf033; }
.btn-danger { color: var(--danger); border-color: var(--danger-soft); }
.btn-ghost  { background: transparent; border-color: transparent; color: var(--text-mute); }
.btn-ghost:hover { color: var(--text); background: var(--bg-2); }

/* ── Cards ────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card--accent { border-color: var(--accent-soft); }

/* ── Toast / status ───────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: calc(var(--topbar-h) + 10px);
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 240px;
  max-width: 360px;
  padding: 10px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-mute);
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.18s, transform 0.18s;
}
.toast.is-shown { opacity: 1; transform: none; }
.toast--info    { border-left-color: var(--info); }
.toast--ok      { border-left-color: var(--accent); }
.toast--warn    { border-left-color: var(--warn); }
.toast--error   { border-left-color: var(--danger); }

/* ── Modals ───────────────────────────────────────────────────────────── */
.modal-root { position: relative; z-index: 400; }
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(3, 6, 12, 0.62);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 401;
}
.modal {
  width: 100%;
  max-width: 520px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow: auto;
  padding: 20px;
}

/* ── Notification panel — Phase 6.10b, slide-down spec ──────────────── */
/* Mirrors mockups/shared_notif.html: anchored below the topbar bell,
 * fixed top-right, max-height 480px, opens via .is-open class.
 * The host element starts with [hidden] which we toggle off, then add
 * .is-open in the next frame for the slide-down transition. */
.notif-panel {
  position: fixed;
  top: var(--topbar-h);
  right: 80px;
  width: 360px;
  max-height: 480px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  z-index: 150;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.18s, transform 0.18s;
  /* Panel is always laid out so the open/close transition can animate
   * opacity + transform. But when closed it is invisible and must NOT
   * capture pointer events — otherwise its fixed-position rectangle
   * silently eats clicks on whatever is behind it (see the dashboard
   * "View bot" button which was unreachable on narrow viewports). */
  pointer-events: none;
}
.notif-panel.is-open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
/* If the JS sets the hidden attribute, fully remove the panel from the
 * layout. `hidden` was being silently overridden by display:flex above. */
.notif-panel[hidden] { display: none; }
.np-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
}
.np-header a {
  color: var(--accent);
  text-decoration: none;
  font-size: 9px;
  text-transform: none;
  letter-spacing: 0;
}
.np-header a:hover { text-decoration: underline; }
.np-list {
  flex: 1;
  overflow-y: auto;
}
.np-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-mute);
  font-size: 13px;
}
.np-item {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background 0.1s;
}
.np-item:hover { background: var(--bg-2); }
.np-item.is-unread { border-left: 2px solid var(--accent); }
.np-icon {
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 2px;
}
.np-body { flex: 1; min-width: 0; }
.np-title {
  font-size: 11.5px;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.np-detail {
  font-size: 10px;
  color: var(--text-mute);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.np-time {
  font-size: 9px;
  color: var(--text-dim);
  font-family: var(--mono);
  flex-shrink: 0;
}
.np-bot { color: var(--bot); }
.np-ch  { color: var(--info); }

/* ── Auth / login screen (no token) ───────────────────────────────────── */
/* Full-screen centered card so the bug where the old input was off-center
 * can never come back. */
.auth-screen {
  position: fixed; inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 20%, rgba(68,224,32,0.06), transparent 60%), var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.auth-logo {
  height: 36px;
  margin: 0 auto 14px;
  display: block;
}
.auth-card h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 4px;
}
.auth-sub {
  font-size: 13px;
  color: var(--text-mute);
  margin: 0 0 20px;
}
.auth-card label {
  display: block;
  text-align: left;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--text-mute);
}
.auth-card label span {
  display: block;
  margin-bottom: 4px;
}
.auth-card label input {
  width: 100%;
}
.auth-card .btn-primary {
  width: 100%;
  padding: 10px;
  margin-top: 8px;
}

/* ── Page loading / empty states ──────────────────────────────────────── */
.page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-mute);
  font-size: 14px;
}
.page-error {
  max-width: 520px;
  margin: 60px auto;
  padding: 24px;
  background: var(--bg-1);
  border: 1px solid var(--danger-soft);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius);
  color: var(--text);
}
.page-error h2 { margin: 0 0 8px; font-size: 16px; }
.page-error pre {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg);
  padding: 10px;
  border-radius: var(--radius-sm);
  overflow: auto;
}

/* ── Utility helpers ──────────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
/* ══════════════════════════════════════════════════════════════════════
 *  Global permission / question modals (Phase 6.4)
 *  CSS tuned to match mockups/permission_modal.html
 * ════════════════════════════════════════════════════════════════════ */
.perm-backdrop {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  padding: 40px 20px;
}
.perm-backdrop::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(68,224,32,0.04) 0%, transparent 40%),
    radial-gradient(circle at 80% 60%, rgba(106,169,255,0.04) 0%, transparent 40%);
  z-index: 0;
  pointer-events: none;
}
.perm-modal {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 460px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 25px 80px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.03);
  overflow: hidden;
}

.perm-head {
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  display: flex;
  align-items: center;
  gap: 12px;
}
.bot-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-3);
  border: 1.5px solid var(--bot);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--bot);
  flex-shrink: 0;
}
.perm-head__info { flex: 1; min-width: 0; }
.perm-head__name {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.perm-head__source {
  font-size: 10px;
  color: var(--text-mute);
  margin-top: 2px;
  font-family: var(--mono);
}
.perm-head__source .ctx { color: var(--info); }
.perm-head__source .ctx-session { color: var(--accent); }

.modal-close {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  width: 28px;
  height: 28px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--bg-3); color: var(--text); }

.perm-body { padding: 16px 18px; }

.req-type-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  font-weight: 700;
  color: var(--warn);
  margin-bottom: 8px;
}
.req-type-label.question { color: var(--info); }
.req-type-label.plan     { color: var(--accent); }

.req-text {
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 12px;
}
.req-text code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 12px;
}

.tool-call {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 11px;
  margin-bottom: 12px;
}
.tool-call .name { color: var(--info); font-weight: 700; }
.tool-call .args { color: var(--text-mute); margin-top: 4px; word-break: break-all; }
.tool-call .args .key { color: var(--text-dim); }
.tool-call .args .val { color: var(--text); }
.tool-call .args > div { margin-top: 2px; }

/* Diff preview — rendered for Edit/MultiEdit permission requests.
 * Each line is .line.add (+), .line.del (-), or .line.ctx (@@ header). */
.diff {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.5;
  margin-bottom: 12px;
  max-height: 160px;
  overflow-y: auto;
  white-space: pre;
  word-break: normal;
}
.diff .line { padding-left: 4px; }
.diff .line.add { color: #4ade80; }
.diff .line.del { color: var(--danger); }
.diff .line.ctx { color: var(--text-mute); }

.auto-approve {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 9px 12px;
  margin-bottom: 12px;
  font-size: 11px;
  color: var(--text-mute);
}
.auto-approve label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex-wrap: wrap;
}
.auto-approve input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
}
.auto-approve .duration {
  margin-left: auto;
  display: flex;
  gap: 4px;
}
.auto-approve .dur {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-mute);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 9px;
  cursor: pointer;
  font-family: var(--mono);
}
.auto-approve .dur.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}
.auto-approve .scope {
  margin-top: 6px;
  font-size: 9.5px;
  color: var(--text-dim);
  padding-left: 22px;
}

.perm-foot {
  padding: 12px 18px 14px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}
.perm-foot .btn {
  flex: 1;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
}
.perm-foot .btn.btn-ghost { flex: 0 0 auto; }

/* Mobile variant (mockup "Mobile variant"): the primary CTA takes a
 * full row at the top — thumb-reachable — and all other buttons flow
 * 50/50 on the second row. Works for every footer variant in both
 * permission and question modals (plan: Approve/Reject/Show session;
 * free-text: Send/Cancel/Show session; permission: Approve/Deny/Show
 * session; choices: Custom answer/Show session — degenerates to two
 * siblings sharing the row). Triggered at ≤600px. */
@media (max-width: 600px) {
  .perm-modal { max-width: 100%; border-radius: 8px; }
  .perm-foot { flex-wrap: wrap; gap: 6px; }
  .perm-foot .btn.btn-primary        { order: -1; flex: 1 1 100%; }
  .perm-foot .btn:not(.btn-primary)  { flex: 1 1 calc(50% - 3px); }
}

/* Question-specific bits */
.choices {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  text-align: left;
}
.choice:hover {
  background: var(--bg-3);
  border-color: var(--accent);
}
.choice .num {
  display: inline-block;
  background: var(--bg-3);
  color: var(--text-mute);
  width: 18px;
  height: 18px;
  border-radius: 4px;
  text-align: center;
  line-height: 18px;
  font-size: 9px;
  font-family: var(--mono);
  font-weight: 700;
  flex-shrink: 0;
}
.choice__body { display: flex; flex-direction: column; gap: 2px; }
.choice__label { font-weight: 500; }
.choice__desc  { font-size: 11px; }

.text-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 6px;
  font-family: var(--sans);
  font-size: 12px;
  outline: none;
  margin-bottom: 12px;
  resize: vertical;
  min-height: 70px;
}
.text-input:focus { border-color: var(--accent); }

.plan-summary {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.plan-summary .ptitle {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.plan-summary .pphase {
  font-size: 10.5px;
  color: var(--text-mute);
  line-height: 1.5;
  padding-left: 12px;
  position: relative;
}
.plan-summary .pphase::before {
  content: "•";
  position: absolute;
  left: 2px;
  color: var(--accent);
}

.stack-counter {
  position: absolute;
  top: 50px;
  right: 24px;
  background: var(--warn);
  color: #0b0f16;
  font-size: 10px;
  padding: 3px 9px;
  border-radius: 10px;
  font-weight: 700;
  z-index: 3;
}
.stack-shadow {
  position: absolute;
  top: 60px;
  left: 50%;
  width: 460px;
  height: 420px;
  max-width: calc(100% - 40px);
  pointer-events: none;
  z-index: 1;
}
.stack-shadow::before, .stack-shadow::after {
  content: "";
  position: absolute;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}
.stack-shadow::before {
  transform: translate(6px, 8px);
  opacity: 0.5;
}
.stack-shadow::after {
  transform: translate(12px, 14px);
  opacity: 0.3;
}

/* ── Phase 6.10c — Confirmation modal helper ─────────────────────────── */
.modal--confirm {
  max-width: 460px;
}
.modal--confirm .modal__body {
  padding: 16px 20px;
}
.modal--confirm .confirm-body {
  font-size: 13px;
  color: var(--text);
  line-height: 1.55;
  white-space: pre-wrap;
}
.modal--confirm .confirm-body code {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: var(--mono);
  color: var(--accent);
}
.modal--confirm .confirm-error {
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--danger-soft);
  border-left: 3px solid var(--danger);
  color: var(--danger);
  font-size: 12px;
  border-radius: var(--radius-sm);
}
.modal--confirm .form-label {
  display: block;
  margin: 14px 0 6px;
  font-size: 12px;
  color: var(--text-mute);
}
.modal--confirm input[type="text"] {
  width: 100%;
  font-family: var(--mono);
}
.btn-warn {
  background: var(--warn);
  color: #0b0f16;
  border-color: var(--warn);
  font-weight: 600;
}
.btn-warn:hover { background: #ffcd45; }

.text-mute  { color: var(--text-mute); }
.text-dim   { color: var(--text-dim); }
.mono       { font-family: var(--mono); }
.flex       { display: flex; }
.flex-col   { display: flex; flex-direction: column; }
.gap-8      { gap: 8px; }
.gap-12     { gap: 12px; }
.mt-8       { margin-top: 8px; }
.mt-16      { margin-top: 16px; }
.mb-8       { margin-bottom: 8px; }
.hidden     { display: none !important; }


/* ══════════════════════════════════════════════════════════════════════
 *  Shared modal form primitives (used by bots page, later phases too)
 * ════════════════════════════════════════════════════════════════════ */
/* Sectioned padding via negative margins: .modal keeps padding:20px for
 * the body area, but the head + foot pull outside that padding so their
 * borders span edge-to-edge — matches mockup tpl-* templates. No change
 * needed in modals that don't wrap their content in .modal__body. */
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 14px;
  margin: -20px -20px 18px;
  border-bottom: 1px solid var(--border);
}
.modal__head h2 {
  margin: 0;
  font-size: 14px;
  font-family: var(--mono);
  font-weight: 600;
  flex: 1;
}
.modal__foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 20px 16px;
  margin: 14px -20px -20px;
  border-top: 1px solid var(--border);
}
.modal--wide { max-width: 720px; }

.form-label {
  display: block;
  margin: 14px 0 6px;
  font-size: 12px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.form-label:first-child { margin-top: 0; }
.form-label input[type="checkbox"] { margin-right: 6px; }
.form-hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-mute);
}
.form-hint.is-warn {
  color: var(--warn);
}

.btn-sm { padding: 4px 9px; font-size: 12px; }

/* Swatches + chips shared across pages */
.bot-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #0b0f16;
  font-weight: 700;
  font-size: 11px;
  flex-shrink: 0;
}
.color-chip {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 6px;
  border: 1px solid rgba(255,255,255,0.12);
}
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-3);
  font-size: 11px;
  color: var(--text-mute);
  border: 1px solid var(--border-soft);
}
.pill--online  { color: var(--accent); border-color: var(--accent-soft); }
.pill--working { color: var(--info);   border-color: var(--info-soft); }
.pill--offline { color: var(--text-dim); }
.pill--team    { color: var(--bot);    border-color: var(--bot-soft); background: var(--bot-soft); }

.warn-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--warn-soft);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text);
}

.flex-spacer { flex: 1; }


/* ══════════════════════════════════════════════════════════════════════
 *  Sessions manager modal  (Phase 6.11g — mockup-as-template)
 *  Matches mockups/sessions_manager.html. Opened globally via
 *  openSessionPicker(bot); can appear on top of any page, so it lives
 *  in core.css rather than a per-page sheet.
 * ════════════════════════════════════════════════════════════════════ */
.spm-backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: fixed;
  inset: 0;
  z-index: 500;
}
.spm-modal {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.7);
  padding: 0;
}
.spm-modal .modal-header {
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  margin: 0;
}
.spm-modal .modal-header .bot-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-3);
  border: 1.5px solid var(--bot);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--bot);
  flex-shrink: 0;
}
.spm-modal .modal-header .info { flex: 1; min-width: 0; }
.spm-modal .modal-header .title {
  font-size: 14px;
  font-family: var(--mono);
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
.spm-modal .modal-header .subtitle {
  font-size: 10.5px;
  color: var(--text-mute);
  font-family: var(--mono);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.spm-modal .modal-header .close {
  background: 0;
  border: 0;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 4px;
}
.spm-modal .modal-header .close:hover { background: var(--bg-3); color: var(--text); }

.spm-modal .modal-toolbar {
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.spm-modal .modal-toolbar .pill {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-mute);
  padding: 3px 9px;
  border-radius: 10px;
  font-size: 10px;
  cursor: pointer;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.spm-modal .modal-toolbar .pill.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}
.spm-modal .modal-toolbar .pill:hover:not(.active) { border-color: var(--text-dim); }
.spm-modal .modal-toolbar .pill.danger {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}
.spm-modal .modal-toolbar .pill.danger:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--danger);
}
.spm-modal .modal-toolbar .spacer { flex: 1; }
.spm-modal .modal-toolbar .toolbar-stat {
  font-size: 10px;
  color: var(--text-dim);
  font-family: var(--mono);
}

.spm-modal .modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px 16px;
}

.spm-modal .btn {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 10px;
  font-weight: 500;
  font-family: var(--sans);
  transition: background 0.1s;
}
.spm-modal .btn:hover { background: var(--bg-3); }
.spm-modal .btn.primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}
.spm-modal .btn.primary:hover { background: #5af029; }
.spm-modal .btn.danger {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.4);
}
.spm-modal .btn.danger:hover { background: rgba(239, 68, 68, 0.1); }
.spm-modal .btn.sm { padding: 2px 7px; font-size: 9px; }

/* Session cards */
.spm-modal .session-card {
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
  transition: border-color 0.15s;
}
.spm-modal .session-card:hover { border-color: var(--border); }
.spm-modal .session-card.active-session { border-color: var(--accent); }
.spm-modal .session-card.throwaway { opacity: 0.6; }
.spm-modal .session-card.throwaway:hover { opacity: 1; }

.spm-modal .sc-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
}
.spm-modal .sc-head .sc-icon {
  font-size: 13px;
  flex-shrink: 0;
}
.spm-modal .sc-head .sc-info {
  flex: 1;
  min-width: 0;
}
.spm-modal .sc-head .sc-name {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.spm-modal .sc-head .sc-name .badge {
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
}
.spm-modal .sc-head .sc-name .badge.main      { background: var(--accent); color: #000; }
.spm-modal .sc-head .sc-name .badge.satellite { background: rgba(106, 169, 255, 0.15); color: var(--info); }
.spm-modal .sc-head .sc-name .badge.listener  { background: var(--bg-3); color: var(--text-dim); }
.spm-modal .sc-head .sc-name .badge.current   { background: var(--warn); color: #000; }
.spm-modal .sc-head .sc-meta {
  font-size: 9.5px;
  color: var(--text-dim);
  margin-top: 2px;
  font-family: var(--mono);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.spm-modal .sc-head .sc-meta .size { color: var(--text-mute); }
.spm-modal .sc-head .sc-actions {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
  align-items: center;
}
.spm-modal .sc-hint {
  font-size: 9px;
  color: var(--text-dim);
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-style: italic;
}

.spm-modal .sc-detail {
  padding: 0 14px 12px;
  border-top: 1px solid var(--border-soft);
  margin-top: 0;
}
.spm-modal .sc-stats {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  font-size: 9.5px;
  color: var(--text-dim);
  font-family: var(--mono);
  flex-wrap: wrap;
}
.spm-modal .sc-stats strong { color: var(--text-mute); }

.spm-modal .sc-preview {
  background: var(--bg);
  border-radius: 4px;
  padding: 8px 10px;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-mute);
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
}
.spm-modal .sc-preview.scrollable { max-height: 320px; }
.spm-modal .sc-preview.loading,
.spm-modal .sc-preview.error,
.spm-modal .sc-preview.empty {
  color: var(--text-dim);
  font-style: italic;
  max-height: none;
}
.spm-modal .sc-preview.error { color: var(--warn); font-style: normal; }
.spm-modal .sc-preview .pv-row {
  padding: 2px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.04);
}
.spm-modal .sc-preview .pv-row:last-child { border-bottom: none; }
.spm-modal .sc-preview .pv-role {
  color: var(--bot);
  font-weight: 500;
  margin-right: 4px;
}
.spm-modal .sc-preview .pv-user .pv-role { color: var(--accent); }
.spm-modal .sc-preview .pv-tool .pv-role { color: var(--info); }
.spm-modal .sc-preview .pv-detail { color: var(--text-dim); }
.spm-modal .sc-preview .who { color: var(--bot); font-weight: 500; }
.spm-modal .sc-preview .who.user { color: var(--accent); }

.spm-modal .sc-detail-actions {
  display: flex;
  gap: 5px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.spm-modal .rename-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  align-items: center;
}
.spm-modal .rename-row input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 10px;
  border-radius: var(--radius);
  outline: none;
}

.spm-modal .summary-card {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-top: 8px;
}
.spm-modal .summary-card .sum-label {
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 6px;
}
.spm-modal .summary-card .sum-text {
  font-size: 11px;
  color: var(--text);
  line-height: 1.5;
}
.spm-modal .summary-card .sum-actions {
  display: flex;
  gap: 5px;
  margin-top: 8px;
}

.spm-modal .runner-badge {
  font-size: 8px;
  background: var(--bg-3);
  color: var(--text-dim);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--mono);
}

.spm-modal .notif-empty,
.spm-modal .page-loading {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-mute);
  font-size: 12px;
}


/* ══════════════════════════════════════════════════════════════════════
 *  Form modal + chips-input primitives (shared by formModal.js, used by
 *  every page-level form modal: teams create/edit/add-member, bots
 *  create/edit/avatar, settings add-ref, etc.)
 *  Mirrors mockups/teams.html .modal-bg + .chips-input + .autocomplete.
 * ════════════════════════════════════════════════════════════════════ */

.form-modal-backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 401;
}
.form-modal {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.7);
  padding: 0;
  display: flex;
  flex-direction: column;
}
.form-modal .modal-header {
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}
.form-modal .modal-header h3 {
  margin: 0;
  font-size: 14px;
  font-family: var(--mono);
  font-weight: 600;
  flex: 1;
  color: var(--text);
}
.form-modal .modal-header .close {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 4px;
}
.form-modal .modal-header .close:hover { background: var(--bg-3); color: var(--text); }

.form-modal .modal-body {
  padding: 16px 20px;
  flex: 1;
  overflow-y: auto;
}
.form-modal .modal-footer {
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin: 0;
}
.form-modal .modal-footer .btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
}
.form-modal .modal-footer .btn.primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}
.form-modal .modal-footer .btn.primary:hover { background: #5af029; }

.form-modal__error {
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(239, 68, 68, 0.08);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 11px;
}

/* Form-groups inside the form modal */
.form-modal .form-group { margin-bottom: 14px; }
.form-modal .form-group:last-child { margin-bottom: 0; }
.form-modal .form-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  font-weight: 600;
  margin: 0 0 5px;
  font-family: var(--mono);
}
.form-modal .form-input,
.modal .form-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 12px;
  outline: none;
  box-sizing: border-box;
}
.form-modal .form-input:focus,
.modal .form-input:focus { border-color: var(--accent); }
.form-modal .form-input.mono,
.modal .form-input.mono { font-family: var(--mono); }
textarea.form-input { resize: vertical; min-height: 60px; }
.form-modal .form-select,
.modal .form-select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  outline: none;
  appearance: none;
  cursor: pointer;
  box-sizing: border-box;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.form-modal .form-select:focus,
.modal .form-select:focus { border-color: var(--accent); }
.form-modal .form-hint {
  font-size: 9.5px;
  color: var(--text-dim);
  margin-top: 4px;
}
.form-modal .form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}
.form-modal .form-check input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
}

/* Radio cards — the big clickable role selectors from tpl-add-member */
.form-modal .radio-card-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-modal .radio-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.1s;
}
.form-modal .radio-card:hover { border-color: var(--text-dim); }
.form-modal .radio-card.is-selected { border-color: var(--accent); }
.form-modal .radio-card input[type="radio"] {
  accent-color: var(--accent);
  margin-top: 2px;
}
.form-modal .radio-card .rc-body { flex: 1; }
.form-modal .radio-card .rc-title {
  font-size: 11px;
  color: var(--text);
  font-weight: 600;
}
.form-modal .radio-card .rc-title .rc-note {
  font-size: 9px;
  color: var(--warn);
  font-weight: 400;
}
.form-modal .radio-card .rc-desc {
  font-size: 9.5px;
  color: var(--text-mute);
  line-height: 1.4;
  margin-top: 2px;
}

/* Chips-input widget (used inside form-modal and also standalone) */
.chips-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 36px;
  cursor: text;
  align-items: center;
}
.chips-input:focus-within { border-color: var(--accent); }
.chips-input__list {
  display: contents;
}
.chips-input .chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 2px 8px 2px 8px;
  font-size: 10px;
  color: var(--bot);
  font-family: var(--mono);
  white-space: nowrap;
}
.chips-input .chip .x {
  cursor: pointer;
  color: var(--text-dim);
  font-size: 11px;
  margin-left: 2px;
  padding: 0 2px;
}
.chips-input .chip .x:hover { color: var(--danger); }
.chips-input .chip.team {
  color: var(--info);
  border-color: rgba(106, 169, 255, 0.3);
  background: rgba(106, 169, 255, 0.08);
}
.chips-input .chip.channel {
  color: var(--info);
  border-color: rgba(106, 169, 255, 0.25);
  background: rgba(106, 169, 255, 0.05);
}
.chips-input .chip.ref {
  color: var(--warn);
  border-color: rgba(240, 180, 41, 0.25);
  background: rgba(240, 180, 41, 0.06);
}
.chips-input .chips-input__field {
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 11px;
  outline: none;
  flex: 1;
  min-width: 100px;
  font-family: var(--mono);
  padding: 2px 4px;
}
.chips-input .chips-input__field::placeholder { color: var(--text-dim); }

/* Autocomplete dropdown below a chips-input */
.autocomplete {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 4px;
  max-height: 180px;
  overflow-y: auto;
  display: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.autocomplete.open { display: block; }
.ac-item {
  padding: 6px 10px;
  cursor: pointer;
  font-size: 11px;
  font-family: var(--mono);
  display: flex;
  align-items: center;
  gap: 8px;
}
.ac-item:hover { background: var(--bg-3); }
.ac-item .ac-type {
  font-size: 8.5px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  min-width: 44px;
}
.ac-item .ac-name { color: var(--bot); }
.ac-item .ac-name.team-name { color: var(--info); }

/* ── Refresh badge: loading state + "updated Ns ago" + ↻ button ────
 * Shared across any section h3 that renders runner-backed data.
 * Mount: <span class="refresh-badge">age <button class="refresh-btn">↻</button></span> */
.refresh-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 9px;
  color: var(--text-dim);
  font-family: var(--mono);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  margin-left: auto;
}
.refresh-badge.loading { color: var(--accent); }
.refresh-badge.loading::before {
  content: '';
  width: 8px;
  height: 8px;
  border: 1.5px solid var(--accent);
  border-right-color: transparent;
  border-radius: 50%;
  animation: refresh-spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes refresh-spin { to { transform: rotate(360deg); } }
.refresh-btn {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 11px;
  padding: 0 3px;
  line-height: 1;
  border-radius: 3px;
}
.refresh-btn:hover { color: var(--accent); background: var(--accent-soft); }
.refresh-age.stale { color: var(--warn); }

/* ── Plan modal (components/planModal.js) ───────────────────────── */
.plan-modal { max-width: 640px; }
.plan-modal .modal-header { gap: 10px; align-items: flex-start; }
.plan-modal .plan-state-pill {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 9px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 2px;
}
.plan-modal .plan-state-pill.draft          { background: var(--bg-2); color: var(--text-mute); }
.plan-modal .plan-state-pill.ready          { background: rgba(240, 180, 41, 0.15); color: var(--warn); }
.plan-modal .plan-state-pill.pending       { background: rgba(240, 180, 41, 0.2); color: var(--warn); }
.plan-modal .plan-state-pill.pending_review { background: rgba(240, 180, 41, 0.2); color: var(--warn); }
.plan-modal .plan-state-pill.shared         { background: rgba(68, 224, 32, 0.15); color: var(--accent); }
.plan-modal .plan-state-pill.active         { background: rgba(31, 210, 255, 0.15); color: var(--info); }
.plan-modal .plan-state-pill.archived       { background: var(--bg-1); color: var(--text-dim); }
.plan-modal .modal-header .info .title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}
.plan-modal .modal-header .info .subtitle {
  font-size: 10px;
  color: var(--text-dim);
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.plan-modal .modal-body {
  padding: 14px 18px;
  overflow-y: auto;
  max-height: calc(85vh - 170px);
}

.plan-modal .plan-modal-timeline {
  border-left: 2px solid var(--border-soft);
  padding-left: 14px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.plan-modal .plan-step {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  position: relative;
}
.plan-modal .plan-step .step-marker {
  position: absolute;
  left: -23px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-1);
  border: 2px solid var(--border-soft);
  color: var(--text-dim);
  font-size: 9px;
  font-family: var(--mono);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.plan-modal .plan-step.done .step-marker {
  background: rgba(68, 224, 32, 0.2);
  border-color: var(--accent);
  color: var(--accent);
}
.plan-modal .plan-step.active .step-marker {
  background: rgba(31, 210, 255, 0.18);
  border-color: var(--info);
  color: var(--info);
}
.plan-modal .plan-step .step-text-wrap { flex: 1; }
.plan-modal .plan-step .step-text {
  font-size: 11.5px;
  color: var(--text);
  line-height: 1.5;
}
.plan-modal .plan-step.done .step-text {
  color: var(--text-mute);
  text-decoration: line-through;
}
.plan-modal .plan-step .step-substep {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 2px;
  font-family: var(--mono);
}

.plan-modal .plan-modal-body-md {
  background: var(--bg-1);
  border-radius: 4px;
  padding: 12px 14px;
  font-size: 11px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border-soft);
}

.plan-modal .plan-mentions {
  margin-top: 10px;
  font-size: 10px;
  color: var(--text-dim);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.plan-modal .plan-mentions-label {
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-family: var(--mono);
  font-size: 9px;
  margin-right: 4px;
}
.plan-modal .plan-mentions .mention {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
}

.plan-modal .plan-modal-footer {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 10px 16px;
  border-top: 1px solid var(--border-soft);
}
.plan-modal .plan-modal-footer .spacer { flex: 1; }
.plan-modal .plan-foot-note {
  font-size: 10px;
  color: var(--text-dim);
  font-style: italic;
}
.plan-modal .btn.danger {
  color: var(--danger, #ef4444);
  border-color: rgba(239, 68, 68, 0.3);
}
.plan-modal .btn.danger:hover { background: rgba(239, 68, 68, 0.08); }

/* ── Logs modal (components/logsModal.js) ───────────────────────── */
.logs-modal { max-width: 900px; width: 90vw; max-height: 88vh; display: flex; flex-direction: column; }
.logs-modal .modal-header { gap: 10px; align-items: center; }
.logs-modal .modal-header .info { flex: 1; }
.logs-modal .modal-header .info .title { font-size: 13px; font-weight: 600; color: var(--text); }
.logs-modal .modal-header .info .subtitle { font-size: 10px; color: var(--text-dim); margin-top: 2px; }
.logs-modal .logs-toolbar { display: flex; gap: 6px; align-items: center; }
.logs-modal .logs-toolbar select {
  background: var(--bg-1);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 3px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-family: var(--mono);
}
.logs-modal .modal-body { overflow: hidden; flex: 1; padding: 0; }
.logs-modal .logs-pre {
  margin: 0;
  padding: 14px 18px;
  height: 100%;
  max-height: calc(88vh - 70px);
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Doc viewer modal — authed fetch + inline rendering so bots'
 * bipper_share_doc uploads can be read without a second auth hop. */
.doc-modal { max-width: 900px; width: min(90vw, 900px); }
.doc-modal .modal-header { gap: 10px; align-items: center; }
.doc-modal .doc-icon {
  font-size: 20px; line-height: 1; flex-shrink: 0;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 4px;
}
.doc-modal .modal-header .info { flex: 1; min-width: 0; }
.doc-modal .modal-header .info .title {
  font-family: var(--mono); font-size: 13px; font-weight: 600;
  color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.doc-modal .modal-header .info .subtitle {
  font-size: 10px; color: var(--text-dim); margin-top: 2px;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.doc-modal .modal-body {
  padding: 0;
  max-height: calc(85vh - 60px);
  overflow: auto;
}
.doc-code {
  margin: 0;
  padding: 16px 20px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  white-space: pre-wrap;
  word-break: break-word;
}
.doc-md {
  padding: 20px 24px;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.65;
}
.doc-md h1, .doc-md h2, .doc-md h3, .doc-md h4, .doc-md h5, .doc-md h6 {
  color: var(--text); margin: 16px 0 8px; font-weight: 600; line-height: 1.3;
}
.doc-md h1 { font-size: 18px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.doc-md h2 { font-size: 16px; }
.doc-md h3 { font-size: 14px; color: var(--accent); }
.doc-md h4 { font-size: 13px; }
.doc-md p { margin: 8px 0; }
.doc-md strong { color: var(--text); font-weight: 600; }
.doc-md em { font-style: italic; }
.doc-md ul { margin: 8px 0; padding-left: 22px; }
.doc-md li { margin: 3px 0; }
.doc-md code {
  font-family: var(--mono);
  background: var(--bg-2);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  color: var(--info);
}
.doc-md pre.dm-code {
  margin: 10px 0;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow-x: auto;
  font-size: 11px;
  line-height: 1.5;
}
.doc-md pre.dm-code code { background: transparent; padding: 0; color: var(--text); }
.doc-md a { color: var(--info); text-decoration: underline; }
.doc-md a:hover { color: var(--accent); }
.doc-inline-img, .doc-inline-video {
  max-width: 100%; display: block; margin: 0 auto;
}
.doc-inline-pdf { width: 100%; height: 80vh; border: 0; }

/* Channel members picker — per-bot checkbox list. Sits over the
 * teams-based membership so you can toggle one bot without touching
 * the whole team. */
.ch-mem-modal { max-width: 520px; width: min(92vw, 520px); }
.ch-mem-modal .modal-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; max-height: 70vh; }
.ch-mem-modal .ch-mem-search {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-family: var(--mono);
  box-sizing: border-box;
}
.ch-mem-modal .ch-mem-search:focus { outline: none; border-color: var(--accent); }
.ch-mem-modal .ch-mem-list {
  max-height: 55vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: -4px;
  padding: 4px;
}
.ch-mem-modal .ch-mem-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  transition: background 0.12s;
}
.ch-mem-modal .ch-mem-row:hover { background: var(--bg-2); }
.ch-mem-modal .ch-mem-row.checked { background: rgba(68, 224, 32, 0.08); }
.ch-mem-modal .ch-mem-row input[type="checkbox"] {
  width: 14px; height: 14px; cursor: pointer; accent-color: var(--accent);
}
.ch-mem-modal .ch-mem-swatch {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.ch-mem-modal .ch-mem-name { flex: 1; }
.ch-mem-modal .ch-mem-meta {
  font-size: 10px; color: var(--text-dim);
}
.ch-mem-modal .modal-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
