/* Synapse Canvas — Glassmorphism design system
   Typography: Inter (variable weight)
   Spacing: 4px base grid (4, 8, 12, 16, 24, 32, 48)
   Colors: imported from palette.css */

/* palette.css is loaded via <link> in index.html for reliable loading */

/* ── Layout Tokens ────────────────────────────── */

:root {
  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-8: 48px;

  /* Typography — Inter variable with optical sizing */
  --font-display: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Fira Code", Menlo, monospace;

  /* Type scale — minor third (1.2) */
  --text-xs: 0.694rem;    /* 11.1px */
  --text-sm: 0.833rem;    /* 13.3px */
  --text-base: 1rem;      /* 16px */
  --text-lg: 1.2rem;      /* 19.2px */
  --text-xl: 1.44rem;     /* 23px */
  --text-2xl: 1.728rem;   /* 27.6px */
  --text-3xl: 2.074rem;   /* 33.2px */

  /* Line heights — tighter for headings, looser for body */
  --leading-tight: 1.15;
  --leading-snug: 1.3;
  --leading-normal: 1.5;
  --leading-relaxed: 1.7;

  /* Letter spacing */
  --tracking-tight: -0.025em;
  --tracking-normal: 0;
  --tracking-wide: 0.04em;
  --tracking-wider: 0.08em;

  /* Surfaces */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --sidebar-width: 220px;
  --sidebar-collapsed-width: 56px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;
}

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

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

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: var(--leading-normal);
  letter-spacing: var(--tracking-normal);
  font-feature-settings: "cv01", "cv02", "cv03", "cv04";  /* Inter stylistic alternates */
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  /* Ambient gradient orbs — gives glass surfaces something to show through */
  background-image:
    radial-gradient(ellipse 50% 40% at 15% 5%, var(--color-accent-subtle), transparent),
    radial-gradient(ellipse 40% 35% at 85% 10%, var(--color-amber-bg), transparent),
    radial-gradient(ellipse 60% 40% at 50% 95%, var(--color-accent-bg), transparent);
  background-attachment: fixed;
}

[data-theme="light"] body {
  background-image:
    radial-gradient(ellipse 50% 40% at 15% 5%, var(--color-accent-bg), transparent),
    radial-gradient(ellipse 40% 35% at 85% 10%, var(--color-amber-bg), transparent),
    radial-gradient(ellipse 60% 40% at 50% 95%, var(--color-accent-tint), transparent);
}

/* ── Sidebar ────────────────────────────────── */

#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  z-index: 200;
  display: flex;
  flex-direction: column;
  background: var(--brand);
  border-right: 1px solid var(--color-accent-border-strong);
  box-shadow: var(--shadow-md);
  transition: transform var(--duration-normal) var(--ease-out);
}

.sidebar-header {
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--sp-2);
}

.sidebar-header h1 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  color: #fff;
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  min-width: 0;
  flex: 1 1 auto;
  white-space: normal;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.sidebar-header h1 .brand-icon {
  width: 1.3em;
  height: 1.3em;
  flex-shrink: 0;
  opacity: 0.9;
}

/* ── Sidebar Collapse Toggle ───────────── */

#sidebar-collapse {
  background: rgba(255, 255, 255, 0.10);
  color: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  align-self: start;
  transition: all var(--duration-fast) var(--ease-out);
}

#sidebar-collapse:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

#sidebar-collapse i {
  font-size: var(--text-base);
  transition: transform var(--duration-normal) var(--ease-out);
}

/* Collapsed state: rotate chevron */
.sidebar-collapsed #sidebar-collapse i {
  transform: rotate(180deg);
}

/* ── Sidebar Collapsed State ────────────── */
/* .sidebar-collapsed is applied to <body> */

body.sidebar-collapsed #sidebar {
  width: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .sidebar-header {
  padding: var(--sp-3) var(--sp-2) var(--sp-2);
}

body.sidebar-collapsed .sidebar-header h1 {
  justify-content: center;
  overflow: hidden;
  font-size: 0;
  line-height: 0;
}

body.sidebar-collapsed .sidebar-header h1 .brand-icon {
  display: none;
}

body.sidebar-collapsed #sidebar-collapse {
  margin-left: 0;
}

body.sidebar-collapsed .nav-link span {
  display: none;
}

body.sidebar-collapsed .nav-link {
  justify-content: center;
  padding: var(--sp-2);
}

body.sidebar-collapsed #theme-toggle span {
  display: none;
}

body.sidebar-collapsed #theme-toggle {
  justify-content: center;
  padding: var(--sp-2);
}

body.sidebar-collapsed #main-content {
  margin-left: var(--sidebar-collapsed-width);
}

/* ── Nav Menu (sidebar) ──────────────────── */

#nav-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--sp-3) var(--sp-2);
  flex: 1;
}

.nav-link {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: var(--tracking-wide);
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast) var(--ease-out);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.nav-link i {
  font-size: var(--text-lg);
  width: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.nav-link.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.22);
  font-weight: 600;
}

.nav-link:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -2px;
}

/* Sub-navigation — indented child links */
.nav-sub {
  padding-left: calc(var(--sp-3) + 24px + var(--sp-2));
  font-size: var(--text-xs);
  opacity: 0.85;
}
.nav-sub i {
  font-size: var(--text-sm);
  width: 18px;
}
.nav-sub.active {
  opacity: 1;
}

/* ── Sidebar Footer ──────────────────────── */

.sidebar-footer {
  padding: var(--sp-3) var(--sp-2);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

/* ── Theme Toggle ────────────────────────────── */

#theme-toggle {
  width: 100%;
  background: rgba(255, 255, 255, 0.10);
  color: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-sm);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-sm);
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  transition: all var(--duration-fast) var(--ease-out);
}

#theme-toggle i {
  font-size: var(--text-lg);
  width: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#theme-toggle:hover {
  background: rgba(255, 255, 255, 0.18);
}

#theme-toggle:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -2px;
}

#theme-toggle:active {
  transform: scale(0.98);
}

/* ── Sidebar Overlay (mobile) ────────────── */

#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 199;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

#sidebar-overlay.active {
  display: block;
}

/* ── Topbar (mobile header) ──────────────── */

#topbar {
  display: none;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  background: var(--brand);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

#sidebar-toggle {
  background: none;
  border: none;
  color: #fff;
  font-size: var(--text-xl);
  cursor: pointer;
  padding: var(--sp-1);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--duration-fast) var(--ease-out);
}

#sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
}

#topbar-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
}

/* ── Main Content Layout ─────────────────── */

#main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left var(--duration-normal) var(--ease-out);
}

/* ── View Visibility ──────────────────────── */

.view-hidden {
  display: none !important;
}

/* ── Mobile: Sidebar off-canvas ──────────── */

@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #main-content {
    margin-left: 0;
  }

  #topbar {
    display: flex;
  }

  #canvas-view,
  #history-view {
    height: calc(100vh - 44px);
  }

  #system-view {
    height: calc(100vh - 44px);
  }
}

.theme-toggle-icon,
.cards-area-icon,
.live-feed-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.theme-toggle-icon {
  width: 16px;
  height: 16px;
  color: var(--color-amber);
}

.theme-toggle-icon svg,
.cards-area-icon svg,
.live-feed-icon svg {
  width: 100%;
  height: 100%;
}

.theme-toggle-label {
  line-height: 1;
}

/* ── Canvas View — Full-Viewport Projection ── */

#canvas-view {
  position: relative;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Ambient glow behind content — set dynamically via JS */
#canvas-view::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  opacity: 0.08;
  background: radial-gradient(
    ellipse 80% 60% at 50% 30%,
    var(--canvas-glow, var(--color-accent)),
    transparent
  );
  transition: opacity 0.8s var(--ease-out);
  pointer-events: none;
}

#canvas-spotlight {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* ── Canvas Title Bar ─────────────────────── */

.canvas-title-bar {
  flex-shrink: 0;
  padding: var(--sp-6) var(--sp-8) var(--sp-4);
  animation: slideDown 0.6s var(--ease-out);
}

.canvas-title-text {
  font-family: var(--font-display);
  font-size: clamp(var(--text-2xl), 4vw, var(--text-3xl));
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  color: var(--color-text);
  text-wrap: balance;
}

/* ── Canvas Content — fills viewport ──────── */

.canvas-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 var(--sp-8) var(--sp-8);
  font-size: clamp(0.9375rem, 1.5vw, 1.125rem);
  line-height: 1.8;
  overflow-y: auto;
  animation: fadeIn 0.6s var(--ease-out) 0.1s both;
}

.canvas-content > .content-block {
  display: flex;
  flex-direction: column;
  padding: var(--sp-4) 0;
  max-width: 100%;
}

.canvas-content > .content-block.format-image {
  flex: 1;
  min-height: 0;
}

