/* =======================================================================
   Model Server Dashboard — Design System
   Brand: "the robot works" — Green-anchored dual-theme palette
   Dark accent: #00D494 | Light accent: #00A872
   ======================================================================= */

/* -- CSS Custom Properties (Dark theme default) -- */
:root,
[data-theme="dark"] {
  --bg-primary: #0f1117;
  --bg-secondary: #161926;
  --bg-card: #1a1d2e;
  --bg-card-hover: #1f2337;
  --bg-elevated: #232740;
  --bg-input: #1e2235;

  --text-primary: #e8eaf0;
  --text-secondary: #9ca3b8;
  --text-muted: #636b83;

  --border-color: rgba(255 255 255 / 0.06);
  --border-color-strong: rgba(255 255 255 / 0.12);

  /* Brand accent — slightly muted for dark backgrounds */
  --accent: #00D494;
  --accent-light: #33EDBA;
  --accent-gradient: linear-gradient(135deg, #00D494, #00B87D);
  --accent-glow: rgba(0 212 148 / 0.12);

  /* Semantic palette (green-harmonized) */
  --color-primary: #00D494;
  /* brand green */
  --color-secondary: #0EA5E9;
  /* sky blue */
  --color-tertiary: #F59E0B;
  /* amber */
  --color-quaternary: #A78BFA;
  /* soft purple */
  --color-neutral: #64748B;
  /* slate */

  /* Status colors */
  --status-running: #00D494;
  --status-running-bg: rgba(0 212 148 / 0.12);
  --status-stopped: #6b7280;
  --status-stopped-bg: rgba(107 114 128 / 0.12);
  --status-error: #F87171;
  --status-error-bg: rgba(248 113 113 / 0.12);
  --status-creating: #FBBF24;
  --status-creating-bg: rgba(251 191 36 / 0.12);
  --status-degraded: #FB923C;
  --status-degraded-bg: rgba(251 146 60 / 0.12);

  --toast-success: #00D494;
  --toast-error: #F87171;
  --toast-info: #0EA5E9;

  --sidebar-width: 240px;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;

  --glass-bg: rgba(26 29 46 / 0.7);
  --glass-border: rgba(255 255 255 / 0.08);
  --glass-blur: 16px;

  --shadow-card: 0 4px 24px rgba(0 0 0 / 0.2);
  --shadow-elevated: 0 8px 32px rgba(0 0 0 / 0.3);

  color-scheme: dark;
}

[data-theme="light"] {
  --bg-primary: #f5f5f7;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #fafafa;
  --bg-elevated: #ffffff;
  --bg-input: #f0f0f4;

  --text-primary: #1a1a2e;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;

  --border-color: rgba(0 0 0 / 0.06);
  --border-color-strong: rgba(0 0 0 / 0.12);

  /* Brand accent — darker for light backgrounds */
  --accent: #00A872;
  --accent-light: #009966;
  --accent-gradient: linear-gradient(135deg, #00A872, #008F60);
  --accent-glow: rgba(0 168 114 / 0.1);

  /* Semantic palette (light-mode tuned) */
  --color-primary: #00A872;
  --color-secondary: #0284C7;
  --color-tertiary: #D97706;
  --color-quaternary: #7C3AED;
  --color-neutral: #475569;

  /* Status — darker for readability on white */
  --status-running: #00A872;
  --status-running-bg: rgba(0 168 114 / 0.1);
  --status-error: #DC2626;
  --status-error-bg: rgba(220 38 38 / 0.08);
  --status-creating: #D97706;
  --status-creating-bg: rgba(217 119 6 / 0.08);
  --status-degraded: #EA580C;
  --status-degraded-bg: rgba(234 88 12 / 0.08);

  --toast-success: #00A872;
  --toast-error: #DC2626;
  --toast-info: #0284C7;

  --glass-bg: rgba(255 255 255 / 0.7);
  --glass-border: rgba(0 0 0 / 0.06);

  --shadow-card: 0 1px 8px rgba(0 0 0 / 0.06);
  --shadow-elevated: 0 4px 16px rgba(0 0 0 / 0.08);

  color-scheme: light;
}

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

html {
  font-size: 14px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--accent);
  color: white;
}

/* -- Scrollbar -- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* =======================================================================
   Sidebar
   ======================================================================= */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-color);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
}

.logo svg {
  color: var(--accent-light);
}

.logo-text {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.machine-name {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  margin-top: 4px;
  padding-left: 34px;
  /* align with logo text (icon width + gap) */
}

/* -- Dev mode toggle (sidebar header) -- */
.dev-mode-toggle {
  display: flex;
  gap: 0;
  margin-top: 10px;
  padding: 0 12px 0 34px;
  border-radius: 6px;
}

.dev-mode-btn {
  flex: 1;
  padding: 4px 0;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid var(--border-color-strong);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.dev-mode-btn:first-child {
  border-radius: 5px 0 0 5px;
  border-right: none;
}

.dev-mode-btn:last-child {
  border-radius: 0 5px 5px 0;
}

.dev-mode-btn.active {
  background: var(--accent-glow);
  color: var(--accent-light);
  border-color: var(--accent);
}

.dev-mode-btn.active[data-env="dev"] {
  --dev-accent: #F59E0B;
  background: rgba(245, 158, 11, 0.12);
  color: #F59E0B;
  border-color: #F59E0B;
}

/* When dev mode is active, also style the non-active button border */
.dev-mode-toggle.dev-active .dev-mode-btn:not(.active) {
  border-color: rgba(245, 158, 11, 0.3);
}

.dev-mode-namespace {
  font-size: 0.72rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary);
  padding: 4px 12px 0 34px;
  transition: color var(--transition);
}

.dev-mode-namespace.dev-active {
  color: #F59E0B;
  opacity: 1;
}

.dev-mode-hint {
  font-size: 0.62rem;
  color: var(--text-secondary);
  padding: 2px 12px 0 34px;
  opacity: 0.7;
  font-style: italic;
}

/* Dev mode page top-border (safety indicator) */
body.dev-mode-active::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, #F59E0B, #FB923C, #F59E0B);
  z-index: 9999;
}

.nav-list {
  list-style: none;
  padding: 12px 8px;
  flex: 1;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
}

.nav-link:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.nav-link.active {
  background: var(--accent-glow);
  color: var(--accent-light);
}

.nav-link.active svg {
  color: var(--accent-light);
}

/* Status indicator dot (e.g. robot link active) */
.nav-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--status-running, #00D494);
  margin-left: auto;
  flex-shrink: 0;
  box-shadow: 0 0 6px var(--status-running, #00D494);
  animation: nav-dot-pulse 2s ease-in-out infinite;
}

@keyframes nav-dot-pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* -- User profile (sidebar bottom) -- */
.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
  flex-shrink: 0;
}

/* Fallback initials circle when no avatar image */
.user-avatar-fallback {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sign-out-btn {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.sign-out-btn:hover {
  color: var(--status-error);
  border-color: var(--status-error);
  background: var(--status-error-bg);
}

/* -- Connection status -- */
.connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 500;
}

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

.connection-status.connected .status-dot {
  background: var(--status-running);
  box-shadow: 0 0 6px var(--status-running);
  animation: pulse-dot 2s infinite;
}

.connection-status.connected .status-text {
  color: var(--status-running);
}

.connection-status.disconnected .status-dot {
  background: var(--status-error);
}

.connection-status.disconnected .status-text {
  color: var(--text-muted);
}

.connection-status.reconnecting .status-dot {
  background: var(--status-creating);
  animation: pulse-dot 1s infinite;
}

.connection-status.reconnecting .status-text {
  color: var(--status-creating);
}

@keyframes pulse-dot {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

/* -- Theme toggle -- */
.theme-toggle {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.theme-toggle:hover {
  color: var(--text-primary);
  border-color: var(--border-color-strong);
  background: var(--bg-card);
}

[data-theme="dark"] .icon-sun {
  display: block;
}

[data-theme="dark"] .icon-moon {
  display: none;
}

[data-theme="light"] .icon-sun {
  display: none;
}

[data-theme="light"] .icon-moon {
  display: block;
}

/* =======================================================================
   Main Content
   ======================================================================= */
.main-content {
  flex: 1;
  overflow-y: auto;
  height: 100vh;
}

.page-container {
  padding: 28px 32px;
  max-width: 1400px;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =======================================================================
   Typography
   ======================================================================= */
.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-bottom: 24px;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
}

/* =======================================================================
   Cards
   ======================================================================= */
.card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: all var(--transition);
}

.card:hover {
  border-color: var(--border-color-strong);
  box-shadow: var(--shadow-elevated);
}

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

.card-title {
  font-size: 0.88rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

/* =======================================================================
   Grid Layouts
   ======================================================================= */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

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

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

/* =======================================================================
   Metric Displays
   ======================================================================= */
.metric-value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.metric-value.small {
  font-size: 1.4rem;
}

.metric-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.metric-accent {
  color: var(--accent-light);
}

.metric-green {
  color: var(--status-running);
}

.metric-red {
  color: var(--status-error);
}

.metric-amber {
  color: var(--status-creating);
}

/* -- Progress bar -- */
.progress-bar {
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  margin-top: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
  background: var(--accent-gradient);
}

.progress-fill.green {
  background: var(--status-running);
}

.progress-fill.amber {
  background: var(--status-creating);
}

.progress-fill.red {
  background: var(--status-error);
}

/* =======================================================================
   Status Badge
   ======================================================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-running {
  background: var(--status-running-bg);
  color: var(--status-running);
}

.badge-stopped {
  background: var(--status-stopped-bg);
  color: var(--status-stopped);
}

.badge-error {
  background: var(--status-error-bg);
  color: var(--status-error);
}

.badge-creating {
  background: var(--status-creating-bg);
  color: var(--status-creating);
}

.badge-launching {
  background: var(--status-creating-bg);
  color: var(--status-creating);
}

.badge-stopping {
  background: var(--status-creating-bg);
  color: var(--status-creating);
}

.badge-degraded {
  background: var(--status-degraded-bg);
  color: var(--status-degraded);
}

.badge-ok {
  background: var(--status-running-bg);
  color: var(--status-running);
}

/* =======================================================================
   Buttons
   ======================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
}

.btn-primary:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  color: var(--text-primary);
  border-color: var(--border-color-strong);
  background: var(--bg-card-hover);
}

.btn-danger {
  background: var(--status-error);
  color: white;
}

.btn-danger:hover {
  filter: brightness(1.15);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

.btn-sm.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 40%, transparent);
}

.btn-icon {
  padding: 6px 8px;
}

/* =======================================================================
   Tables
   ======================================================================= */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table.resizable {
  table-layout: fixed;
}

th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color-strong);
  position: relative;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Resize handle on the right edge of each th */
th .col-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  cursor: col-resize;
  background: transparent;
  transition: background 0.15s ease;
  z-index: 2;
}

th .col-resize-handle:hover,
th .col-resize-handle.active {
  background: var(--accent);
}

td {
  padding: 12px 14px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

tr:hover td {
  background: var(--bg-card-hover);
}

td.mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
}

/* =======================================================================
   Log / Code viewer
   ======================================================================= */
.log-viewer {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--text-secondary);
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* =======================================================================
   Toast Notifications
   ======================================================================= */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow-elevated);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  max-width: 420px;
  animation: slideInRight 0.3s ease;
  font-size: 0.88rem;
}

.toast.toast-success {
  border-left: 3px solid var(--toast-success);
}

.toast.toast-error {
  border-left: 3px solid var(--toast-error);
}

.toast.toast-info {
  border-left: 3px solid var(--toast-info);
}

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.toast.toast-success .toast-icon {
  color: var(--toast-success);
}

.toast.toast-error .toast-icon {
  color: var(--toast-error);
}

.toast.toast-info .toast-icon {
  color: var(--toast-info);
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(40px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateX(40px);
  }
}

