/* ═══════════════════════════════════════════════════════════════════════════
   COSMO 2.3 — Design System
   Aesthetic: Refined Observatory — warm ground, precise ink, deliberate accent
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=DM+Sans:ital,opsz,wght@0,9..40,300..700;1,9..40,300..700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Ground */
  --bg: #f4f1eb;
  --bg-alt: #faf8f4;
  --bg-soft: #eae7e0;
  --surface: rgba(255, 255, 255, 0.64);

  /* Ink */
  --text: #1a1a18;
  --text-secondary: #6b6860;
  --muted: #8a857c;

  /* Accent — deep petrol, used sparingly */
  --accent: #1a5c52;
  --accent-hover: #13443d;
  --accent-soft: rgba(26, 92, 82, 0.08);
  --accent-glow: rgba(26, 92, 82, 0.14);

  /* Warm signal */
  --warm: #c4873a;
  --warm-soft: rgba(196, 135, 58, 0.10);

  /* Status */
  --danger: #a33b2e;
  --danger-soft: rgba(163, 59, 46, 0.08);
  --success: #2d7a52;

  /* Surfaces */
  --border: rgba(26, 26, 24, 0.09);
  --border-strong: rgba(26, 26, 24, 0.16);
  --shadow: 0 1px 3px rgba(26, 26, 24, 0.04), 0 8px 24px rgba(26, 26, 24, 0.06);
  --shadow-sm: 0 1px 2px rgba(26, 26, 24, 0.05);
  --shadow-lg: 0 4px 12px rgba(26, 26, 24, 0.03), 0 20px 48px rgba(26, 26, 24, 0.08);

  /* Console / dark surfaces */
  --console-bg: #141a17;
  --console-text: #e8e5df;
  --console-muted: #706c64;
  --console-accent: #5db8a3;
  --console-border: rgba(255, 255, 255, 0.06);

  /* Radii — tighter, more architectural */
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;

  /* Typography */
  --display: "Instrument Serif", "Georgia", serif;
  --sans: "DM Sans", "Helvetica Neue", sans-serif;
  --mono: "JetBrains Mono", "SF Mono", "Consolas", monospace;

  /* Motion */
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-out: cubic-bezier(0, 0, 0.25, 1);
  --duration: 160ms;
  --duration-slow: 280ms;

  /* Query tab variable bridge — unifies the two design systems */
  --bg-primary: var(--bg-alt);
  --bg-secondary: var(--surface);
  --bg-tertiary: var(--bg-soft);
  --text-primary: var(--text);
  --text-secondary: var(--text-secondary);
  --text-muted: var(--muted);
  --border-color: var(--border);
  --accent-primary: var(--accent);
  --accent-color: var(--warm);
}

/* ── Reset ────────────────────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(circle at 86% 8%, rgba(26, 92, 82, 0.07), transparent 24%),
    linear-gradient(180deg, #fbfcfc 0%, #f6f7f5 46%, #f2f4f2 100%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, textarea, select {
  font: inherit;
}

button {
  border: 0;
}

.hidden {
  display: none !important;
}

/* ── Shell ────────────────────────────────────────────────────────────────── */

.app-shell {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  width: 100%;
  min-height: 100vh;
  margin: 0;
}

.workspace-shell {
  min-width: 0;
  padding: 12px 30px 40px;
}

.workspace-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.refresh-shell-btn {
  min-width: 112px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid rgba(26, 92, 82, 0.22);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

/* ── COSMO23 rail ────────────────────────────────────────────────────────── */

.side-rail {
  position: sticky;
  top: 0;
  min-height: 100vh;
  padding: 28px 18px 22px;
  color: #eafcff;
  background:
    radial-gradient(circle at 15% 7%, rgba(26, 215, 255, 0.22), transparent 17%),
    radial-gradient(circle at 78% 56%, rgba(31, 186, 153, 0.17), transparent 23%),
    linear-gradient(180deg, #051923 0%, #04181f 54%, #021316 100%);
  box-shadow: 12px 0 36px rgba(5, 26, 37, 0.12);
  overflow-y: auto;
}

.side-rail::after {
  content: "";
  position: absolute;
  inset: auto 20px 0;
  height: 180px;
  background: radial-gradient(circle, rgba(28, 211, 186, 0.15), transparent 66%);
  pointer-events: none;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 28px;
}

.brand-orbit {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(91, 230, 255, 0.8);
  display: grid;
  place-items: center;
  box-shadow: 0 0 28px rgba(32, 199, 255, 0.4), inset 0 0 20px rgba(32, 199, 255, 0.2);
}

.brand-orbit span {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #55e3ff;
  box-shadow: 0 0 18px #55e3ff;
}

.brand-name {
  font-size: 25px;
  line-height: 1;
  font-weight: 800;
}

.brand-subtitle,
.side-section-title {
  margin-top: 8px;
  color: #6ef1df;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.25;
}

.side-nav,
.side-section {
  display: grid;
  gap: 10px;
}

.side-nav {
  margin-bottom: 22px;
}

.side-nav-btn,
.space-link,
.review-update {
  color: inherit;
  text-decoration: none;
}

.side-nav-btn,
.space-link {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: rgba(234, 252, 255, 0.9);
  font-weight: 700;
  cursor: pointer;
  padding: 0 12px;
  text-align: left;
}

.side-nav-btn:hover,
.space-link:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(118, 246, 226, 0.12);
}

.side-nav-btn.active {
  color: #f8ffff;
  background: rgba(23, 156, 132, 0.44);
  border-color: rgba(80, 239, 217, 0.2);
  box-shadow: inset 3px 0 0 #70f1e5, 0 12px 28px rgba(24, 184, 151, 0.11);
}

.side-nav-btn.disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.side-icon,
.space-mark {
  width: 22px;
  color: #8df7eb;
  font-size: 18px;
  text-align: center;
}

.side-section {
  padding-top: 16px;
  border-top: 1px solid rgba(142, 247, 235, 0.24);
}

.side-section-title {
  color: rgba(234, 252, 255, 0.72);
  font-size: 13px;
  margin: 0 0 6px;
}

.space-link {
  position: relative;
  min-height: 44px;
  border-color: rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.03);
}