.canvas-content > .content-block.format-html,
.canvas-content > .content-block.format-artifact {
  flex: 1;
  min-height: 0;
}

.canvas-content > .content-block.format-chart {
  flex: 1;
  min-height: 0;
}

/* Content blocks inside templates use normal block flow (not flex)
   so that mermaid SVGs and other dynamic content get natural height. */
.briefing-section-body .content-block,
.comparison-side-body .content-block,
.dashboard-widget-body .content-block,
.steps-step-body .content-block,
.slides-slide .content-block {
  display: block;
  padding: var(--sp-2) 0;
  max-width: 100%;
}

.canvas-content .content-block iframe {
  min-height: 200px;
}

.canvas-content .format-html iframe,
.canvas-content .format-artifact iframe {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.canvas-content .format-table table {
  font-size: clamp(var(--text-sm), 1.2vw, var(--text-base));
}

.canvas-content .format-code pre,
.canvas-content .json-view,
.canvas-content .diff-view,
.canvas-content .log-view {
  font-size: clamp(var(--text-xs), 1.1vw, var(--text-sm));
  padding: var(--sp-5);
  border-radius: var(--radius-md);
}

.canvas-content .format-markdown pre {
  padding: var(--sp-5);
  border-radius: var(--radius-md);
}

/* Mermaid and chart blocks expand in Canvas View */
.canvas-content .format-mermaid pre.mermaid,
.canvas-content .format-chart pre.mermaid {
  padding: var(--sp-6);
}

.canvas-content .format-chart canvas {
  height: 100%;
  max-height: 100%;
}

/* Metric type — large centered display */
.canvas-content .format-metric {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 30vh;
}

.canvas-content .metric-value {
  font-size: clamp(3rem, 10vw, 8rem);
}

/* ── Canvas Info Bar — floating bottom glass ── */

.canvas-info-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-8);
  background:
    linear-gradient(0deg, var(--glass-highlight), transparent 140%),
    var(--glass-bg-strong);
  border-top: 1px solid var(--glass-stroke);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--glass-inner-shadow);
  animation: slideUp 0.5s var(--ease-out) 0.2s both;
}

.canvas-info-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
  animation: glow-pulse 2s infinite;
}

.canvas-info-agent {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
}

.canvas-info-id {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.canvas-info-divider {
  width: 1px;
  height: 16px;
  background: var(--color-border);
  flex-shrink: 0;
}

.canvas-info-tags {
  display: flex;
  gap: var(--sp-1);
}

.canvas-info-tags .tag-chip {
  font-size: var(--text-xs);
}

.canvas-info-time {
  margin-left: auto;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.canvas-info-card-id {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  opacity: 0.6;
}

/* ── Canvas Empty State ───────────────────── */

.canvas-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  color: var(--color-text-muted);
  animation: fadeIn 0.8s var(--ease-out);
}

.canvas-empty-icon {
  font-size: 4rem;
  opacity: 0.2;
  line-height: 1;
  filter: drop-shadow(0 0 20px var(--color-accent));
}

.canvas-empty-text {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 500;
  letter-spacing: -0.01em;
}

.canvas-empty-sub {
  font-size: var(--text-sm);
}

/* ── Animations ──────────────────────────── */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes glow-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px currentColor; }
  50% { opacity: 0.5; box-shadow: 0 0 4px currentColor; }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes feedIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px) scale(0.9); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px) scale(0.9); }
}

/* Old animation names (kept for JS compatibility) */
@keyframes canvasFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes canvasSlideDown {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes canvasSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Filter Bar ──────────────────────────────── */

#filter-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-left: auto;
  flex-wrap: wrap;
}

#filter-bar select {
  appearance: none;
  background:
    linear-gradient(180deg, var(--glass-highlight), transparent),
    var(--glass-bg);
  color: var(--color-text);
  border: 1px solid var(--glass-stroke);
  border-radius: 999px;
  padding: var(--sp-1) var(--sp-3);
  padding-right: var(--sp-5);
  font-size: var(--text-sm);
  cursor: pointer;
  backdrop-filter: blur(var(--glass-blur-subtle));
  -webkit-backdrop-filter: blur(var(--glass-blur-subtle));
  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='%237d8590'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: all var(--duration-fast) var(--ease-out);
}

#filter-bar select:hover {
  border-color: var(--color-border-accent);
}

#filter-bar select:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

#card-count {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── Dashboard View ─────────────────────────── */

#history-view {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#history-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* ── System View ────────────────────────────── */

#system-view {
  height: 100vh;
  overflow-y: auto;
}

/* ── Dashboard View ────────────────────────────── */

#dashboard-view {
  height: 100vh;
  overflow-y: auto;
  padding: var(--sp-5);
  max-width: 1400px;
  margin: 0 auto;
}

.dash-strip {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  padding: var(--sp-4) var(--sp-5);
  background:
    linear-gradient(180deg, var(--glass-highlight), transparent 30%),
    var(--glass-bg);
  border: 1px solid var(--glass-stroke);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--glass-inner-shadow), var(--shadow-sm);
  margin-bottom: var(--sp-5);
}

.dash-strip.is-new {
  animation: scaleIn 0.3s var(--ease-out) both;
}

.dash-strip-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
}

.dash-strip-count {
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: 1;
}

.dash-strip-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--color-text-muted);
}

.dash-strip-separator {
  width: 1px;
  height: 24px;
  background: var(--glass-stroke);
}

.dash-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}

.dash-widget {
  background:
    linear-gradient(180deg, var(--glass-highlight), transparent 30%),
    var(--glass-bg);
  border: 1px solid var(--glass-stroke);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--glass-inner-shadow), var(--shadow-sm);
  transition: all var(--duration-normal) var(--ease-out);
}

.dash-widget.is-new {
  animation: scaleIn 0.4s var(--ease-out) both;
}

.dash-widget:hover {
  border-color: var(--color-border-accent);
  box-shadow: var(--glass-inner-shadow), var(--shadow-md), var(--shadow-glow);
  transform: translateY(-2px);
}

.dash-widget.is-new:nth-child(1) { animation-delay: 0.05s; }
.dash-widget.is-new:nth-child(2) { animation-delay: 0.1s; }
.dash-widget.is-new:nth-child(3) { animation-delay: 0.15s; }
.dash-widget.is-new:nth-child(4) { animation-delay: 0.2s; }

.dash-widget-header {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--color-accent);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--glass-stroke);
  margin-bottom: var(--sp-3);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  user-select: none;
}

.dash-widget-header:hover {
  color: var(--color-text);
}

.dash-widget-header i {
  font-size: var(--text-base);
  opacity: 0.8;
}

.dash-widget-chevron {
  margin-left: auto;
  font-size: var(--text-sm);
  opacity: 0.5;
  transition: transform var(--duration-normal) var(--ease-out);
}

.dash-widget-chevron.expanded {
  transform: rotate(180deg);
}

.dash-widget-summary {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: 1.5;
}

.dash-widget-detail {
  display: none;
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--glass-stroke);
}

.dash-widget-detail.expanded {
  display: block;
}

/* Agent tiles */
.dash-agent-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--sp-3);
}

.dash-agent-tile {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  font-size: var(--text-sm);
}

.dash-agent-tile .system-status-dot {
  flex-shrink: 0;
}

.dash-agent-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-agent-task {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Attention items */
.dash-alert-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.dash-alert-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  font-size: var(--text-sm);
}

.dash-alert-item i {
  flex-shrink: 0;
}

.dash-alert-item.alert-warning {
  border-left: 3px solid var(--color-warning);
}

.dash-alert-item.alert-error {
  border-left: 3px solid var(--color-danger);
}

.dash-alert-item.alert-info {
  border-left: 3px solid var(--color-accent);
}

/* Task bar chart */
.dash-task-bars {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.dash-task-bar-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--text-sm);
}

.dash-task-bar-label {
  width: 80px;
  text-transform: capitalize;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
}

.dash-task-bar-track {
  flex: 1;
  height: 8px;
  background: var(--color-surface-raised);
  border-radius: 4px;
  overflow: hidden;
}

.dash-task-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s var(--ease-out);
}

.dash-task-bar-count {
  width: 28px;
  text-align: right;
  font-weight: 600;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

/* Activity feed */
.dash-timeline {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.dash-timeline-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  font-size: var(--text-sm);
}

.dash-timeline-time {
  flex-shrink: 0;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 48px;
}

.dash-timeline-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-timeline-agent {
  font-weight: 600;
}

/* Memory items */
.dash-memory-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.dash-memory-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  font-size: var(--text-sm);
}

.dash-memory-key {
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  flex-shrink: 0;
  min-width: 100px;
}