/* =======================================================================
   Modal
   ======================================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
}

.modal-overlay[hidden] {
  display: none !important;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius);
  padding: 28px;
  min-width: 380px;
  max-width: 500px;
  box-shadow: var(--shadow-elevated);
  animation: scaleIn 0.2s ease;
}

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

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-title {
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.modal-message {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-bottom: 24px;
  line-height: 1.5;
  white-space: pre-line;
  overflow-wrap: break-word;
  word-break: break-word;
}

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

/* =======================================================================
   Server Cards
   ======================================================================= */
.server-card {
  position: relative;
  overflow: hidden;
}

.server-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.server-card.state-running::before {
  background: var(--status-running);
}

.server-card.state-creating::before {
  background: var(--status-creating);
}

.server-card.state-error::before {
  background: var(--status-error);
}

.server-card.state-stopped::before {
  background: var(--status-stopped);
}

.server-info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.85rem;
}

.server-info-row .label {
  color: var(--text-muted);
  min-width: 80px;
}

.server-info-row .value {
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
}

.server-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
}

/* -- Inference State Panel -- */
.inference-state-panel {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.inference-state-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.inference-state-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.inference-state-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.inference-state-body {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem;
  line-height: 1.5;
}

.inference-state-placeholder {
  color: var(--text-muted);
  font-style: italic;
  font-family: inherit;
}

.inference-table {
  width: 100%;
  border-collapse: collapse;
}

.inference-table td {
  padding: 3px 0;
  border: none;
  font-size: 0.76rem;
  vertical-align: top;
}

.inference-table tr:hover td {
  background: transparent;
}

.inference-label {
  color: var(--text-muted);
  font-weight: 600;
  width: 60px;
  white-space: nowrap;
}

.inference-values {
  color: var(--text-secondary);
  word-break: break-all;
}

.inference-group {
  display: block;
  margin-bottom: 1px;
}

.inference-group b {
  color: var(--accent-light);
  margin-right: 4px;
}

.inference-na {
  color: var(--text-muted);
}

/* =======================================================================
   Health dot
   ======================================================================= */
.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.health-dot.ok {
  background: var(--status-running);
  box-shadow: 0 0 4px var(--status-running);
}

.health-dot.degraded {
  background: var(--status-degraded);
}

.health-dot.error {
  background: var(--status-error);
}

.health-dot.unknown {
  background: var(--text-muted);
}

/* =======================================================================
   Charts
   ======================================================================= */
.chart-container {
  position: relative;
  width: 100%;
  height: 220px;
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* =======================================================================
   Empty state
   ======================================================================= */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state h3 {
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.toolbar-spacer {
  flex: 1;
}

/* =======================================================================
   Event log specific
   ======================================================================= */
.event-row {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
  align-items: flex-start;
}

.event-time {
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  min-width: 75px;
  flex-shrink: 0;
}

.event-source {
  font-weight: 600;
  min-width: 70px;
  flex-shrink: 0;
}

.event-message {
  color: var(--text-secondary);
  flex: 1;
}

.event-source.system {
  color: var(--accent-light);
}

.event-source.gpu {
  color: var(--status-creating);
}

.event-source.container {
  color: var(--status-running);
}

.event-source.server {
  color: #a78bfa;
}

/* -- Filter chips -- */
.filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  transition: all var(--transition);
  font-family: inherit;
}

.chip.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent-light);
}

.chip:hover:not(.active) {
  border-color: var(--border-color-strong);
  color: var(--text-primary);
}

/* =======================================================================
   Gauge ring (Dashboard)
   ======================================================================= */
.gauge-ring {
  position: relative;
  width: 110px;
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gauge-ring svg {
  position: absolute;
  transform: rotate(-90deg);
}

.gauge-ring .gauge-value {
  font-size: 1.4rem;
  font-weight: 700;
  z-index: 1;
}

.gauge-row {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

/* Dashboard section title */
.dash-section-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin: 0 0 12px 0;
}

/* Dashboard gauges row */
.dash-gauges-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px 16px;
}

.dash-gauge-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 100px;
  flex: 1;
}

.dash-gauge-item .gauge-ring {
  width: 88px;
  height: 88px;
}

.dash-gauge-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.dash-gauge-detail {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* =======================================================================
   Utility
   ======================================================================= */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-8 {
  gap: 8px;
}

.gap-16 {
  gap: 16px;
}

.gap-24 {
  gap: 24px;
}

.mb-16 {
  margin-bottom: 16px;
}

.mb-24 {
  margin-bottom: 24px;
}

.mt-16 {
  margin-top: 16px;
}

.text-mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

/* =======================================================================
   Login Screen
   ======================================================================= */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20000;
}

.login-overlay[hidden] {
  display: none !important;
}

.login-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 40px;
  min-width: 360px;
  max-width: 420px;
  box-shadow: var(--shadow-elevated);
  text-align: center;
  animation: scaleIn 0.3s ease;
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
  color: var(--accent-light);
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-bottom: 28px;
}

.login-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}

.login-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.login-input::placeholder {
  color: var(--text-muted);
}

.login-error {
  color: var(--status-error);
  font-size: 0.82rem;
  margin-top: 8px;
  margin-bottom: 0;
}

.login-error[hidden] {
  display: none;
}

.login-btn {
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  font-size: 0.95rem;
  justify-content: center;
}

/* -- Form Fields -- */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input {
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color-strong);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.88rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder {
  color: var(--text-muted);
}

select.form-input {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.form-error {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--status-error-bg);
  color: var(--status-error);
  border-radius: 8px;
  font-size: 0.85rem;
}

.form-error.hidden {
  display: none;
}

.launch-form {
  padding: 16px 0 4px;
}

/* -- Local/Cloud toggle (launch form header) -- */
.launch-env-toggle {
  display: flex;
  gap: 0;
  padding: 0 16px;
}

.launch-env-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 0;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid var(--border-color-strong);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.launch-env-btn:first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  border-right: none;
}

.launch-env-btn:last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.launch-env-btn.active {
  background: var(--accent-glow);
  color: var(--accent-light);
  border-color: var(--accent);
}

.launch-env-btn.active[data-mode="cloud"] {
  background: rgba(14, 165, 233, 0.12);
  color: #38BDF8;
  border-color: #0EA5E9;
}

.launch-env-btn:not(.active):hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* -- Cloud Options panel -- */
.cloud-options {
  background: rgba(14, 165, 233, 0.04);
  border: 1px solid rgba(14, 165, 233, 0.15);
  border-radius: var(--radius);
  overflow: hidden;
  animation: slideDown 0.2s ease;
}

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

.cloud-options-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #38BDF8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 16px;
  background: rgba(14, 165, 233, 0.06);
  border-bottom: 1px solid rgba(14, 165, 233, 0.1);
}

.cloud-options-body {
  padding: 12px 16px;
}

/* -- GPU Tier radio cards -- */
.gpu-tier-selector {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gpu-tier-option {
  cursor: pointer;
}

.gpu-tier-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.gpu-tier-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 0.8rem;
  border: 1px solid var(--border-color-strong);
  border-radius: 6px;
  color: var(--text-muted);
  transition: all var(--transition);
}

.gpu-tier-name {
  font-weight: 700;
  font-size: 0.8rem;
  min-width: 60px;
  color: var(--text-secondary, var(--text-muted));
}

.gpu-tier-spec {
  font-size: 0.72rem;
  color: var(--text-muted);
  opacity: 0.7;
  flex: 1;
}

.gpu-tier-instance {
  font-size: 0.68rem;
  font-family: var(--font-mono, monospace);
  color: var(--text-muted);
  opacity: 0.5;
  white-space: nowrap;
}

.gpu-tier-option input[type="radio"]:checked + .gpu-tier-label {
  background: rgba(14, 165, 233, 0.1);
  color: #38BDF8;
  border-color: #0EA5E9;
}

.gpu-tier-option input[type="radio"]:checked + .gpu-tier-label .gpu-tier-name {
  color: #38BDF8;
}

.gpu-tier-option input[type="radio"]:checked + .gpu-tier-label .gpu-tier-spec,
.gpu-tier-option input[type="radio"]:checked + .gpu-tier-label .gpu-tier-instance {
  opacity: 1;
  color: rgba(56, 189, 248, 0.7);
}

/* -- Flex utility -- */
.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

/* -- Server error banner -- */
.server-error-banner {
  margin: 8px 0;
  padding: 8px 12px;
  background: var(--status-error-bg);
  color: var(--status-error);
  border-radius: 6px;
  font-size: 0.82rem;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
}

.server-warning-banner {
  margin: 8px 0;
  padding: 8px 12px;
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border-radius: 6px;
  font-size: 0.82rem;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  border-left: 3px solid #f59e0b;
}

/* -- Dashboard server summary list -- */
.server-summary-list {
  padding: 4px 0;
}

.server-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-color);
}

.server-summary-row:last-child {
  border-bottom: none;
}

.server-summary-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 8px;
}

/* -- Checkpoint detail panel -- */
.ckpt-row:hover {
  background: var(--bg-hover);
}

.ckpt-row-active {
  background: var(--bg-hover);
}

.ckpt-detail-row {
  background: var(--bg-card);
}

.ckpt-detail-row.hidden {
  display: none;
}

.ckpt-detail-panel {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
}

.ckpt-detail-grid {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 6px 12px;
  font-size: 0.82rem;
}

.ckpt-detail-label {
  color: var(--text-muted);
  font-weight: 500;
}

.ckpt-detail-value {
  color: var(--text-primary);
  word-break: break-all;
}

/* -- Checkpoint split pane -- */
.ckpt-split-pane {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.ckpt-table-pane {
  overflow-x: auto;
}

.ckpt-config-pane {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

.ckpt-config-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
}

.ckpt-config-content {
  display: flex;
  flex-direction: column;
}

.ckpt-config-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.ckpt-config-tab {
  padding: 6px 12px;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.ckpt-config-tab:hover {
  color: var(--text-primary);
}

.ckpt-config-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.ckpt-config-tree {
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-main);
  overflow: auto;
}

/* JSON tree */
.jt-line {
  white-space: nowrap;
}

.jt-toggle:hover {
  background: var(--bg-hover);
  border-radius: 3px;
}

.jt-arrow {
  display: inline-block;
  width: 14px;
  font-size: 0.65rem;
  color: var(--text-muted);
  user-select: none;
}

.jt-key {
  color: #7cacf8;
}

.jt-string {
  color: #a8d4a4;
}

.jt-number {
  color: #7ec8e3;
}

.jt-bool {
  color: #d4a0d4;
}

.jt-null {
  color: var(--text-muted);
  font-style: italic;
}

.jt-preview {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-style: italic;
}

.jt-children {
  padding-left: 18px;
}

.jt-collapsed-tail {
  color: var(--text-primary);
}

@media (max-width: 960px) {
  .ckpt-split-pane {
    grid-template-columns: 1fr;
  }
}

/* =======================================================================
   Robot Data Link Test
   ======================================================================= */

/* Config form */
.robot-config-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 0 4px;
}

.robot-form-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.robot-form-row .form-input {
  flex: 1;
  min-width: 0;
}

.robot-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 100px;
  flex-shrink: 0;
}

.robot-label .text-muted {
  font-weight: 400;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.robot-form-actions {
  display: flex;
  gap: 8px;
  padding-top: 4px;
}

/* Status grid */
.robot-status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 12px 0 4px;
}

.robot-status-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
}

.robot-status-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.robot-stat-value {
  font-size: 0.85rem;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-primary);
}

/* Camera preview */
.robot-camera-container {
  padding: 8px 0 4px;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.robot-camera-img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  background: var(--bg-primary);
}

.robot-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 2rem 0;
}

.robot-placeholder svg {
  opacity: 0.4;
}

/* State data table */
.robot-state-content {
  padding: 4px 0;
}

.robot-state-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.robot-state-table th {
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-color-strong);
}

.robot-state-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
}

.robot-state-key {
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  width: 140px;
}

.robot-state-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-primary);
  word-break: break-all;
}

.robot-state-val code {
  background: transparent;
  padding: 0;
}

.robot-state-unit {
  color: var(--text-muted);
  font-size: 0.72rem;
  white-space: nowrap;
  width: 40px;
}

/* =======================================================================
   Health Monitor Page
   ======================================================================= */