.space-link.active {
  background: rgba(23, 156, 132, 0.46);
  border-color: rgba(80, 239, 217, 0.18);
  box-shadow: 0 18px 38px rgba(24, 184, 151, 0.16);
}

.space-link strong {
  margin-left: auto;
  padding: 3px 10px;
  border-radius: 999px;
  color: #70f1e5;
  background: rgba(112, 241, 229, 0.14);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.space-link:not(.active) strong {
  color: #ffd56e;
  background: rgba(255, 213, 110, 0.14);
}

.version-card {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(112, 241, 229, 0.28);
  border-radius: 14px;
  background: rgba(3, 36, 42, 0.64);
  box-shadow: inset 0 0 24px rgba(112, 241, 229, 0.05);
}

.version-card h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.version-line {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 10px 0;
  color: rgba(234, 252, 255, 0.9);
  font-weight: 600;
}

.ok-dot,
.info-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #23df87;
}

.info-dot {
  background: #43c7ff;
}

.review-update {
  margin-top: 18px;
  width: 100%;
  min-height: 40px;
  border: 1px solid rgba(112, 241, 229, 0.22);
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: rgba(0, 0, 0, 0.12);
  cursor: pointer;
}

/* ── Masthead ─────────────────────────────────────────────────────────────── */

.masthead {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.masthead h1,
.panel h2,
.map-scaffold h3,
.empty-state h3 {
  margin: 0;
  font-family: var(--sans);
  font-weight: 800;
  letter-spacing: 0;
}

.masthead h1 {
  font-size: clamp(2rem, 2.7vw, 2.55rem);
  line-height: 1.1;
}

.masthead-copy {
  max-width: 64ch;
}

.masthead-text {
  margin: 6px 0 0;
  line-height: 1.55;
  color: var(--text-secondary);
  font-size: 13.5px;
}

.masthead-status {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(190px, 1fr);
  gap: 14px;
  min-width: min(420px, 42%);
}

.status-card {
  min-height: 82px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 16px 18px;
}

.status-card span {
  color: var(--accent);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
}

.status-card span::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #04966d;
  margin-right: 9px;
}

.status-card strong {
  color: #0b1220;
  font-size: 17px;
  font-weight: 700;
}

.status-card strong.managed {
  color: var(--accent);
}

.eyebrow {
  margin: 0 0 4px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 500;
}

/* ── Navigation ───────────────────────────────────────────────────────────── */

.top-nav {
  display: none;
  gap: 10px;
  margin: 14px 0 12px;
  flex-wrap: nowrap;
  align-items: center;
  overflow-x: auto;
  padding-bottom: 8px;
}

.top-nav-btn,
.primary-btn,
.ghost-btn,
.danger-btn,
.filter-pill,
.detail-tab {
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

.top-nav-btn {
  background: transparent;
  color: #273142;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 56px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

.top-nav-btn span {
  color: currentColor;
  font-size: 18px;
  line-height: 1;
}

.top-nav-btn:hover {
  background: rgba(255, 255, 255, 0.72);
  border-color: var(--border);
  color: var(--accent);
}

.top-nav-btn.active {
  background: #fff;
  color: var(--accent);
  border-color: var(--border);
  box-shadow: var(--shadow);
  border-bottom-color: var(--accent);
  border-bottom-width: 3px;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
}

.primary-btn:hover {
  background: var(--accent-hover);
}

.top-nav-btn.active:hover {
  background: #fff;
  color: var(--accent);
}

.ghost-btn {
  background: var(--accent-soft);
  color: var(--accent);
}

.ghost-btn:hover {
  background: var(--accent-glow);
}

.danger-btn {
  background: var(--danger-soft);
  color: var(--danger);
}

.danger-btn:hover {
  background: rgba(163, 59, 46, 0.14);
}

/* ── Views ────────────────────────────────────────────────────────────────── */

.view {
  display: none;
}

.view.active {
  display: block;
}

.launch-layout,
.brains-layout,
.watch-layout {
  display: grid;
  gap: 16px;
}

.launch-layout {
  grid-template-columns: minmax(0, 1fr) minmax(340px, 430px);
  gap: 18px;
}

.brains-layout {
  grid-template-columns: minmax(310px, 360px) minmax(0, 1fr);
}

.watch-layout {
  grid-template-columns: minmax(240px, 0.85fr) minmax(0, 1fr) minmax(0, 1fr);
  align-items: stretch;
}

/* ── Panels ───────────────────────────────────────────────────────────────── */

.panel {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  padding: 24px 26px;
  min-width: 0;
  backdrop-filter: blur(14px);
}

.panel-feed {
  min-height: 620px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.panel-head-copy {
  max-width: 44ch;
  color: var(--text-secondary);
  line-height: 1.5;
  font-size: 13px;
}

.panel-title {
  margin: 0 0 12px;
  font-family: var(--sans);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0;
}

/* ── Chips, badges, cards ─────────────────────────────────────────────────── */

.status-chip,
.summary-card,
.mini-chip,
.source-badge {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.stat-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.status-chip {
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
}

.status-chip.subtle {
  color: var(--muted);
}

.summary-grid,
.brain-stats,
.watch-status-grid,
.overview-grid {
  display: grid;
  gap: 10px;
}

.summary-grid,
.brain-stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.summary-card {
  padding: 10px 12px;
}

.summary-label,
.stat-label,
.overview-card-label {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 500;
}

.summary-value,
.overview-card-value {
  font-weight: 600;
  font-size: 13px;
}

/* ── Forms ─────────────────────────────────────────────────────────────────── */

.form-stack,
.toolbar-stack {
  display: grid;
  gap: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.compact-grid {
  gap: 8px 10px;
}

.span-2 {
  grid-column: span 2;
}

.field {
  display: grid;
  gap: 4px;
}

.field > span {
  color: #111827;
  font-size: 12px;
  font-weight: 700;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--text);
  padding: 10px 12px;
  min-height: 42px;
  transition: border-color var(--duration) var(--ease);
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field textarea {
  min-height: 100px;
  resize: vertical;
}

.field-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 12.5px;
}

.catalog-codex-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-alt);
}

.catalog-codex-list .catalog-codex-empty {
  align-self: center;
}

.catalog-codex-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 100px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--accent);
  font-size: 12px;
  font-family: var(--mono);
  white-space: nowrap;
}