.dash-memory-content {
  flex: 1;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-memory-author {
  flex-shrink: 0;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

@media (max-width: 768px) {
  .dash-strip {
    flex-wrap: wrap;
    gap: var(--sp-3);
  }
  .dash-agent-tiles {
    grid-template-columns: 1fr;
  }
}

#system-panel {
  padding: var(--sp-5);
  max-width: 1400px;
  margin: 0 auto;
}

#system-panel-content {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  padding: var(--sp-4) 0 var(--sp-8);
}
/* Only animate on first render — subsequent updates swap content without fade */
#system-panel-content.is-new {
  animation: fadeIn 0.4s var(--ease-out);
}

/* System Groups — logical grouping of related sections */
.system-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(400px, 100%), 1fr));
  gap: var(--sp-4);
}

/* System Sections — glass panels */
.system-section {
  background:
    linear-gradient(180deg, var(--glass-highlight), transparent 30%),
    var(--glass-bg);
  border: 1px solid var(--glass-stroke);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--glass-inner-shadow), var(--shadow-sm);
  transition: all var(--duration-normal) var(--ease-out);
  overflow-x: auto;
  min-width: 0;
}

.system-section.is-new {
  animation: scaleIn 0.4s var(--ease-out) both;
}

.system-section:hover {
  border-color: var(--color-border-accent);
  box-shadow: var(--glass-inner-shadow), var(--shadow-md), var(--shadow-glow);
  transform: translateY(-2px);
}

/* Stagger system section animations */
.system-section.is-new:nth-child(1) { animation-delay: 0s; }
.system-section.is-new:nth-child(2) { animation-delay: 0.05s; }
.system-section.is-new:nth-child(3) { animation-delay: 0.1s; }
.system-section.is-new:nth-child(4) { animation-delay: 0.15s; }
.system-section.is-new:nth-child(5) { animation-delay: 0.2s; }
.system-section.is-new:nth-child(6) { animation-delay: 0.25s; }
.system-section.is-new:nth-child(7) { animation-delay: 0.3s; }
.system-section.is-new:nth-child(8) { animation-delay: 0.35s; }
.system-section.is-new:nth-child(9) { animation-delay: 0.4s; }
.system-section.is-new:nth-child(10) { animation-delay: 0.45s; }
.system-section.is-new:nth-child(11) { animation-delay: 0.5s; }
.system-section.is-new:nth-child(12) { animation-delay: 0.55s; }

.system-section-header {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  line-height: var(--leading-tight);
  color: var(--color-accent);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--glass-stroke);
  margin-bottom: var(--sp-3);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.system-section-header i {
  font-size: var(--text-base);
  opacity: 0.8;
}

.system-section-body {
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--color-text-secondary);
}

/* Tips banner — glass with accent glow */
.system-tips {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  background:
    linear-gradient(135deg, var(--color-accent-subtle), var(--color-accent-tint)),
    var(--glass-bg);
  border: 1px solid var(--color-accent-border-strong);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  color: var(--color-text);
  line-height: 1.5;
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--glass-inner-shadow), 0 0 30px var(--color-accent-bg);
  animation: slideDown 0.5s var(--ease-out);
}

[data-theme="light"] .system-tips {
  background:
    linear-gradient(135deg, var(--color-accent-bg), var(--color-accent-tint)),
    var(--glass-bg);
  border-color: var(--color-accent-border-strong);
}

.system-tips-icon {
  font-size: var(--text-xl);
  flex-shrink: 0;
  filter: drop-shadow(0 0 6px var(--color-accent-ring));
}

.system-tips-text {
  flex: 1;
}

.system-tips-count {
  font-size: var(--text-xs);
  color: var(--color-accent);
  white-space: nowrap;
  flex-shrink: 0;
  background: var(--color-accent-subtle);
  padding: 2px var(--sp-2);
  border-radius: 999px;
}

/* Environment table */
.system-env-table td {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

/* Description cells — allow text wrapping */
.desc-cell {
  white-space: normal !important;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.env-key-cell {
  white-space: nowrap;
  color: var(--color-accent);
}

.env-val-cell {
  word-break: break-all;
}

/* Skill tags in Skill Sets table */
.skill-list-cell {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}

.skill-tag {
  display: inline-block;
  padding: 2px var(--sp-2);
  background: var(--color-accent-subtle);
  border: 1px solid var(--glass-stroke);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--color-accent);
  white-space: nowrap;
  transition: all var(--duration-fast) var(--ease-out);
}

.skill-tag:hover {
  background: var(--color-accent);
  color: var(--color-bg);
  transform: translateY(-1px);
}

/* Empty state */
.system-empty {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-style: italic;
  padding: var(--sp-3) 0;
  text-align: center;
}

/* Scope badge — glass pill */
.scope-badge {
  display: inline-block;
  padding: 2px var(--sp-2);
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: lowercase;
  background: var(--color-tint-light-subtle);
  color: var(--color-text-muted);
  border: 1px solid var(--glass-stroke);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.scope-badge[data-scope="project"] {
  color: var(--color-success);
  border-color: var(--color-success-border);
  background: var(--color-success-subtle);
}

.scope-badge[data-scope="plugin"] {
  color: var(--color-accent);
  border-color: var(--color-accent-ring);
  background: var(--color-accent-subtle);
}

.scope-badge[data-scope="synapse"] {
  color: var(--color-warning);
  border-color: var(--color-warning-border);
  background: var(--color-warning-subtle);
}

.scope-badge[data-scope="user"] {
  color: var(--color-accent);
  border-color: var(--color-accent-border-strong);
  background: var(--color-accent-subtle);
}

.scope-badge[data-scope="active-project"] {
  color: var(--color-signal);
  border-color: var(--color-signal-border);
  background: var(--color-signal-subtle);
}

.system-agent {
  padding: var(--sp-1) 0;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.system-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

/* System Agents Table */
.system-agents-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.system-agents-table th {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-accent);
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--glass-stroke);
  white-space: nowrap;
  background: var(--color-accent-hover);
}

.system-agents-table th:first-child {
  border-radius: var(--radius-sm) 0 0 0;
}

.system-agents-table th:last-child {
  border-radius: 0 var(--radius-sm) 0 0;
}

.system-agents-table td {
  padding: var(--sp-2) var(--sp-3);
  white-space: normal;
  overflow-wrap: anywhere;
  color: var(--color-text-secondary);
  vertical-align: top;
  border-bottom: 1px solid var(--color-border-faint);
  transition: background var(--duration-fast);
}

.system-agents-table tbody tr {
  transition: all var(--duration-fast) var(--ease-out);
}

.system-agents-table tbody tr:hover {
  background: var(--color-accent-hover);
}

.system-agents-table tbody tr:hover td {
  border-bottom-color: var(--color-accent-glow);
}

/* Agent-specific: single-row with horizontal scroll */
.system-agents-table.agents-nowrap {
  table-layout: auto;
}
.system-agents-table.agents-nowrap td {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

.agent-dot-cell {
  width: 20px;
  text-align: center;
}

.agent-name-cell {
  font-weight: 600;
  color: var(--color-text) !important;
  white-space: normal;
  overflow-wrap: anywhere;
}

.agent-role-cell {
  overflow-wrap: anywhere;
}

.agent-port-cell {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-accent) !important;
}

.agent-dir-cell {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  overflow-wrap: anywhere;
  word-break: break-all;
}

.agent-current-cell {
  overflow-wrap: anywhere;
}

.agent-status-cell {
  font-weight: 600;
  font-size: var(--text-xs);
}

/* ── Cards Area ─────────────────────────────── */

#cards-area {
  max-width: 1400px;
  margin: 0 auto;
}

#cards-area-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
}

.cards-area-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cards-area-kicker {
  font-size: var(--text-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-amber);
}

.cards-area-heading-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.cards-area-icon,
.live-feed-icon {
  width: 20px;
  height: 20px;
  color: var(--color-amber);
}

#cards-area-header h2 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-snug);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

#cards-area-header h2 i {
  color: var(--color-accent);
  font-size: var(--text-xl);
}

/* Message Tools — glass pill */
.message-tools {
  padding: var(--sp-2);
  border: 1px solid var(--glass-stroke);
  border-radius: 999px;
  background:
    linear-gradient(180deg, var(--glass-highlight), transparent 150%),
    var(--glass-bg);
  box-shadow: var(--glass-inner-shadow), var(--shadow-md);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}

/* ── Live Feed ───────────────────────────────── */

#live-feed {
  padding: var(--sp-4) var(--sp-5);
  max-width: 1400px;
  margin: 0 auto;
}

.live-feed-band {
  position: relative;
  margin-top: var(--sp-4);
  border: 1px solid var(--glass-stroke);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, var(--glass-highlight), transparent 30%),
    var(--glass-bg);
  box-shadow: var(--glass-inner-shadow), var(--shadow-sm);
  overflow: hidden;
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  animation: scaleIn 0.4s var(--ease-out);
  transition: all var(--duration-normal) var(--ease-out);
}