/* Metric grid — 3 items per row by default, 4 for inference */
.health-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.health-metrics-grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.health-metrics-grid-wide {
  grid-template-columns: repeat(5, 1fr);
}

.health-metric-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.health-metric-value {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
}

.health-metric-value.health-metric-small {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  line-height: 1.5;
}

.health-metric-value.health-metric-small b {
  color: var(--text-primary);
  font-weight: 600;
}

.health-metric-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.health-sparkline {
  margin-top: 4px;
}

.sparkline-svg {
  display: block;
}

.sparkline-label {
  fill: var(--text-muted);
  font-size: 7px;
  font-family: 'JetBrains Mono', monospace;
}

.health-metric-unit {
  font-size: 0.7em;
  font-weight: 400;
  color: var(--text-muted);
}

.health-inactive-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Status dot (connected / disconnected / stale) */
.health-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.health-status-dot.connected {
  background: var(--status-running);
  box-shadow: 0 0 6px var(--status-running);
  animation: pulse-dot 2s infinite;
}

.health-status-dot.disconnected {
  background: var(--text-muted);
}

.health-status-dot.stale {
  background: var(--status-creating);
  animation: pulse-dot 1.5s infinite;
}

/* Connection info grid */
.health-connection-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.health-conn-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.health-conn-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.health-conn-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88rem;
  color: var(--text-primary);
}

/* Spacing helpers */
.mb-12 {
  margin-bottom: 12px;
}

/* Responsive: collapse health grids on narrow viewports */
@media (max-width: 900px) {

  .health-metrics-grid,
  .health-metrics-grid-4,
  .health-metrics-grid-wide {
    grid-template-columns: repeat(2, 1fr);
  }

  .health-connection-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* =======================================================================
   Log Bundles Page
   ======================================================================= */
.lb-layout {
  display: flex;
  gap: 20px;
  height: calc(100vh - 160px);
  min-height: 400px;
}

.lb-sidebar {
  width: 380px;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lb-filter-bar {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.lb-bundle-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}

.lb-bundle-item {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
  transition: all var(--transition);
}

.lb-bundle-item:hover {
  border-color: var(--border-color-strong);
  background: var(--bg-card-hover);
}

.lb-bundle-item.active {
  border-color: var(--accent);
  background: var(--accent-glow);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-card);
}

.lb-bundle-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.lb-bundle-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.lb-bundle-icon {
  flex-shrink: 0;
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

.lb-bundle-item.active .lb-bundle-icon {
  color: var(--accent-light);
}

.lb-bundle-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-bundle-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.lb-bundle-age {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.lb-bundle-badge {
  font-size: 0.6rem !important;
  padding: 1px 6px !important;
}

.lb-bundle-info {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* File list inside expanded bundle */
.lb-file-list {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lb-file-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 6px;
}

.lb-file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
}

.lb-file-item:hover {
  background: var(--bg-card-hover);
}

.lb-file-item.active {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent-light);
}

.lb-file-icon {
  font-size: 0.85rem;
  flex-shrink: 0;
}

.lb-file-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-secondary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-file-item.active .lb-file-name {
  color: var(--accent-light);
}

.lb-file-size {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ── Directory tree inside bundle ──────────────────────────────────────── */
.lb-dir-group {
  margin-top: 2px;
}

.lb-dir-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: all var(--transition);
}

.lb-dir-header:hover {
  background: var(--bg-card-hover);
}

.lb-dir-arrow {
  font-size: 0.6rem;
  color: var(--text-muted);
  width: 10px;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.lb-dir-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-dir-children {
  padding-left: 16px;
  border-left: 1px solid var(--border-color);
  margin-left: 12px;
}

.lb-loading,
.lb-loading-sm {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 16px 12px;
  text-align: center;
}

.lb-loading-sm {
  font-size: 0.78rem;
  padding: 8px;
}

.lb-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 16px;
  color: var(--text-muted);
}

.lb-empty p {
  font-size: 0.85rem;
}

/* ── Viewer Panel ──────────────────────────────────────────────────────── */
.lb-viewer-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.lb-viewer-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: 32px;
}

.lb-viewer-empty h3 {
  color: var(--text-secondary);
  font-size: 1rem;
}

.lb-viewer-empty p {
  font-size: 0.85rem;
  max-width: 300px;
}

.lb-viewer-active {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.lb-viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  background: var(--bg-secondary);
}

.lb-toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.lb-toolbar-filename {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.lb-toolbar-bundle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.lb-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lb-wrap-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.lb-wrap-toggle input {
  cursor: pointer;
}

.lb-viewer-content {
  flex: 1;
  overflow: auto;
  padding: 0;
}

.lb-viewer-content pre {
  margin: 0;
  padding: 16px;
  background: transparent;
  min-height: 100%;
}

.lb-viewer-content code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  line-height: 1.65;
  tab-size: 4;
  white-space: pre-wrap;
  word-break: break-word;
}

.lb-viewer-content.no-wrap code {
  white-space: pre;
  word-break: normal;
}

/* Override highlight.js background to match panel */
.lb-viewer-content pre code.hljs {
  background: transparent;
  padding: 0;
}

/* ── Log-level highlighting ────────────────────────────────────────────── */
.log-error {
  color: var(--status-error);
  font-weight: 600;
}

.log-warning {
  color: var(--status-creating);
  font-weight: 600;
}

.log-info {
  color: var(--status-running);
  font-weight: 500;
}

.log-debug {
  color: var(--text-muted);
}

.log-timestamp {
  color: var(--text-muted);
}

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .lb-layout {
    flex-direction: column;
    height: auto;
  }

  .lb-sidebar {
    width: 100%;
    min-width: unset;
    max-height: 40vh;
  }

  .lb-viewer-panel {
    min-height: 50vh;
  }
}

/* =======================================================================
   Latency Inspection Page
   ======================================================================= */

.lat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 16px;
  flex-wrap: wrap;
}

.lat-subheader {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.lat-subheader-bundle {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 36px;
}

.lat-back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
  padding: 0;
}

.lat-back-btn:hover {
  border-color: var(--accent);
  color: var(--accent-light);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.lat-content {
  min-height: 400px;
}

.lat-empty {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0;
  color: var(--text-muted);
}

.lat-empty h3 {
  color: var(--text-secondary);
  font-size: 1rem;
}

.lat-empty p {
  font-size: 0.85rem;
  max-width: 400px;
}

/* ── Inference Analyzer Landing Page ──────────────────────────────────── */
.lat-bundle-list-landing {
  width: 100%;
}

.lat-landing-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 16px;
  color: var(--text-muted);
}

.lat-landing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.lat-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.lat-filter-input {
  padding: 5px 12px;
  font-size: 0.82rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--glass-bg);
  color: var(--text-primary);
  outline: none;
  width: 260px;
  transition: border-color var(--transition);
}

.lat-filter-input:focus {
  border-color: var(--accent);
}

.lat-filter-input::placeholder {
  color: var(--text-muted);
}

.lat-filter-chips {
  display: flex;
  gap: 4px;
}

.lat-filter-search-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.lat-filter-clear {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px 4px;
  line-height: 1;
  border-radius: 50%;
  transition: color var(--transition), background var(--transition);
  display: none;
}

.lat-filter-clear:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.lat-filter-search-wrap.has-text .lat-filter-clear {
  display: block;
}

.lat-filter-search-wrap.has-text .lat-filter-input {
  padding-right: 28px;
}

.lat-landing-count {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.lat-landing-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lat-landing-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  cursor: pointer;
  transition: all var(--transition);
}

.lat-landing-card:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--glass-bg));
  transform: translateX(2px);
}

.lat-landing-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.lat-landing-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lat-landing-date {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.lat-landing-instruction {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 6px;
}

.lat-landing-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.lat-landing-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.lat-landing-badge.sync {
  background: color-mix(in srgb, #3b82f6 18%, transparent);
  border: 1px solid color-mix(in srgb, #3b82f6 35%, transparent);
  color: #60a5fa;
}

.lat-landing-badge.async {
  background: color-mix(in srgb, #f59e0b 18%, transparent);
  border: 1px solid color-mix(in srgb, #f59e0b 35%, transparent);
  color: #fbbf24;
}

.lat-landing-ckpt {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 360px;
}

.lat-landing-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  color: var(--accent-light);
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
}

.lat-landing-size {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-left: auto;
}

.lat-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 64px 16px;
  color: var(--text-muted);
}

.lat-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: #fff;
  border-radius: 50%;
  animation: lat-spin 0.8s linear infinite;
}

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

.lat-progress-wrap {
  width: 320px;
  max-width: 80%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.lat-progress-bar {
  height: 100%;
  width: 0%;
  min-width: 4px;
  background: linear-gradient(90deg, #fff, #a0d8ef);
  border-radius: 4px;
  transition: width 0.3s ease-out;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.5);
  animation: lat-bar-pulse 1.5s ease-in-out infinite;
}

@keyframes lat-bar-pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(255, 255, 255, 0.4); }
  50% { box-shadow: 0 0 16px rgba(255, 255, 255, 0.7); }
}

.lat-loading-timer {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
}

/* -- Config Panel (two-card layout) -- */
.lat-config-panel {
  margin-bottom: 12px;
}

.lat-config-row {
  display: flex;
  gap: 12px;
}

.lat-config-card {
  flex: 1;
  min-width: 0;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lat-config-card-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.lat-config-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: 4px;
}

.lat-config-empty {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 8px 0;
}

.lat-config-ckpt {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lat-config-ckpt-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
}

.lat-config-ckpt-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
}

.lat-config-instruction {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lat-config-instruction-icon {
  font-size: 1.1rem;
}

.lat-config-instruction-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  font-style: italic;
}

.lat-config-params {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.lat-config-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.72rem;
  font-family: 'JetBrains Mono', monospace;
}

.lat-config-pill.tune-on {
  border-color: rgba(0, 212, 148, 0.3);
}

.lat-config-pill.tune-on .lat-config-pill-value {
  color: #6bcf7f;
}

.lat-config-pill.tune-off {
  opacity: 0.55;
}

.lat-config-pill.tune-off .lat-config-pill-value {
  color: var(--text-muted);
}

.lat-config-pill-label {
  color: var(--text-muted);
  font-weight: 600;
}

.lat-config-pill-value {
  color: var(--accent-light);
  font-weight: 700;
}

.lat-config-datasets {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.lat-config-dataset-chip {
  display: inline-flex;
  padding: 2px 7px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.68rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary);
}

.lat-config-crops {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.lat-config-crops-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

.lat-config-crop-chip {
  display: inline-flex;
  padding: 2px 7px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.68rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary);
}

.lat-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.lat-stat-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: help;
  transition: border-color var(--transition);
}

.lat-stat-card:hover {
  border-color: var(--border-color-strong);
}

.lat-stat-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.lat-stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.lat-chart-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 8px;
  margin-bottom: 16px;
}

.lat-chart {
  width: 100%;
}

/* Plotly dark mode overrides */
.lat-chart .plotly .modebar {
  right: 8px !important;
}

/* Analyze button on log bundle cards */
.lb-analyze-btn {
  padding: 2px 8px !important;
  font-size: 0.72rem !important;
  line-height: 1.2 !important;
  border-radius: 6px !important;
  background: color-mix(in srgb, var(--accent) 15%, transparent) !important;
  border: 1px solid var(--accent) !important;
  color: var(--accent-light) !important;
  cursor: pointer !important;
}

.lb-analyze-btn:hover {
  background: color-mix(in srgb, var(--accent) 30%, transparent) !important;
}

/* Override Plotly's 'move' cursor in pan mode with a grab hand */
.lat-chart .nsewdrag[style*="cursor: move"] {
  cursor: grab !important;
}

.lat-chart .nsewdrag[style*="cursor: move"]:active {
  cursor: grabbing !important;
}

/* Collapsible chart sections */
.lat-section {
  margin-bottom: 8px;
}

.lat-section-toggle {
  cursor: pointer;
  user-select: none;
  padding: 8px 12px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color var(--transition), background var(--transition);
}