.provider-grid,
.toggle-grid {
  display: grid;
  gap: 8px;
}

.provider-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.toggle-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
  transition: border-color var(--duration) var(--ease);
}

.toggle-chip:hover {
  border-color: var(--border-strong);
}

.toggle-chip input {
  margin: 0;
}

/* ── Disclosure ───────────────────────────────────────────────────────────── */

.section-disclosure {
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  margin-top: 4px;
}

.section-disclosure summary {
  cursor: pointer;
  padding: 16px 0 8px;
  font-weight: 800;
  font-size: 13px;
  list-style: none;
}

.section-disclosure summary::-webkit-details-marker {
  display: none;
}

.section-disclosure summary::after {
  content: "Show";
  float: right;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.section-disclosure[open] summary::after {
  content: "Hide";
}

.disclosure-content {
  border-top: 1px solid var(--border);
  padding: 14px 0 0;
  display: grid;
  gap: 10px;
}

/* ── Provider sections ────────────────────────────────────────────────────── */

.provider-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 0;
  margin: 0;
}

.provider-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
}

.provider-section-head .toggle-chip {
  border: none;
  background: transparent;
  padding: 0;
  min-height: auto;
}

.provider-section-body {
  border-top: 1px solid var(--border);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.provider-section-body[hidden] {
  display: none;
}

.provider-status-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 0;
  margin-bottom: 4px;
}

.provider-status-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

.provider-status-dot .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.provider-status-dot[data-state="connected"] .dot { background: var(--success); }
.provider-status-dot[data-state="connected"] { color: var(--text-secondary); }
.provider-status-dot[data-state="partial"] .dot { background: var(--warm); }
.provider-status-dot[data-state="missing"] .dot { background: var(--danger); }
.provider-status-dot[data-state="disabled"] .dot { background: var(--muted); opacity: 0.4; }
.provider-status-dot[data-state="disabled"] { opacity: 0.5; }

.provider-status-indicator {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--muted);
}

.provider-status-indicator[data-state="connected"] { color: var(--success); }
.provider-status-indicator[data-state="partial"] { color: var(--warm); }
.provider-status-indicator[data-state="missing"] { color: var(--danger); }

.provider-primary-action {
  display: grid;
  gap: 6px;
}

.provider-primary-action .primary-btn {
  width: 100%;
}

.oauth-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  font-size: 12px;
}

.oauth-status .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.oauth-status.expired .dot { background: var(--warm); }

.oauth-status .oauth-info {
  flex: 1;
  color: var(--text-secondary);
}

.oauth-status:empty { display: none; }

.compact-disclosure {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.compact-disclosure summary {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
  list-style: none;
}

.compact-disclosure summary::-webkit-details-marker { display: none; }

.compact-disclosure summary::after {
  content: "Show";
  float: right;
  color: var(--muted);
  font-size: 11px;
}

.compact-disclosure[open] summary::after { content: "Hide"; }

.compact-disclosure .disclosure-content {
  border-top: 1px solid var(--border);
  padding: 10px;
  display: grid;
  gap: 8px;
}

/* ── Action rows ──────────────────────────────────────────────────────────── */

.form-actions,
.action-row,
.filter-row,
.detail-tab-row,
.brain-head-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.form-actions {
  justify-content: flex-end;
  align-items: center;
  margin-top: 4px;
}

.form-actions .primary-btn {
  min-width: 178px;
}

.launch-insights-panel {
  display: grid;
  gap: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.insight-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  padding: 24px;
}

.insight-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.insight-card-head.compact {
  justify-content: space-between;
  gap: 14px;
}

.insight-card h2 {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 800;
}

.insight-icon,
.glance-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.insight-icon {
  width: 28px;
  height: 28px;
  color: var(--accent);
  font-size: 25px;
}

.glance-list {
  display: grid;
  gap: 18px;
}

.glance-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.glance-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 18px;
}