.live-feed-band:hover {
  border-color: var(--color-border-accent);
  box-shadow: var(--glass-inner-shadow), var(--shadow-md), var(--shadow-glow);
  transform: translateY(-2px);
}

/* Removed: accent top-edge shimmer */

.live-feed-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--glass-stroke);
}

.live-feed-title-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.live-feed-kicker {
  font-size: var(--text-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-amber);
}

.live-feed-caption {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.live-feed-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--color-success);
  box-shadow: 0 0 8px var(--color-success);
  animation: pulse 2s infinite;
}

.live-feed-label {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  color: var(--color-text);
}

.live-feed-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

/* Live feed items — glass cards */
.live-feed-item {
  background:
    linear-gradient(180deg, var(--glass-highlight), transparent),
    var(--color-bg-card);
  border: 1px solid var(--glass-stroke);
  border-radius: var(--radius-md);
  box-shadow: var(--glass-inner-shadow);
  overflow: hidden;
  transition: all var(--duration-normal) var(--ease-out);
  backdrop-filter: blur(var(--glass-blur-subtle));
  -webkit-backdrop-filter: blur(var(--glass-blur-subtle));
}

.live-feed-item.is-new {
  animation: feedIn 0.28s var(--ease-out);
  border-color: var(--color-border-accent);
  box-shadow: var(--glass-inner-shadow), 0 0 0 1px var(--color-accent-subtle);
}

[data-theme="light"] .live-feed-item {
  background:
    linear-gradient(180deg, var(--glass-highlight), transparent),
    var(--color-bg-card);
}

.live-feed-item:hover {
  border-color: var(--color-border-accent);
  box-shadow: var(--glass-inner-shadow), var(--shadow-md);
  transform: translateX(4px);
}

.live-feed-item-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  border-bottom: 1px solid var(--glass-stroke);
}

.live-feed-item-header .agent-badge {
  flex-shrink: 0;
}

.live-feed-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 4px currentColor;
}

.live-feed-agent-id {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.live-feed-title {
  flex: 1;
  min-width: 0;
  font-size: var(--text-sm);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-feed-time {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.live-feed-empty {
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  padding: var(--sp-4);
  font-style: italic;
}

/* ── Agent Panels — glass containers ─────────── */

#canvas-grid {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5) var(--sp-8);
}

.agent-panel {
  background:
    linear-gradient(180deg, var(--glass-highlight), transparent 30%),
    var(--glass-bg);
  border: 1px solid var(--glass-stroke);
  border-radius: var(--radius-lg);
  overflow: hidden;
  padding: 0;
  box-shadow: var(--glass-inner-shadow), var(--shadow-sm);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  transition: all var(--duration-normal) var(--ease-out);
}

.agent-panel.is-new {
  animation: scaleIn 0.32s var(--ease-out) both;
}

.agent-panel:hover {
  border-color: var(--color-border-accent);
  box-shadow: var(--glass-inner-shadow), var(--shadow-md), var(--shadow-glow);
  transform: translateY(-2px);
}

.agent-panel-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--glass-stroke);
  cursor: pointer;
  user-select: none;
  transition: background var(--duration-fast);
}

.agent-panel-header:hover {
  background: var(--color-accent-hover);
}

.agent-panel-name {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--color-accent);
  flex: 1;
  min-width: 0;
}

.agent-panel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

.agent-panel-id {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}

.agent-panel-count {
  font-size: var(--text-xs);
  color: var(--color-accent);
  font-variant-numeric: tabular-nums;
  background: var(--color-accent-subtle);
  padding: 2px var(--sp-2);
  border-radius: 9999px;
  border: 1px solid var(--glass-stroke);
  font-weight: 600;
}

.agent-panel-arrow {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  transition: transform var(--duration-normal) var(--ease-out);
}

.agent-panel-arrow.collapsed {
  transform: rotate(-90deg);
}

.agent-panel-body {
  display: flex;
  flex-direction: column;
}

.agent-panel-body.collapsed {
  display: none;
}

.agent-panel-empty {
  padding: var(--sp-5);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-style: italic;
}

/* ── Card ────────────────────────────────────── */

.canvas-card {
  background: var(--color-bg-raised);
  border-bottom: 1px solid var(--glass-stroke);
  transition: all var(--duration-fast) var(--ease-out);
}

.canvas-card.is-new {
  animation: cardIn 0.28s var(--ease-out);
}

.canvas-card:last-child {
  border-bottom: none;
}

.canvas-card:hover {
  background: var(--color-accent-tint);
}

[data-theme="light"] .canvas-card:hover {
  background: var(--color-accent-tint);
}

.canvas-card > header {
  position: static;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  background: transparent;
}

.card-format-icon {
  font-size: var(--text-lg);
  color: var(--color-accent);
  flex-shrink: 0;
  opacity: 0.7;
}

.canvas-card > header h2 {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-snug);
  color: var(--color-text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-badge {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px var(--sp-2);
  border-radius: 9999px;
  background: var(--color-accent-subtle);
  color: var(--color-accent);
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid var(--color-accent-border);
}

/* ── Tags ────────────────────────────────────── */

.tag-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-5) 0;
}

.tag-chip {
  font-size: var(--text-xs);
  padding: 2px var(--sp-2);
  border-radius: var(--radius-sm);
  background: var(--color-tint-light-subtle);
  color: var(--color-text-muted);
  border: 1px solid var(--glass-stroke);
  transition: all var(--duration-fast);
}

.tag-chip:hover {
  background: var(--color-accent-subtle);
  color: var(--color-accent);
}

/* ── Content Blocks ──────────────────────────── */

.content-block {
  padding: var(--sp-3) var(--sp-5);
}

.content-block + .content-block {
  border-top: 1px solid var(--glass-stroke);
}

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

/* Markdown-specific font stack — optimized for document readability */
.format-markdown {
  --md-font: "Source Sans 3", var(--font-body);
  --md-mono: "Source Code Pro", var(--font-mono);
  font-family: var(--md-font);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Headings — tight leading, weight hierarchy with subtle color shift */
.format-markdown h2 {
  font-family: var(--md-font);
  font-size: var(--text-xl);
  font-weight: 650;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text);
  margin: var(--sp-5) 0 var(--sp-2);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--color-border);
}

.format-markdown h2:first-child {
  margin-top: 0;
}

.format-markdown h3 {
  font-family: var(--md-font);
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text);
  margin: var(--sp-4) 0 var(--sp-2);
}

.format-markdown h4 {
  font-family: var(--md-font);
  font-size: var(--text-base);
  font-weight: 600;
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-normal);
  color: var(--color-text-secondary);
  margin: var(--sp-3) 0 var(--sp-1);
}

/* Paragraphs */
.format-markdown p {
  margin: var(--sp-2) 0;
}

.format-markdown p:first-child {
  margin-top: 0;
}

/* Bold & italic */
.format-markdown strong {
  font-weight: 600;
  color: var(--color-text);
}

.format-markdown em {
  font-style: italic;
  color: var(--color-text-secondary);
}

/* Strikethrough */
.format-markdown del {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

/* Inline code — pill-shaped accent badge */
.format-markdown code {
  background: var(--color-accent-subtle);
  padding: 2px 7px;
  border-radius: 5px;
  font-family: var(--md-mono);
  font-size: 84%;
  color: var(--color-accent);
  font-weight: 500;
  border: 1px solid var(--color-accent-border);
  white-space: nowrap;
}

[data-theme="light"] .format-markdown code {
  background: var(--color-accent-bg);
  border-color: var(--color-accent-border);
}

/* Code blocks — inset panel with refined mono type */
.format-markdown pre {
  background: var(--color-bg-inset);
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: var(--sp-3) 0;
  border: 1px solid var(--glass-stroke);
  box-shadow: var(--glass-inner-shadow);
}

.format-markdown pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  border: none;
  font-family: var(--md-mono);
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--color-text);
  line-height: var(--leading-relaxed);
  white-space: pre;
}

/* Lists — clean indentation with subtle markers */
.format-markdown ul,
.format-markdown ol {
  padding-left: var(--sp-5);
  margin: var(--sp-2) 0;
}

.format-markdown li {
  margin: var(--sp-1) 0;
  line-height: var(--leading-normal);
  color: var(--color-text);
}

.format-markdown li::marker {
  color: var(--color-text-muted);
}

/* Links — brand accent with subtle underline */
.format-markdown a {
  color: var(--color-accent);
  text-decoration: none;
  border-bottom: 1px solid var(--color-accent-border);
  transition: border-color var(--duration-fast), opacity var(--duration-fast);
}

.format-markdown a:hover {
  border-bottom-color: var(--color-accent);
  opacity: 0.9;
}