.lat-section-toggle:hover {
  color: var(--text-primary);
  background: color-mix(in srgb, var(--glass-bg) 80%, var(--accent));
}

.lat-section-toggle::before {
  content: '▶';
  font-size: 0.65rem;
  transition: transform 0.2s ease;
}

.lat-section[open]>.lat-section-toggle::before {
  transform: rotate(90deg);
}

/* Hide default marker in webkit / blink */
.lat-section-toggle::-webkit-details-marker {
  display: none;
}

/* Side-by-side joint space charts */
.lat-joints-row {
  display: flex;
  gap: 8px;
}

.lat-joint-card {
  flex: 1;
  min-width: 0;
}

/* Chunk inspector hint */
.lat-chunk-hint,
.lat-chunk-hint.hidden {
  display: none;
}

/* Subsection label inside unified inspection block */
.lat-subsection-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 8px 4px;
  margin-top: 12px;
  margin-bottom: 4px;
}

/* Arm filter toggle group */
.lat-arm-filter {
  display: flex;
  gap: 2px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 2px;
}

.lat-arm-filter .chip {
  font-size: 0.72rem;
  padding: 2px 10px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1.4;
}

.lat-arm-filter .chip:hover {
  color: var(--text-primary);
  background: var(--glass-bg);
}

.lat-arm-filter .chip.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ── Player Bar (mirrors da-player) ──────────────────────────────────── */
.lat-player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin: 12px 0;
  flex-wrap: wrap;
}

.lat-player button {
  background: var(--glass-bg);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all var(--transition);
  line-height: 1;
}

.lat-player button:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-color-strong);
}

.lat-player button:active {
  transform: scale(0.95);
}

.lat-player button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.lat-play-btn {
  padding: 4px 12px !important;
  font-weight: 600;
}

.lat-play-btn.playing {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}

.lat-video-speed-select,
.da-video-speed-select {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--glass-bg);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  cursor: pointer;
}

.lat-video-speed-select:focus,
.da-video-speed-select:focus {
  outline: none;
  border-color: var(--accent);
}

.lat-scrubber {
  flex: 1;
  min-width: 200px;
  accent-color: var(--accent);
  cursor: pointer;
}

.lat-frame-info {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── 4-Camera Video Grid — 2x2 default, sticky 1x4 ──────────────────── */
.lat-video-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}

.lat-video-pane {
  background: #111;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 16/10;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Sticky 1x4 mode */
.lat-video-row--sticky {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  z-index: 900;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: var(--bg-primary);
  padding: 4px 32px 0;
  max-width: 1400px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  margin-bottom: 0;
}

.lat-video-row--sticky .lat-video-pane {
  aspect-ratio: 16/10;
  border-radius: 4px;
}

.lat-video-row--sticky .lat-video-pane img,
.lat-video-row--sticky .lat-video-pane video {
  object-fit: cover;
}

.lat-video-row--sticky .lat-video-pane-label {
  font-size: 0.55rem;
  top: 3px;
  left: 4px;
  padding: 1px 4px;
}

/* Player bar sticks below sticky video */
.lat-player--sticky {
  position: fixed;
  top: calc((min(100vw - var(--sidebar-width), 1400px) - 64px) / 4 * 10 / 16 + 4px);
  left: var(--sidebar-width);
  right: 0;
  z-index: 900;
  max-width: 1400px;
  padding: 4px 32px;
  border-radius: 0;
  margin-bottom: 0;
  background: var(--bg-secondary);
  border-top: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Sticky toggle button */
.lat-sticky-on {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}

.lat-video-pane img,
.lat-video-pane video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.lat-video-pane-label {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.6);
  z-index: 1;
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 6px;
  border-radius: 4px;
}

.lat-video-placeholder {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* ── Legacy PNG Row ──────────────────────────────────────────────────── */
.lat-video-legacy-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.lat-video-pane-legacy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.lat-video-pane-note {
  font-size: 0.68rem;
  color: var(--text-muted);
  opacity: 0.7;
  font-style: italic;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.lat-video-frame-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #0a0a0a;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  min-height: 200px;
  padding: 8px;
  overflow: hidden;
}

.lat-video-frame-container img {
  max-width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 4px;
  image-rendering: auto;
}

.lat-video-frame-container .lat-video-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 32px;
}


/* ── Chunk Stack ──────────────────────────────────────────────────────── */
.lat-chunk-stack {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow-x: auto;
  margin-bottom: 8px;
}

.lat-cs-gap-marker {
  font-size: 0.65rem;
  font-weight: 700;
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.12);
  border: 1px dashed rgba(255, 107, 107, 0.4);
  border-radius: 3px;
  padding: 1px 5px;
  white-space: nowrap;
  letter-spacing: 0.03em;
}

.lat-cs-axis {
  display: flex;
  margin-bottom: 4px;
}

.lat-cs-tick {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  flex-shrink: 0;
  opacity: 0.5;
}

.lat-cs-tick.highlight {
  opacity: 1;
  color: var(--text-secondary);
  font-weight: 600;
}

.lat-cs-row {
  display: flex;
  align-items: center;
  margin-bottom: 3px;
}

.lat-cs-row.current {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-radius: 4px;
  margin-left: -4px;
  margin-right: -4px;
  padding: 1px 4px;
}

.lat-cs-label {
  width: 66px;
  flex-shrink: 0;
  font-size: 0.7rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
  text-align: right;
  padding-right: 4px;
  white-space: nowrap;
  overflow: hidden;
}

.lat-cs-row.current .lat-cs-label {
  color: var(--accent-light);
  font-weight: 700;
}

.lat-cs-blocks {
  display: flex;
  flex-shrink: 0;
}

.lat-cs-block {
  height: 18px;
  flex-shrink: 0;
  border-radius: 3px;
  margin: 0 1px;
  opacity: 0.5;
  transition: opacity 0.15s;
  cursor: default;
  position: relative;
}

.lat-cs-block:hover {
  opacity: 1;
  z-index: 10;
}

/* Tooltip on hover — uses data-tip attribute */
.lat-cs-block[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e1e2e;
  color: #e0e0e0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  line-height: 1.5;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.15);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  white-space: pre;
  pointer-events: none;
  z-index: 100;
  min-width: 180px;
}

.lat-cs-block[data-tip]:hover::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 1px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1e1e2e;
  z-index: 100;
  pointer-events: none;
}

.lat-cs-block.active {
  opacity: 1;
  box-shadow: 0 0 0 1.5px var(--accent);
}

.lat-cs-block.overlap {
  opacity: 0.85;
  background-image: repeating-linear-gradient(45deg, transparent, transparent 3px,
      rgba(0, 0, 0, 0.35) 3px, rgba(0, 0, 0, 0.35) 6px);
}

.lat-cs-block.grid-highlight {
  opacity: 1;
  box-shadow: 0 0 0 2px #fff, 0 0 8px rgba(255,255,255,0.5);
  z-index: 20;
}

.lat-cs-block.outlier,
.lat-cs-swatch.outlier {
  background: repeating-linear-gradient(
    45deg,
    #ff6b35,
    #ff6b35 3px,
    #1a1a2e 3px,
    #1a1a2e 6px
  ) !important;
  border: 2px solid #ff6b35 !important;
  box-shadow: 0 0 6px rgba(255, 107, 53, 0.5);
  opacity: 1;
}

.lat-cs-legend-hint {
  font-style: italic;
  opacity: 0.5;
  font-size: 0.7rem;
}

.lat-cs-empty {
  height: 18px;
  flex-shrink: 0;
  margin: 0 1px;
}

.lat-cs-legend {
  display: flex;
  gap: 18px;
  margin-top: 12px;
  padding-left: 90px;
  flex-wrap: wrap;
}

.lat-cs-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.lat-cs-swatch {
  width: 20px;
  height: 18px;
  border-radius: 3px;
  background: var(--accent);
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.15);
}

.lat-cs-swatch.active {
  box-shadow: 0 0 0 1.5px var(--accent);
  background: var(--accent);
}

.lat-cs-swatch.overlap {
  background: #6bcf7f;
  opacity: 0.85;
  background-image: repeating-linear-gradient(45deg, transparent, transparent 3px,
      rgba(0, 0, 0, 0.35) 3px, rgba(0, 0, 0, 0.35) 6px);
}

/* -- Per-Joint Chunk Stacks -- */
.lat-js-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lat-js-column-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  padding: 2px 0;
}

.lat-js-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px;
  overflow-x: auto;
}

.lat-js-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 6px;
  font-family: 'JetBrains Mono', monospace;
}

.lat-js-ref0 {
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--text-muted);
}

.lat-js-row {
  display: flex;
  align-items: stretch;
  min-height: 22px;
}

.lat-js-row.current {
  background: rgba(255 255 255 / 0.04);
}

.lat-js-row.dispatch {
  border-top: 2px solid var(--accent);
  margin-top: 2px;
}

.lat-js-row.state {
  border-top: 1px solid rgba(77, 171, 247, 0.3);
  margin-top: 2px;
}

.lat-js-axis {
  margin-bottom: 2px;
}

.lat-js-label {
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  padding: 0 4px;
  white-space: nowrap;
}

.lat-js-row.current .lat-js-label {
  color: var(--text-primary);
}

.lat-js-label.dispatch {
  color: var(--accent-light);
  font-weight: 700;
}

.lat-js-label.state {
  color: #4dabf7;
  font-weight: 700;
}

.lat-js-cell {
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.lat-js-cell.axis {
  color: var(--text-muted);
  font-size: 0.6rem;
  font-weight: 600;
  padding: 1px 0;
}

.lat-js-cell.axis.hl {
  color: var(--text-secondary);
}

.lat-js-cell.val {
  color: var(--text-secondary);
  padding: 2px 2px;
  border-bottom: 1px solid var(--border-color);
}

.lat-js-cell.val.active {
  color: var(--text-primary);
  font-weight: 600;
  background: rgba(255 255 255 / 0.04);
}

.lat-js-cell.val.overlap {
  color: var(--text-secondary);
  opacity: 0.8;
  background: rgba(107 207 127 / 0.06);
}

.lat-js-cell.val.dispatch {
  color: var(--accent-light);
  font-weight: 700;
  background: rgba(0 212 148 / 0.08);
}

.lat-js-cell.val.state {
  color: #4dabf7;
  font-weight: 600;
  background: rgba(77 171 247 / 0.06);
}

.lat-js-cell.empty {
  border-bottom: 1px solid var(--border-color);
  opacity: 0.2;
}



/* ── Chunk Stack ──────────────────────────────────────────────────────── */
.lat-chunk-stack {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow-x: auto;
  margin-bottom: 8px;
}

.lat-cs-axis {
  display: flex;
  margin-bottom: 4px;
}

.lat-cs-tick {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  flex-shrink: 0;
  opacity: 0.5;
}

.lat-cs-tick.highlight {
  opacity: 1;
  color: var(--text-secondary);
  font-weight: 600;
}

.lat-cs-row {
  display: flex;
  align-items: center;
  margin-bottom: 3px;
}

.lat-cs-row.current {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-radius: 4px;
  margin-left: -4px;
  margin-right: -4px;
  padding: 1px 4px;
}

.lat-cs-label {
  min-width: 66px;
  flex-shrink: 0;
  font-size: 0.7rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
  text-align: right;
  padding-right: 4px;
  white-space: nowrap;
  overflow: visible;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
}

.lat-cs-row.current .lat-cs-label {
  color: var(--accent-light);
  font-weight: 700;
}

.lat-cs-blocks {
  display: flex;
  flex-shrink: 0;
}

.lat-cs-block {
  height: 18px;
  flex-shrink: 0;
  border-radius: 3px;
  margin: 0 1px;
  opacity: 0.5;
  transition: opacity 0.15s;
  cursor: default;
}

.lat-cs-block:hover {
  opacity: 0.9;
}

.lat-cs-block.active {
  opacity: 1;
  box-shadow: 0 0 0 1.5px var(--accent);
}

.lat-cs-block.overlap {
  opacity: 0.75;
  background-image: repeating-linear-gradient(45deg, transparent, transparent 2px,
      rgba(255, 255, 255, 0.1) 2px, rgba(255, 255, 255, 0.1) 4px);
}

.lat-cs-empty {
  height: 18px;
  flex-shrink: 0;
  margin: 0 1px;
}

.lat-cs-legend {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  padding-left: 90px;
}

/* (Legend styles consolidated above in the first Chunk Stack section) */

/* =======================================================================
   Dataset Analyzer Page
   ======================================================================= */

.da-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 16px;
  flex-wrap: wrap;
}