.glance-icon.warm {
  color: #9b672a;
  background: rgba(196, 135, 58, 0.16);
}

.glance-icon.cool {
  color: var(--accent);
  background: rgba(26, 92, 82, 0.12);
}

.glance-item strong,
.recent-run-row strong {
  display: block;
  color: #111827;
  font-weight: 800;
}

.glance-item span,
.recent-run-row small,
.provider-mini-summary span {
  display: block;
  color: var(--text-secondary);
  line-height: 1.4;
}

.provider-mini-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.provider-mini-summary strong {
  color: var(--accent);
  font-size: 20px;
  font-weight: 800;
}

.recent-runs-list {
  display: grid;
}

.recent-run-row {
  width: 100%;
  min-height: 68px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px 10px;
  border-top: 1px solid var(--border);
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.recent-run-row:first-child {
  border-top: 0;
}

.recent-run-row:hover {
  background: rgba(26, 92, 82, 0.05);
}

.recent-run-row em {
  padding: 2px 10px;
  border-radius: 999px;
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.recent-run-row em.complete {
  color: var(--success);
  background: rgba(45, 122, 82, 0.11);
}

.recent-run-row em.active {
  color: #1770a6;
  background: rgba(67, 199, 255, 0.14);
}

.recent-run-row b {
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}

.link-btn {
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-weight: 800;
  padding: 0;
}

.recent-empty {
  color: var(--muted);
  padding: 18px 0 4px;
}

/* ── Brain library ────────────────────────────────────────────────────────── */

.brain-library-panel {
  max-height: calc(100vh - 335px);
  min-height: 560px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: sticky;
  top: 24px;
}

.brain-detail-panel {
  min-height: 560px;
  max-height: calc(100vh - 335px);
  overflow: auto;
}

.brain-filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.brain-location-select {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-alt);
  color: var(--text);
  font-size: 12px;
  font-family: var(--sans);
}

.library-count {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.filter-pill {
  background: transparent;
  color: var(--text-secondary);
}

.filter-pill:hover {
  background: var(--accent-soft);
}

.filter-pill.active,
.detail-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-glow);
}

.brain-library-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  min-width: 0;
  padding-right: 4px;
}

.activity-feed,
.console-feed,
.snapshot-list,
.overview-list {
  display: grid;
  gap: 6px;
}

.brain-card {
  display: grid;
  min-width: 0;
  width: 100%;
  gap: 3px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

.brain-card:hover {
  background: var(--surface);
  border-color: var(--border);
}

.brain-card.active {
  border-color: rgba(26, 92, 82, 0.28);
  background: var(--accent-soft);
}

.brain-card-head {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: center;
  min-width: 0;
  overflow: hidden;
}

.brain-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.brain-card-title {
  margin: 0;
  flex: 1;
  min-width: 0;
  max-width: 100%;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brain-card-copy {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brain-card-topic {
  font-weight: 400;
  color: var(--muted);
}

.brain-card-info {
  display: flex;
  gap: 10px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}

.brain-active-dot {
  color: var(--success);
}

.brain-chip-row {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  overflow: hidden;
}

.meta-chip-row {
  display: none;
}

.mini-chip,
.source-badge {
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
}

.source-badge {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: transparent;
  white-space: nowrap;
  font-size: 10px;
  flex-shrink: 0;
}

/* ── Empty state ──────────────────────────────────────────────────────────── */

.empty-state {
  min-height: 460px;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  color: var(--muted);
}

.empty-state p {
  margin: 0;
  max-width: 44ch;
  line-height: 1.55;
  font-size: 13px;
}

/* ── Brain detail ─────────────────────────────────────────────────────────── */

.brain-detail-shell {
  display: grid;
  gap: 14px;
}

.brain-detail-panel,
.hub-preview,
.intel-content,
#view-query > .panel,
#view-map > .panel,
.interactive-panel {
  min-height: calc(100vh - 335px);
}

.brain-detail-head {
  align-items: center;
}

.detail-tab-row {
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.detail-tab {
  background: transparent;
  color: var(--text-secondary);
}

.detail-tab-panel {
  display: none;
}

.detail-tab-panel.active {
  display: block;
}

.overview-section {
  display: grid;
  gap: 8px;
}

.overview-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.overview-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.overview-card-value {
  line-height: 1.5;
  font-size: 13px;
}

.overview-list,
.snapshot-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.overview-list li,
.snapshot-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
}

.snapshot-item-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 4px;
}

.snapshot-item-copy {
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.5;
}

/* ── Continue ─────────────────────────────────────────────────────────────── */

.continue-intro,
.query-brain-bar {
  display: grid;
  gap: 12px;
}

.continue-intro {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  margin-bottom: 12px;
}

.continue-intro h3,
.map-scaffold h4 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
}

.continue-intro p,
.map-scaffold-copy p {
  margin: 4px 0 0;
  color: var(--text-secondary);
  line-height: 1.5;
  font-size: 13px;
}

/* ══════════════════════════════════════════════════════════════════════════
   Brain Map
   ══════════════════════════════════════════════════════════════════════════ */

.map-scaffold {
  display: grid;
  gap: 10px;
  height: 100%;
}

.map-scaffold-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.map-head-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.map-toolbar {
  display: none;
  gap: 3px;
  align-items: center;
}
.map-toolbar.visible { display: flex; }

.map-toolbar-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-alt);
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all var(--duration) var(--ease);
}
.map-toolbar-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(26, 92, 82, 0.2);
}