/* Blockquote — left border accent stripe */
.format-markdown blockquote {
  margin: var(--sp-3) 0;
  padding: var(--sp-2) var(--sp-4);
  border-left: 3px solid var(--color-accent-border-strong);
  background: var(--color-accent-tint);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--color-text-secondary);
  font-style: italic;
}

.format-markdown blockquote code {
  font-style: normal;
}

/* Horizontal rule — subtle divider */
.format-markdown hr {
  border: none;
  height: 1px;
  background: var(--color-border);
  margin: var(--sp-5) 0;
}

/* Tables inside markdown — clean minimal style */
.format-markdown table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: var(--sp-3) 0;
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--glass-stroke);
}

.format-markdown th {
  background: var(--color-accent-bg);
  font-family: var(--md-font);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--color-text-secondary);
  padding: var(--sp-2) var(--sp-3);
  text-align: left;
  border-bottom: 1px solid var(--glass-stroke);
}

.format-markdown td {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--color-border-faint);
  color: var(--color-text);
}

.format-markdown tr:last-child td {
  border-bottom: none;
}

.format-markdown tr:hover td {
  background: var(--color-tint-light);
}

/* Images */
.format-markdown img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin: var(--sp-2) 0;
}

/* Mermaid */
.format-mermaid pre.mermaid,
.format-mermaid [data-processed="true"] {
  background: var(--color-bg-inset);
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  text-align: center;
  height: auto;
  overflow: visible;
  border: 1px solid var(--glass-stroke);
}

.mermaid-panel {
  background: var(--color-bg-inset);
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-stroke);
  overflow: visible;
}

.mermaid-panel pre.mermaid,
.mermaid-panel [data-processed="true"] {
  background: none;
  border: none;
  padding: 0;
  text-align: center;
  height: auto;
  overflow: visible;
}

/* Shared meta-row styles for mermaid, json, code renderers */
.mermaid-view-meta,
.log-view-meta,
.checklist-view-meta,
.trace-view-meta,
.tip-view-meta,
.json-view-meta,
.code-view-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: var(--sp-4);
  margin-bottom: var(--sp-3);
}

.mermaid-title,
.log-title,
.checklist-title,
.trace-title,
.tip-title,
.json-title,
.code-title {
  min-width: 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
}

.mermaid-filename,
.log-filename,
.checklist-filename,
.trace-filename,
.tip-filename,
.json-filename,
.code-filename {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.format-mermaid {
  overflow: visible;
  height: auto;
}

.format-mermaid svg,
.dep-graph svg {
  display: block;
  max-width: 100%;
  height: auto !important;
  margin: 0 auto;
}

/* Mermaid SVG node styling — refined typography and subtle depth */
.format-mermaid .node rect,
.format-mermaid .node circle,
.format-mermaid .node polygon,
.dep-graph .node rect,
.dep-graph .node circle,
.dep-graph .node polygon {
  rx: 8;
  ry: 8;
  stroke-width: 1.5px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.08));
}

.format-mermaid .node .label,
.dep-graph .node .label {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

/* Refined edge lines */
.format-mermaid .edgePath path.path,
.dep-graph .edgePath path.path {
  stroke-width: 1.5px;
  stroke-linecap: round;
}

/* Edge labels — small, clean, monospaced */
.format-mermaid .edgeLabel,
.dep-graph .edgeLabel {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

/* Arrowheads */
.format-mermaid marker path,
.dep-graph marker path {
  stroke-width: 0;
}

/* Cluster / subgraph — subtle grouped look */
.format-mermaid .cluster rect,
.dep-graph .cluster rect {
  rx: 10;
  ry: 10;
  stroke-width: 1px;
  stroke-dasharray: 4 2;
}

.format-mermaid .cluster .nodeLabel,
.dep-graph .cluster .nodeLabel {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* Sequence diagram actors */
.format-mermaid .actor {
  rx: 6;
  ry: 6;
  stroke-width: 1.5px;
}

.format-mermaid .actor-man text,
.format-mermaid .messageText {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 12px;
  font-weight: 500;
}

/* Note boxes */
.format-mermaid .note rect {
  rx: 6;
  ry: 6;
  stroke-width: 1px;
}

.format-mermaid .noteText {
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  font-size: 11px;
}

/* Dark mode refinements */
[data-theme="dark"] .format-mermaid .node rect,
[data-theme="dark"] .format-mermaid .node circle,
[data-theme="dark"] .format-mermaid .node polygon,
[data-theme="dark"] .dep-graph .node rect,
[data-theme="dark"] .dep-graph .node circle,
[data-theme="dark"] .dep-graph .node polygon {
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.3));
}

/* Light mode — softer shadows */
[data-theme="light"] .format-mermaid .node rect,
[data-theme="light"] .format-mermaid .node circle,
[data-theme="light"] .format-mermaid .node polygon,
[data-theme="light"] .dep-graph .node rect,
[data-theme="light"] .dep-graph .node circle,
[data-theme="light"] .dep-graph .node polygon {
  filter: drop-shadow(0 1px 2px rgba(64, 81, 181, 0.1));
}

/* Table */
.format-table table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--glass-stroke);
}

.format-table th,
.format-table td {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--glass-stroke);
  text-align: left;
}

.format-table th {
  background: var(--color-accent-bg);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-accent);
}

.format-table tr:hover td {
  background: var(--color-accent-tint);
}

/* JSON */
.json-view {
  background: var(--color-bg-inset);
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  overflow-x: auto;
  white-space: pre;
  color: var(--color-success);
  border: 1px solid var(--glass-stroke);
}

.json-view code {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Diff — Side by Side */
.diff-side-by-side {
  display: flex;
  border: 1px solid var(--glass-stroke);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.diff-pane {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
}

.diff-pane pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.6;
}

.diff-pane-left {
  border-right: 1px solid var(--glass-stroke);
}

.diff-row {
  display: flex;
  min-height: 1.6em;
}

.diff-line-num {
  display: inline-block;
  width: 3.5em;
  padding: 0 var(--sp-2);
  text-align: right;
  color: var(--color-text-muted);
  opacity: 0.5;
  flex-shrink: 0;
  user-select: none;
}

.diff-line-text {
  flex: 1;
  padding: 0 var(--sp-2);
  white-space: pre;
}

.diff-del {
  background: var(--color-danger-subtle);
  color: var(--color-danger);
}

.diff-add {
  background: var(--color-success-subtle);
  color: var(--color-success);
}

.diff-empty {
  background: var(--color-bg-inset);
  opacity: 0.4;
}

.diff-hunk {
  background: var(--color-accent-subtle);
  color: var(--color-accent);
  font-weight: 600;
}

.diff-hunk .diff-line-text {
  font-size: var(--text-xs);
}

.diff-header {
  color: var(--color-text-muted);
}

.diff-ctx {
  background: var(--color-bg-inset);
}

/* Code */
.format-code pre {
  background: var(--color-bg-inset);
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
  border: 1px solid var(--glass-stroke);
}

.format-code code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

/* Image */
.format-image img {
  border-radius: var(--radius-md);
}

.canvas-content .format-image img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Chart */
.format-chart canvas {
  background: var(--color-bg-raised);
  border-radius: var(--radius-md);
  padding: var(--sp-3);
}

.format-chart pre.mermaid {
  background: var(--color-bg-inset);
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  text-align: center;
  border: 1px solid var(--glass-stroke);
}

/* HTML / Artifact (sandboxed) */
.format-html iframe,
.format-artifact iframe {
  background: #fff;
  border-radius: var(--radius-md);
}
[data-theme="dark"] .format-html iframe,
[data-theme="dark"] .format-artifact iframe {
  background: #1a1a2e;
}

/* ── Footer ──────────────────────────────────── */

.canvas-card > footer {
  padding: var(--sp-2) var(--sp-5);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  border-top: 1px solid var(--glass-stroke);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Log ─────────────────────────────────────── */

.log-view {
  background: var(--color-bg-inset);
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  overflow-x: auto;
  white-space: pre;
  line-height: 1.7;
  border: 1px solid var(--glass-stroke);
}

.log-info { color: var(--color-accent); }
.log-warn { color: var(--color-warning); }
.log-error { color: var(--color-danger); }

.tip-view {
  background: var(--color-bg-inset);
  border: 1px solid var(--glass-stroke);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  font-size: var(--text-sm);
  color: var(--color-text);
  white-space: pre-wrap;
}

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

.status-badge {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.success { background: var(--color-success); box-shadow: 0 0 8px var(--color-success); }
.status-dot.warn { background: var(--color-warning); box-shadow: 0 0 8px var(--color-warning); }
.status-dot.error { background: var(--color-danger); box-shadow: 0 0 8px var(--color-danger); }
.status-dot.running { background: var(--color-accent); box-shadow: 0 0 8px var(--color-accent); animation: pulse 1.5s infinite; }

.status-label {
  font-size: var(--text-xl);
  font-weight: 700;
  font-family: var(--font-display);
}

.status-detail {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  padding: 0 var(--sp-3) var(--sp-2);
}

/* ── Metric ──────────────────────────────────── */

.metric-value {
  font-size: var(--text-3xl);
  font-weight: 700;
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.metric-unit {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  margin-left: var(--sp-1);
  font-weight: 400;
}

.metric-label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--sp-1);
}

/* ── Checklist ───────────────────────────────── */

.checklist-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) 0;
  font-size: var(--text-sm);
  transition: opacity var(--duration-fast);
}