.da-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.da-select {
  min-width: 340px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
}

.da-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.da-content {
  min-height: 400px;
}

.da-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 64px 16px;
  color: var(--text-muted);
  text-align: center;
}

.da-empty h3 {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Landing table */
.da-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
}

.da-landing-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.da-landing-table thead th {
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  user-select: none;
}

.da-th-sort {
  cursor: pointer;
  transition: color var(--transition);
}

.da-th-sort:hover {
  color: var(--text-primary);
}

.da-landing-row {
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.da-landing-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.da-landing-row td {
  padding: 10px 12px;
  vertical-align: middle;
}

.da-cell-name {
  min-width: 200px;
  vertical-align: top;
}

.da-cell-name-text {
  font-weight: 600;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
}

.da-cell-num {
  white-space: nowrap;
  text-align: left;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
}

.da-cell-date {
  white-space: nowrap;
  color: var(--text-secondary);
}

.da-cell-path {
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.da-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  align-items: center;
}

.da-row-task {
  font-style: italic;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.da-empty p {
  font-size: 0.85rem;
  max-width: 400px;
}

.da-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 64px 16px;
  color: var(--text-muted);
}

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

.da-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.da-stat-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  transition: border-color var(--transition);
}

.da-stat-card:hover {
  border-color: var(--border-color-strong);
}

.da-stat-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.da-stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Per-joint lag breakdown table */
.da-lag-table {
  width: 100%;
  margin-top: 8px;
}

.da-lag-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.da-lag-table th {
  text-align: left;
  padding: 5px 8px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.da-lag-table td {
  padding: 4px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
}

.da-lag-label {
  font-weight: 700;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted) !important;
  white-space: nowrap;
}

.da-lag-sep {
  border-left: 2px solid var(--border-color) !important;
}

.da-lag-best {
  color: #4ade80 !important;
  font-weight: 700;
}

.da-lag-worst {
  color: #f87171 !important;
  font-weight: 700;
}

/* Data tooltip system */
[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translateX(-50%);
  margin-bottom: 6px;
  background: #1a1a2e;
  color: #e0e0e0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.72rem;
  font-weight: 400;
  font-family: 'Inter', sans-serif;
  text-transform: none;
  letter-spacing: normal;
  line-height: 1.45;
  white-space: normal;
  width: max-content;
  max-width: 300px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-tooltip]:hover::after {
  opacity: 1;
}

.da-lag-label[data-tooltip]::after {
  left: 0;
  transform: none;
}

/* Episode table */
.da-episode-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-bottom: 16px;
}

.da-episode-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.da-episode-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
}

.da-episode-table tr {
  cursor: pointer;
  transition: background var(--transition);
}

.da-episode-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.da-episode-table tbody tr.active {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.da-episode-table .da-task-cell {
  font-family: 'Inter', sans-serif;
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.75rem;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Dataset metadata row */
.da-meta-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.da-meta-block {
  flex: 1;
  min-width: 250px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 12px 16px;
}

.da-meta-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.da-meta-content {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.da-task-tag {
  display: inline-block;
  background: rgba(139, 92, 246, 0.12);
  color: #c084fc;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-family: 'Inter', sans-serif;
  margin: 2px;
}

/* Shared chart/section patterns (reuse lat- patterns) */
.da-chart-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 8px;
  margin-bottom: 16px;
}

.da-chart {
  width: 100%;
}

.da-section {
  margin-bottom: 8px;
}

.da-section-toggle {
  cursor: pointer;
  user-select: none;
  padding: 8px 12px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color var(--transition), background var(--transition);
}

.da-section-toggle:hover {
  color: var(--text-primary);
  background: color-mix(in srgb, var(--glass-bg) 80%, var(--accent));
}

.da-section-toggle::before {
  content: '▶';
  font-size: 0.65rem;
  transition: transform 0.2s ease;
}

.da-section[open]>.da-section-toggle::before {
  transform: rotate(90deg);
}

.da-section-toggle::-webkit-details-marker {
  display: none;
}

/* Video frames row — default 2x2 grid */
.da-video-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}

.da-video-pane {
  background: #111;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 16/10;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.da-video-pane img,
.da-video-pane video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.da-video-pane-label {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.6);
  z-index: 1;
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 6px;
  border-radius: 4px;
}

.da-video-placeholder {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Sticky 1x4 mode when scrolled past */
.da-video-row--sticky {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  z-index: 900;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: var(--bg-primary);
  padding: 4px 32px 0;
  max-width: 1400px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  margin-bottom: 0;
}

.da-video-row--sticky .da-video-pane {
  aspect-ratio: 16/10;
  border-radius: 4px;
}

.da-video-row--sticky .da-video-pane img,
.da-video-row--sticky .da-video-pane video {
  object-fit: cover;
}

.da-video-row--sticky .da-video-pane-label {
  font-size: 0.55rem;
  top: 3px;
  left: 4px;
  padding: 1px 4px;
}

/* Player bar sticks below sticky video */
.da-player--sticky {
  position: fixed;
  top: calc((min(100vw - var(--sidebar-width), 1400px) - 64px) / 4 * 10 / 16 + 4px);
  left: var(--sidebar-width);
  right: 0;
  z-index: 900;
  max-width: 1400px;
  padding: 4px 32px;
  border-radius: 0;
  margin-bottom: 0;
  background: var(--bg-secondary);
  border-top: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.da-player--sticky .da-player-title-row {
  padding: 0;
}

/* Sticky toggle button */
.da-sticky-on {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}

/* Player bar */
.da-player {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.da-player-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 0;
}

.da-player-title-row .da-episode-label {
  flex: 1;
}

.da-continuous-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}

.da-player-controls-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.da-player button {
  background: var(--glass-bg);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all var(--transition);
  line-height: 1;
}

.da-player button:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-color-strong);
}

.da-player .da-play-btn.playing {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.da-player .da-btn-disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.da-btn-locked {
  opacity: 0.6;
  cursor: default !important;
  pointer-events: none;
}

.da-btn-flash {
  animation: da-flash 0.3s ease 2;
}

@keyframes da-flash {

  0%,
  100% {
    border-color: var(--border-color);
  }

  50% {
    border-color: #fbbf24;
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
  }
}

.da-scrubber {
  flex: 1;
  min-width: 200px;
  accent-color: var(--accent);
  cursor: pointer;
}

.da-frame-info {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.da-player-spacer {
  flex: 1;
}

.da-episode-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 600px;
  text-align: center;
}

.da-continuous-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Episode set chips */
.da-set-chips {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: nowrap;
}

.da-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  font-size: 0.65rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
}

.da-chip--clickable {
  cursor: pointer;
}

.da-chip--clickable:hover {
  filter: brightness(1.3);
  transform: scale(1.1);
}

.da-chip--playing {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.4);
}

.da-chip--ready {
  background: rgba(52, 211, 153, 0.2);
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.4);
}

.da-chip--staging {
  opacity: 0.5;
}

.da-chip--staging.da-chip--ready {
  opacity: 1;
  background: rgba(96, 165, 250, 0.2);
  color: #60a5fa;
  border-color: rgba(96, 165, 250, 0.4);
}

.da-chip--loading {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.35);
  animation: da-chip-pulse 1.2s ease-in-out infinite;
}

.da-chip--staging.da-chip--loading {
  opacity: 0.8;
}

@keyframes da-chip-pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.da-chip-divider {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 6px;
}

.da-divider-arrow {
  font-size: 0.5rem;
  color: rgba(255, 255, 255, 0.2);
  line-height: 1;
}

.da-divider-text {
  font-size: 0.55rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.35);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.da-chip-divider--clickable {
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.4);
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.da-chip-divider--clickable .da-divider-text {
  color: var(--accent);
}

.da-chip-divider--clickable .da-divider-arrow {
  color: var(--accent);
  font-size: 0.55rem;
}

.da-chip-divider--clickable:hover {
  background: rgba(52, 211, 153, 0.2);
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.35);
  border-color: var(--accent);
}

.da-chip-divider--clickable:active {
  transform: scale(0.95);
}

.da-set-label {
  font-size: 0.55rem;
  font-weight: 800;
  color: rgba(52, 211, 153, 0.5);
  letter-spacing: 1px;
  margin-right: 4px;
}

/* Custom upward-expanding dropdown */
.da-custom-select {
  position: relative;
  display: inline-block;
}

.da-custom-select-btn {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--glass-bg);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  cursor: pointer;
  line-height: 1;
  transition: all var(--transition);
  white-space: nowrap;
  text-align: center;
  min-width: 44px;
}

.da-custom-select-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-color-strong);
}

.da-custom-select-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 100%;
  background: var(--bg-elevated, var(--bg-secondary));
  border: 1px solid var(--border-color-strong, var(--border-color));
  border-radius: 6px;
  padding: 4px;
  z-index: 100;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.4);
  max-height: 240px;
  overflow-y: auto;
}

.da-custom-select-menu.open {
  display: flex;
  flex-direction: column;
}

.da-custom-select-item {
  padding: 5px 10px;
  font-size: 0.78rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  text-align: center;
}

.da-custom-select-item:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.da-custom-select-item.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* Joint charts row */
.da-joints-row {
  display: flex;
  gap: 8px;
}

.da-joint-card {
  flex: 1;
  min-width: 0;
}

/* Arm/Joint filter (reuse lat pattern) */
.da-arm-filter {
  display: flex;
  gap: 2px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 2px;
}

.da-arm-filter .chip {
  font-size: 0.72rem;
  padding: 2px 10px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1.4;
}

.da-arm-filter .chip:hover {
  color: var(--text-primary);
  background: var(--glass-bg);
}

.da-arm-filter .chip.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.da-subsection-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 8px 4px;
  margin-top: 12px;
  margin-bottom: 4px;
}

/* Per-joint two-column layout (mirrors lat-js-column) */
.da-js-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.da-js-column-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  padding: 2px 0;
}

.da-chart-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  padding: 6px 0 2px;
}