.map-brain-bar {
  margin-bottom: 12px;
  max-width: 360px;
}

.map-canvas-wrap {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  height: clamp(420px, calc(100vh - 500px), 620px);
  min-height: 0;
  background: var(--console-bg);
}

.map-canvas {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.map-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 100%;
  min-height: 500px;
  color: var(--console-muted);
  font-family: var(--mono);
  font-size: 12px;
}

.map-loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--console-border);
  border-top-color: var(--console-accent);
  border-radius: 50%;
  animation: map-spin 0.8s linear infinite;
}

@keyframes map-spin {
  to { transform: rotate(360deg); }
}

.map-empty {
  display: grid;
  place-items: center;
  height: 100%;
  min-height: 500px;
  color: var(--console-muted);
  font-family: var(--mono);
  font-size: 12px;
}

/* ── Node detail panel ──────────────────────────────────────── */

.map-detail-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 320px;
  height: 100%;
  background: rgba(20, 26, 23, 0.97);
  backdrop-filter: blur(16px);
  border-left: 1px solid var(--console-border);
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform var(--duration-slow) var(--ease-out);
  z-index: 10;
  padding: 18px;
  box-sizing: border-box;
}
.map-detail-panel.open {
  transform: translateX(0);
}

.map-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.map-detail-tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0;
  font-weight: 500;
  text-transform: uppercase;
}

.map-detail-close {
  background: none;
  border: none;
  color: var(--console-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color var(--duration) var(--ease);
}
.map-detail-close:hover { color: var(--console-text); }

.map-detail-concept {
  color: var(--console-text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--console-border);
}

.map-detail-meta {
  display: grid;
  gap: 5px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--console-border);
}

.map-meta-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
}

.map-meta-label { color: var(--console-muted); }
.map-meta-value { color: var(--console-accent); }

.map-detail-connections {
  margin-bottom: 14px;
}

.map-connections-title {
  color: var(--console-muted);
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 500;
  margin-bottom: 6px;
}

.map-connection-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  padding: 5px 7px;
  border: none;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  margin-bottom: 2px;
  transition: background var(--duration) var(--ease);
}
.map-connection-item:hover {
  background: rgba(255, 255, 255, 0.07);
}

.map-connection-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}

.map-connection-type {
  color: var(--console-muted);
  font-family: var(--mono);
  font-size: 10px;
  flex-shrink: 0;
  width: 82px;
}

.map-connection-label {
  color: rgba(232, 229, 223, 0.7);
  font-family: var(--sans);
  font-size: 11.5px;
  line-height: 1.4;
}

.map-detail-actions {
  padding-top: 10px;
}

.map-action-btn {
  width: 100%;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--duration) var(--ease);
}
.map-action-btn:hover { background: var(--accent-hover); }

/* ══════════════════════════════════════════════════════════════════════════
   Intelligence View
   ══════════════════════════════════════════════════════════════════════════ */

.intel-layout {
  display: grid;
  grid-template-columns: minmax(200px, 240px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.intel-sidebar {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 335px);
  overflow: auto;
}

.intel-brain-bar {
  margin-bottom: 14px;
}

.intel-nav {
  display: grid;
  gap: 2px;
}

.intel-tab {
  display: block;
  width: 100%;
  padding: 8px 12px;
  text-align: left;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

.intel-tab:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.intel-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.intel-content {
  overflow: hidden;
}

.intel-content-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.intel-content-body {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 440px);
  overflow: auto;
  padding-right: 4px;
}

.intel-empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 60px 20px;
}

/* ── Intel cards ──────────────────────────────────────────── */

.intel-card {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.intel-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}

.intel-card-title {
  font-weight: 600;
  font-size: 13px;
  margin: 0;
}

.intel-card-meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.intel-card-body {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.intel-card-body pre {
  background: var(--console-bg);
  color: var(--console-text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Status badges ────────────────────────────────────────── */

.intel-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0;
}

.intel-badge-done { background: rgba(45, 122, 82, 0.1); color: var(--success); }
.intel-badge-active { background: var(--accent-soft); color: var(--accent); }
.intel-badge-pending { background: var(--warm-soft); color: var(--warm); }
.intel-badge-failed { background: var(--danger-soft); color: var(--danger); }
.intel-badge-blocked { background: rgba(138, 133, 124, 0.1); color: var(--muted); }

/* ── Stat row ─────────────────────────────────────────────── */

.intel-stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.intel-stat {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.intel-stat-label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--muted);
  margin-bottom: 2px;
}

.intel-stat-value {
  font-size: 18px;
  font-family: var(--display);
  color: var(--text);
}

/* ── Executive ring ──────────────────────────────────────── */

.exec-coherence-bar {
  height: 10px;
  border-radius: 5px;
  background: var(--border);
  overflow: hidden;
  margin-top: 6px;
}

.exec-coherence-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 300ms var(--ease), background 300ms var(--ease);
}

.exec-coherence-fill[data-zone="healthy"] { background: var(--success); }
.exec-coherence-fill[data-zone="warning"] { background: var(--warm); }
.exec-coherence-fill[data-zone="critical"] { background: var(--danger); }