.checklist-item.checked {
  color: var(--color-text-muted);
  text-decoration: line-through;
  opacity: 0.6;
}

/* ── Timeline ────────────────────────────────── */

.timeline {
  position: relative;
  padding-left: var(--sp-5);
}

.timeline-event {
  position: relative;
  padding-bottom: var(--sp-4);
  border-left: 2px solid var(--glass-stroke);
  padding-left: var(--sp-4);
  transition: border-color var(--duration-fast);
}

.timeline-event:hover {
  border-left-color: var(--color-accent);
}

.timeline-event::before {
  content: "";
  position: absolute;
  left: -5px;
  top: var(--sp-1);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 0 6px var(--color-accent);
}

.timeline-event:last-child {
  padding-bottom: 0;
}

.timeline-ts {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.timeline-text {
  font-size: var(--text-sm);
}

.timeline-agent {
  font-size: var(--text-xs);
  color: var(--color-accent);
}

/* ── Alert ───────────────────────────────────── */

.alert-card {
  border-left: 4px solid var(--color-accent);
  padding: var(--sp-3) var(--sp-4);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background:
    linear-gradient(90deg, var(--color-accent-subtle), transparent),
    var(--color-bg-inset);
}

.alert-card.error {
  border-left-color: var(--color-danger);
  background: linear-gradient(90deg, var(--color-danger-subtle), transparent), var(--color-bg-inset);
}

.alert-card.warn {
  border-left-color: var(--color-warning);
  background: linear-gradient(90deg, var(--color-warning-subtle), transparent), var(--color-bg-inset);
}

.alert-message {
  font-size: var(--text-base);
  font-weight: 500;
}

.alert-source {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--sp-1);
}

/* ── File Preview ────────────────────────────── */

.file-path {
  font-size: var(--text-xs);
  color: var(--color-accent);
  padding: var(--sp-2) var(--sp-3);
  background: var(--color-accent-bg);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  font-family: var(--font-mono);
  border: 1px solid var(--glass-stroke);
  border-bottom: none;
}

/* ── Trace ───────────────────────────────────── */

.trace-span {
  padding: var(--sp-1) 0;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
}

.trace-bar {
  display: inline-block;
  height: 6px;
  background: var(--color-success);
  border-radius: 3px;
  min-width: 4px;
  margin-right: var(--sp-2);
  vertical-align: middle;
  box-shadow: 0 0 4px var(--color-success);
}

.trace-bar.error {
  background: var(--color-danger);
  box-shadow: 0 0 4px var(--color-danger);
}

.trace-children { padding-left: var(--sp-5); }

/* ── Task Board ──────────────────────────────── */

.task-board {
  display: flex;
  gap: var(--sp-3);
  overflow-x: auto;
}

.task-column {
  flex: 1;
  min-width: 150px;
}

.task-column-header {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  padding: var(--sp-2);
  border-bottom: 2px solid var(--glass-stroke);
  margin-bottom: var(--sp-2);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.task-column-header .task-column-count {
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
  font-weight: 400;
}

.task-column[data-status="pending"] .task-column-header {
  border-bottom-color: var(--color-warning);
  color: var(--color-warning);
}

.task-column[data-status="in_progress"] .task-column-header {
  border-bottom-color: var(--color-accent);
  color: var(--color-accent);
}

.task-column[data-status="completed"] .task-column-header {
  border-bottom-color: var(--color-success);
  color: var(--color-success);
}

.task-item {
  background:
    linear-gradient(180deg, var(--glass-highlight), transparent),
    var(--glass-bg);
  border: 1px solid var(--glass-stroke);
  border-radius: var(--radius-md);
  padding: var(--sp-3);
  margin-bottom: var(--sp-2);
  font-size: var(--text-sm);
  line-height: 1.4;
  transition: all var(--duration-fast) var(--ease-out);
  backdrop-filter: blur(var(--glass-blur-subtle));
  -webkit-backdrop-filter: blur(var(--glass-blur-subtle));
}

.task-item:hover {
  border-color: var(--color-border-accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.task-item-detail {
  display: none;
  margin-top: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--glass-stroke);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  line-height: 1.6;
}

.task-item-detail.expanded {
  display: block;
}

.task-detail-row {
  display: flex;
  gap: var(--sp-2);
  padding: 1px 0;
}

.task-detail-label {
  font-weight: 600;
  color: var(--color-text-muted);
  min-width: 80px;
  flex-shrink: 0;
}

.task-detail-label::after {
  content: ":";
}

.task-assignee {
  font-size: var(--text-xs);
  color: var(--color-accent);
  margin-top: var(--sp-1);
}

.task-detail-desc {
  flex-direction: column;
  gap: var(--sp-1);
}

.task-detail-md {
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--color-text);
  overflow-x: auto;
}

.task-detail-md p {
  margin: 0 0 var(--sp-1) 0;
}

.task-detail-md h1, .task-detail-md h2, .task-detail-md h3,
.task-detail-md h4, .task-detail-md h5, .task-detail-md h6 {
  margin: var(--sp-2) 0 var(--sp-1) 0;
  font-size: 1em;
  font-weight: 600;
  color: var(--color-text);
}

.task-detail-md code {
  background: var(--glass-bg);
  padding: 0.1em 0.3em;
  border-radius: var(--radius-sm);
  font-size: 0.9em;
}

.task-detail-md pre {
  background: var(--color-bg-inset);
  padding: var(--sp-2);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: var(--sp-1) 0;
  border: 1px solid var(--glass-stroke);
}

.task-detail-md pre code {
  background: none;
  padding: 0;
  font-family: var(--md-mono, monospace);
  font-size: var(--text-xs);
  white-space: pre;
  color: var(--color-text);
}

.task-detail-md a {
  color: var(--color-accent);
  text-decoration: none;
  border-bottom: 1px solid var(--color-accent-border, transparent);
}

.task-detail-md a:hover {
  opacity: 0.9;
}

.task-detail-md blockquote {
  margin: var(--sp-1) 0;
  padding: var(--sp-1) var(--sp-2);
  border-left: 3px solid var(--color-accent-border-strong, var(--color-accent));
  background: var(--color-accent-tint, transparent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.task-detail-md ul, .task-detail-md ol {
  margin: 0 0 var(--sp-1) 0;
  padding-left: var(--sp-4);
}

.task-detail-md table {
  border-collapse: collapse;
  width: 100%;
  margin: var(--sp-1) 0;
  font-size: var(--text-xs);
  overflow-x: auto;
  display: block;
}

.task-detail-md th, .task-detail-md td {
  padding: var(--sp-1) var(--sp-2);
  border: 1px solid var(--glass-stroke);
  text-align: left;
}

.task-detail-md th {
  background: var(--glass-bg);
  font-weight: 600;
}

.task-fail-reason {
  font-size: var(--text-xs);
  color: var(--color-danger, #e74c3c);
  margin-top: var(--sp-1);
  font-style: italic;
}

.task-view-toggle {
  display: flex;
  gap: var(--sp-1);
  margin-bottom: var(--sp-3);
}

.task-view-btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-stroke);
  border-radius: var(--radius-sm);
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.task-view-btn.active {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
  font-weight: 600;
}

.task-view-btn:hover:not(.active) {
  border-color: var(--color-accent);
}

/* ── Toast Notifications — glass float ──────── */

#toast-container {
  position: fixed;
  top: 64px;
  right: var(--sp-5);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
}

.toast {
  background:
    linear-gradient(180deg, var(--glass-highlight), transparent 120%),
    var(--glass-bg-strong);
  color: var(--color-text);
  border: 1px solid var(--glass-stroke);
  border-left: 1px solid var(--glass-stroke);
  border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-sm);
  backdrop-filter: blur(var(--glass-blur-strong));
  -webkit-backdrop-filter: blur(var(--glass-blur-strong));
  box-shadow: var(--glass-inner-shadow), var(--shadow-lg);
  animation: toastIn 0.3s var(--ease-spring), toastOut 0.3s ease-in 4.5s forwards;
  pointer-events: auto;
  max-width: 360px;
}

.toast .toast-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.toast .toast-agent {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

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

@media (max-width: 640px) {
  header {
    flex-wrap: wrap;
    padding: var(--sp-2) var(--sp-3);
    gap: var(--sp-2);
  }

  header h1 {
    font-size: var(--text-lg);
  }

  #nav-menu {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  #filter-bar {
    width: 100%;
  }

  #canvas-grid {
    padding: var(--sp-3);
    gap: var(--sp-3);
  }

  #system-panel {
    padding: var(--sp-3);
  }

  .system-group {
    grid-template-columns: 1fr;
  }

  .task-board {
    flex-direction: column;
  }

  .canvas-title-bar {
    padding: var(--sp-4) var(--sp-4) var(--sp-3);
  }

  .canvas-content {
    padding: 0 var(--sp-4) var(--sp-4);
  }

  .canvas-info-bar {
    padding: var(--sp-3) var(--sp-4);
  }
}