@media (max-width: 900px) {
  .da-video-row {
    grid-template-columns: 1fr;
  }

  .da-video-row--sticky {
    grid-template-columns: repeat(2, 1fr);
  }

  .da-joints-row {
    flex-direction: column;
  }

  .lat-video-row {
    grid-template-columns: 1fr;
  }

  .lat-video-row--sticky {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* =======================================================================
   Robot Configurator Page
   ======================================================================= */
.status-ok { background: rgba(74,222,128,0.15); color: #4ade80; }
.status-err { background: rgba(248,113,113,0.15); color: #f87171; }
.status-warn { background: rgba(251,191,36,0.15); color: #fbbf24; }
.status-active { background: rgba(59,130,246,0.18); color: #60a5fa; }
.status-planning { background: rgba(168,85,247,0.15); color: #c084fc; }
.status-muted { background: rgba(148,163,184,0.12); color: #94a3b8; }
.family-grt { background: rgba(139,92,246,0.15); color: #c084fc; }
.family-act { background: rgba(59,130,246,0.15); color: #60a5fa; }
.family-openpi { background: rgba(20,184,166,0.15); color: #2dd4bf; }

.rc-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--border-color-strong, var(--border-color));
  background: var(--bg-input, var(--bg-tertiary));
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  line-height: 1.3;
  flex-shrink: 0;
  white-space: nowrap;
}

.rc-chip:hover {
  border-color: var(--accent);
  background: var(--accent-dim, rgba(99, 102, 241, 0.12));
}

.rc-chip-active {
  border-color: var(--accent);
  background: var(--accent-dim, rgba(99, 102, 241, 0.15));
  box-shadow: 0 0 0 1px var(--accent);
}

/* ================================================================   TipTap Editor Styles
   ======================================================================= */
.tiptap-editor-wrap {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md, 8px);
  background: var(--bg-card, #1a1a2e);
  overflow: hidden;
}

.tiptap-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-tertiary, #151525);
}

.tiptap-btn-group {
  display: inline-flex;
  gap: 2px;
  padding: 0 4px;
  border-right: 1px solid var(--border-color);
}
.tiptap-btn-group:last-of-type { border-right: none; }

.tiptap-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.tiptap-btn:hover { background: var(--glass-bg, rgba(255,255,255,0.06)); color: var(--text-primary); }
.tiptap-btn.active { background: var(--accent); color: #fff; }
.tiptap-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.tiptap-mode-toggle {
  margin-left: auto;
  display: inline-flex;
  gap: 2px;
  background: var(--bg-secondary, #0f0f1a);
  border-radius: 4px;
  padding: 2px;
}
.tiptap-mode-toggle .btn {
  padding: 2px 10px;
  font-size: 0.72rem;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.tiptap-mode-toggle .btn.active { background: var(--accent); color: #fff; }

.tiptap-content {
  min-height: 120px;
  max-height: 500px;
  overflow-y: auto;
  padding: 16px 20px;
}

/* TipTap ProseMirror content styles */
.tiptap-content .tiptap {
  outline: none;
  min-height: 100px;
  color: var(--text-primary);
  font-size: 0.88rem;
  line-height: 1.65;
}

.tiptap-content .tiptap p { margin: 0 0 8px; }
.tiptap-content .tiptap h2 { font-size: 1.3rem; margin: 20px 0 8px; color: var(--text-primary); }
.tiptap-content .tiptap h3 { font-size: 1.1rem; margin: 16px 0 6px; color: var(--text-primary); }
.tiptap-content .tiptap ul, .tiptap-content .tiptap ol { padding-left: 24px; margin: 6px 0; }
.tiptap-content .tiptap li { margin: 2px 0; }
.tiptap-content .tiptap blockquote {
  border-left: 3px solid var(--accent);
  padding: 8px 16px;
  margin: 12px 0;
  background: rgba(139,92,246,0.05);
  border-radius: 0 6px 6px 0;
  color: var(--text-secondary);
}
.tiptap-content .tiptap pre {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 12px 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  overflow-x: auto;
}
.tiptap-content .tiptap code {
  background: var(--bg-tertiary);
  padding: 2px 5px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82em;
  color: #c084fc;
}
.tiptap-content .tiptap pre code { background: transparent; padding: 0; color: inherit; }
.tiptap-content .tiptap img {
  max-width: 100%;
  border-radius: 6px;
  margin: 8px 0;
}

/* Image drop-target highlight */
.tiptap-content.tiptap-drop-target {
  outline: 2px dashed var(--accent, #6366f1);
  outline-offset: -2px;
  background: rgba(99, 102, 241, 0.04);
}

/* Uploading placeholder image */
.tiptap-content .tiptap img[alt^="upload-"],
.tiptap-content .tiptap img[alt^="drop-upload-"] {
  animation: img-upload-pulse 1.5s ease-in-out infinite;
  border: 1px dashed var(--border-color);
}

@keyframes img-upload-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 0.3; }
}
.tiptap-content .tiptap hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 16px 0;
}
.tiptap-content .tiptap a.tiptap-link { color: var(--accent); text-decoration: underline; }

/* Task list styling */
.tiptap-content .tiptap ul[data-type="taskList"] {
  list-style: none;
  padding-left: 4px;
}
.tiptap-content .tiptap ul[data-type="taskList"] li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.tiptap-content .tiptap ul[data-type="taskList"] li label {
  flex-shrink: 0;
  margin-top: 2px;
}

/* Placeholder */
.tiptap-content .tiptap p.is-editor-empty:first-child::before {
  color: var(--text-muted);
  content: attr(data-placeholder);
  float: left;
  height: 0;
  pointer-events: none;
  opacity: 0.5;
}

.tiptap-markdown-area {
  width: 100%;
  min-height: 120px;
  max-height: 500px;
  padding: 16px 20px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: none;
  resize: vertical;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  outline: none;
}

/* =======================================================================
   Experiment Detail Page Styles
   ======================================================================= */
.experiment-page {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px 60px;
}

.experiment-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.experiment-breadcrumb a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.15s;
}
.experiment-breadcrumb a:hover { opacity: 0.8; }
.breadcrumb-sep { opacity: 0.3; }
.breadcrumb-current { color: var(--text-secondary); }

.experiment-header {
  margin-bottom: 28px;
}

.experiment-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.experiment-title-input {
  flex: 1;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 4px 0;
  outline: none;
  transition: border-color 0.2s;
}
.experiment-title-input:focus {
  border-bottom-color: var(--accent);
}

.experiment-meta-badges {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.badge-select {
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 0.78rem;
  cursor: pointer;
  outline: none;
}
.badge-select:focus { border-color: var(--accent); }

.experiment-hypothesis {
  width: 100%;
  padding: 10px 14px;
  background: rgba(139,92,246,0.05);
  border: 1px solid rgba(139,92,246,0.15);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-style: italic;
  resize: vertical;
  min-height: 48px;
  outline: none;
  transition: border-color 0.2s;
}
.experiment-hypothesis:focus { border-color: var(--accent); }
.experiment-hypothesis::placeholder { color: var(--text-muted); opacity: 0.6; }

/* Tag chip selector */
.experiment-tags {
  margin-top: 12px;
}
.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  min-height: 8px;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  background: rgba(139, 92, 246, 0.15);
  color: #c084fc;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: background 0.15s;
}
.tag-chip:hover {
  background: rgba(139, 92, 246, 0.25);
}
.tag-chip-remove {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 2px;
  opacity: 0.6;
  line-height: 1;
}
.tag-chip-remove:hover { opacity: 1; }

.tag-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.tag-text-input {
  flex: 1;
  max-width: 220px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.2s;
}
.tag-text-input:focus { border-color: var(--accent); }
.tag-text-input::placeholder { color: var(--text-muted); opacity: 0.5; }

.tag-suggestions {
  margin-top: 10px;
  padding: 12px;
  border-radius: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tag-category {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.tag-category-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  width: 90px;
  flex-shrink: 0;
}
.tag-suggestion {
  padding: 3px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}
.tag-suggestion:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.tag-suggestion.active {
  background: rgba(139, 92, 246, 0.2);
  border-color: var(--accent);
  color: #c084fc;
}

.experiment-section {
  margin-bottom: 28px;
}

.section-heading {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 12px;
}

.rc-chip-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.rc-chip-meta {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.rc-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
}

.rc-col-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.rc-summary-box {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.rc-stat {
  text-align: center;
}

.rc-stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent-light);
  letter-spacing: -0.02em;
}

.rc-stat-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.rc-config-item:hover {
  background: var(--bg-tertiary) !important;
}

.rc-config-item.active {
  background: var(--accent-dim, rgba(99, 102, 241, 0.12)) !important;
  border-left: 3px solid var(--accent);
}

/* ── Robot Configurator: Crop Editor ──────────────────────────────────── */

.rc-crop-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.rc-crop-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px;
  transition: border-color var(--transition);
}

.rc-crop-card:hover {
  border-color: var(--border-color-strong);
}

.rc-crop-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.rc-toggle {
  position: relative;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
}

.rc-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.rc-toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 9px;
  background: var(--bg-tertiary);
  border: 1px solid var(--text-primary);
  transition: background 0.2s, border-color 0.2s;
  cursor: pointer;
}

.rc-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.2s, background 0.2s;
}

.rc-toggle input:checked+.rc-toggle-track {
  background: var(--accent);
  border-color: var(--accent);
}

.rc-toggle input:checked+.rc-toggle-track::after {
  transform: translateX(14px);
  background: #fff;
}

.rc-crop-cam-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.rc-crop-preview {
  cursor: crosshair;
  user-select: none;
}

.rc-crop-overlay {
  border: 2px solid var(--accent) !important;
  background: rgba(99, 102, 241, 0.12) !important;
  border-radius: 2px;
  transition: none;
}

/* =======================================================================
   Effective Config Summary (Launch Panel)
   ======================================================================= */

.ecs-details {
  margin-top: 16px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  overflow: hidden;
}

.ecs-toggle {
  cursor: pointer;
  user-select: none;
  padding: 10px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color var(--transition), background var(--transition);
}

.ecs-toggle::-webkit-details-marker {
  display: none;
}

.ecs-toggle:hover {
  color: var(--text-primary);
  background: color-mix(in srgb, var(--glass-bg) 80%, var(--accent));
}

.ecs-toggle-icon {
  font-size: 0.6rem;
  transition: transform 0.2s ease;
  display: inline-block;
}

.ecs-details[open]>.ecs-toggle .ecs-toggle-icon {
  transform: rotate(90deg);
}

.ecs-content {
  padding: 2px 14px 14px;
}

.ecs-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 10px 0;
}

.ecs-section {
  padding: 8px 0;
}

.ecs-section+.ecs-section {
  border-top: 1px solid var(--border-color);
}

.ecs-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.ecs-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 2px 0;
  font-size: 0.78rem;
  line-height: 1.45;
}

.ecs-key {
  flex-shrink: 0;
  width: 90px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: right;
}

.ecs-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-primary);
  word-break: break-word;
}

.ecs-dim {
  color: var(--text-muted);
  font-weight: 400;
}

.ecs-default {
  color: var(--text-muted);
  font-weight: 400;
  font-style: italic;
}

.ecs-chip {
  display: inline-block;
  padding: 1px 7px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin: 1px 2px;
}

.ecs-chip-dim {
  opacity: 0.5;
}

.ecs-chip-hot {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
  color: #10b981;
}

.ecs-val-hot {
  color: #10b981;
}

.ecs-mem-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 0.68rem;
  font-weight: 700;
  margin-left: 6px;
}

.ecs-mem-ok {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.ecs-mem-warn {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.ecs-mem-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Hardcoded constraints — read-only locked rows */
.ecs-section-locked {
  border-top: 1px dashed rgba(255,255,255,0.08) !important;
  opacity: 0.65;
}
.ecs-row-locked .ecs-val {
  font-style: italic;
}
.ecs-lock {
  font-size: 0.6rem;
  margin-right: 2px;
}
.ecs-chip-locked {
  opacity: 0.5;
  font-style: italic;
  border-style: dashed;
}

/* =======================================================================
   Dataset Selector Box (Launch Panel)
   ======================================================================= */

.train-datasets-box {
  border: 1px solid var(--border-color-strong);
  border-radius: 8px;
  background: var(--bg-input);
  padding: 0;
  overflow: hidden;
}

/* Header row — matches ds-row grid */
.ds-header {
  display: grid;
  grid-template-columns: 18px 1fr 1.2fr 80px 60px 65px;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-color-strong, rgba(255, 255, 255, 0.15));
  background: var(--bg-tertiary);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.ds-hdr-chk {
  width: 36px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.ds-hdr {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

/* Scrollable body */
.ds-body {
  max-height: 200px;
  overflow-y: auto;
  padding: 4px 12px;
}

/* Dataset row — grid for column alignment */
.ds-row {
  display: grid;
  grid-template-columns: 18px 1fr 1.2fr 80px 60px 65px;
  align-items: center;
  gap: 16px;
  padding: 5px 4px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.85rem;
}

.ds-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.ds-row.ds-previewing {
  background: rgba(16, 185, 129, 0.12);
}

.ds-row.ds-previewing:hover {
  background: rgba(16, 185, 129, 0.18);
}

.ds-row.ds-incompatible {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.ds-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ds-episodes {
  font-size: 0.75rem;
  color: var(--text-primary);
  text-align: left;
  white-space: nowrap;
}

.ds-date {
  font-size: 0.7rem;
  color: var(--text-primary);
  text-align: left;
  white-space: nowrap;
}

.ds-version {
  font-size: 0.7rem;
  color: var(--text-primary);
  text-align: left;
  white-space: nowrap;
}

.ds-path {
  font-size: 0.7rem;
  color: var(--text-muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Cloud mode status badges */
.ds-badge {
  display: inline-block;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 4px;
}

.ds-badge-cached {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Tiny spinner shown during stale-while-revalidate S3 refresh */
.ds-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ds-spin 0.7s linear infinite;
  vertical-align: middle;
}
.ds-spinner.hidden { display: none; }
@keyframes ds-spin { to { transform: rotate(360deg); } }

/* Environment badge (prod / dev / local) */
.ds-env-badge {
  display: inline-block;
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 4px;
}
.ds-env-badge.hidden { display: none; }
.ds-env-prod {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.ds-env-dev {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.ds-env-local {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

/* Manual refresh button */
.ds-refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: 4px;
  padding: 0;
  vertical-align: middle;
  transition: color 0.15s, background 0.15s;
}
.ds-refresh-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

/* =======================================================================
   Crop Preview (Launch Panel)
   ======================================================================= */

#crop-preview-panel {
  margin-top: 16px;
}

.cp-details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.cp-details>.cp-grid {
  padding: 8px;
}

.cp-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  list-style: none;
  transition: background 0.15s;
}

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

.cp-summary:hover {
  background: var(--bg-secondary);
}

.cp-summary-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cp-toggle-icon {
  font-size: 0.6rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border-color-strong);
}

.cp-details[open]>.cp-summary .cp-toggle-icon {
  transform: rotate(90deg);
}

/* Contextual hint text */
.cp-hint-expand {
  display: none;
}

.cp-hint-collapse {
  display: inline;
}

.cp-details:not([open])>.cp-summary .cp-hint-expand {
  display: inline;
}

.cp-details:not([open])>.cp-summary .cp-hint-collapse {
  display: none;
}

/* When collapsed, remove bottom border */
.cp-details:not([open])>.cp-summary {
  border-bottom: none;
}

.cp-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.cp-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
}

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

.cp-cell {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.cp-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  padding: 6px 8px 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cp-crop-info {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--accent-light);
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  padding: 1px 5px;
  border-radius: 4px;
}

.cp-frame-wrap {
  position: relative;
  background: #0a0a0a;
  aspect-ratio: 16/10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cp-frame-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cp-no-frame {
  color: var(--text-muted);
  font-size: 0.72rem;
  display: none;
  align-items: center;
  justify-content: center;
  position: absolute;
  inset: 0;
}

.cp-crop-rect {
  position: absolute;
  border: 2px solid var(--accent);
  background: rgba(99, 102, 241, 0.12);
  border-radius: 2px;
  pointer-events: none;
  display: none;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
}

/* =======================================================================
   SchemaFormRenderer (sfr-*) — Dynamic Form Fields
   ======================================================================= */

.sfr-fields {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 16px;
}

.sfr-field {
  min-width: 0;
}

.sfr-field.sfr-field-full {
  grid-column: 1 / -1;
}

.sfr-field .form-input,
.sfr-field .sfr-input {
  width: 100%;
  box-sizing: border-box;
}

.sfr-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.sfr-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.35;
}

.sfr-note {
  font-size: 0.68rem;
  font-style: italic;
  color: var(--text-muted);
  margin-top: 2px;
}

.sfr-memory-dot {
  font-size: 0.5rem;
  vertical-align: middle;
  margin-right: 2px;
}

.sfr-memory-legend {
  grid-column: 1 / -1;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* Locked fields — hardcoded container constants */
.sfr-field-locked {
  opacity: 0.55;
  pointer-events: none;
}
.sfr-lock {
  font-size: 0.6rem;
  margin-right: 2px;
}
.sfr-locked-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 4px 0;
  display: block;
}

/* Toggle switch */
.sfr-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.82rem;
}

.sfr-toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.sfr-toggle-track {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.sfr-toggle-input:checked+.sfr-toggle-track {
  background: var(--accent);
  border-color: var(--accent);
}

.sfr-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.sfr-toggle-input:checked+.sfr-toggle-track .sfr-toggle-thumb {
  transform: translateX(16px);
}

.sfr-toggle-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 24px;
}

/* JSON textarea */
.sfr-json {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  resize: vertical;
  min-height: 48px;
}

/* Group section headers */
.sfr-group-header {
  grid-column: 1 / -1;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color-strong, var(--border));
}

/* Advanced section */
.sfr-advanced-section {
  grid-column: 1 / -1;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-top: 4px;
  background: var(--bg-secondary);
}

.sfr-advanced-toggle {
  cursor: pointer;
  user-select: none;
  padding: 8px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color var(--transition);
}

.sfr-advanced-toggle::-webkit-details-marker {
  display: none;
}

.sfr-advanced-toggle:hover {
  color: var(--text-primary);
}

.sfr-advanced-icon {
  font-size: 0.6rem;
  display: inline-block;
  transition: transform 0.15s ease;
}

.sfr-advanced-badge {
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.sfr-advanced-body {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 16px;
  padding: 4px 12px 12px;
}

/* Conditional reset */
.sfr-conditional-reset {
  display: inline-block;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--accent-light);
  margin-left: 6px;
  padding: 0 4px;
  border-radius: 4px;
  transition: background var(--transition);
  vertical-align: middle;
}

.sfr-conditional-reset:hover {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
}

/* =======================================================================
   Training Config Info — Preset summary card (tci-*)
   ======================================================================= */

.tci-card {
  /* Card sits inside #train-config-info which already has bg + radius */
}

.tci-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.tci-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 500;
}

.empty-state-sm {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  background: var(--bg-tertiary);
  border-radius: 8px;
  border: 1px dashed var(--border-color);
}

/* Save indicator */
.experiment-save-indicator {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  z-index: 1000;
  transition: all 0.3s ease;
}
.experiment-save-indicator.saved { background: rgba(34,197,94,0.15); color: #22c55e; }
.experiment-save-indicator.unsaved { background: rgba(251,191,36,0.15); color: #fbbf24; }
.experiment-save-indicator.saving { background: rgba(96,165,250,0.15); color: #60a5fa; }
.experiment-save-indicator.error { background: rgba(248,113,113,0.15); color: #f87171; }

/* =======================================================================
   Experiment View-Only Mode
   ======================================================================= */

/* ── FAB toggle button ──────────────────────────────────────────────── */
.experiment-mode-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 1001;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border: none;
  border-radius: 28px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255,255,255,0.06);
  letter-spacing: 0.01em;
}
.experiment-mode-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255,255,255,0.1);
}
.experiment-mode-fab:active {
  transform: translateY(0);
}

/* Variant: "Edit" button (shown in view mode) */
.experiment-mode-fab--edit {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #fff;
}
.experiment-mode-fab--edit:hover {
  background: linear-gradient(135deg, #7c7ff7 0%, #a78bfa 100%);
}

/* Variant: "Done" button (shown in edit mode) */
.experiment-mode-fab--done {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
}
.experiment-mode-fab--done:hover {
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
}

.experiment-mode-fab .fab-icon {
  font-size: 1.05rem;
  line-height: 1;
}

/* ── Edit mode banner ───────────────────────────────────────────────── */
.experiment-edit-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  margin-bottom: 20px;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.2);
  font-size: 0.8rem;
  color: #a78bfa;
  animation: editBannerIn 0.3s ease;
}
.experiment-edit-banner .edit-banner-icon {
  font-size: 1rem;
}
@keyframes editBannerIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── View-mode content styles ───────────────────────────────────────── */

/* View-mode title — rendered as h1 instead of input */
.experiment-view-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 4px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

/* Status badge in view mode */
.experiment-view-status {
  display: inline-flex;
  align-items: center;
  padding: 4px 14px;
  border-radius: 14px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: capitalize;
  letter-spacing: 0.03em;
}
.experiment-view-status--planning   { background: rgba(168,85,247,0.15); color: #c084fc; }
.experiment-view-status--active     { background: rgba(59,130,246,0.18); color: #60a5fa; }
.experiment-view-status--concluded  { background: rgba(34,197,94,0.15);  color: #22c55e; }
.experiment-view-status--archived   { background: rgba(148,163,184,0.12); color: #94a3b8; }

/* Hypothesis as a styled blockquote */
.experiment-view-hypothesis {
  margin: 16px 0 0;
  padding: 14px 20px;
  border-left: 4px solid var(--accent, #6366f1);
  border-radius: 0 10px 10px 0;
  background: rgba(139, 92, 246, 0.05);
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-style: italic;
  line-height: 1.65;
}
.experiment-view-hypothesis::before {
  content: '"';
  font-size: 2rem;
  color: rgba(139, 92, 246, 0.3);
  font-family: Georgia, serif;
  line-height: 0;
  vertical-align: -0.35em;
  margin-right: 4px;
}
.experiment-view-hypothesis-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-style: normal;
  margin-bottom: 6px;
}

/* Read-only tag pills (no remove × button) */
.experiment-view-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}
.experiment-view-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 12px;
  background: rgba(139, 92, 246, 0.12);
  color: #c084fc;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* View-mode prose sections (replaces TipTap editor chrome) */
.experiment-view-prose {
  padding: 16px 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.75;
}
.experiment-view-prose h2 { font-size: 1.25rem; margin: 20px 0 8px; color: var(--text-primary); }
.experiment-view-prose h3 { font-size: 1.05rem; margin: 16px 0 6px; color: var(--text-primary); }
.experiment-view-prose p { margin: 0 0 10px; }
.experiment-view-prose ul, .experiment-view-prose ol { padding-left: 24px; margin: 8px 0; }
.experiment-view-prose li { margin: 4px 0; }
.experiment-view-prose blockquote {
  border-left: 3px solid var(--accent);
  padding: 10px 16px;
  margin: 12px 0;
  background: rgba(139, 92, 246, 0.04);
  border-radius: 0 6px 6px 0;
  color: var(--text-muted);
  font-style: italic;
}
.experiment-view-prose pre {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 14px 18px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  overflow-x: auto;
}
.experiment-view-prose code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82em;
  color: #c084fc;
}
.experiment-view-prose pre code { background: transparent; padding: 0; color: inherit; }
.experiment-view-prose img { max-width: 100%; border-radius: 8px; margin: 8px 0; }
.experiment-view-prose a { color: var(--accent); text-decoration: underline; }
.experiment-view-prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.85rem;
}
.experiment-view-prose table th,
.experiment-view-prose table td {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  text-align: left;
}
.experiment-view-prose table th {
  background: var(--bg-tertiary);
  font-weight: 600;
  color: var(--text-primary);
}
.experiment-view-prose hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 20px 0;
}

/* Empty prose placeholder in view mode */
.experiment-view-prose-empty {
  padding: 20px 0;
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.85rem;
  opacity: 0.6;
}

/* View-mode linked items — clean table without action column */
.experiment-view-items-table {
  width: 100%;
}

/* View-mode assignees — badges only, no dropdown */
.experiment-view-assignees {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.experiment-view-assignee {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 4px;
  border-radius: 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Section dividers in view mode for cleaner separation */
.experiment-page--view .experiment-section {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.experiment-page--view .experiment-section:last-of-type {
  border-bottom: none;
}

/* Smooth entrance animation for sections */
.experiment-page--view .experiment-section {
  animation: viewSectionIn 0.35s ease both;
}
.experiment-page--view .experiment-section:nth-child(2) { animation-delay: 0.05s; }
.experiment-page--view .experiment-section:nth-child(3) { animation-delay: 0.10s; }
.experiment-page--view .experiment-section:nth-child(4) { animation-delay: 0.15s; }
.experiment-page--view .experiment-section:nth-child(5) { animation-delay: 0.20s; }
.experiment-page--view .experiment-section:nth-child(6) { animation-delay: 0.25s; }
.experiment-page--view .experiment-section:nth-child(7) { animation-delay: 0.30s; }
.experiment-page--view .experiment-section:nth-child(8) { animation-delay: 0.35s; }

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

/* Date metadata line in view mode */
.experiment-view-meta-line {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.experiment-view-meta-line span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.15s ease;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color-strong, rgba(255,255,255,0.15));
  border-radius: 12px;
  padding: 24px;
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.06);
  animation: slideUp 0.2s ease;
}

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

.modal-content .form-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  margin-top: 4px;
  transition: border-color 0.15s;
}
.modal-content .form-input:focus { border-color: var(--accent); }
.modal-content textarea.form-input { resize: vertical; min-height: 48px; }

/* Entity picker in Add Item modal */
.add-item-results {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
}
.add-item-result {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 0.85rem;
}
.add-item-result:hover {
  background: rgba(99,102,241,0.12);
}
.add-item-result-label {
  font-weight: 500;
  color: var(--text-primary);
}
.add-item-result-sub {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-left: auto;
}
.add-item-empty {
  padding: 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.add-item-selected {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(99,102,241,0.1);
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text-primary);
}
.add-item-selected span:first-child { flex: 1; font-weight: 500; }

.btn-primary { background: var(--accent); color: #fff !important; border-color: var(--accent); }
.btn-primary:hover { opacity: 0.9; }
.btn-danger { background: rgba(248,113,113,0.15); color: #f87171; border-color: rgba(248,113,113,0.3); }
.btn-danger:hover { background: rgba(248,113,113,0.25); }

.role-baseline { background: rgba(96,165,250,0.15); color: #60a5fa; }
.role-candidate { background: rgba(139,92,246,0.15); color: #c084fc; }
.role-control { background: rgba(20,184,166,0.15); color: #2dd4bf; }
.role-ablation { background: rgba(251,191,36,0.15); color: #fbbf24; }
.role-none { background: var(--bg-tertiary); color: var(--text-muted); }

.experiment-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 0;
  color: var(--text-muted);
}
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tracking Browser — data-table and clickable-row ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
  position: relative;
  user-select: none;
}

.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.clickable-row {
  cursor: pointer;
  transition: background 0.12s ease;
}
.clickable-row:hover { background: var(--bg-card-hover); }
.clickable-row.expanded { background: rgba(99, 102, 241, 0.06); }

.inline-detail td {
  padding: 0 !important;
  border-top: 2px solid var(--accent);
  background: var(--bg-secondary);
}

.member-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.member-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 4px;
  border-radius: 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.member-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  flex-shrink: 0;
  object-fit: cover;
}

.member-remove {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1;
  margin-left: 2px;
  transition: color 0.15s;
}
.member-remove:hover { color: var(--danger, #f87171); }

.member-select {
  padding: 3px 8px;
  border-radius: 16px;
  border: 1px dashed var(--border-color);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
}
.member-select:hover { border-color: var(--accent); color: var(--accent); }
.tci-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.tci-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-primary);
}

.tci-mem {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 0.9rem;
}

.tci-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0 16px;
}

.tci-col {
  min-width: 0;
}

.tci-col-title {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
  padding-bottom: 3px;
  border-bottom: 1px solid var(--border-color);
}

.tci-footer {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-color);
}

.tci-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 0.8rem;
}

.tci-label {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  min-width: 56px;
  flex-shrink: 0;
}

.tci-val {
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.tci-chip {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 1px 8px;
  border-radius: 12px;
  white-space: nowrap;
}

.tci-dim {
  color: var(--text-muted);
  font-style: italic;
}

.tci-section-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-top: 8px;
  margin-bottom: 2px;
  padding-top: 6px;
  border-top: 1px solid var(--border-color);
}

/* ── Custom Select Dropdown ── */
.custom-select {
  position: relative;
}

.custom-select-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color-strong);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.custom-select-display:hover {
  border-color: var(--border-color-strong);
}

.custom-select.open .custom-select-display {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.custom-select-arrow {
  color: var(--text-muted);
  font-size: 0.8rem;
  transition: transform 0.2s;
}

.custom-select.open .custom-select-arrow {
  transform: rotate(180deg);
}

.custom-select-options {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-input);
  border: 1px solid var(--border-color-strong);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 100;
}

.custom-select.open .custom-select-options {
  display: block;
}

.custom-select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-primary);
  transition: background 0.1s;
}