.exec-timeline {
  display: grid;
  gap: 6px;
}

.exec-timeline-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.exec-timeline-item:last-child { border-bottom: none; }

.exec-timeline-cycle {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  min-width: 40px;
}

.exec-actions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.exec-actions-table th {
  text-align: left;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--muted);
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
}

.exec-actions-table td {
  padding: 5px 8px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.exec-section {
  display: grid;
  gap: 12px;
}

/* ── Review quality scores ───────────────────────────────── */

.review-quality-scores {
  display: flex;
  gap: 6px;
}

.review-score {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0;
}

.review-score[data-quality="high"] { background: rgba(45, 122, 82, 0.12); color: var(--success); }
.review-score[data-quality="mid"] { background: var(--warm-soft); color: var(--warm); }
.review-score[data-quality="low"] { background: var(--danger-soft); color: var(--danger); }
.review-score[data-quality="none"] { background: rgba(138, 133, 124, 0.08); color: var(--muted); }

.review-summary-section {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.review-summary-section h5 {
  font-size: 11px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--muted);
  margin: 8px 0 4px;
}

.review-summary-section ul {
  margin: 0;
  padding-left: 16px;
}

.review-summary-section li {
  margin-bottom: 3px;
}

.goal-progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
}

.goal-progress-bar > div {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 300ms var(--ease);
}

.deliverable-file-list {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ── Markdown viewer ──────────────────────────────────────── */

.intel-markdown {
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
}

.intel-markdown h1,
.intel-markdown h2,
.intel-markdown h3 {
  font-family: var(--display);
  font-weight: 400;
  margin: 18px 0 8px;
}

.intel-markdown h1 { font-size: 20px; }
.intel-markdown h2 { font-size: 17px; }
.intel-markdown h3 { font-size: 15px; }
.intel-markdown p { margin: 0 0 8px; }

.intel-markdown code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg-soft);
  padding: 1px 5px;
  border-radius: 3px;
}

.intel-markdown pre code {
  background: var(--console-bg);
  color: var(--console-text);
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

/* ── Clickable insight/review ─────────────────────────────── */

.intel-clickable {
  cursor: pointer;
  transition: border-color var(--duration) var(--ease);
}

.intel-clickable:hover {
  border-color: var(--border-strong);
}

/* ══════════════════════════════════════════════════════════════════════════
   Watch View
   ══════════════════════════════════════════════════════════════════════════ */

.watch-status-grid {
  grid-template-columns: 1fr;
}

.stat-card {
  padding: 12px;
}

.activity-feed,
.console-feed {
  max-height: calc(100vh - 455px);
  min-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

#view-watch .panel:first-child {
  align-self: stretch;
}

#view-watch .panel-feed {
  min-height: calc(100vh - 335px);
}

.feed-item {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
}

.feed-time {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  margin-bottom: 4px;
}

.feed-body {
  line-height: 1.5;
  font-size: 13px;
}

.console-line {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--console-border);
  background: var(--console-bg);
  color: var(--console-text);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.console-line.error {
  background: #1f1210;
  border-color: rgba(163, 59, 46, 0.25);
}

.console-line-head {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--console-accent);
  margin-bottom: 4px;
  font-weight: 500;
}

/* ── Query ────────────────────────────────────────────────────────────────── */

.query-brain-bar {
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  margin-bottom: 14px;
}

.query-brain-note {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  line-height: 1.5;
  font-size: 12.5px;
}

.query-tab-host {
  min-height: calc(100vh - 470px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.52);
}

/* ── Toast ────────────────────────────────────────────────────────────────── */

.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 6px;
  z-index: 50;
}

.toast {
  max-width: min(340px, calc(100vw - 32px));
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--console-bg);
  color: var(--console-text);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  border: 1px solid var(--console-border);
}

.toast.error {
  background: #2a1410;
  border-color: rgba(163, 59, 46, 0.3);
}

/* ══════════════════════════════════════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 1200px) {
  .panel-feed {
    min-height: 420px;
  }

  #view-launch .launch-layout > section.panel .panel-head {
    flex-direction: column;
  }
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-rail {
    position: relative;
    min-height: auto;
    padding: 22px;
  }

  .brand-lockup {
    margin-bottom: 22px;
  }

  .side-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 18px;
  }

  .side-section {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: center;
  }

  .side-section-title {
    grid-column: 1 / -1;
  }

  .version-card {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    margin-top: 18px;
  }
}

@media (max-width: 900px) {
  .app-shell {
    width: 100%;
    margin: 0;
  }

  .workspace-shell {
    padding: 14px;
  }

  .masthead {
    padding: 16px;
    flex-direction: column;
    align-items: stretch;
  }

  .masthead-status {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .summary-grid,
  .launch-layout,
  .brains-layout,
  .watch-layout,
  .intel-layout,
  .hub-layout,
  .brain-stats,
  .overview-grid,
  .watch-status-grid,
  .toggle-grid,
  .provider-grid,
  .query-brain-bar {
    grid-template-columns: 1fr;
  }

  .top-nav-btn {
    flex: 0 0 auto;
  }

  .brain-library-panel,
  .hub-sidebar,
  .intel-sidebar {
    position: static;
    max-height: none;
  }

  .brain-library-list,
  .hub-brain-list,
  .intel-content-body,
  .activity-feed,
  .console-feed {
    max-height: none;
  }

  .continue-intro {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .panel {
    padding: 14px;
    border-radius: var(--radius-lg);
  }

  .panel-head,
  .brain-card-head,
  .brain-card-meta,
  .snapshot-item-head,
  .map-scaffold-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }

  .top-nav {
    display: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-x: visible;
  }

  .top-nav-btn {
    width: 100%;
  }

  .side-nav,
  .side-section {
    grid-template-columns: 1fr;
  }

  .brand-lockup {
    align-items: flex-start;
  }

  .brain-card-topic {
    display: none;
  }
}

@media (max-width: 480px) {
  .top-nav {
    display: none;
    grid-template-columns: 1fr;
  }

  .masthead h1 {
    font-size: 1.6rem;
  }

  .status-chip,
  .top-nav-btn,
  .primary-btn,
  .ghost-btn,
  .danger-btn,
  .filter-pill,
  .detail-tab,
  .toggle-chip {
    width: 100%;
    justify-content: center;
  }

  .action-row,
  .form-actions,
  .detail-tab-row,
  .brain-head-actions,
  .filter-row {
    display: grid;
    grid-template-columns: 1fr;
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   Interactive Chat
   ══════════════════════════════════════════════════════════════════════════ */