/* ── Backdrop-filter fallback ──────────────── */

@supports not (backdrop-filter: blur(1px)) {
  header,
  .system-section,
  .agent-panel,
  .live-feed-band,
  .live-feed-item,
  .toast,
  .task-item,
  .canvas-info-bar {
    background: var(--color-bg-raised) !important;
  }
}

/* ── Briefing Template ──────────────────────── */

.briefing-container {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.briefing-summary {
  padding: var(--sp-3) var(--sp-4);
  border-left: 1px solid var(--glass-stroke);
  background: var(--color-bg-inset);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: var(--text-base);
  line-height: 1.6;
}

.briefing-toc {
  padding: var(--sp-3) var(--sp-4);
  background: var(--color-bg-inset);
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-stroke);
}

.briefing-toc-title {
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: var(--sp-2);
}

.briefing-toc-item {
  display: block;
  padding: var(--sp-1) 0;
  color: var(--color-accent);
  text-decoration: none;
  font-size: var(--text-sm);
  transition: opacity var(--duration-fast);
}

.briefing-toc-item:hover {
  opacity: 0.7;
}

.briefing-toggle-all {
  align-self: flex-end;
  padding: var(--sp-1) var(--sp-3);
  background: var(--color-bg-inset);
  border: 1px solid var(--glass-stroke);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.briefing-toggle-all:hover {
  background: var(--color-bg-overlay);
  color: var(--color-text);
}

.briefing-section {
  border: 1px solid var(--glass-stroke);
  border-radius: var(--radius-md);
}

.briefing-section-divider {
  border: none;
  border-bottom: 1px solid var(--glass-stroke);
  border-radius: 0;
}

.briefing-section-header {
  display: flex;
  align-items: center;
  padding: var(--sp-3) var(--sp-4);
  background: var(--color-accent-tint);
  user-select: none;
  cursor: pointer;
  transition: background var(--duration-fast);
}

.briefing-section-header:hover {
  background: var(--color-accent-bg);
}

.briefing-section-header::before {
  content: "\25BE";  /* ▾ */
  margin-right: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  transition: transform var(--duration-normal) var(--ease-out);
}

.briefing-section-header.collapsed::before {
  transform: rotate(-90deg);
}

.briefing-section-title {
  margin: 0;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
}

.briefing-section-summary {
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.briefing-section-body {
  padding: var(--sp-3) var(--sp-4);
  transition: opacity var(--duration-normal) var(--ease-out), padding var(--duration-normal);
  opacity: 1;
  overflow: visible;
}

.briefing-section-body.collapsed {
  height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
}

/* Compact mode (dashboard) — tighter spacing */
.briefing-compact .briefing-toc {
  display: none;
}

.briefing-compact .briefing-section-header {
  padding: var(--sp-2) var(--sp-3);
}

.briefing-compact .briefing-section-body {
  padding: var(--sp-2) var(--sp-3);
}

/* ── Comparison Template ────────────────────── */

.comparison-container {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.comparison-summary {
  padding: var(--sp-3) var(--sp-4);
  border-left: 1px solid var(--glass-stroke);
  background: var(--color-bg-inset);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: var(--text-base);
  line-height: 1.6;
}

.comparison-sides {
  display: flex;
  gap: var(--sp-4);
}

.comparison-side-by-side .comparison-sides {
  flex-direction: row;
}

.comparison-stacked .comparison-sides {
  flex-direction: column;
}

.comparison-side {
  flex: 1;
  border: 1px solid var(--glass-stroke);
  border-radius: var(--radius-md);
  overflow: visible;
}

.comparison-side-label {
  padding: var(--sp-2) var(--sp-3);
  background: var(--color-accent-hover);
  font-weight: 600;
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text);
  border-bottom: 1px solid var(--glass-stroke);
}

.comparison-side-body {
  padding: var(--sp-3);
}

/* ── Dashboard Template ─────────────────────── */

.dashboard-template {
  display: grid;
  grid-template-columns: repeat(var(--dashboard-cols, 2), 1fr);
  gap: var(--sp-3);
}

.dashboard-widget {
  border: 1px solid var(--glass-stroke);
  border-radius: var(--radius-md);
  overflow: visible;
  display: flex;
  flex-direction: column;
}

.dashboard-widget-title {
  padding: var(--sp-2) var(--sp-3);
  background: var(--color-accent-hover);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-text);
  border-bottom: 1px solid var(--glass-stroke);
}

.dashboard-widget-body {
  padding: var(--sp-3);
  flex: 1;
}

/* ── Steps Template ─────────────────────────── */

.steps-container {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.steps-summary {
  padding: var(--sp-3) var(--sp-4);
  border-left: 1px solid var(--glass-stroke);
  background: var(--color-bg-inset);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: var(--text-base);
  line-height: 1.6;
}

.steps-progress {
  position: relative;
  height: 6px;
  background: var(--color-bg-inset);
  border-radius: 3px;
  overflow: visible;
}

.steps-progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--color-accent);
  border-radius: 3px;
  transition: width 0.5s var(--ease-out);
  box-shadow: 0 0 8px var(--color-accent);
}

.steps-progress-label {
  position: absolute;
  right: 0;
  top: -18px;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
}

.steps-step {
  display: flex;
  gap: var(--sp-3);
  position: relative;
  padding-bottom: var(--sp-3);
}

.steps-step-marker {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-bg-inset);
  border: 2px solid var(--glass-stroke);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  flex-shrink: 0;
  z-index: 1;
  transition: all var(--duration-normal) var(--ease-out);
}

.steps-step-done .steps-step-marker {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: white;
  box-shadow: 0 0 8px var(--color-accent);
}

.steps-step-content {
  flex: 1;
  min-width: 0;
}

.steps-step-title {
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--color-text);
  padding-top: var(--sp-1);
}

.steps-step-done .steps-step-title {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

.steps-step-description {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-top: var(--sp-1);
}

.steps-step-body {
  margin-top: var(--sp-2);
}

.steps-connector {
  position: absolute;
  left: 13px;
  top: 30px;
  bottom: 0;
  width: 2px;
  background: var(--glass-stroke);
}

.steps-step-done .steps-connector {
  background: var(--color-accent);
  box-shadow: 0 0 4px var(--color-accent);
}

/* ── Plan Template ──────────────────────────── */

.plan-container {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.plan-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.plan-status-badge {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-full, 999px);
  text-transform: uppercase;
}

.plan-status-proposed {
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.plan-status-active {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.plan-status-completed {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.plan-status-cancelled {
  background: rgba(107, 114, 128, 0.15);
  color: #6b7280;
  border: 1px solid rgba(107, 114, 128, 0.3);
}

.plan-dag {
  border: 1px solid var(--glass-stroke);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  background: var(--color-bg-inset);
  overflow: auto;
}

.plan-progress {
  position: relative;
  height: 6px;
  background: var(--color-bg-inset);
  border-radius: 3px;
  overflow: visible;
  margin-top: var(--sp-2);
}

.plan-progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--color-accent);
  border-radius: 3px;
  transition: width 0.5s var(--ease-out);
  box-shadow: 0 0 8px var(--color-accent);
}

.plan-progress-label {
  position: absolute;
  right: 0;
  top: -18px;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
}

.plan-step-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.plan-step-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-md);
  background: var(--color-bg-inset);
  border: 1px solid var(--glass-stroke);
  transition: all var(--duration-normal) var(--ease-out);
}

.plan-step-item-completed {
  opacity: 0.7;
}