.custom-select-option:hover {
  background: rgba(255, 255, 255, 0.06);
}

.custom-select-option.selected {
  background: rgba(99, 102, 241, 0.12);
}

.custom-select-name {
  font-weight: 500;
  white-space: nowrap;
}

.custom-select-stats {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
  margin-left: 16px;
}


/* =======================================================================
   @Mention Entity Chips
   ======================================================================= */
.entity-mention {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 8px 1px 6px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.5;
  cursor: pointer;
  vertical-align: baseline;
  transition: filter 0.15s, box-shadow 0.15s;
  background: rgba(99, 102, 241, 0.15);
  color: #a78bfa;
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.entity-mention:hover {
  filter: brightness(1.2);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.3);
}

/* Type-specific chip colors */
.entity-mention--dataset {
  background: rgba(96, 165, 250, 0.12);
  color: #60a5fa;
  border-color: rgba(96, 165, 250, 0.25);
}
.entity-mention--dataset:hover {
  box-shadow: 0 0 8px rgba(96, 165, 250, 0.3);
}

.entity-mention--training_run {
  background: rgba(192, 132, 252, 0.12);
  color: #c084fc;
  border-color: rgba(192, 132, 252, 0.25);
}
.entity-mention--training_run:hover {
  box-shadow: 0 0 8px rgba(192, 132, 252, 0.3);
}