.interactive-layout {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: calc(100vh - 455px);
  min-height: 520px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.52);
  overflow: hidden;
}

.interactive-context-bar {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 16px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.interactive-context-bar strong {
  color: var(--text);
  font-weight: 600;
}

.interactive-messages {
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.interactive-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}

.interactive-msg-user {
  align-self: flex-end;
  background: var(--accent-soft);
  color: var(--text);
}

.interactive-msg-assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.interactive-msg-assistant pre {
  background: var(--console-bg);
  color: var(--console-text);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  margin: 6px 0;
}

.interactive-msg-assistant code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg-soft);
  padding: 1px 5px;
  border-radius: 3px;
}

.interactive-msg-assistant pre code {
  background: transparent;
  padding: 0;
}

.interactive-msg-system {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
  padding: 4px 0;
  max-width: 100%;
}

.interactive-msg-error {
  border-color: rgba(163, 59, 46, 0.25);
  background: var(--danger-soft);
  color: var(--danger);
}

.interactive-tool-card {
  align-self: center;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: rgba(26, 92, 82, 0.05);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  max-width: 90%;
}

.interactive-tool-card .tool-name {
  font-weight: 600;
  color: var(--accent);
}

.interactive-tool-card .tool-result {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 10px;
  line-height: 1.4;
}

.interactive-input-area {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
}

.interactive-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

#interactive-model {
  max-width: 260px;
  min-height: 36px;
  font-size: 0.82rem;
}

.interactive-status {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.interactive-compose {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.interactive-compose textarea {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-alt);
  color: var(--text);
  padding: 8px 10px;
  font-family: var(--sans);
  font-size: 13px;
  resize: none;
  min-height: 44px;
}

.interactive-compose textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.interactive-compose textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.interactive-compose .primary-btn {
  flex-shrink: 0;
  min-height: 44px;
}

.interactive-thinking {
  align-self: flex-start;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
  padding: 6px 0;
}

/* ══════════════════════════════════════════════════════════════════════════
   Hub View
   ══════════════════════════════════════════════════════════════════════════ */

.hub-layout {
  display: grid;
  grid-template-columns: minmax(310px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.hub-sidebar {
  max-height: calc(100vh - 335px);
  min-height: 560px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: sticky;
  top: 24px;
}

.hub-toolbar-actions {
  display: flex;
  gap: 6px;
}

.hub-brain-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  min-width: 0;
  padding-right: 4px;
  margin-top: 8px;
}

.hub-brain-item {
  display: flex;
  min-width: 0;
  width: 100%;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

.hub-brain-item:hover {
  background: var(--surface);
  border-color: var(--border);
}

.hub-brain-item-active {
  border-color: rgba(26, 92, 82, 0.28);
  background: var(--accent-soft);
}

.hub-brain-check {
  flex-shrink: 0;
  padding-top: 2px;
  cursor: pointer;
}

.hub-brain-check input {
  margin: 0;
  cursor: pointer;
}

.hub-brain-info {
  flex: 1;
  min-width: 0;
}

.hub-brain-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hub-brain-topic {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.hub-brain-meta {
  display: flex;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
}

/* ── Preview panel ──────────────────────────────────────────── */

.hub-preview {
  min-height: calc(100vh - 335px);
}

.hub-empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 60px 20px;
}

.hub-error {
  color: var(--danger);
}

.hub-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.hub-preview-header h3 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 20px;
}

.hub-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.hub-stat-card {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.hub-stat-label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--muted);
  margin-bottom: 2px;
}

.hub-stat-value {
  font-size: 18px;
  font-family: var(--display);
  color: var(--text);
}

.hub-preview-meta {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.hub-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}

.hub-meta-label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--muted);
  flex-shrink: 0;
}

.hub-meta-value {
  color: var(--text-secondary);
  text-align: right;
  word-break: break-all;
}

.hub-meta-path {
  font-family: var(--mono);
  font-size: 10px;
}

.hub-preview-actions {
  display: flex;
  gap: 6px;
}

/* ── Modal overlay ──────────────────────────────────────────── */

.hub-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  place-items: center;
}