.plan-step-icon {
  font-size: var(--text-lg);
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.plan-step-subject {
  flex: 1;
  font-weight: 500;
  font-size: var(--text-base);
  color: var(--color-text);
}

.plan-step-item-completed .plan-step-subject {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

.plan-step-agent {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  padding: var(--sp-1) var(--sp-2);
  background: var(--glass-bg);
  border-radius: var(--radius-sm, 4px);
  flex-shrink: 0;
}

.plan-step-status {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  flex-shrink: 0;
  min-width: 80px;
  text-align: right;
}

/* ── Slides Template ────────────────────────── */

.slides-container {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.slides-viewport {
  min-height: 200px;
  border: 1px solid var(--glass-stroke);
  border-radius: var(--radius-md);
  overflow: visible;
}

.slides-slide {
  padding: var(--sp-4);
}

.slides-slide-hidden {
  display: none;
}

.slides-slide-title {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--sp-3);
  padding-bottom: var(--sp-2);
  border-bottom: 2px solid var(--color-accent);
}

.slides-slide-body {
  min-height: 120px;
}

.slides-slide-notes {
  margin-top: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--color-bg-inset);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  font-style: italic;
  border: 1px solid var(--glass-stroke);
}

.slides-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  padding: var(--sp-2);
}

.slides-nav-btn {
  padding: var(--sp-2) var(--sp-4);
  background: var(--glass-bg);
  border: 1px solid var(--glass-stroke);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  backdrop-filter: blur(var(--glass-blur-subtle));
  -webkit-backdrop-filter: blur(var(--glass-blur-subtle));
}

.slides-nav-btn:hover:not(:disabled) {
  background: var(--color-accent-subtle);
  border-color: var(--color-accent);
  transform: translateY(-1px);
}

.slides-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.slides-nav-indicator {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  font-weight: 600;
  min-width: 60px;
  text-align: center;
}

/* ── Progress card ──────────────────────────── */

.progress-label {
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--color-text);
}

.progress-bar {
  position: relative;
  height: 24px;
  background: var(--glass-bg);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--glass-stroke);
}

.progress-fill {
  height: 100%;
  border-radius: 12px;
  transition: width 0.4s ease;
}

.progress-fill.progress-in_progress { background: var(--color-accent); }
.progress-fill.progress-completed { background: var(--color-success); }
.progress-fill.progress-failed { background: var(--color-danger); }
.progress-fill.progress-paused { background: var(--color-warning); }

.progress-pct {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text);
}

.progress-counter {
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  margin-top: 4px;
}

.progress-steps {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.progress-step {
  font-size: 0.85rem;
  padding: 4px 8px;
  border-radius: 4px;
  color: var(--color-text-secondary);
}

.progress-step.done { color: var(--color-success); text-decoration: line-through; opacity: 0.7; }
.progress-step.active { color: var(--color-accent); font-weight: 600; background: var(--glass-bg); }

/* ── Terminal card ─────────────────────────── */

.terminal-output {
  background: #1a1a2e;
  color: #e0e0e0;
  padding: 16px;
  border-radius: 8px;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ANSI color classes */
.ansi-bold { font-weight: bold; }
.ansi-black { color: #555; }
.ansi-red { color: #ff5555; }
.ansi-green { color: #50fa7b; }
.ansi-yellow { color: #f1fa8c; }
.ansi-blue { color: #6272a4; }
.ansi-magenta { color: #ff79c6; }
.ansi-cyan { color: #8be9fd; }
.ansi-white { color: #f8f8f2; }
.ansi-bright-black { color: #6272a4; }
.ansi-bright-red { color: #ff6e6e; }
.ansi-bright-green { color: #69ff94; }
.ansi-bright-yellow { color: #ffffa5; }
.ansi-bright-blue { color: #d6acff; }
.ansi-bright-magenta { color: #ff92df; }
.ansi-bright-cyan { color: #a4ffff; }
.ansi-bright-white { color: #ffffff; }

/* ── Dependency graph card ─────────────────── */

.dep-graph {
  padding: 8px;
}

.dep-graph .mermaid {
  display: flex;
  justify-content: center;
}

/* ── Cost card ─────────────────────────────── */

.cost-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.cost-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid var(--glass-stroke);
  font-weight: 600;
  color: var(--color-text);
}

.cost-table td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--glass-stroke);
  color: var(--color-text-secondary);
}

.cost-table td:nth-child(n+2),
.cost-table th:nth-child(n+2) {
  text-align: right;
}

.cost-table tbody tr:hover {
  background: var(--glass-bg);
}

.cost-table tfoot td {
  border-top: 2px solid var(--glass-stroke);
  border-bottom: none;
  padding-top: 8px;
  color: var(--color-text);
  font-weight: bold;
}

/* ── Link Preview Card ──────────────────────── */

.link-preview-card {
  display: flex;
  gap: var(--sp-4);
  padding: var(--sp-4);
  border: 1px solid var(--glass-stroke);
  border-left: 4px solid var(--color-accent);
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  text-decoration: none;
  color: inherit;
  transition: background var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
  cursor: pointer;
  overflow: hidden;
}

.link-preview-card:hover {
  background: var(--glass-hover);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.link-preview-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.link-preview-site {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.link-preview-favicon {
  width: 16px;
  height: 16px;
  border-radius: 2px;
  flex-shrink: 0;
}

.link-preview-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-accent);
  line-height: var(--leading-snug);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.link-preview-description {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: var(--leading-normal);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.link-preview-url {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-preview-thumbnail {
  flex-shrink: 0;
  width: 120px;
  height: 80px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.link-preview-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 480px) {
  .link-preview-card {
    flex-direction: column;
  }
  .link-preview-thumbnail {
    width: 100%;
    height: 160px;
    order: -1;
  }
}

/* ── Responsive — template adjustments ──────── */

@media (max-width: 640px) {
  .comparison-sides {
    flex-direction: column;
  }

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

/* -- Admin View -- */
#admin-view { height: 100%; }
#admin-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: var(--sp-4);
  gap: var(--sp-4);
}
.admin-section-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  margin: 0 0 var(--sp-2) 0;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-shrink: 0;
}
#admin-agents-widget {
  flex-shrink: 0;
  max-height: 250px;
  overflow: hidden;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-stroke);
  border-radius: var(--radius-md);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
}
.admin-agents-table-wrap {
  overflow: auto;
  flex: 1;
  min-height: 0;
}
#admin-agents-widget .system-agents-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--color-bg);
}
#admin-agents-widget.splitter-resized {
  max-height: none;
}
#admin-splitter {
  height: 6px;
  cursor: row-resize;
  flex-shrink: 0;
  position: relative;
  margin: -3px 0;
  z-index: 1;
  background: transparent;
}
#admin-splitter::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--glass-stroke);
  transition: width var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out);
}
#admin-splitter:hover::after,
#admin-splitter.dragging::after,
#admin-splitter:focus-visible::after {
  background: var(--color-accent);
  width: 60px;
}
body.splitter-dragging {
  user-select: none;
  cursor: row-resize;
}
@media (max-width: 768px) {
  #admin-splitter { display: none; }
}
#admin-feed-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-stroke);
  border-radius: var(--radius-md);
  padding: var(--sp-3);
}
#admin-feed {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-height: 0;
}
.admin-bubble {
  max-width: 90%;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  animation: cardIn 300ms ease-out both;
}
.admin-bubble-user {
  align-self: flex-end;
  background: var(--color-accent);
  color: #fff;
  border-bottom-right-radius: var(--sp-1);
}
.admin-bubble-agent {
  align-self: flex-start;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-bottom-left-radius: var(--sp-1);
}
.admin-bubble-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-xs);
  font-weight: 600;
  opacity: 0.7;
  margin-bottom: var(--sp-2);
}
.admin-bubble-user .admin-bubble-header { display: none; }
.admin-bubble-body {
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.admin-bubble-time {
  font-size: var(--text-xs);
  opacity: 0.5;
}
#admin-input-bar {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-stroke);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}
#admin-target-badge {
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
  padding: var(--sp-2) 0;
  flex-shrink: 0;
}
#admin-target-badge.has-target {
  color: var(--color-accent);
  font-weight: 600;
}
.admin-selectable-table tbody tr {
  cursor: pointer;
}
.admin-selectable-table tbody tr.admin-row-selected,
.admin-selectable-table tbody tr.admin-row-selected:hover {
  background: color-mix(in srgb, var(--color-accent) 20%, transparent) !important;
  outline: 1px solid color-mix(in srgb, var(--color-accent) 40%, transparent);
  outline-offset: -1px;
}
.admin-selectable-table tbody tr.admin-row-selected td {
  color: var(--text-primary);
}
#admin-message-input {
  flex: 1;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--glass-stroke);
  border-radius: var(--radius-sm);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  resize: none;
  line-height: var(--leading-normal);
  max-height: 120px;
  overflow-y: auto;
}
#admin-message-input:focus {
  outline: none;
  border-color: var(--color-accent);
}
#admin-send-btn {
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--text-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: stretch;
  transition: filter 150ms ease-out, transform 100ms ease-out;
}
#admin-send-btn:hover { filter: brightness(1.1); }
#admin-send-btn:active { transform: scale(0.97); }
.admin-spinner {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  animation: fadeIn 300ms ease-out;
}
.admin-spinner-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent);
  animation: glow-pulse 1.5s ease-in-out infinite;
}