.entity-mention--checkpoint {
  background: rgba(45, 212, 191, 0.12);
  color: #2dd4bf;
  border-color: rgba(45, 212, 191, 0.25);
}
.entity-mention--checkpoint:hover {
  box-shadow: 0 0 8px rgba(45, 212, 191, 0.3);
}

.entity-mention--experiment {
  background: rgba(251, 191, 36, 0.12);
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.25);
}
.entity-mention--experiment:hover {
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.3);
}

.entity-mention--evaluation {
  background: rgba(244, 114, 182, 0.12);
  color: #f472b6;
  border-color: rgba(244, 114, 182, 0.25);
}
.entity-mention--evaluation:hover {
  box-shadow: 0 0 8px rgba(244, 114, 182, 0.3);
}

.entity-mention--task {
  background: rgba(251, 146, 60, 0.12);
  color: #fb923c;
  border-color: rgba(251, 146, 60, 0.25);
}
.entity-mention--task:hover {
  box-shadow: 0 0 8px rgba(251, 146, 60, 0.3);
}

.entity-mention--user {
  background: rgba(156, 163, 175, 0.12);
  color: #9ca3af;
  border-color: rgba(156, 163, 175, 0.25);
}
.entity-mention--user:hover {
  box-shadow: 0 0 8px rgba(156, 163, 175, 0.3);
}


/* =======================================================================
   @Mention Suggestion Dropdown
   ======================================================================= */

/* ── Container ────────────────────────────────────────────────── */
/* NOTE: position, width, max-height, z-index, flex are set INLINE
   in editor.js to override body's display:flex. CSS only adds visuals. */
.mention-dropdown {
  display: flex;
  flex-direction: column;
  background: linear-gradient(
    165deg,
    rgba(22, 24, 40, 0.97) 0%,
    rgba(16, 18, 32, 0.98) 100%
  );
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.55),
    0 8px 24px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  overflow: hidden;
}

/* Slide-in animation depending on position */
.mention-dropdown--below {
  animation: mentionSlideDown 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: top left;
}
.mention-dropdown--above {
  animation: mentionSlideUp 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: bottom left;
}

@keyframes mentionSlideDown {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes mentionSlideUp {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Scrollable body ──────────────────────────────────────────── */
.mention-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  scroll-behavior: smooth;
}
.mention-body::-webkit-scrollbar {
  width: 4px;
}
.mention-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
.mention-body::-webkit-scrollbar-track {
  background: transparent;
}

/* ── Section headers ──────────────────────────────────────────── */
.mention-section {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 4px;
}
.mention-section:first-child {
  margin-top: 0;
  padding-top: 4px;
}

.mention-section-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.mention-section-count {
  margin-left: auto;
  font-size: 0.6rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.22);
  min-width: 14px;
  text-align: right;
}

/* ── Item rows ────────────────────────────────────────────────── */
.mention-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s ease;
  border-left: 2px solid transparent;
  margin: 1px 0;
}

.mention-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.mention-item.selected {
  background: rgba(255, 255, 255, 0.07);
  border-left-color: rgba(255, 255, 255, 0.35);
}

/* ── Icon badge (colored tinted background) ───────────────────── */
.mention-icon-badge {
  font-size: 0.85rem;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  /* background and color set inline from ENTITY_TYPE_COLORS */
}

/* Legacy icon class (fallback) */
.mention-icon {
  font-size: 1rem;
  flex-shrink: 0;
  width: 26px;
  text-align: center;
}

/* ── Item text ────────────────────────────────────────────────── */
.mention-item-text {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  flex: 1;
  white-space: nowrap;
}

.mention-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.88);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.mention-item.selected .mention-label {
  color: #fff;
}

.mention-subtitle {
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.32);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  flex-shrink: 1;
  max-width: 40%;
}

/* ── Empty state ──────────────────────────────────────────────── */
.mention-empty {
  padding: 24px 16px;
  color: rgba(255, 255, 255, 0.35);
  font-size: 0.82rem;
  text-align: center;
  line-height: 1.6;
}

.mention-empty-icon {
  display: block;
  font-size: 1.6rem;
  margin-bottom: 6px;
  opacity: 0.5;
}

.mention-empty strong {
  color: rgba(255, 255, 255, 0.55);
  font-weight: 600;
}

/* ── Footer with keyboard hints ───────────────────────────────── */
.mention-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.mention-footer-count {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.25);
}

.mention-footer-keys {
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  gap: 8px;
}

.mention-footer-keys kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 16px;
  padding: 0 4px;
  font-family: inherit;
  font-size: 0.58rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  margin-right: 2px;
}

/* =======================================================================
   Add Item Modal — Entity Linker
   ======================================================================= */
.add-item-modal {
  max-width: 560px;
  padding: 0;
  overflow: hidden;
}

.add-item-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.add-item-modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}
.add-item-modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.12s ease;
}
.add-item-modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

/* Type filter pills */
.add-item-type-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.add-item-pill {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.add-item-pill:hover {
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}
.add-item-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* Search row */
.add-item-search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 22px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  transition: border-color 0.15s ease;
}
.add-item-search-row:focus-within {
  border-color: var(--accent);
}
.add-item-search-icon {
  font-size: 0.85rem;
  opacity: 0.5;
  flex-shrink: 0;
}
.add-item-search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: inherit;
}
.add-item-search-input::placeholder {
  color: var(--text-muted);
}

/* Results list */
.add-item-results-wrap {
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 14px;
}
.add-item-results-wrap::-webkit-scrollbar { width: 4px; }
.add-item-results-wrap::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
.add-item-results-wrap::-webkit-scrollbar-track { background: transparent; }

.add-item-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s ease;
}
.add-item-result:hover {
  background: rgba(255, 255, 255, 0.06);
}
.add-item-result-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.add-item-result-text {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}
.add-item-result-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.add-item-result-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
}

.add-item-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 28px 16px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* Selected entity banner */
.add-item-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 22px;
  padding: 10px 14px;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 10px;
}
.add-item-selected-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Metadata fields */
.add-item-meta-fields {
  padding: 12px 22px 0;
  display: grid;
  gap: 10px;
}
.add-item-meta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.add-item-meta-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.add-item-meta-label .form-input {
  font-size: 0.82rem;
}

/* Action buttons */
.add-item-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 14px 22px 18px;
}


/* -- Members/Assignees -- */
.member-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.member-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 4px 8px 4px 4px;
  border-radius: 16px;
  font-size: 0.8rem;
}
.member-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.6rem;
  object-fit: cover;
  flex-shrink: 0;
}
.member-remove {
  cursor: pointer;
  opacity: 0.5;
  margin-left: 4px;
}
.member-remove:hover {
  opacity: 1;
  color: var(--danger);
}
.member-select {
  padding: 4px 8px;
  border-radius: 16px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
}
.member-select:hover {
  border-color: var(--accent);
  color: var(--text);
}