.hub-modal-overlay.active {
  display: grid;
}

.hub-modal {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  max-width: 560px;
  width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  display: grid;
  gap: 14px;
}

.hub-modal h3 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 20px;
}

.hub-modal h4 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 16px;
}

.hub-modal-desc {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.hub-modal-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* ── Merge dialog ───────────────────────────────────────────── */

.hub-merge-brains {
  display: grid;
  gap: 4px;
}

.hub-merge-brain-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
}

.hub-merge-node-count {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}

.hub-merge-options {
  display: grid;
  gap: 10px;
}

.hub-threshold-slider {
  width: 100%;
  height: 6px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--border);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.hub-threshold-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-alt);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.hub-threshold-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-alt);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.hub-merge-preview-area {
  min-height: 0;
}

.hub-preview-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.hub-merge-progress-area {
  display: grid;
  gap: 8px;
}

.hub-merge-phase {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.hub-merge-progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.hub-merge-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  width: 0;
  transition: width 300ms var(--ease);
}

.hub-merge-status {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}

.hub-merge-complete {
  display: grid;
  gap: 12px;
}

.hub-merge-complete p {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ── Fork dialog ────────────────────────────────────────────── */

.hub-fork-types {
  display: flex;
  gap: 8px;
}

/* ── Responsive ─────────────────────────────────────────────── */

@media (max-width: 900px) {
  .hub-layout {
    grid-template-columns: 1fr;
  }

  .hub-sidebar {
    max-height: none;
    position: static;
  }
}

@media (max-width: 900px) {
  .hub-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .hub-preview-stats {
    grid-template-columns: 1fr;
  }
}

/* ── Ingest tab ──────────────────────────────────────────── */
.ingest-layout {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(300px, 1.2fr);
  gap: 20px;
  max-width: none;
}

.ingest-label-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.ingest-label-row label {
  font-family: var(--mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--text-secondary);
}

.ingest-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg);
}

.ingest-dropzone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.ingest-dropzone-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.ingest-dropzone-text {
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--text-secondary);
}

.ingest-dropzone-sub {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 8px 0;
}

.ingest-browse-btn {
  font-family: var(--sans);
  font-size: 0.85rem;
  padding: 6px 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  transition: all 0.15s ease;
}

.ingest-browse-btn:hover {
  background: var(--accent);
  color: #fff;
}

.ingest-upload-list {
  margin-top: 12px;
}

.ingest-upload-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  border-bottom: 1px solid var(--border-light, #eee);
}

.ingest-upload-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ingest-upload-size {
  color: var(--text-muted);
  font-size: 0.7rem;
  flex-shrink: 0;
}

.ingest-upload-status {
  flex-shrink: 0;
  font-size: 0.75rem;
  min-width: 100px;
  text-align: right;
}

.ingest-upload-status.status-ok { color: var(--accent); font-weight: 600; }
.ingest-upload-status.status-uploaded { color: var(--accent); }
.ingest-upload-status.status-ingesting { color: var(--warm); }
.ingest-upload-status.status-err { color: #c0392b; }
.ingest-upload-status.status-warn { color: var(--warm); }
.ingest-upload-status.status-pending { color: var(--text-muted); }

.ingest-stats {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.ingest-stat-sep {
  margin: 0 6px;
  color: var(--text-muted);
}

.ingest-file-list {
  overflow-y: auto;
  max-height: calc(100vh - 280px);
}

.ingest-file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border-light, #eee);
  font-size: 0.82rem;
}

.ingest-file-row:hover {
  background: var(--accent-soft);
}

.ingest-file-name {
  font-family: var(--mono);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

.ingest-file-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: 4px;
}

.ingest-file-nodes {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.ingest-file-time {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.ingest-file-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 2px 6px;
  border-radius: 4px;
}

.ingest-file-remove:hover {
  background: rgba(192, 57, 43, 0.1);
  color: #c0392b;
}

.ingest-empty-state {
  text-align: center;
  color: var(--text-muted);
  font-family: var(--sans);
  font-size: 0.9rem;
  padding: 40px 20px;
}

.ingest-no-run {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(244, 241, 235, 0.9);
  z-index: 10;
}

.ingest-no-run p {
  font-family: var(--display);
  font-size: 1.3rem;
  color: var(--text-secondary);
}

.tab-disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ── Managed by Home23 mode ──────────────────────────────────────────────── */

.status-chip.managed {
  color: var(--accent);
  font-weight: 600;
  border-color: var(--accent);
  background: var(--accent-soft);
}

.managed-mode-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  border: 1px solid rgba(26, 92, 82, 0.15);
}

.managed-mode-icon {
  flex-shrink: 0;
  color: var(--accent);
  margin-top: 1px;
}

.managed-mode-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  line-height: 1.45;
}

.managed-mode-text strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.managed-mode-text span {
  color: var(--text-secondary);
}

.managed-link {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(26, 92, 82, 0.3);
  text-underline-offset: 2px;
  font-weight: 500;
}

.managed-link:hover {
  text-decoration-color: var(--accent);
}

.managed-provider-grid {
  display: grid;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 8px 0;
}

.managed-provider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  background: var(--surface);
}

.managed-provider-row:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

.managed-provider-state {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0;
}

.managed-provider-state.connected {
  color: var(--success);
}

.managed-provider-state.disabled {
  color: var(--muted);
  opacity: 0.6;
}

#view-ingest {
  position: relative;
}
