/* Shared cockpit-inspired shell overrides for the MeAll web surfaces. */

:root {
  /* Native tap overlays clash with app controls; retain keyboard focus styles. */
  -webkit-tap-highlight-color: transparent;
  --app-font: 'Avenir Next', 'Segoe UI', sans-serif;
  --app-mono: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  --surface-elevated: rgba(255, 255, 255, 0.9);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --row-surface: rgba(17, 25, 20, 0.04);
  --panel-border: rgba(17, 25, 20, 0.09);
  --panel-border-strong: rgba(17, 25, 20, 0.15);
  --panel-surface: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
  --panel-header-bg: linear-gradient(180deg, rgba(17, 25, 20, 0.055), rgba(17, 25, 20, 0.015));
  --header-shadow: 0 18px 44px rgba(17, 25, 20, 0.08);
  --panel-shadow: 0 22px 48px rgba(17, 25, 20, 0.08);
  --bg-primary: #f2f5f3;
  --bg-secondary: var(--surface-elevated);
  --bg-tertiary: #e7ece8;
  --text-primary: #0b0f0d;
  --text-secondary: #5d665f;
  --border-color: rgba(17, 25, 20, 0.13);
  --accent: #00d87f;
  --accent-hover: #00bf71;
}

html.dark {
  --surface-elevated: rgba(21, 21, 21, 0.92);
  --surface-strong: rgba(17, 17, 17, 0.97);
  --row-surface: rgba(255, 255, 255, 0.035);
  --panel-border: rgba(255, 255, 255, 0.09);
  --panel-border-strong: rgba(255, 255, 255, 0.16);
  --panel-surface: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
  --panel-header-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
  --header-shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
  --panel-shadow: 0 28px 72px rgba(0, 0, 0, 0.34);
  --bg-primary: #060706;
  --bg-secondary: var(--surface-elevated);
  --bg-tertiary: #0f1110;
  --text-primary: #f5f7f5;
  --text-secondary: #9ca59f;
  --border-color: rgba(255, 255, 255, 0.12);
}

html.electron-mac.dark {
  --bg-primary: rgba(6, 7, 6, 0.54);
  --bg-secondary: rgba(21, 21, 21, 0.72);
  --bg-tertiary: rgba(15, 17, 16, 0.8);
}

html.electron-windows {
  --surface-elevated: rgba(255, 255, 255, 0.68);
  --surface-strong: rgba(255, 255, 255, 0.82);
  --row-surface: rgba(255, 255, 255, 0.24);
  --panel-header-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.08));
  --bg-primary: rgba(242, 245, 243, 0.58);
  --bg-secondary: var(--surface-elevated);
  --bg-tertiary: rgba(231, 236, 232, 0.72);
}

html.electron-windows.dark {
  --surface-elevated: rgba(21, 21, 21, 0.66);
  --surface-strong: rgba(17, 17, 17, 0.8);
  --row-surface: rgba(255, 255, 255, 0.055);
  --panel-header-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.085), rgba(255, 255, 255, 0.025));
  --bg-primary: rgba(6, 7, 6, 0.48);
  --bg-secondary: var(--surface-elevated);
  --bg-tertiary: rgba(15, 17, 16, 0.72);
}

html {
  overflow: hidden;
  height: 100%;
}

body {
  background: var(--bg-primary) !important;
  color: var(--text-primary);
  font-family: var(--app-font);
  font-size: 15px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100vh;
  min-height: 100vh !important;
  position: relative;
  background-image:
    radial-gradient(circle at 12% 0%, rgba(0, 216, 127, 0.12), transparent 28%),
    radial-gradient(circle at 88% 8%, rgba(255, 255, 255, 0.06), transparent 22%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.01), rgba(255, 255, 255, 0));
  background-attachment: fixed;
}

body > header {
  flex: 0 0 auto;
}

body > .container {
  flex: 1 1 auto;
  min-height: 0;
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding-right: max(48px, calc((100% - 1392px) / 2 + 24px)) !important;
  padding-left: max(48px, calc((100% - 1392px) / 2 + 24px)) !important;
  overflow-y: auto;
}

html.electron-mac,
html.electron-mac body,
html.electron-windows,
html.electron-windows body {
  background-color: transparent !important;
}

html.electron-mac.meall-no-vibrancy body {
  background-color: #fafafa !important;
}

html.electron-mac.meall-no-vibrancy.dark body {
  background-color: #0a0a0a !important;
}

html.electron-mac body {
  background-image: none;
}

html.electron-app body {
  background-attachment: scroll;
  background-image: none;
}

html.electron-app *,
html.electron-app *::before,
html.electron-app *::after {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

html.electron-app .logo,
html.electron-app .logo.pulsate,
html.electron-app .logo.animate,
html.electron-app .tab-loader-logo {
  animation: none !important;
}

html.electron-windows #tabWebviewContainer {
  background: transparent;
}

html.electron-webview body {
  background-image: none !important;
}

html.electron-mac header {
  top: 0;
  width: 100%;
  max-width: none;
  margin: 0 !important;
  padding: 18px 24px 18px 92px !important;
  border-top: 0 !important;
  border-radius: 0;
  -webkit-app-region: drag;
}

html.electron-mac body > .welcome-hero {
  top: 68px;
}

html.electron-mac body > .welcome-hero:not(.collapsed) {
  height: calc(100vh - 68px);
}

html.electron-mac header button,
html.electron-mac header a,
html.electron-mac header input,
html.electron-mac header select,
html.electron-mac header textarea,
html.electron-mac header [role='button'] {
  -webkit-app-region: no-drag;
}

html.electron-mac.dark body > .container {
  scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
}

html.electron-mac.dark body > .container::-webkit-scrollbar {
  width: 12px;
}

html.electron-mac.dark body > .container::-webkit-scrollbar-track {
  background: transparent;
}

html.electron-mac.dark body > .container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

html.electron-mac.dark body > .container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.38);
  background-clip: padding-box;
}

html.electron-app body > .container {
  scrollbar-color: color-mix(in srgb, var(--text-secondary) 34%, transparent) transparent;
}

html.electron-app body > .container::-webkit-scrollbar {
  width: 12px;
}

html.electron-app body > .container::-webkit-scrollbar-track {
  background: transparent;
}

html.electron-app body > .container::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text-secondary) 28%, transparent);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

html.electron-app body > .container::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--text-secondary) 46%, transparent);
  background-clip: padding-box;
}

html.dark:not(.electron-mac):not(.electron-windows) body > .container {
  scrollbar-color: rgba(255, 255, 255, 0.3) #0b0f0d;
}

html.dark:not(.electron-mac):not(.electron-windows) body > .container::-webkit-scrollbar {
  width: 12px;
}

html.dark:not(.electron-mac):not(.electron-windows) body > .container::-webkit-scrollbar-track {
  background: #0b0f0d;
}

html.dark:not(.electron-mac):not(.electron-windows) body > .container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.24);
  border: 3px solid #0b0f0d;
  border-radius: 999px;
}

html.dark:not(.electron-mac):not(.electron-windows) body > .container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.4);
}

a {
  color: var(--accent);
  text-decoration-color: rgba(0, 216, 127, 0.35);
}

a:hover {
  color: var(--accent-hover);
}

header {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  margin: 0 !important;
  padding: 22px 24px !important;
  background: var(--panel-surface), var(--bg-secondary) !important;
  border: 0 !important;
  border-radius: 0;
  box-shadow: var(--header-shadow);
  overflow: visible;
}

html.electron-windows header {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.05)),
    rgba(242, 245, 243, 0.34) !important;
}

html.electron-windows.dark header {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018)),
    rgba(6, 7, 6, 0.3) !important;
}

header::after {
  content: '';
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 216, 127, 0.45), transparent);
}

.header-left,
.header-controls,
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-left {
  min-width: 0;
}

.header-brand {
  display: flex; flex-direction: column; line-height: 1.2;
}

.header-brand-name {
  font-size: 14px; font-weight: 700; letter-spacing: 0.02em;
  color: var(--text-primary) !important;
}

.header-brand-subtitle {
  font-size: 11px; font-weight: 500; letter-spacing: 0.04em;
  color: var(--text-secondary) !important;
}

header h1,
.header-title {
  display: none;
}

.logo {
  display: inline-block;
  position: relative;
  overflow: visible;
  isolation: isolate;
  color: var(--text-primary) !important;
  -webkit-text-fill-color: currentColor;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.14em;
  text-shadow: 0 0 10px rgba(0, 216, 127, 0.18);
}

html:not(.dark) .logo,
html:not(.dark) .logo.pulsate,
html:not(.dark) .logo.animate {
  color: #0b0f0d !important;
  -webkit-text-fill-color: #0b0f0d !important;
  text-shadow:
    0 0 1px rgba(11, 15, 13, 0.18),
    0 0 8px rgba(0, 216, 127, 0.18),
    0 0 18px rgba(0, 216, 127, 0.2),
    0 0 30px rgba(0, 216, 127, 0.12) !important;
}

html:not(.dark) .logo.pulsate,
html:not(.dark) .logo.animate {
  animation: none !important;
}

html.dark .logo,
html.dark .logo.pulsate,
html.dark .logo.animate {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  animation: none !important;
}

.logo::after {
  content: '△_△';
  position: absolute;
  inset: 0;
  pointer-events: none;
  color: currentColor;
  -webkit-text-fill-color: currentColor;
  text-shadow:
    0 0 8px rgba(255, 255, 255, 0.86),
    0 0 28px rgba(0, 216, 127, 0.56),
    0 0 64px rgba(0, 216, 127, 0.34),
    0 0 108px rgba(0, 216, 127, 0.18);
  opacity: 0.34;
  transform: translateZ(0);
  will-change: opacity;
  animation: meallOptimizedLogoGlow 2.8s ease-in-out infinite;
}

html:not(.dark) .logo::after {
  text-shadow:
    0 0 8px rgba(0, 0, 0, 0.1),
    0 0 24px rgba(0, 216, 127, 0.34),
    0 0 58px rgba(0, 216, 127, 0.24),
    0 0 94px rgba(0, 216, 127, 0.14);
  opacity: 0.42;
}

#brandLogo,
#configBrandLogo {
  text-shadow:
    0 0 3px rgba(255, 255, 255, 0.72),
    0 0 14px rgba(0, 216, 127, 0.44),
    0 0 28px rgba(0, 216, 127, 0.24) !important;
}

@keyframes meallOptimizedLogoGlow {
  0%, 100% {
    opacity: 0.28;
  }
  50% {
    opacity: 0.62;
  }
}

.flat-icon {
  display: block;
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.has-flat-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.flat-icon-only {
  justify-content: center;
}

.config-nav-btn > span.has-flat-icon,
.config-section > h2.has-flat-icon,
.section > h2.has-flat-icon,
.header-btn.has-flat-icon,
.btn.has-flat-icon,
#mountModalTitle.has-flat-icon,
.pull-modal-title.has-flat-icon {
  gap: 10px;
}

/* ── Modal close icon (like Settings/TOS modals: bare ×, no button look) ── */
#mountModal .modal-close,
#pairingApprovalModal .modal-close,
#nodeModal .modal-close,
#sudoModal .modal-close,
#newAgentModal .modal-close,
#logsModal .modal-close {
  border: none;
  background: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
  border-radius: 6px;
  transition: background 0.15s;
}

#mountModal .modal-close:hover,
#pairingApprovalModal .modal-close:hover,
#nodeModal .modal-close:hover,
#newAgentModal .modal-close:hover,
#logsModal .modal-close:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.node-status-refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  padding: 4px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.node-status-refresh:hover:not(:disabled) {
  background: var(--border-color);
  color: var(--text-primary);
}

.node-status-refresh:disabled {
  cursor: wait;
  opacity: 0.55;
}

.node-settings-section {
  margin-top: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  interpolate-size: allow-keywords;
}

.node-settings-section::details-content {
  block-size: 0;
  overflow: hidden;
  opacity: 0;
  transition:
    block-size 0.3s ease,
    opacity 0.2s ease,
    content-visibility 0.3s allow-discrete;
}

.node-settings-section[open]::details-content {
  block-size: auto;
  opacity: 1;
}

.node-settings-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  color: var(--text-primary);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.node-settings-summary::-webkit-details-marker {
  display: none;
}

.node-settings-summary:hover {
  background: color-mix(in srgb, var(--border-color) 35%, transparent);
}

.node-settings-summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.node-settings-heading {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.node-settings-heading strong {
  font-size: 13px;
}

.node-settings-heading small {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.35;
}

.node-settings-chevron {
  width: 8px;
  height: 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.3s ease;
}

.node-settings-section[open] .node-settings-chevron {
  transform: rotate(225deg);
}

.node-settings-content {
  padding: 0 16px 14px;
  border-top: 1px solid var(--border-color);
}

@media (prefers-reduced-motion: reduce) {
  .node-settings-section::details-content,
  .node-settings-chevron {
    transition: none;
  }
}

.node-settings-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}

.node-settings-field textarea,
.node-settings-field select {
  width: 100%;
  padding: 9px 10px;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font: inherit;
  font-weight: 400;
  resize: vertical;
}

.node-settings-field small,
.node-settings-warning {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.4;
}

.node-operation-spinner {
  width: 22px;
  height: 22px;
  margin: 0 auto 20px;
  border: 2px solid color-mix(in srgb, var(--text-secondary) 24%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: node-operation-spin 0.8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .node-operation-spinner {
    animation-duration: 1.8s;
  }
}

.node-settings-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  color: var(--text-primary);
  font-size: 12px;
  line-height: 1.4;
}

.node-settings-check input {
  margin-top: 2px;
}

.node-settings-warning {
  margin: 8px 0 0;
  color: var(--warning, #e8b04a);
}

.node-connected-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 12px;
}

.node-connected-badge {
  flex: 0 0 auto;
  padding: 2px 8px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  font-weight: 600;
}

.node-connected-device {
  flex: 0 0 auto;
  color: var(--text-secondary);
  font-family: var(--app-mono, monospace);
}

.node-connected-state {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--text-primary);
}

.node-connected-empty {
  margin: 12px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
}

.node-connected-action {
  flex: 0 0 auto;
  min-height: 28px;
}

/* While the modal is still loading its first status report, the settings
   sections stay visible but cannot be opened or interacted with. */
#nodeModalContent.node-settings-loading .node-settings-section {
  opacity: 0.45;
  pointer-events: none;
}

/* Prevent glow from being clipped on the pairing icon */
#pairingApprovalModal .modal-body {
  overflow: visible !important;
  padding-top: 8px;
}

/* ── Pairing modal chat icon glow ─────────────────────────────────── */
.pairing-chat-icon {
  animation: pairingIconGlow 2.4s ease-in-out infinite;
}

@keyframes pairingIconGlow {
  0%, 100% {
    filter: drop-shadow(0 0 4px rgba(255,255,255,0.8)) drop-shadow(0 0 11px rgba(255,255,255,0.4)) drop-shadow(0 0 19px rgba(0,216,127,0.3)) drop-shadow(0 0 40px rgba(0,216,127,0.2));
  }
  50% {
    filter: drop-shadow(0 0 2px rgba(255,255,255,0.6)) drop-shadow(0 0 6px rgba(255,255,255,0.3)) drop-shadow(0 0 10px rgba(0,216,127,0.2)) drop-shadow(0 0 28px rgba(0,216,127,0.12));
  }
}

/* ── Light mode: the icon is dark, glow uses dark tones ── */
html:not(.dark) .pairing-chat-icon {
  stroke: #0b0f0d !important;
  animation: pairingIconGlowLight 2.4s ease-in-out infinite;
}

@keyframes pairingIconGlowLight {
  0%, 100% {
    filter: drop-shadow(0 0 4px rgba(0,0,0,0.08)) drop-shadow(0 0 8px rgba(0,216,127,0.18));
  }
  50% {
    filter: drop-shadow(0 0 1px rgba(0,0,0,0.06)) drop-shadow(0 0 4px rgba(0,216,127,0.12));
  }
}

@keyframes sudoSpin {
  to { transform: rotate(360deg); }
}

.vm-menu-toggle .flat-icon,
.header-btn .flat-icon,
.btn .flat-icon,
.config-nav-btn .flat-icon,
.pull-modal-title .flat-icon,
#mountModalTitle .flat-icon {
  width: 16px;
  height: 16px;
}

.phase-emoji.has-flat-icon,
.empty-state-icon.has-flat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.phase-emoji .flat-icon {
  width: 18px;
  height: 18px;
}

.empty-state-icon .flat-icon {
  width: 30px;
  height: 30px;
}

.container,
.page-toolbar {
  width: calc(100% - 48px) !important;
  max-width: 1392px !important;
  margin: 0 auto !important;
}

.container {
  padding: 18px 24px 18px !important;
}

.page-toolbar {
  margin: 0 auto;
  padding: 18px 24px 0 !important;
}

#mainLayout.container {
  gap: 16px !important;
}

.btn,
.header-btn,
.nav-back-button,
.back-btn,
.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 9px !important;
  border: 1px solid var(--panel-border-strong);
  background: var(--row-surface);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease,
    color 0.18s ease;
}

.btn .spinner {
  margin-top: 0;
  flex: 0 0 auto;
}

.btn-modelrelay-dashboard {
  min-width: 128px;
}

.btn-modelrelay-dashboard.is-loading {
  gap: 4px;
}

.btn-modelrelay-dashboard.is-loading .spinner {
  width: 12px;
  height: 12px;
  border-width: 2px;
}

#submitPairingBtn,
#approvePairingBtn {
  min-width: 128px;
}

.header-controls .btn,
.header-controls .header-btn,
.header-right .btn,
.header-right .header-btn {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 9px !important;
  border-color: color-mix(in srgb, var(--panel-border-strong) 70%, transparent);
  background: color-mix(in srgb, var(--bg-secondary) 60%, transparent) !important;
  color: var(--text-secondary);
  font-size: 0.867rem;
  font-weight: 600;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
}

.header-controls .btn:hover:not(:disabled),
.header-controls .header-btn:hover:not(:disabled),
.header-right .btn:hover:not(:disabled),
.header-right .header-btn:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--accent) 28%, var(--panel-border-strong));
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-secondary)) !important;
  color: var(--text-primary);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.1);
}

.header-controls .btn.active,
.header-controls .header-btn.active,
.header-controls .btn[aria-pressed='true'],
.header-controls .header-btn[aria-pressed='true'],
.header-controls .btn[data-active='true'],
.header-controls .header-btn[data-active='true'],
.header-right .btn.active,
.header-right .header-btn.active,
.header-right .btn[aria-pressed='true'],
.header-right .header-btn[aria-pressed='true'],
.header-right .btn[data-active='true'],
.header-right .header-btn[data-active='true'] {
  border-color: color-mix(in srgb, var(--accent) 32%, var(--panel-border-strong));
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-secondary)) !important;
  color: var(--text-primary);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.12);
}

.btn:hover:not(:disabled),
.header-btn:hover:not(:disabled),
.nav-back-button:hover:not(:disabled),
.back-btn:hover:not(:disabled),
.modal-close:hover:not(:disabled) {
  transform: none !important;
  border-color: rgba(0, 216, 127, 0.28);
  background: rgba(0, 216, 127, 0.08);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.1);
}

.btn-primary {
  background: linear-gradient(180deg, #00dc83, #00c874) !important;
  border-color: rgba(0, 216, 127, 0.32) !important;
  color: #ffffff !important;
  box-shadow: 0 12px 22px rgba(0, 216, 127, 0.18);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #14e08a, #00c06f) !important;
  box-shadow: 0 14px 24px rgba(0, 216, 127, 0.2);
}

.btn-secondary,
.header-btn,
.nav-back-button,
.back-btn {
  background: var(--row-surface) !important;
}

#section-providers .btn-onboarding,
#section-channels .btn-onboarding,
.skill-card .btn-primary {
  background: var(--row-surface) !important;
  border-color: var(--panel-border-strong) !important;
  color: var(--text-primary) !important;
  box-shadow: none !important;
}

#section-providers .btn-onboarding:hover:not(:disabled),
#section-channels .btn-onboarding:hover:not(:disabled),
.skill-card .btn-primary:hover:not(:disabled) {
  background: rgba(0, 216, 127, 0.08) !important;
  border-color: rgba(0, 216, 127, 0.24) !important;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.08) !important;
}

.skill-card .btn-primary:disabled {
  box-shadow: none !important;
}

.btn-danger {
  background: rgba(209, 41, 61, 0.12) !important;
  color: #ffb9c1 !important;
  border-color: rgba(209, 41, 61, 0.28) !important;
  box-shadow: 0 14px 26px rgba(209, 41, 61, 0.12);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(209, 41, 61, 0.18) !important;
}

.btn-manual {
  background: transparent !important;
  color: var(--text-secondary) !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
}

.btn:disabled,
.header-btn:disabled,
.nav-back-button:disabled,
.back-btn:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

input:not([type='checkbox']):not([type='radio']),
select,
textarea {
  background: var(--bg-tertiary) !important;
  border: 1px solid var(--panel-border-strong) !important;
  border-radius: 10px !important;
  color: var(--text-primary);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  font-family: var(--app-font);
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

input:not([type='checkbox']):not([type='radio']):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(0, 216, 127, 0.42) !important;
  box-shadow: 0 0 0 3px rgba(0, 216, 127, 0.12);
}

input::placeholder,
textarea::placeholder {
  color: rgba(156, 165, 159, 0.8);
}

.welcome-hero,
.system-check-card,
.config-sidebar,
.config-content,
.section:not(.config-section),
.vm-card,
.provider-card,
.advanced-config-card,
.snapshot-item,
.warning-box,
.onboarding-container {
  position: relative;
  overflow: hidden;
  background: var(--panel-surface), var(--bg-secondary) !important;
  border: 1px solid var(--panel-border-strong) !important;
  border-radius: 16px !important;
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

@media (prefers-reduced-motion: reduce) {
  .snapshot-item,
  .warning-box,
  .onboarding-container {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

.welcome-hero,
.system-check-card,
.vm-card,
.provider-card,
.snapshot-item,
.advanced-config-card {
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

.system-check-card:hover,
.vm-card:hover,
.provider-card:hover,
.snapshot-item:hover,
.advanced-config-card:hover {
  transform: none !important;
  border-color: rgba(0, 216, 127, 0.22) !important;
  box-shadow: 0 28px 56px rgba(0, 0, 0, 0.2);
}

.system-check-card,
.welcome-hero,
.vm-card,
.advanced-config-card,
.section:not(.config-section) {
  padding: 20px !important;
}

.system-check-card:not(.expanded) {
  padding-bottom: 0 !important;
}

.config-content {
  min-height: 560px;
}

.config-section {
  padding: 24px 26px !important;
}

.system-check-header,
.modal-header {
  margin: -20px -20px 18px !important;
  padding: 14px 18px !important;
  background: var(--panel-header-bg) !important;
  border-bottom: 1px solid var(--panel-border) !important;
}

.system-check-header {
  transition: none !important;
  margin: -20px -20px 0 !important;
  border-bottom: 0 !important;
}

.system-check-card.expanded .system-check-header {
  border-bottom: 1px solid var(--panel-border) !important;
}

.system-check-content {
  margin-top: 0 !important;
  padding-top: 0 !important;
  border-top: 0 !important;
  opacity: 0;
  pointer-events: none;
  /* Toggle immediately, without fading content during the layout change. */
  transition: none !important;
}

.system-check-card.expanded .system-check-content {
  margin-top: 12px !important;
  padding-top: 0 !important;
  border-top: 0 !important;
  opacity: 1 !important;
  pointer-events: auto;
}

.config-section > h2:first-child {
  display: flex !important;
  align-items: center;
  gap: 10px;
  margin: -24px -26px 0 !important;
  padding: 16px 18px 8px !important;
  background: linear-gradient(180deg, rgba(17, 25, 20, 0.05), rgba(17, 25, 20, 0.018)) !important;
  border-bottom: 0 !important;
  font-size: 16px !important;
  font-weight: 650 !important;
  letter-spacing: 0.005em;
}

.config-section > h2:first-child .flat-icon {
  width: 15px;
  height: 15px;
  color: var(--text-secondary);
}

.config-section > h2:first-child + p {
  margin: 0 -26px 22px !important;
  padding: 0 18px 16px !important;
  background: linear-gradient(180deg, rgba(17, 25, 20, 0.05), rgba(17, 25, 20, 0.018)) !important;
  border-bottom: 1px solid var(--panel-border) !important;
  color: var(--text-secondary) !important;
  font-size: 13px !important;
  line-height: 1.68 !important;
  max-width: none !important;
}

.config-section > h2:first-child + p strong {
  color: var(--text-primary);
}

.section:not(.config-section) > h2:first-child {
  margin: -20px -20px 18px !important;
  padding: 14px 18px !important;
  background: var(--panel-header-bg) !important;
  border-bottom: 1px solid var(--panel-border) !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  letter-spacing: 0.01em;
}

.modal-header h2,
.system-check-header h2,
.system-check-header h3 {
  margin: 0;
}

body > .welcome-hero {
  position: absolute;
  top: 76px;
  right: 0;
  left: 0;
  z-index: 90;
  width: 100%;
  max-width: none;
  margin: 0 !important;
  padding: 24px max(48px, calc((100% - 1392px) / 2 + 24px)) !important;
  border: 0 !important;
  border-radius: 0 !important;
  background:
    radial-gradient(circle at 88% 100%, rgba(0, 216, 127, 0.2), transparent 48%),
    linear-gradient(180deg, var(--bg-secondary), rgba(0, 216, 127, 0.045)),
    var(--bg-secondary) !important;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.12);
  text-align: left;
  transition: padding 0.22s ease, max-height 0.22s ease;
  overflow-y: auto;
}

body:has(> .welcome-hero) > .container {
  padding-top: 86px !important;
}

.welcome-hero::before {
  display: none;
}

.welcome-hero-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  gap: 24px;
}

.welcome-overview {
  min-width: 0;
  grid-column: 1 / -1;
}

.welcome-header-title {
  margin: 0;
  margin-left: -10px;
  color: var(--text-primary);
  font-size: 17px;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.02em;
  transition: opacity 0.18s ease;
}

.welcome-hero:not(.collapsed) .welcome-header-title {
  opacity: 0;
}

.welcome-eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.welcome-title {
  margin: 0;
  color: var(--text-primary) !important;
  font-size: clamp(22px, 2.4vw, 32px) !important;
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.04em;
  background: none !important;
  -webkit-text-fill-color: currentColor !important;
}

.welcome-subtitle {
  max-width: 760px;
  margin: 10px 0 0 !important;
  color: var(--text-secondary) !important;
  font-size: 14px !important;
  line-height: 1.65;
}

.welcome-toggle-btn {
  position: absolute;
  top: 14px;
  right: 24px;
  flex: 0 0 auto;
  white-space: nowrap;
}

.welcome-expanded-content {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  max-height: 440px;
  margin-top: 24px;
  padding-top: 20px;
  opacity: 1;
  overflow: hidden;
  transition:
    max-height 0.28s ease,
    margin-top 0.28s ease,
    padding-top 0.28s ease,
    opacity 0.16s ease;
}

body > .welcome-hero:not(.collapsed) {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 76px);
  padding-top: 14px !important;
  padding-bottom: 48px !important;
  overflow: hidden;
}

.welcome-hero:not(.collapsed) .welcome-expanded-content {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  padding-right: 12px;
  align-content: start;
  overflow-y: auto;
  scrollbar-color: var(--border-color, #333) transparent;
}

.welcome-hero:not(.collapsed) .welcome-expanded-content::-webkit-scrollbar-track {
  background: transparent;
}

.welcome-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: 12px;
  order: 1;
}

.welcome-step {
  display: flex;
  gap: 10px;
  min-height: 128px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: var(--row-surface);
}

.welcome-step-number {
  display: inline-flex;
  flex: 0 0 22px;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(0, 216, 127, 0.14);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.welcome-step-icon {
  display: inline-flex;
  margin-right: 8px;
  color: var(--text-primary);
  vertical-align: -9px;
}

.welcome-step-icon .flat-icon {
  width: 30px;
  height: 30px;
}

.welcome-step strong,
.welcome-faq summary {
  color: var(--text-primary);
  font-size: 17px;
  font-weight: 650;
}

.welcome-step p,
.welcome-faq p {
  margin: 5px 0 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}

.welcome-faq {
  column-count: 2;
  column-gap: 12px;
  order: 2;
}

@media (max-width: 900px) {
  .welcome-faq {
    column-count: 1;
  }
}

.welcome-faq details {
  break-inside: avoid;
  margin-bottom: 12px;
  padding: 9px 11px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: var(--row-surface);
  overflow: hidden;
  transition: background 0.2s ease;
}

.welcome-faq summary {
  cursor: pointer;
  list-style-position: inside;
}

.welcome-faq p {
  margin: 0;
}

.welcome-faq details[open] {
  background: rgba(0, 216, 127, 0.06);
}

.welcome-faq details[open] p {
  margin-top: 8px;
}

.welcome-hero.collapsed {
  display: block;
  padding-top: 14px !important;
  padding-bottom: 14px !important;
  background: var(--panel-surface), var(--bg-secondary) !important;
  box-shadow: var(--header-shadow);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  cursor: default;
}

.welcome-hero.collapsed .welcome-expanded-content {
  max-height: 0;
  margin-top: 0;
  padding-top: 0;
  opacity: 0;
}

.system-check-header {
  align-items: center;
  cursor: pointer;
}

#systemCheckCard,
#vmSection {
  margin-left: -24px;
  margin-right: -24px;
}

.system-check-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.system-check-actions {
  display: flex;
  align-self: stretch;
  align-items: stretch;
  gap: 10px;
}

.system-check-actions #createVmBtn {
  align-self: stretch;
  justify-content: flex-end;
  min-width: 280px;
  margin: -14px -18px -14px 0;
  background: linear-gradient(90deg, transparent, rgba(0, 216, 127, 0.1) 72%) !important;
  color: var(--text-primary) !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.system-check-actions #createVmBtn:hover:not(:disabled) {
  background: linear-gradient(90deg, transparent, rgba(0, 216, 127, 0.14) 72%) !important;
  box-shadow: none !important;
}

.system-check-actions #createVmBtn::before {
  content: '+';
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
}

.check-item {
  background: var(--row-surface);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 12px 14px;
}

.check-item + .check-item {
  margin-top: 10px;
}

.vm-section-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px 0 18px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--panel-border);
}

.vm-section-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.vm-section-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0;
  color: var(--text-primary);
}

.vm-section-title.has-flat-icon {
  display: flex;
  align-items: center;
  gap: 8px;
}

.vm-section-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 4px 0 0;
  line-height: 1.4;
  max-width: 520px;
}

.vm-grid {
  display: grid;
  gap: 16px !important;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
}

@media (min-width: 980px) {
  .vm-grid {
    grid-template-columns: repeat(2, minmax(min(320px, 100%), 1fr));
  }
}

.vm-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 248px;
  overflow: visible !important;
  padding-bottom: 0 !important;
  container-type: inline-size;
}

.vm-card.menu-open {
  z-index: 20010 !important;
}

.vm-card h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.025em;
}

.vm-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.vm-card-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: color 0.15s ease;
}

.vm-card-title:hover {
  color: var(--accent);
}

.vm-card-pills {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.vm-card-pills:empty {
  display: none;
}

.config-status-pill:empty {
  display: none;
}

/* Header actions — primary action + ⋮ toggle pinned top-right */
.vm-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex: 0 0 auto;
}

.vm-header-actions .btn {
  white-space: nowrap;
}

.vm-header-actions .vm-header-primary {
  padding: 7px 14px;
  font-size: 12.5px;
}

.vm-header-actions .vm-header-toggle {
  min-width: 36px;
  width: 36px;
  height: 34px;
  padding: 0;
  justify-content: center;
  flex: 0 0 auto;
}

.vm-card.menu-open .vm-header-toggle {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

/* Quick actions — icon-over-label square buttons pinned between the header
   and the orb columns, so Hub, Folders, Settings, Sudo and Node stay
   one tap away without opening ⋮. */
.vm-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  align-content: center;
  justify-content: flex-start;
}

.vm-quick-actions:empty {
  display: none;
}

.vm-quick-actions .vm-quick-btn {
  flex: 0 0 auto;
  width: 58px;
  height: 42px;
  position: relative;
  display: block;
  overflow: hidden;
  padding: 0;
  text-align: right;
}

.vm-quick-actions .vm-quick-cover {
  position: absolute;
  top: -13px;
  left: -18px;
  line-height: 1;
  color: var(--text-secondary);
  opacity: 0.7;
  pointer-events: none;
}

.vm-quick-actions .vm-quick-cover svg,
.vm-quick-actions .vm-quick-cover .flat-icon {
  width: 52px;
  height: 52px;
}

.vm-quick-actions .vm-quick-cover:not(:has(svg)) {
  font-size: 44px;
}

/* Bottom fade so the bleeding cover art never fights the label */
.vm-quick-actions .vm-quick-btn::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 62%;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55), transparent);
  pointer-events: none;
}

.vm-quick-actions .vm-quick-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.vm-quick-actions .vm-quick-label {
  position: absolute;
  right: 6px;
  bottom: 5px;
  left: 6px;
  z-index: 1;
  font-size: 10px;
  font-weight: 650;
  line-height: 1.2;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vm-quick-actions .vm-quick-primary {
  background: rgba(0, 216, 127, 0.1);
  border-color: rgba(0, 216, 127, 0.55);
  color: #7bf1a8;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 0 2px rgba(0, 216, 127, 0.12),
    0 4px 14px rgba(0, 0, 0, 0.35);
}

.vm-quick-actions .vm-quick-primary .vm-quick-label {
  color: #7bf1a8;
}

/* Sandbox card body — agents own column top-to-bottom; right side stacks
   the quick buttons on top with models/skills/channels columns below. */
.vm-card-body {
  --orb: 40px;
  --orb-gap: 8px;
}

.vm-sandbox-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid color-mix(in srgb, var(--text-secondary) 14%, transparent);
}

.vm-agents-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.vm-agents-orbit-wrap {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

/* Nudge up to compensate the label row above, so the hero sits optically centered. */
.vm-agents-orbit-wrap .vm-agents-orbit {
  transform: translateY(-9px);
}

.vm-agents-orbit,
.vm-agents-orbit-wrap {
  min-width: 0;
}

.vm-side-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

/* Sandbox card orb grid — models | skills | channels side by side */
.vm-orb-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  min-width: 0;
}

.vm-orb-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
  min-width: max-content;
  max-width: 100%;
}

.vm-orb-col + .vm-orb-col {
  border-left: 1px solid color-mix(in srgb, var(--text-secondary) 10%, transparent);
  padding-left: 16px;
}

.vm-orb-col-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vm-orb-col-label .vm-orb-col-icon {
  flex: 0 0 auto;
}

/* Featured column (agents) — bigger orbs, highlighted ring + label */
.vm-orb-col-featured .vm-orb-col-label {
  color: color-mix(in srgb, var(--accent) 80%, white);
  opacity: 1;
}

.vm-orb-col-featured .vm-agent-orb {
  width: calc(var(--orb) * 1.28);
  height: calc(var(--orb) * 1.28);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent),
    0 4px 12px rgba(0, 0, 0, 0.35);
}

/* Main agent — the hero of the card, clearly bigger than the rest */
.vm-orb-col-featured .vm-agent-orb.vm-agent-main {
  width: calc(var(--orb) * 2);
  height: calc(var(--orb) * 2);
  border-width: 2px;
  border-color: color-mix(in srgb, var(--accent) 75%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent),
    0 8px 24px rgba(0, 0, 0, 0.45);
}

.vm-orb-col-featured .vm-agent-orb.vm-agent-main .vm-agent-emoji,
.vm-orb-col-featured .vm-agent-orb.vm-agent-main .vm-agent-initial {
  font-size: calc(var(--orb) * 2 * 0.52);
}

.vm-orb-col-featured .vm-agent-emoji,
.vm-orb-col-featured .vm-agent-initial {
  font-size: calc(var(--orb) * 1.28 * 0.52);
}

/* Agent orbit — hero top-center, small orbs fanned on the lower radial */
.vm-agents-orbit-wrap {
  min-width: 0;
}

.vm-agents-orbit {
  position: relative;
  width: 100%;
}

.vm-agents-orbit.is-solo {
  height: auto;
}

.vm-orbit-hero {
  display: flex;
  justify-content: center;
  padding-top: 12px;
}

/* Docked + orb — bottom-right of the hero, slightly overlapping it */
.vm-hero-dock {
  position: relative;
  display: inline-block;
}

/* Bare + icon docked at the hero's bottom-right — not an orb. */
.vm-hero-dock .vm-add-agent {
  position: absolute;
  right: -14px;
  bottom: 2px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  margin: 0;
  background: none;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  box-shadow: none;
  color: var(--text-secondary);
  cursor: pointer;
  appearance: none;
  transition: opacity 0.15s ease;
}

/* Stays out of the way while the hero itself is hovered. */
.vm-hero-dock:has(.vm-agent-main:hover) .vm-add-agent {
  opacity: 0;
  pointer-events: none;
}

.vm-hero-dock .vm-add-agent:hover,
.vm-hero-dock .vm-add-agent:focus-visible {
  color: var(--accent);
  background: none;
  box-shadow: none;
  transform: none;
  outline: none;
}

.vm-hero-dock .vm-add-agent svg {
  display: block;
}

/* The hero always paints above the docked plus. */
.vm-hero-dock .vm-agent-main {
  position: relative;
  z-index: 6;
}

.vm-orbit-fan {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.vm-orbit-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

/* New-agent modal — starters first, custom on demand */
.new-agent-modal-content {
  max-width: 680px;
  min-height: min(600px, calc(100vh - 120px));
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 60%),
    var(--panel-surface, var(--bg-secondary));
  border-top: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
}

/* Birth customization step inside the create-sandbox modal reuses the
   new-agent starter cards; the modal just needs more room. */
#createVmModal.birth-step .modal-content {
  max-width: 600px;
}

#createVaBirth {
  flex-direction: column;
  min-height: 0;
}

#birthNameGroup {
  margin-top: 14px;
}

#birthNameGroup input {
  width: 100%;
}

.birth-optional {
  font-weight: 400;
  font-size: 12px;
  color: var(--text-secondary);
}

.birth-pills {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.birth-pill {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--panel-border, var(--border-color));
  background: color-mix(in srgb, var(--bg-secondary) 55%, transparent);
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

.birth-pill strong {
  font-size: 13px;
}

.birth-pill span {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.35;
}

.birth-pill:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.birth-pill.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-secondary));
}

#birthLanguageGroup input {
  width: 100%;
}

/* New-agent provisioning loading view — the modal swaps its body for a
   pulsing orb + status while the workspace is created. */
.new-agent-loading {
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 64px 20px;
  text-align: center;
}

.new-agent-loading-orb {
  width: 148px;
  height: 148px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 55%, transparent);
  animation: newAgentPulse 1.6s ease-in-out infinite;
}

.new-agent-loading-orb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.new-agent-loading-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid color-mix(in srgb, var(--text-secondary) 24%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: newAgentSpin 0.8s linear infinite;
}

@keyframes newAgentSpin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes newAgentPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.06);
    opacity: 0.85;
  }
}

.new-agent-loading-title {
  margin: 4px 0 0;
  font-weight: 800;
  font-size: 24px;
}

.new-agent-loading-sub {
  margin: 0;
  font-size: 15px;
  color: var(--text-secondary);
}

/* Agent orb surface buttons — open the sandbox's own Control UI chat (the
   📞 Call button lands on OpenClaw Talk, ready for the mic). */
.vm-agent-call-btn,
.vm-agent-chat-btn {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-secondary);
}

.vm-agent-call-btn:hover,
.vm-agent-chat-btn:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--text-primary);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.voice-call-content {
  max-width: 480px;
  width: 480px;
  display: flex;
  flex-direction: column;
  height: min(700px, calc(100vh - 80px));
  max-height: calc(100vh - 80px);
  overflow: hidden;
  border-radius: 24px;
  position: relative;
}

.voice-call-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 20px 0 8px;
  flex: 0 0 auto;
}

/* Before the first transcript lands, the stage owns the modal — a ringing
   screen, not a form. */
.voice-call-content:not(.has-transcript) .voice-call-stage {
  flex: 1 1 auto;
  justify-content: center;
  padding-bottom: 20px;
}

.voice-call-orb {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  font-weight: 800;
  background: color-mix(in srgb, var(--accent) 16%, var(--bg-secondary));
  color: var(--text-primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 45%, transparent);
}

.voice-call-orb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Page-level `img { display: block }` rules defeat the UA `[hidden]` style;
   without this the empty avatar slot keeps occupying the orb. */
.voice-call-orb img[hidden] {
  display: none;
}

.voice-call-orb.is-speaking {
  animation: newAgentPulse 1.6s ease-in-out infinite;
}

.voice-call-stage h2 {
  margin: 4px 0 0;
  font-size: 20px;
}

.voice-call-status {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.voice-call-live {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fff;
  background: #e5484d;
  border-radius: 6px;
  padding: 2px 7px;
}

.voice-call-spinner {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-top-color: var(--accent);
  animation: voiceSpinnerSpin 0.8s linear infinite;
}

@keyframes voiceSpinnerSpin {
  to {
    transform: rotate(360deg);
  }
}

.voice-call-timer {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

/* Failure popover: floating pill above the controls, visible without reading
   the status line. */
.voice-call-error-pill {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 104px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 14px;
  background: color-mix(in srgb, #e5484d 14%, var(--bg-secondary));
  border: 1px solid color-mix(in srgb, #e5484d 45%, transparent);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-primary);
}

.voice-call-error-pill[hidden] {
  display: none;
}

.voice-call-error-dismiss {
  flex: 0 0 auto;
  margin-left: auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: color-mix(in srgb, #e5484d 22%, transparent);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* Bubble stack: all turns stay in the DOM; older ones fade out above the
   mask. The stack is top-aligned so overflow is reachable — the renderer
   pins to the bottom (and releases the pin while the user scrolls back).
   No box: it blends into the call surface; only a subtle bottom edge
   separates it from the controls. */
.voice-transcript {
  flex: 1 1 auto;
  min-height: 140px;
  height: auto;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
  padding: 40px 6px 12px;
  border-radius: 12px;
  background: transparent;
  border-bottom: 1px solid var(--panel-border, var(--border-color));
  mask-image: linear-gradient(to bottom, transparent 0, #000 34px);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 34px);
}

.voice-transcript[hidden] {
  display: none;
}

/* Scrollbar: slim and themed to the call surface (browser default paints a
   white track in dark mode). Matches the .modal-body scrollbar convention. */
.voice-transcript {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--text-secondary) 40%, transparent) transparent;
}

.voice-transcript::-webkit-scrollbar {
  width: 6px;
}

.voice-transcript::-webkit-scrollbar-track {
  background: transparent;
}

.voice-transcript::-webkit-scrollbar-thumb {
  background-color: color-mix(in srgb, var(--text-secondary) 34%, transparent);
  border-radius: 4px;
}

.voice-transcript::-webkit-scrollbar-thumb:hover {
  background-color: color-mix(in srgb, var(--text-secondary) 55%, transparent);
}

.voice-bubble {
  font-size: 13px;
  line-height: 1.45;
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 14px;
  color: var(--text-primary);
  word-break: break-word;
  animation: voiceBubbleIn 160ms ease-out backwards;
  flex: 0 0 auto;
}

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

.voice-bubble.user {
  align-self: flex-end;
  text-align: right;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  border-bottom-right-radius: 4px;
}

.voice-bubble.agent {
  align-self: flex-start;
  background: color-mix(in srgb, var(--bg-secondary) 85%, var(--panel-border, var(--border-color)));
  border-bottom-left-radius: 4px;
}

.voice-bubble.is-draft {
  opacity: 0.62;
  font-style: normal;
}

.voice-bubble.is-draft::after {
  content: '…';
  opacity: 0.7;
}

.voice-bubble:empty {
  display: none;
}

.voice-call-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  flex: 0 0 auto;
  padding-bottom: 6px;
}

/* Mobile-call style round controls: big tap targets, icon-only. */
.voice-call-ctrl {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px solid var(--panel-border, var(--border-color));
  background: var(--bg-secondary);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease;
}

.voice-call-ctrl:active {
  transform: scale(0.94);
}

.voice-icon {
  width: 26px;
  height: 26px;
}

.voice-icon-mic-off {
  display: none;
}

.voice-call-ctrl.is-muted {
  background: color-mix(in srgb, #e5484d 14%, var(--bg-secondary));
  border-color: color-mix(in srgb, #e5484d 45%, transparent);
}

.voice-call-ctrl.is-muted .voice-icon-mic {
  display: none;
}

.voice-call-ctrl.is-muted .voice-icon-mic-off {
  display: block;
}

.voice-hangup-ctrl {
  background: #e5484d;
  border-color: transparent;
  color: #fff;
}

.voice-hangup-ctrl:hover {
  background: color-mix(in srgb, #e5484d 88%, #000);
}

/* Small screens: the call is the whole screen — a real phone call surface.
   !important because the shared .modal-content base rules (max-height,
   radius, padding) appear later in the cascade and would otherwise win. */
@media (max-width: 640px) {
  #voiceCallModal.active {
    padding: 0;
  }

  .voice-call-content {
    width: 100% !important;
    max-width: none !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    padding: 20px 16px max(6px, env(safe-area-inset-bottom)) !important;
  }

  .voice-call-orb {
    width: 104px;
    height: 104px;
    font-size: 38px;
  }

  .voice-bubble {
    max-width: 88%;
  }
}

.new-agent-modal-content .modal-header {
  flex: 0 0 auto;
}

.new-agent-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: clip;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--panel-border-strong, var(--border-color)) transparent;
}

.new-agent-scroll::-webkit-scrollbar {
  width: 6px;
}

.new-agent-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.new-agent-scroll::-webkit-scrollbar-thumb {
  background-color: var(--panel-border-strong, var(--border-color));
  border-radius: 4px;
}

.new-agent-modal-content .new-agent-footer {
  flex: 0 0 auto;
  padding-top: 12px;
  border-top: 1px solid color-mix(in srgb, var(--text-secondary) 12%, transparent);
  margin-top: 12px;
}

.new-agent-intro {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-primary);
  margin: 0 0 20px;
  max-width: 52ch;
}

.new-agent-eyebrow {
  display: block;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 5px;
}

.new-agent-starter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 10px 4px 6px;
}

.new-agent-starter-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  text-align: center;
  background: linear-gradient(
    160deg,
    color-mix(in srgb, var(--bg-secondary) 55%, white 3%),
    var(--bg-secondary)
  );
  border: 2px solid color-mix(in srgb, var(--text-secondary) 18%, transparent);
  border-radius: 16px;
  padding: 20px 12px 18px;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.new-agent-starter-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.new-agent-starter-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 24%, transparent),
    0 12px 28px rgba(0, 0, 0, 0.45);
}

.new-agent-starter-card:hover {
  transform: translateY(-2px);
}

.new-agent-starter-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent),
    0 8px 20px rgba(0, 0, 0, 0.35);
}

.new-agent-starter-card img {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin-top: 6px;
}

.new-agent-starter-card .new-agent-avatar-edit {
  display: none;
}

.new-agent-starter-card.is-selected .new-agent-avatar-edit {
  display: inline-flex;
}

.new-agent-starter-avatar {
  position: relative;
  display: inline-block;
}

.new-agent-orb-wrap {
  position: relative;
  display: inline-block;
}

.new-agent-avatar-edit {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1px solid color-mix(in srgb, var(--text-secondary) 35%, transparent);
  cursor: pointer;
  padding: 0;
  color: #fff;
}

.new-agent-avatar-edit svg {
  display: block;
}

.new-agent-avatar-edit:hover {
  border-color: var(--accent);
}

/* Shared avatar picker popover */
.avatar-popover {
  position: fixed;
  z-index: 60000;
  display: grid;
  grid-template-columns: repeat(6, 36px);
  gap: 6px;
  padding: 10px;
  background: #1a1a1e;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}

.new-agent-starter-card strong {
  font-size: 18px;
  margin-top: 6px;
  margin-bottom: 6px;
}

.new-agent-starter-card span {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.new-agent-custom-btn {
  width: 100%;
  margin-top: 18px;
  padding: 12px;
  border-style: dashed;
  background: transparent;
}

.new-agent-custom-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.new-agent-orb {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  background: var(--bg-secondary);
  border: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent),
    0 8px 24px rgba(0, 0, 0, 0.4);
}

.new-agent-orb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#newAgentModal .form-group {
  margin-bottom: 14px;
}

#newAgentModal .form-group > label {
  display: block;
  font-size: 12px;
  font-weight: 650;
  margin-bottom: 6px;
}

#newAgentModal input[type='text'],
#newAgentModal textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  line-height: 1.5;
}

#newAgentModal textarea {
  min-height: 76px;
  resize: vertical;
}

.new-agent-gallery {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.new-agent-thumb {
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  overflow: hidden;
  padding: 0;
  background: transparent;
  border: 2px solid transparent;
  cursor: pointer;
}

.new-agent-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.new-agent-thumb.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent);
}

.new-agent-emoji-picker {
  position: relative;
  display: inline-block;
}

.new-agent-emoji-btn {
  min-width: 110px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--bg-secondary);
  border: 1px solid color-mix(in srgb, var(--text-secondary) 25%, transparent);
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
}

.new-agent-emoji-btn[data-has-emoji='true'] {
  font-size: 20px;
}

.new-agent-emoji-pop {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(8, 34px);
  gap: 2px;
  padding: 10px;
  background: #1a1a1e;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  max-height: 220px;
  overflow-y: auto;
}

.new-agent-emoji-pop[hidden] {
  display: none;
}

.new-agent-emoji-opt {
  width: 34px;
  height: 34px;
  font-size: 20px;
  line-height: 1;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.new-agent-emoji-opt:hover {
  background: rgba(255, 255, 255, 0.08);
}

.new-agent-emoji-opt.is-selected {
  border-color: var(--accent);
}

.new-agent-error {
  font-size: 12.5px;
  color: #ff9aa5;
  margin-bottom: 10px;
}

.new-agent-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

#newAgentStartersView,
#newAgentCustomView {
  min-height: 430px;
}

@media (max-width: 560px) {
  .new-agent-starter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .new-agent-emoji-pop {
    grid-template-columns: repeat(6, 34px);
  }
}

.vm-orbit-fan .vm-agent-orb {
  pointer-events: auto;
  cursor: pointer;
}

/* Small orbit orbs never move on hover — glow only, keeping their place. */
.vm-orbit-fan .vm-agent-orb:hover,
.vm-orbit-fan .vm-agent-orb:focus-visible,
.vm-orbit-fan .vm-agent-orb:active {
  transform: none;
  border-color: color-mix(in srgb, var(--accent) 70%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 24%, transparent),
    0 10px 22px rgba(0, 0, 0, 0.4);
  z-index: 100;
}

/* Programmatically opened popover (after orbit swap). */
.vm-agent-orb.is-open .vm-agent-tip {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
  pointer-events: auto;
}

.vm-agents-orbit .vm-agent-orb:not(.vm-agent-main) {
  width: calc(var(--orb) * 1.05);
  height: calc(var(--orb) * 1.05);
}

.vm-agents-orbit .vm-agent-orb:not(.vm-agent-main) .vm-agent-emoji,
.vm-agents-orbit .vm-agent-orb:not(.vm-agent-main) .vm-agent-initial {
  font-size: calc(var(--orb) * 1.05 * 0.52);
}

/* Muted "stopped" note after the sandbox name */
.vm-stopped-tag {
  font-size: 12px;
  font-style: italic;
  color: var(--text-secondary);
  opacity: 0.75;
  flex: 0 0 auto;
}

/* Status dot before the sandbox title */
.vm-status-dot {  width: 13px;
  height: 13px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: #6b7280;
}

.vm-status-dot.is-running {
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.8);
}

.vm-status-dot.is-stopped {
  background: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
}

.vm-status-dot.is-attention {
  background: #eab308;
  box-shadow: 0 0 8px rgba(234, 179, 8, 0.8);
  animation: vm-status-pulse 2s ease-in-out infinite;
}

@keyframes vm-status-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.vm-orb-cells {
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: var(--orb-gap);
  justify-content: start;
  align-content: start;
  /* Reserve 3 rows so columns (and the orbit next door) never shift. */
  min-height: calc(var(--orb) * 3 + var(--orb-gap) * 2);
}

.vm-orb-cells.cells-1 {
  grid-template-columns: auto;
}

.vm-orb-cells.cells-2 {
  grid-template-columns: repeat(2, auto);
}

.vm-orb-cells.cells-3 {
  grid-template-columns: repeat(3, auto);
}

.vm-orb-cells.cells-4 {
  grid-template-columns: repeat(4, auto);
}

.vm-cell-empty {
  font-size: 12px;
  color: var(--text-secondary);
  opacity: 0.45;
  font-style: italic;
}

.vm-agent-orb,
.vm-skill-orb,
.vm-channel-orb,
.vm-more-orb {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--orb);
  height: var(--orb);
  border-radius: 50%;
  overflow: visible;
  background: linear-gradient(
    145deg,
    color-mix(in srgb, var(--bg-secondary) 60%, white 4%),
    var(--bg-secondary)
  );
  border: 1px solid color-mix(in srgb, var(--text-secondary) 30%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 2px 6px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
  cursor: default;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.22s ease,
    border-color 0.22s ease;
}

/* Stopped sandboxes — card contents grayed out except Start. Only the icon
   art itself is muted so popovers keep rendering fully solid. */
.vm-card[data-vm-state='Stopped'] .vm-agent-orb,
.vm-card[data-vm-state='Stopped'] .vm-skill-orb,
.vm-card[data-vm-state='Stopped'] .vm-channel-orb,
.vm-card[data-vm-state='Stopped'] .vm-more-orb,
.vm-card[data-vm-state='Stopped'] .vm-model-orb {
  background: var(--bg-secondary);
  border-color: color-mix(in srgb, var(--text-secondary) 25%, transparent);
  box-shadow: none;
}

.vm-card[data-vm-state='Stopped'] .vm-orb-icon,
.vm-card[data-vm-state='Stopped'] .vm-agent-emoji,
.vm-card[data-vm-state='Stopped'] .vm-agent-initial,
.vm-card[data-vm-state='Stopped'] .vm-agent-img,
.vm-card[data-vm-state='Stopped'] .vm-skill-img,
.vm-card[data-vm-state='Stopped'] .vm-channel-img,
.vm-card[data-vm-state='Stopped'] .vm-orb-more,
.vm-card[data-vm-state='Stopped'] .vm-model-badge,
.vm-card[data-vm-state='Stopped'] .vmp-img,
.vm-card[data-vm-state='Stopped'] .vmp-mark {
  filter: grayscale(1);
  opacity: 0.5;
}

.vm-card[data-vm-state='Stopped'] .vm-orb-col-label {
  opacity: 0.5;
}

.vm-card[data-vm-state='Stopped'] .vm-quick-actions .vm-quick-btn:not(.vm-start) {
  filter: grayscale(1);
  opacity: 0.45;
}

.vm-channel-img {
  width: calc(var(--orb) * 0.6);
  height: calc(var(--orb) * 0.6);
  object-fit: contain;
  display: block;
  border-radius: 50%;
}

.vm-skill-img {
  width: calc(var(--orb) * 0.52);
  height: calc(var(--orb) * 0.52);
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}

.vm-more-orb {
  border-style: dashed;
  background: transparent;
  box-shadow: none;
}

.vm-agent-orb:hover,
.vm-agent-orb:focus-visible,
.vm-skill-orb:hover,
.vm-skill-orb:focus-visible,
.vm-channel-orb:hover,
.vm-channel-orb:focus-visible,
.vm-more-orb:hover,
.vm-more-orb:focus-visible,
.vm-model-orb:hover,
.vm-model-orb:focus-visible {
  transform: scale(1.18) translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 70%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 24%, transparent),
    0 10px 22px rgba(0, 0, 0, 0.4);
  z-index: 5;
}

/* Model orbs — round, provider logo inside, small type badge bottom-right */
.vm-model-orb {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--orb);
  height: var(--orb);
  border-radius: 50%;
  overflow: visible;
  background: linear-gradient(
    145deg,
    color-mix(in srgb, var(--bg-secondary) 60%, white 4%),
    var(--bg-secondary)
  );
  border: 1px solid color-mix(in srgb, var(--text-secondary) 30%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 2px 6px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
  cursor: default;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.22s ease,
    border-color 0.22s ease;
}

.vm-model-orb .vmp-img {
  width: calc(var(--orb) * 0.52);
  height: calc(var(--orb) * 0.52);
}

.vm-model-orb .vmp-mark {
  width: calc(var(--orb) * 0.52);
  height: calc(var(--orb) * 0.52);
  font-size: calc(var(--orb) * 0.22);
}

.vm-model-badge {
  position: absolute;
  right: -3px;
  bottom: -3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(var(--orb) * 0.48);
  height: calc(var(--orb) * 0.48);
  min-width: 16px;
  min-height: 16px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 85%, black);
  border: 2px solid var(--bg-primary, #101010);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

.vm-model-badge-icon {
  display: block;
}

.vm-agent-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.vm-channel-img {
  width: 25px;
  height: 25px;
  object-fit: contain;
  display: block;
}

.vm-agent-emoji,
.vm-agent-initial,
.vm-orb-icon {
  font-size: calc(var(--orb) * 0.52);
  line-height: 1;
  font-weight: 700;
  color: var(--text-primary);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}

.vm-orb-more {
  font-size: calc(var(--orb) * 0.34);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-secondary);
}

.vm-agent-tip,
.vm-orb-tip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%) translateY(4px) scale(0.96);
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 160px;
  max-width: 240px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #1a1a1e;
  background: var(--panel-solid, #1a1a1e);
  color: #f0f0f0;
  color: var(--text-primary, #f0f0f0);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  font-size: 12px;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s cubic-bezier(0.34, 1.4, 0.64, 1);
  z-index: 60;
  white-space: normal;
  text-align: left;
}

.vm-agent-tip strong,
.vm-orb-tip strong {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
}

.vm-agent-tip span,
.vm-orb-tip span {
  color: #c6c6cc;
}

.vm-model-orb .vm-orb-tip {
  min-width: 240px;
  max-width: 320px;
}

.vm-orb-tip .vm-orb-model-line {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  font-weight: 400;
  color: color-mix(in srgb, var(--accent) 75%, white);
  word-break: break-all;
}

.vm-orb-tip .vm-orb-model-line b {
  font-family: inherit;
  font-weight: 700;
  color: #f0f0f0;
}

.vm-agent-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}


.vm-agent-orb:hover .vm-agent-tip,
.vm-agent-orb:focus-visible .vm-agent-tip,
.vm-agent-orb:focus-within .vm-agent-tip,
.vm-agent-orb:active .vm-agent-tip,
.vm-skill-orb:hover .vm-orb-tip,
.vm-skill-orb:focus-visible .vm-orb-tip,
.vm-skill-orb:active .vm-orb-tip,
.vm-channel-orb:hover .vm-orb-tip,
.vm-channel-orb:focus-visible .vm-orb-tip,
.vm-channel-orb:active .vm-orb-tip,
.vm-more-orb:hover .vm-orb-tip,
.vm-more-orb:focus-visible .vm-orb-tip,
.vm-more-orb:active .vm-orb-tip,
.vm-model-orb:hover .vm-orb-tip,
.vm-model-orb:focus-visible .vm-orb-tip,
.vm-model-orb:active .vm-orb-tip {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
  pointer-events: auto;
}

/* Fluid orb sizing — columns always fit, no overlap, no uneven cards.
   Narrow cards shrink the orbs stepwise; phones stack with a tidy grid. */
@container (max-width: 620px) {
  .vm-card-body {
    --orb: 34px;
    --orb-gap: 6px;
  }

  .vm-orb-grid {
    gap: 10px 12px;
  }

  .vm-header-actions .vm-header-primary {
    padding: 6px 10px;
    font-size: 12px;
  }
}

@container (max-width: 500px) {
  .vm-card-body {
    --orb: 30px;
  }

  .vm-orb-grid {
    gap: 10px;
    grid-column: 1 / -1;
  }

  .vm-orb-col + .vm-orb-col {
    border-left: none;
    padding-left: 0;
  }

  /* Keep the spotlight full width on compact cards. */
  .vm-sandbox-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .vm-agents-col {
    border-right: none;
    padding-right: 0;
    border-bottom: none;
    padding-bottom: 0;
  }

  .vm-side-col {
    display: flex;
  }

  .vm-quick-actions {
    align-content: center;
  }
}

@container (max-width: 380px) {
  .vm-card-body {
    --orb: 36px;
  }

  .vm-orb-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px 12px;
  }

  .vm-header-actions .vm-header-primary > span:last-child {
    display: none;
  }

  .vm-header-actions .vm-header-primary {
    padding: 7px 10px;
  }
}

@container (max-width: 300px) {
  .vm-card-body {
    --orb: 28px;
    --orb-gap: 5px;
  }

  .vm-orb-grid {
    gap: 12px 8px;
  }

  .vm-orb-col-label {
    font-size: 9px;
  }
}

/* Card body — modern flat layout */
.vm-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0 12px;
  min-width: 0;
  flex: 1 1 auto;
}

.vm-card-body.is-empty {
  justify-content: center;
  min-height: 60px;
}

.vm-body-empty,
.vm-body-muted {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-secondary);
}

/* Provider icon marks (shared by model cells) */
.vmp-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.vmp-img {
  display: block;
  width: 18px;
  height: 18px;
  object-fit: contain;
  flex-shrink: 0;
}

/* Top line: stats + channel tags */
.vm-top-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 550;
  color: var(--text-secondary);
  letter-spacing: -0.01em;
}

.vm-stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.vm-stat-dot {
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.55;
  flex-shrink: 0;
}

.vm-channel-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
}

/* Model area: dashed border container with "AI Models" badge */
.vm-model-area {
  position: relative;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 10px;
  padding: 14px 10px 10px;
  margin-top: 6px;
}

.vm-model-area-label {
  position: absolute;
  top: -9px;
  left: 10px;
  padding: 0 8px;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--accent) 70%, var(--text-secondary));
  background: var(--panel-surface), var(--bg-secondary);
  line-height: 1.5;
  border-radius: 4px;
}

/* Model line: 4 horizontal cells */
.vm-model-line {
  display: flex;
  align-items: stretch;
  gap: 5px;
}

.vm-model-cell {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--row-surface);
  line-height: 1.35;
}

.vm-mc-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 550;
  color: var(--text-secondary);
}

.vm-mc-icon {
  flex-shrink: 0;
  display: block;
  color: var(--accent);
  opacity: 0.7;
}

.vm-mc-label {
  flex-shrink: 0;
}

.vm-mc-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.vm-mc-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline;
}

.vm-mc-empty {
  color: var(--text-secondary);
  font-weight: 500;
}

.vm-mc-fallback {
  color: var(--text-secondary);
  font-weight: 550;
  font-style: italic;
}

.vm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: auto;
}

.vm-actions .btn-primary + .vm-compact-action {
  margin-left: 5px;
}

.vm-card .btn {
  min-height: 34px;
  padding: 0 11px;
  font-size: 12px;
}

.vm-actions .btn-primary {
  background: rgba(0, 216, 127, 0.1) !important;
  color: var(--text-primary) !important;
  border-color: rgba(0, 216, 127, 0.22) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 10px 22px rgba(0, 0, 0, 0.12);
}

.vm-actions .btn:hover:not(:disabled) {
  border-color: rgba(0, 216, 127, 0.18) !important;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08) !important;
}

.vm-actions .btn-primary:hover:not(:disabled) {
  background: rgba(0, 216, 127, 0.14) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 8px 16px rgba(0, 0, 0, 0.1) !important;
}

#saveBtn {
  background: rgba(0, 216, 127, 0.1) !important;
  color: var(--text-primary) !important;
  border-color: rgba(0, 216, 127, 0.22) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 10px 22px rgba(0, 0, 0, 0.12);
}

#saveBtn:hover:not(:disabled) {
  background: rgba(0, 216, 127, 0.14) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 8px 16px rgba(0, 0, 0, 0.1) !important;
}

.vm-actions .btn-secondary:hover:not(:disabled) {
  background: rgba(0, 216, 127, 0.05) !important;
}

/* Compact action: icon-only by default, expands to show label on hover */
.vm-actions .vm-compact-action {
  flex: 0 0 auto;
  width: auto;
  min-width: 32px;
  max-width: 32px;
  overflow: hidden;
  justify-content: flex-start;
  gap: 0;
  padding: 0 8px;
  white-space: nowrap;
  transition:
    max-width 180ms ease,
    padding 180ms ease,
    gap 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    background-color 180ms ease;
}

.vm-actions .vm-compact-action > span {
  display: block;
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-4px);
  transition:
    max-width 180ms ease,
    opacity 160ms ease,
    transform 160ms ease;
}

.vm-actions .vm-compact-action:hover:not(:disabled),
.vm-actions .vm-compact-action:focus-visible:not(:disabled),
.vm-card.menu-open .vm-actions .vm-compact-action.vm-menu-toggle {
  max-width: 180px;
  gap: 8px;
  padding-right: 12px;
  background: rgba(0, 216, 127, 0.12) !important;
  border-color: rgba(0, 216, 127, 0.3) !important;
  color: var(--text-primary) !important;
}

.vm-actions .vm-compact-action:hover:not(:disabled) > span,
.vm-actions .vm-compact-action:focus-visible:not(:disabled) > span,
.vm-card.menu-open .vm-actions .vm-compact-action.vm-menu-toggle > span {
  max-width: 140px;
  opacity: 1;
  transform: translateX(0);
}

@media (hover: none), (pointer: coarse) {
  .vm-actions .vm-compact-action {
    flex: 1 1 calc(50% - 2px);
    min-width: min(148px, 100%);
    max-width: none;
    gap: 8px;
    padding: 0 12px;
  }

  .vm-actions .vm-compact-action > span {
    max-width: none;
    opacity: 1;
    transform: translateX(0);
  }
}

.vm-menu-toggle {
  min-width: 38px;
  font-size: 12px !important;
}

.vm-menu {
  position: absolute !important;
  min-width: 220px !important;
  max-width: min(260px, calc(100vw - 20px));
  z-index: 10001 !important;
  display: none !important;
  flex-direction: column;
  gap: 4px;
  background: var(--panel-surface), var(--surface-strong) !important;
  border: 1px solid var(--panel-border-strong) !important;
  border-radius: 14px !important;
  box-shadow: 0 24px 54px rgba(0, 0, 0, 0.26);
  padding: 6px;
}

.vm-menu-shell-header {
  display: none;
}

.vm-menu-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.vm-menu-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.vm-menu-close {
  display: none;
}

#vmList,
.vm-section {
  overflow: visible !important;
}

.vm-menu.hidden {
  display: none !important;
}

.vm-menu.visible {
  display: flex !important;
}

.vm-menu [role='menuitem'] {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text-primary);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
}

.vm-menu [role='menuitem'] .has-flat-icon {
  width: 100%;
}

.vm-menu [role='menuitem']:hover {
  background: rgba(0, 216, 127, 0.08);
  border-color: rgba(0, 216, 127, 0.16);
}

.vm-menu [role='menuitem'].delete:hover {
  background: rgba(209, 41, 61, 0.12);
  border-color: rgba(209, 41, 61, 0.24);
  color: #ffb7c0;
}

.vm-card-loading-overlay {
  position: absolute;
  inset: 1px;
  border-radius: 15px !important;
  background: rgba(8, 8, 8, 0.85) !important;
  backdrop-filter: blur(16px);
  overflow: hidden;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 5;
}
.vm-card-loading-overlay.active {
  display: flex;
}

.vm-card-loading-overlay p {
  color: #ffffff !important;
}

.vm-grid .vm-card[onclick*='openCreateVmModal'] {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.01)), var(--bg-secondary) !important;
  border: 1px dashed rgba(0, 216, 127, 0.3) !important;
  color: var(--text-primary) !important;
}

.status-badge,
.config-pill,
.configured-pill {
  display: inline-flex !important;
  align-items: center !important;
  gap: 7px !important;
  border: 1px solid var(--panel-border-strong) !important;
  background: var(--row-surface) !important;
  border-radius: 999px !important;
  box-shadow: none !important;
  padding: 0 11px !important;
  min-height: 26px !important;
  height: auto !important;
  font-size: 11px !important;
  font-weight: 650 !important;
  letter-spacing: 0.01em;
  color: var(--text-primary) !important;
  white-space: nowrap;
}

.status-dot,
.config-dot {
  width: 7px !important;
  height: 7px !important;
  border-radius: 999px !important;
  margin: 0 !important;
  padding: 0 !important;
  flex: 0 0 auto !important;
}

.config-pill .config-text {
  display: inline !important;
  opacity: 1 !important;
  color: inherit !important;
}

.config-pill.loading {
  padding: 0 10px !important;
}

.config-pill.loading .config-text {
  display: none !important;
}

.config-pill.loading .config-dot {
  background: rgba(0, 216, 127, 0.78) !important;
  animation: pulse 1.1s ease-in-out infinite;
}

.status-badge.success,
.status-badge.ok,
.config-pill.configured,
.config-pill.status-pill.success,
.configured-pill {
  background: linear-gradient(180deg, rgba(0, 216, 127, 0.16), rgba(0, 216, 127, 0.1)) !important;
  border-color: rgba(0, 216, 127, 0.26) !important;
}

.status-badge.success .status-dot,
.status-badge.ok .status-dot,
.config-pill.configured .config-dot,
.config-pill.status-pill.success .config-dot {
  background: #19dd8d !important;
}

.status-badge.warning,
.config-pill.not-configured,
.config-pill.status-pill.warning {
  background: linear-gradient(180deg, rgba(242, 191, 73, 0.18), rgba(242, 191, 73, 0.1)) !important;
  border-color: rgba(242, 191, 73, 0.24) !important;
}

.config-pill.status-pill.error {
  background: linear-gradient(180deg, rgba(209, 41, 61, 0.16), rgba(209, 41, 61, 0.1)) !important;
  border-color: rgba(209, 41, 61, 0.24) !important;
}

.status-badge.warning .status-dot,
.config-pill.not-configured .config-dot,
.config-pill.status-pill.warning .config-dot {
  background: #f2bf49 !important;
}

.config-pill.status-pill.error .config-dot {
  background: #d1293d !important;
}

.status-badge.error {
  background: linear-gradient(180deg, rgba(209, 41, 61, 0.16), rgba(209, 41, 61, 0.1)) !important;
  border-color: rgba(209, 41, 61, 0.24) !important;
  color: #ffd8dd !important;
}

.status-badge.error .status-dot {
  background: #ff6e81 !important;
}

.config-pill.offline {
  background: linear-gradient(180deg, rgba(123, 140, 156, 0.18), rgba(123, 140, 156, 0.1)) !important;
  border-color: rgba(123, 140, 156, 0.24) !important;
}

.config-pill.offline .config-dot {
  width: auto !important;
  height: auto !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  font-size: 11px !important;
  background: transparent !important;
}

.configured-pill {
  color: var(--text-primary) !important;
}

.empty-state {
  border-radius: 16px;
  border: 1px dashed var(--panel-border-strong);
  background: var(--panel-surface), var(--bg-secondary);
}

.modal-content,
.pull-modal-content {
  position: relative;
  overflow: hidden;
  background: #ffffff !important;
  border: 1px solid var(--panel-border-strong) !important;
  border-radius: 16px !important;
  box-shadow: var(--panel-shadow);
  padding: 20px !important;
  max-height: calc(100vh - 120px);
}

html.dark .modal-content,
html.dark .pull-modal-content {
  background: #111111 !important;
}

#logsModal .modal-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 0;
  min-height: 0;
  overflow: hidden !important;
}

#logsModal #logsOutput {
  flex: 1 1 auto;
  min-height: 0;
  height: auto !important;
  max-height: none !important;
  overflow-y: auto !important;
}

.modal-close {
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--text-secondary);
}

#logsOutput {
  background: var(--bg-tertiary) !important;
  border: 1px solid var(--panel-border-strong) !important;
  border-radius: 12px !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  font-family: var(--app-mono) !important;
}

.advanced-config-card {
  padding: 0 !important;
  background: linear-gradient(180deg, rgba(17, 25, 20, 0.038), rgba(17, 25, 20, 0.018)), var(--bg-secondary) !important;
  border-color: var(--panel-border) !important;
  box-shadow: 0 14px 28px rgba(17, 25, 20, 0.08) !important;
}

.advanced-config-card:hover {
  border-color: rgba(0, 216, 127, 0.18) !important;
  box-shadow: 0 18px 34px rgba(17, 25, 20, 0.1) !important;
}

.advanced-config-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  margin: 0;
  padding: 6px 18px;
  background: transparent;
  border-bottom: none;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s ease;
}

.advanced-config-card.expanded .advanced-config-header {
  border-bottom-color: var(--panel-border);
}

.advanced-config-title {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
}

.advanced-config-arrow {
  order: 2;
  display: inline;
  margin-left: auto;
  color: var(--text-secondary);
  font-size: 10px;
  line-height: 1;
  transition: transform 0.28s ease;
}

.advanced-config-card.expanded .advanced-config-arrow {
  transform: rotate(90deg);
  color: var(--text-primary);
}

.advanced-config-content {
  margin-top: 0 !important;
  padding: 0 18px 0 !important;
  border-top: 0 !important;
  opacity: 0;
  pointer-events: none;
  transition:
    max-height 0.28s ease,
    padding-top 0.28s ease,
    padding-bottom 0.28s ease,
    opacity 0.18s ease !important;
}

.advanced-config-card.expanded .advanced-config-content {
  padding-top: 18px !important;
  padding-bottom: 18px !important;
  opacity: 1 !important;
  pointer-events: auto;
}

.advanced-config-content .form-group:first-child {
  margin-top: 0 !important;
}

.advanced-config-content .form-group:last-child {
  margin-bottom: 0 !important;
}

.config-sidebar {
  position: static;
  align-self: start;
  gap: 8px;
  padding: 12px !important;
}

.config-sidebar > div:first-child {
  padding: 4px 6px 6px;
  font-size: 11px !important;
  letter-spacing: 0.18em !important;
  color: var(--text-secondary) !important;
}

.config-sidebar hr {
  border-top: 1px solid var(--panel-border) !important;
  margin: 12px 0 6px !important;
}

.config-nav-btn {
  padding: 12px 14px !important;
  border: 1px solid transparent !important;
  border-radius: 9px !important;
  background: transparent !important;
  color: var(--text-secondary) !important;
}

.config-nav-btn:hover {
  background: var(--row-surface) !important;
  border-color: var(--panel-border) !important;
  color: var(--text-primary) !important;
}

.config-nav-btn.active {
  background: rgba(0, 216, 127, 0.1) !important;
  border-color: rgba(0, 216, 127, 0.22) !important;
  box-shadow: none !important;
  color: var(--text-primary) !important;
}

.config-sidebar.saving .config-nav-btn.active {
  color: var(--text-primary) !important;
}

.providers-grid {
  gap: 10px !important;
}

.models-list {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)) !important;
  gap: 10px !important;
}

.model-list-item {
  background: var(--row-surface) !important;
  border: 1px solid var(--panel-border-strong) !important;
  border-radius: 14px !important;
  padding: 12px 14px !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease !important;
}

.model-list-item.expanded {
  grid-column: 1 / -1;
  padding: 20px !important;
}

.model-list-item:hover:not(.disabled) {
  transform: none !important;
  border-color: rgba(0, 216, 127, 0.22) !important;
  background: linear-gradient(180deg, rgba(0, 216, 127, 0.06), rgba(0, 216, 127, 0.03)) !important;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.12) !important;
}

.model-list-item.selected {
  border-color: rgba(0, 216, 127, 0.3) !important;
  background: linear-gradient(180deg, rgba(0, 216, 127, 0.12), rgba(0, 216, 127, 0.05)) !important;
  box-shadow: 0 0 0 1px rgba(0, 216, 127, 0.22), 0 18px 34px rgba(0, 0, 0, 0.12) !important;
}

.model-list-item.selected .model-item-name {
  color: var(--text-primary) !important;
}

.model-item-header {
  gap: 8px !important;
}

.model-item-name {
  font-size: 15px !important;
  font-weight: 650 !important;
  letter-spacing: -0.01em;
}

.model-item-provider,
.model-price-badge,
.model-swe-badge {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 0 9px !important;
  border-radius: 999px !important;
  border: 1px solid var(--panel-border) !important;
  background: rgba(255, 255, 255, 0.04) !important;
  color: var(--text-secondary) !important;
  font-size: 11px !important;
  font-weight: 600 !important;
}

.model-item-provider-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.model-item-provider-icon img {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.model-item-provider-icon .model-item-provider-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 10px;
}

.model-item-provider-icon > span:not(.model-item-provider-mark) {
  width: 16px !important;
  height: 16px !important;
  min-width: 16px !important;
  min-height: 16px !important;
  border-radius: 5px !important;
  font-size: 9px !important;
}

.provider-pill-icon > span {
  width: 16px !important;
  height: 16px !important;
  min-width: 16px !important;
  min-height: 16px !important;
  border-radius: 4px !important;
  font-size: 8px !important;
}

.model-price-badge[data-cost='$'] {
  color: #19dd8d !important;
  border-color: rgba(25, 221, 141, 0.18) !important;
  background: rgba(25, 221, 141, 0.08) !important;
}

.model-price-badge[data-cost='$$'] {
  color: #f2bf49 !important;
  border-color: rgba(242, 191, 73, 0.18) !important;
  background: rgba(242, 191, 73, 0.08) !important;
}

.model-price-badge[data-cost='$$$'] {
  color: #ff9aa8 !important;
  border-color: rgba(255, 154, 168, 0.18) !important;
  background: rgba(255, 154, 168, 0.08) !important;
}

.model-item-tagline {
  color: var(--text-secondary) !important;
  font-size: 13px !important;
}

.model-item-details {
  gap: 8px !important;
  padding-top: 12px !important;
  border-top: 1px solid var(--panel-border) !important;
}

.model-detail-row {
  gap: 10px !important;
}

.detail-icon {
  margin-top: 2px !important;
}

.model-swe-badge {
  background: linear-gradient(180deg, rgba(0, 216, 127, 0.24), rgba(0, 216, 127, 0.14)) !important;
  color: var(--text-primary) !important;
  border: 1px solid rgba(0, 216, 127, 0.2);
  border-radius: 999px !important;
  padding: 2px 7px !important;
}

.model-swe-badge.no-data {
  background: rgba(255, 255, 255, 0.04) !important;
  border-color: var(--panel-border) !important;
  color: var(--text-secondary) !important;
}

.provider-card {
  padding: 12px 14px !important;
}

.provider-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.provider-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: var(--row-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.provider-icon img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.provider-icon > span {
  width: 100% !important;
  height: 100% !important;
  border-radius: inherit !important;
  font-size: 10px !important;
}

.provider-name {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.provider-description,
.help-text {
  color: var(--text-secondary) !important;
  line-height: 1.4;
}

.provider-input-wrapper {
  margin-top: 0 !important;
  padding-top: 0 !important;
  border-top: 0 !important;
  opacity: 0;
  pointer-events: none;
  transition: max-height 0.28s ease, margin-top 0.28s ease, opacity 0.18s ease !important;
}

.provider-card.expanded .provider-input-wrapper {
  margin-top: 14px !important;
  opacity: 1;
  pointer-events: auto;
}

.skill-card .provider-input-wrapper {
  max-height: 0 !important;
  overflow: hidden !important;
  margin-top: 0 !important;
  padding-top: 0 !important;
  border-top: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  transition: max-height 0.28s ease, margin-top 0.28s ease, opacity 0.18s ease !important;
}

.skill-card.expanded .provider-input-wrapper {
  max-height: 800px !important;
  margin-top: 14px !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

.provider-empty-state,
.provider-configured-state {
  background: var(--row-surface);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 16px;
}

.provider-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.provider-actions .help-text {
  font-size: 13px;
}

.openai-subscription-auth {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin: 14px 0;
  padding: 14px;
  border: 1px solid rgba(0, 216, 127, 0.22);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(0, 216, 127, 0.08), var(--row-surface));
}

.openai-auth-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.openai-auth-copy span,
.openai-device-prompt span,
.openai-device-prompt small {
  color: var(--text-secondary);
}

.openai-device-prompt {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--panel-border);
  font-size: 13px;
}

.openai-device-prompt[hidden] {
  display: none;
}

.openai-device-code-block {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.openai-device-code-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.openai-device-code-row strong {
  padding: 6px 10px;
  border-radius: 7px;
  background: var(--panel-surface);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.12em;
}

.openai-copy-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.openai-copy-code:hover {
  color: var(--text-primary);
}

.openai-auth-spinner {
  width: 13px;
  height: 13px;
  margin-right: 8px;
  border-width: 2px;
  border-color: currentColor;
  border-top-color: transparent;
  vertical-align: -2px;
}

@media (max-width: 640px) {
  .openai-subscription-auth {
    grid-template-columns: 1fr;
  }

  .openai-subscription-auth .btn {
    width: 100%;
  }

  .openai-device-prompt {
    grid-column: 1;
  }
}

.provider-card .provider-input-wrapper [style*='border-top'] {
  border-top: 0 !important;
  margin-top: 14px !important;
  padding-top: 14px !important;
}

.provider-card.expanded {
  grid-column: 1 / -1;
  border-color: rgba(0, 216, 127, 0.24) !important;
  padding: 20px !important;
}

.skill-loading .skeleton-bar {
  border-radius: 10px !important;
  background: linear-gradient(90deg, var(--row-surface), rgba(0, 216, 127, 0.12), var(--row-surface)) !important;
}

.behavior-loading-overlay,
.saving-overlay {
  background: rgba(8, 8, 8, 0.85) !important;
  backdrop-filter: blur(16px);
}

.saving-logo {
  position: relative;
  overflow: visible;
  text-shadow: 0 0 18px rgba(0, 216, 127, 0.35);
  animation: none !important;
}

.saving-overlay .saving-logo {
  animation: none !important;
}

.saving-logo::after {
  content: '△_△';
  position: absolute;
  inset: 0;
  pointer-events: none;
  color: currentColor;
  text-shadow:
    0 0 10px rgba(255, 255, 255, 0.86),
    0 0 32px rgba(0, 216, 127, 0.58),
    0 0 78px rgba(0, 216, 127, 0.36),
    0 0 132px rgba(0, 216, 127, 0.2);
  opacity: 0.34;
  transform: translateZ(0);
  will-change: opacity;
  animation: meallOptimizedLogoGlow 2.8s ease-in-out infinite;
}

#snapshotsButtonBar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.snapshot-item {
  padding: 18px 18px 16px !important;
}

.snapshot-meta {
  color: var(--text-secondary) !important;
}

.warning-box {
  background: linear-gradient(180deg, rgba(255, 190, 92, 0.14), rgba(255, 190, 92, 0.08)) !important;
  border-color: rgba(255, 190, 92, 0.24) !important;
  box-shadow: none;
}

.step {
  border-left: 3px solid rgba(0, 216, 127, 0.2) !important;
  border-radius: 12px !important;
  background: var(--row-surface) !important;
}

.step.active {
  border-left-color: var(--accent) !important;
}

.onboarding-container,
#licenseGateContent {
  background:
    radial-gradient(circle at top right, rgba(0, 216, 127, 0.13), transparent 30%),
    #ffffff !important;
  border-radius: 20px !important;
}

html.dark .onboarding-container,
html.dark #licenseGateContent {
  background:
    radial-gradient(circle at top right, rgba(0, 216, 127, 0.13), transparent 30%),
    #111111 !important;
}

#licenseGateContent {
  position: relative;
  overflow: hidden;
  background: #ffffff !important;
  border: 1px solid var(--panel-border-strong) !important;
  border-radius: 16px !important;
  box-shadow: var(--panel-shadow);
  padding: 34px 36px !important;
}

html.dark #licenseGateContent {
  background: #111111 !important;
}


.onboarding-dot {
  background: rgba(255, 255, 255, 0.14) !important;
}

.onboarding-dot.active,
.onboarding-dot.completed {
  background: var(--accent) !important;
  box-shadow: 0 0 0 4px rgba(0, 216, 127, 0.12);
}

.onboarding-title {
  font-size: clamp(24px, 3.2vw, 32px) !important;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.onboarding-description {
  color: var(--text-secondary) !important;
  line-height: 1.7;
}

#licenseGateSubtitle {
  color: var(--text-primary) !important;
  line-height: 1.7;
}

.onboarding-description {
  max-width: 46ch;
  margin-left: auto;
  margin-right: auto;
}

.onboarding-docker-status {
  background: var(--row-surface) !important;
  border: 1px solid var(--panel-border) !important;
  border-radius: 12px !important;
}

#licenseGateMaskedKey {
  background: var(--bg-tertiary) !important;
  border: 1px solid var(--panel-border) !important;
  border-radius: 10px !important;
  padding: 10px 12px !important;
}

@media (max-width: 980px) {
  #mainLayout.container {
    grid-template-columns: 1fr !important;
    grid-template-rows: max-content auto !important;
  }

  .config-sidebar {
    position: static;
    top: auto !important;
  }

  .vm-grid {
    grid-template-columns: 1fr !important;
  }

  .vm-card,
  .provider-card,
  .snapshot-item,
  .advanced-config-card {
    padding-bottom: 20px !important;
  }

  .vm-actions {
    flex-wrap: wrap;
    gap: 4px;
  }

  .vm-actions .btn-primary {
    width: 100%;
    flex: 0 0 100%;
    margin-bottom: 6px;
  }

  .vm-actions .btn {
    min-width: 0;
  }

  .vm-actions .vm-compact-action {
    flex: 1 1 calc(33.333% - 3px);
    min-width: 0;
    max-width: none;
    width: auto;
    padding: 0 11px;
    gap: 8px;
  }

  .vm-actions .vm-compact-action > span {
    max-width: none;
    opacity: 1;
    transform: translateX(0);
  }

  .vm-actions .vm-compact-action:hover:not(:disabled),
  .vm-actions .vm-compact-action:focus-visible:not(:disabled) {
    max-width: none;
    gap: 8px;
    padding-right: 11px;
  }

  .vm-actions .vm-compact-action:hover:not(:disabled) > span,
  .vm-actions .vm-compact-action:focus-visible:not(:disabled) > span {
    max-width: none;
    opacity: 1;
    transform: translateX(0);
  }

  .vm-actions .btn-primary + .vm-compact-action {
    margin-left: 0;
  }
}

@media (max-width: 700px) {
  header {
    top: 0;
    width: 100%;
    max-width: none;
    margin: 0 !important;
    padding: 12px !important;
    border-top: 0;
    border-radius: 0;
    flex-wrap: nowrap;
    gap: 8px;
    align-items: center;
  }

  .header-left {
    flex: 1 1 auto;
    min-width: 0;
  }

  .header-controls,
  .header-right {
    width: auto;
    flex: 0 0 auto;
    flex-wrap: nowrap;
    margin-left: auto;
    justify-content: flex-end;
  }

  #openFeedbackModalBtn,
  #openSettingsModalBtn {
    width: 34px;
    min-width: 34px;
    padding: 0;
    font-size: 0;
  }

  #openFeedbackModalBtn.has-flat-icon,
  #openSettingsModalBtn.has-flat-icon {
    gap: 0;
    justify-content: center;
  }

  body > .container,
  .container,
  .page-toolbar {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  #systemCheckCard,
  #vmSection {
    margin-left: -4px;
    margin-right: -4px;
  }

  .system-check-actions #createVmBtn {
    min-width: 180px;
  }

  body > .welcome-hero {
    top: 56px;
    padding: 14px 12px !important;
  }

  .welcome-toggle-btn {
    right: 12px;
  }

  body > .welcome-hero:not(.collapsed) {
    height: calc(100vh - 56px);
    padding-top: 14px !important;
    padding-bottom: 28px !important;
  }

  body:has(> .welcome-hero) > .container {
    padding-top: 68px !important;
  }

  .welcome-hero-inner {
    align-items: center;
    gap: 12px;
  }

  .welcome-header-title {
    margin-left: 0;
  }

  .welcome-eyebrow {
    margin-bottom: 5px;
  }

  .welcome-title {
    font-size: 22px !important;
  }

  .welcome-expanded-content,
  .welcome-steps,
  .welcome-faq {
    grid-template-columns: 1fr;
  }

  .welcome-expanded-content {
    gap: 14px;
    margin-top: 18px;
    padding-top: 16px;
  }

  .page-toolbar {
    padding-top: 12px;
  }

  .welcome-hero,
  .system-check-card,
  .config-sidebar,
  .config-content,
  .section:not(.config-section),
  .vm-card,
  .provider-card,
  .snapshot-item,
  .modal-content,
  .pull-modal-content,
  .onboarding-container,
  #licenseGateContent {
    border-radius: 14px !important;
    padding-bottom: 20px !important;
  }

  .onboarding-container,
  #licenseGateContent {
    padding: 28px 24px !important;
  }

  .config-section {
    padding: 22px 18px !important;
  }

  .config-section > h2:first-child {
    margin: -22px -18px 0 !important;
    padding: 16px 18px 8px !important;
  }

  .config-section > h2:first-child + p {
    margin: 0 -18px 22px !important;
    padding: 0 18px 16px !important;
  }

  .section:not(.config-section),
  .welcome-hero,
  .system-check-card,
  .vm-card,
  .advanced-config-card {
    padding: 20px !important;
  }

  .advanced-config-card {
    padding: 0 !important;
  }

  .advanced-config-header {
    padding: 15px 16px !important;
  }

  .advanced-config-card.expanded .advanced-config-content {
    padding: 16px !important;
  }

  .section:not(.config-section) > h2:first-child,
  .system-check-header,
  .modal-header {
    margin-left: -20px !important;
    margin-right: -20px !important;
  }

  .vm-actions .vm-compact-action {
    flex: 1 1 calc(50% - 2px);
    min-width: 0;
    max-width: none;
    width: auto;
    padding: 0 11px;
    gap: 8px;
  }

  .vm-actions .vm-compact-action > span {
    max-width: none;
    opacity: 1;
    transform: translateX(0);
  }

  .vm-menu.vm-menu-mobile {
    position: fixed !important;
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    transform: translate(-50%, -50%);
    width: min(320px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    max-height: min(76vh, 520px);
    padding: 0;
    gap: 0;
    overflow: hidden;
    border-radius: 18px !important;
  }

  .vm-menu.vm-menu-mobile .vm-menu-shell-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--panel-border);
  }

  .vm-menu.vm-menu-mobile .vm-menu-close {
    display: inline-flex;
    width: 32px;
    min-width: 32px;
    height: 32px;
    min-height: 32px;
    padding: 0;
    border-radius: 999px !important;
    color: var(--text-secondary);
    box-shadow: none;
  }

  .vm-menu.vm-menu-mobile .vm-menu-close:hover:not(:disabled) {
    background: rgba(0, 216, 127, 0.08) !important;
    border-color: rgba(0, 216, 127, 0.2) !important;
    color: var(--text-primary);
  }

  .vm-menu.vm-menu-mobile .vm-menu-items {
    padding: 8px;
    max-height: calc(min(76vh, 520px) - 56px);
    overflow-y: auto;
  }

  .welcome-title {
    font-size: clamp(18px, 5vw, 24px) !important;
  }
}

@media (max-width: 545px) {
  .vm-card,
  .provider-card,
  .advanced-config-card {
    padding: 14px !important;
  }

  .vm-card-body {
    margin-top: 8px;
  }

  .vm-model-line {
    flex-wrap: wrap;
  }

  .vm-model-cell {
    flex: 1 1 calc(50% - 2.5px);
  }

  .vm-actions .vm-compact-action {
    padding: 0 8px;
  }
}

/* Very small widths — remove every last hard minimum so the page shrinks. */
@media (max-width: 400px) {
  body > .container,
  .container,
  .page-toolbar {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  .vm-grid {
    gap: 12px !important;
  }

  .vm-card {
    padding: 12px !important;
  }

  .system-check-actions {
    flex-wrap: wrap;
  }

  .system-check-actions #createVmBtn {
    min-width: 0;
    flex: 1 1 100%;
  }

  #vmSection {
    margin-left: 0;
    margin-right: 0;
  }
}

/* ─── Tab layer (Electron tab system) ─────────────────────────────── */

body.has-tabs {
  padding-bottom: 33px;
}

#tabWebviewContainer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 33px;
  z-index: 50000;
  display: block;
  background: var(--bg-primary);
  opacity: 0;
  pointer-events: none;
}

#tabWebviewContainer.active {
  opacity: 1;
  pointer-events: auto;
}

html.electron-mac #tabWebviewContainer,
html.electron-windows #tabWebviewContainer {
  background: transparent;
}

html.electron-mac body.viewing-tab > header,
html.electron-mac body.viewing-tab > .container,
html.electron-mac body.viewing-tab > .welcome-hero,
html.electron-windows body.viewing-tab > header,
html.electron-windows body.viewing-tab > .container,
html.electron-windows body.viewing-tab > .welcome-hero {
  display: none;
}

body.viewing-tab .modal,
body.viewing-tab .notification {
  display: none !important;
}

#tabWebviewContainer .tab-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}

#tabWebviewContainer .tab-wrapper.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 2;
}

#tabWebviewContainer .tab-webview {
  width: 100%;
  height: 100%;
  border: none;
}

.tab-drag-region {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  width: 92px;
  height: 68px;
  -webkit-app-region: drag;
}

#tabWebviewContainer .tab-wrapper[data-tab-name^='config-'] .tab-drag-region,
#tabWebviewContainer .tab-wrapper[data-tab-name^='snapshots-'] .tab-drag-region {
  right: 210px;
  width: auto;
}

/* Terminal tabs: the in-page header holds only display-only elements (logo,
   brand, status pill), so the host drag strip can span the full width. The
   -webkit-app-region inside the webview does not propagate to the window. */
#tabWebviewContainer .tab-wrapper[data-tab-name^='terminal-'] .tab-drag-region {
  width: 100%;
}

.tab-cockpit-drag-region {
  position: absolute;
  top: 0;
  z-index: 2;
  -webkit-app-region: drag;
}

.tab-loader {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 24px;
  box-sizing: border-box;
  text-align: center;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  z-index: 1;
  opacity: 1;
  transition: opacity 0.35s ease;
}

.tab-loader.fading {
  opacity: 0;
}

.tab-loader.hidden {
  display: none;
}

html.electron-mac .tab-loader,
html.electron-windows .tab-loader {
  background: transparent;
}

.tab-loader-logo {
  position: relative;
  overflow: visible;
  font-size: 52px;
  color: var(--text-primary, #fff);
  text-shadow:
    0 0 3px rgba(255, 255, 255, 0.72),
    0 0 18px rgba(0, 216, 127, 0.5),
    0 0 42px rgba(0, 216, 127, 0.28);
  animation: none !important;
}

html.electron-app .tab-loader-logo::after {
  content: '△_△';
  position: absolute;
  inset: 0;
  pointer-events: none;
  color: currentColor;
  -webkit-text-fill-color: currentColor;
  text-shadow:
    0 0 10px rgba(255, 255, 255, 0.86),
    0 0 32px rgba(0, 216, 127, 0.58),
    0 0 78px rgba(0, 216, 127, 0.36),
    0 0 132px rgba(0, 216, 127, 0.2);
  opacity: 0.34;
  transform: translateZ(0);
  will-change: opacity;
  animation: meallOptimizedLogoGlow 2.8s ease-in-out infinite;
}

@keyframes loaderPulsate {
  0% {
    text-shadow:
      0 0 2px #fff,
      0 0 4px #fff,
      0 0 6px #fff,
      0 0 10px #0fa,
      0 0 45px #0fa,
      0 0 55px #0fa,
      0 0 70px #0fa,
      0 0 80px #0fa;
  }
  100% {
    text-shadow:
      0 0 4px #fff,
      0 0 11px #fff,
      0 0 19px #fff,
      0 0 40px #0fa,
      0 0 80px #0fa,
      0 0 90px #0fa,
      0 0 100px #0fa,
      0 0 150px #0fa;
  }
}

/* ── Hub navigation chrome ─────────────────────────────────────── */

.tab-nav {
  position: absolute;
  inset: 0 0 auto;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 68px;
  padding: 12px 24px;
  background: var(--panel-surface), var(--bg-secondary);
  border-bottom: 1px solid var(--panel-border-strong);
  box-shadow: var(--header-shadow);
}

.tab-hub-header-brand,
.tab-hub-header-copy {
  display: flex;
  align-items: center;
}

.tab-hub-header-brand {
  flex: 0 0 auto;
  gap: 10px;
}

.tab-hub-header-copy {
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}

.tab-hub-header-logo {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--text-primary);
  text-shadow:
    0 0 8px rgba(0, 216, 127, 0.28),
    0 0 20px rgba(0, 216, 127, 0.14);
}

.tab-hub-header-name {
  font-size: 14px;
  font-weight: 700;
}

.tab-hub-header-subtitle {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-nav-btn {
  margin-left: auto;
  min-width: 72px;
  height: 36px;
  border: 1px solid color-mix(in srgb, var(--panel-border-strong) 70%, transparent);
  border-radius: 9px;
  background: color-mix(in srgb, var(--bg-secondary) 60%, transparent);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}

.tab-nav-btn:hover {
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-secondary));
  border-color: color-mix(in srgb, var(--accent) 45%, var(--panel-border-strong));
}

.tab-nav-btn:active { background: color-mix(in srgb, var(--accent) 16%, var(--bg-secondary)); }
.tab-nav-btn[disabled] { opacity: 0; pointer-events: none; }

.hub-navigation-active .tab-webview {
  height: calc(100% - 68px) !important;
  margin-top: 68px;
}

html.electron-mac .tab-nav {
  padding-left: 92px;
  -webkit-app-region: drag;
}

html.electron-mac .tab-nav-btn { -webkit-app-region: no-drag; }

/* Background tabs must contribute zero draggable rects. Chromium computes
   -webkit-app-region hit-testing geometrically from the layout tree: opacity,
   pointer-events, and z-order are ignored, so a laid-out drag element inside
   an inactive wrapper (e.g. the hub tab-nav's full-width drag strip) would
   keep swallowing clicks on the ACTIVE tab's header even while invisible.
   display:none removes the boxes from the region computation without the
   subtraction side effects that app-region:no-drag would cause. The
   !important beats updateNav()'s inline `display: flex` on .tab-nav;
   re-activating the wrapper stops this rule from matching. */
#tabWebviewContainer .tab-wrapper:not(.active) .tab-nav,
#tabWebviewContainer .tab-wrapper:not(.active) .tab-drag-region,
#tabWebviewContainer .tab-wrapper:not(.active) .tab-cockpit-drag-region {
  display: none !important;
}

/* ── Tab bar ───────────────────────────────────────────────────── */

#tabBar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 33px;
  min-height: 33px;
  z-index: 50001;
  display: flex;
  align-items: stretch;
  background: var(--bg-primary, #111);
  border-top: 1px solid var(--border-color, #222);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color, #333) transparent;
  gap: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateY(100%);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

#tabBar.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#tabBar::-webkit-scrollbar {
  height: 2px;
}

#tabBar::-webkit-scrollbar-thumb {
  background: var(--border-color, #444);
  border-radius: 1px;
}

.tab-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  min-width: 80px;
  max-width: 200px;
  cursor: pointer;
  font-size: 11.5px;
  color: var(--text-secondary, #888);
  background: transparent;
  border: none;
  border-right: 1px solid var(--border-color, #222);
  white-space: nowrap;
  overflow: hidden;
  flex-shrink: 0;
  user-select: none;
  transition: background 0.12s, color 0.12s;
}

.tab-item:hover {
  background: var(--bg-secondary, #1a1a1a);
  color: var(--text-primary, #ccc);
}

.tab-item.active {
  background: var(--bg-secondary, #1e1e1e);
  color: var(--text-primary, #eee);
  border-bottom: 2px solid var(--accent, #4f9);
}

.tab-item .tab-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.tab-item .tab-icon svg {
  display: block;
}

.tab-item .tab-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-item .tab-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: none;
  background: transparent;
  color: var(--text-secondary, #666);
  font-size: 9px;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
}

.tab-item .tab-close:hover {
  background: rgba(255, 60, 60, 0.25);
  color: #f55;
}

/* ── Dashboard tab (fixed left, distinct) ─────────────────────── */

.tab-item.dashboard-tab {
  min-width: 70px;
  max-width: 110px;
  background: rgba(0, 216, 127, 0.08);
  color: var(--accent, #00d87f);
  border-bottom: 2px solid rgba(0, 216, 127, 0.3);
  cursor: pointer;
}

.tab-item.dashboard-tab:hover {
  background: rgba(0, 216, 127, 0.14);
}

.tab-item.dashboard-tab.active {
  background: rgba(0, 216, 127, 0.12);
  color: var(--accent, #00d87f);
  border-bottom-color: var(--accent, #00d87f);
}

.tab-item.dashboard-tab .tab-close {
  display: none;
}

/* ── Drag and drop ────────────────────────────────────────────── */

.tab-item.dragging {
  opacity: 0.35;
}

.tab-item.drag-over {
  border-left: 2px solid var(--accent, #4f9);
}

/* ── Ctrl+Tab Switcher ───────────────────────────────────────── */

#tabSwitcher {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--modal-overlay, rgba(0, 0, 0, 0.55));
  backdrop-filter: blur(4px);
}

@media (prefers-reduced-motion: reduce) {
  .tab-nav-btn,
  .modal-overlay {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}

.tab-switcher-card {
  background: var(--bg-primary, #181818);
  border: 1px solid var(--border-color, #2a2a2a);
  border-radius: 14px;
  padding: 8px;
  min-width: 300px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 12px 48px var(--shadow-color, rgba(0, 0, 0, 0.6));
}

.tab-switcher-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tab-switcher-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--text-secondary, #999);
  font-size: 13.5px;
  cursor: default;
  transition: background 0.08s, color 0.08s;
}

.tab-switcher-item.active {
  background: rgba(0, 216, 127, 0.13);
  color: var(--text-primary, #eee);
}

.tab-switcher-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  color: var(--text-dim, #555);
}

.tab-switcher-icon svg {
  display: block;
}

.tab-switcher-item.active .tab-switcher-icon {
  color: var(--accent, #00d87f);
}

/* Agent spotlight and character selection. Portraits animate only on demand. */
.agent-avatar-media {
  position: relative;
  display: block;
  isolation: isolate;
  overflow: hidden;
  background: #061413;
  border-radius: inherit;
}
.agent-avatar-media img,
.agent-avatar-media .agent-avatar-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  border-radius: inherit;
  object-fit: cover;
}
.agent-avatar-video {
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}
.agent-avatar-media.is-playing .agent-avatar-video {
  opacity: 1;
}
.agent-avatar-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: 42px;
  color: var(--text-primary);
}
.agent-avatar-media.is-fallback img {
  display: none;
}
.agent-avatar-media:focus-visible,
.vm-agent-choice:focus-visible,
.vm-agent-add:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
.vm-agent-roster {
  min-width: 0;
}
.vm-agent-spotlight {
  display: grid;
  grid-template-columns: clamp(112px, 30cqw, 168px) minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  min-width: 0;
}
.vm-agent-portrait > .agent-avatar-media {
  aspect-ratio: 1;
  border-radius: 22px 8px 22px 8px;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
}
.vm-agent-profile {
  min-width: 0;
}
.vm-agent-eyebrow {
  display: block;
  margin-bottom: 5px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent);
}
.vm-agent-name {
  display: block;
  font-size: clamp(21px, 5cqw, 28px);
  line-height: 1.15;
  letter-spacing: -0.04em;
  overflow-wrap: anywhere;
  color: var(--text-primary);
}
.vm-agent-description {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  height: 3em;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 8px 0 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.vm-agent-profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.vm-agent-profile-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid var(--panel-border, var(--border-color));
  border-radius: 8px;
  color: var(--text-primary);
  background: color-mix(in srgb, var(--bg-secondary) 85%, white 4%);
}
.vm-agent-profile-actions .vm-agent-chat-btn {
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-secondary));
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
}
.vm-agent-profile-actions button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.vm-agent-selection {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
  margin-top: 14px;
}
.vm-agent-choice,
.vm-agent-selection .vm-agent-add {
  position: relative;
  width: 48px;
  height: auto;
  display: flex;
  flex: 0 0 48px;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--text-secondary);
  box-shadow: none;
  cursor: pointer;
  transform: none;
}
.vm-agent-choice .agent-avatar-media {
  width: 48px;
  height: 48px;
  border-radius: 13px;
  border: 1px solid color-mix(in srgb, var(--text-secondary) 22%, transparent);
  transition:
    border-color 160ms ease,
    transform 160ms ease;
}
.vm-agent-choice:hover .agent-avatar-media {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.vm-agent-choice .agent-avatar-fallback {
  font-size: 22px;
}
.vm-agent-choice-name,
.vm-agent-selection .vm-agent-add span {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 9px;
  line-height: 1.2;
  text-align: center;
}
.vm-agent-selection .vm-agent-add > svg {
  box-sizing: content-box;
  width: 18px;
  height: 18px;
  padding: 14px;
  border-radius: 13px;
  border: 1px dashed color-mix(in srgb, var(--text-secondary) 30%, transparent);
}
.vm-agent-selection .vm-agent-add:hover {
  color: var(--accent);
}
.vm-agent-selection .vm-agent-add:hover > svg {
  border-color: var(--accent);
}
.vm-agent-roster-wrap {
  min-width: 0;
}
.vm-sandbox-grid > .vm-side-col {
  padding-top: 12px;
  border-top: 1px solid color-mix(in srgb, var(--text-secondary) 12%, transparent);
}
.new-agent-starter-avatar {
  width: 104px;
  height: 104px;
  border-radius: 22px;
}
.new-agent-starter-avatar .agent-avatar-media {
  width: 100%;
  height: 100%;
}
.new-agent-starter-card .agent-avatar-media img {
  width: 100%;
  height: 100%;
  margin: 0;
  border-radius: inherit;
}
.new-agent-starter-card .new-agent-avatar-edit {
  z-index: 3;
}
@container (max-width: 380px) {
  .vm-agent-spotlight {
    grid-template-columns: 108px minmax(0, 1fr);
    gap: 12px;
  }
  .vm-agent-name {
    font-size: 22px;
  }
  .vm-agent-description {
    font-size: 11px;
  }
  .vm-agent-profile-actions button {
    padding: 6px 8px;
    font-size: 11px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .agent-avatar-video {
    display: none;
    transition: none;
  }
  .vm-agent-choice .agent-avatar-media {
    transition: none;
  }
}

/* Compact sandbox roster: agents and menu above a single resource row. */
.vm-card .vm-sandbox-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 1fr); gap: 12px; }
.vm-card .vm-side-col { grid-column: 1 / -1; }
.vm-card .vm-quick-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; align-self: start; }
.vm-card .vm-quick-actions .vm-quick-btn { width: 100%; height: 48px; min-width: 0; }
.vm-card .vm-quick-actions .vm-quick-label { font-size: 9px; left: 3px; right: 3px; }
.vm-card .vm-agent-spotlight { grid-template-columns: clamp(80px, 23cqw, 132px) minmax(0, 1fr); gap: 10px; }
.vm-card .vm-orb-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, 1fr)); gap: 6px; }
.vm-card .vm-orb-col { min-width: 0; }
.vm-card .vm-orb-col + .vm-orb-col { padding-left: 4px; }
.vm-card .vm-orb-cells { --orb: clamp(20px, 5.5cqw, 34px); display: flex; flex-wrap: nowrap; gap: 3px; min-height: var(--orb); align-items: center; }
.vm-card .vm-orb-col:not(:first-child) .vm-orb-cells { gap: 0; }
.vm-card .vm-orb-col:not(:first-child) .vm-orb-cells > :not(:first-child) { margin-left: calc(var(--orb) * -0.25); }
.vm-card .vm-orb-cells > :hover, .vm-card .vm-orb-cells > :focus-visible { z-index: 5; }
.vm-resource-settings { padding: 0; color: var(--text-primary); cursor: pointer; font: inherit; }
.vm-card .vm-orb-more { font-size: 10px; }
.vm-card .vm-orb-icon { font-size: calc(var(--orb) * 0.55); }
/* Reserve enough width for two readable menu buttons on compact cards. */
@container (max-width: 440px) {
  .vm-card .vm-sandbox-grid { grid-template-columns: minmax(0, 1fr) 118px; gap: 10px; }
  .vm-card .vm-quick-actions .vm-quick-label { font-size: 10px; left: 3px; right: 3px; }
}
@container (max-width: 380px) {
  .vm-card .vm-agent-profile-actions { gap: 4px; }
  .vm-card .vm-agent-profile-actions button { padding: 5px; gap: 3px; font-size: 10px; }
  .vm-card .vm-agent-name { font-size: 20px; }
  .vm-card .vm-orb-col-label { font-size: 8px; letter-spacing: 0.03em; gap: 3px; }
}

@container (max-width: 340px) {
  .vm-card .vm-orb-cells { gap: 1px; }
  .vm-card .vm-orb-col + .vm-orb-col { padding-left: 3px; }
  .vm-card .vm-orb-col:not(:first-child) .vm-orb-cells > :not(:first-child) { margin-left: calc(var(--orb) * -0.32); }
}

.vm-card .vm-channel-img { width: calc(var(--orb) * 0.6); height: calc(var(--orb) * 0.6); }

.voice-call-orb { position: relative; }
.voice-call-working-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 180ms ease; pointer-events: none; }
.voice-call-orb.is-working .voice-call-working-video { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .voice-call-orb.is-speaking { animation: none; }
  .voice-call-working-video { display: none; transition: none; }
}

.vm-agent-portrait { position: relative; aspect-ratio: 1; min-width: 0; }
.vm-agent-portrait > .agent-avatar-media { width: 100%; height: 100%; }
.vm-agent-edit-btn { position: absolute; right: 5px; bottom: 5px; z-index: 4; width: 26px; height: 26px; padding: 0; display: grid; place-items: center; border-radius: 8px; border: 1px solid rgba(255,255,255,0.35); color: white; background: rgba(0,0,0,0.7); cursor: pointer; }
.vm-agent-edit-btn:hover { background: var(--accent); color: #061413; }
.vm-agent-edit-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.vm-agent-edit-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.agent-delete-confirm { padding: 16px; border: 1px solid #e5484d; border-radius: 12px; margin: 16px 0; background: color-mix(in srgb, #e5484d 8%, var(--bg-secondary)); }
#newAgentModal [hidden] { display: none !important; }
#newAgentPreviewInner[hidden] { display: none; }

.vm-agent-empty { min-height: 190px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 10px; padding: 12px; border: 1px dashed var(--panel-border, var(--border-color)); border-radius: 16px; }
.vm-agent-empty-icon { color: var(--accent); opacity: 0.7; }
.vm-agent-empty strong { color: var(--text-primary); font-size: 17px; }
.vm-agent-empty p { color: var(--text-secondary); font-size: 12px; margin: 0; }
.vm-agent-empty .vm-add-agent { display: inline-flex; align-items: center; gap: 6px; width: auto; height: auto; border-radius: 8px; }

.tab-loader-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid #00d87f29;
  border-top-color: #00d87f;
  border-radius: 50%;
  animation: tabLoaderSpin .9s linear infinite;
}
.tab-loader-status {
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 320px;
  margin: 0;
}
@keyframes tabLoaderSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .tab-loader-spinner, html.electron-app .tab-loader-logo::after { animation: none; }
}

/* Settings share the page surface; only individual choices are cards. */
body > .container:has(.config-content) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 16px;
  align-content: start;
}
#mainLayout.container { width: 100% !important; max-width: none !important; margin-inline: 0 !important; }
#mainLayout .config-section > h2:first-child { margin: 0 !important; padding: 0 0 10px !important; background: transparent !important; font-size: 28px !important; line-height: 1.25; letter-spacing: -0.02em; }
#mainLayout .config-section > h2:first-child .flat-icon { width: 24px; height: 24px; flex-shrink: 0; }
#mainLayout .config-section > h2:first-child + p { margin: 0 0 24px !important; padding: 0 0 18px !important; background: transparent !important; font-size: 15px !important; line-height: 1.6 !important; }
#mainLayout .settings-overview-grid { max-width: none; margin-inline: 0; }
#mainLayout .settings-bottom-back { display: none; }
#mainLayout.config-home .settings-main-actions > .settings-all-button { display: none; }
#mainLayout.config-home .settings-dashboard-button { display: inline-flex; }
#mainLayout .settings-main-actions > .btn { min-width: 0; min-height: 44px; padding: 10px 16px !important; font-size: 14px !important; box-shadow: none; }
.settings-main-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 60;
  padding: 12px 0;
  background: var(--bg-primary);
}
.settings-main-actions #saveBtn { width: auto !important; }
.settings-all-button { min-height: 44px; font-weight: 700; }
.container .config-sidebar {
  display: none;
  grid-column: 2;
  grid-row: 2;
  align-items: stretch;
}
.container .config-content { grid-column: 1 / -1; grid-row: 2; min-width: 0; }
.container.config-home { grid-template-columns: minmax(0, 1fr) !important; }
.container.config-home .config-content { grid-column: 1 / -1; }
.container .config-content,
.container .config-sidebar {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none;
  backdrop-filter: none;
  border-radius: 0 !important;
  overflow: visible;
}
.container .config-section { padding: 12px 0 28px !important; }
.settings-section-toolbar > .settings-all-button { display: none; }
.vm-stack-select, .vm-quick-description { display: none; }

@media (max-width: 700px) {
  body { height: 100dvh; min-height: 100dvh !important; }
  body > .container:has(.config-content) { grid-template-columns: minmax(0, 1fr) !important; gap: 8px; }
  .container .config-sidebar { display: none; }
  .container .config-content { grid-column: 1 / -1; }
  .settings-main-actions { flex-wrap: wrap; }
  .settings-main-actions .btn { flex: 1; }
  .settings-overview-grid { gap: 12px; margin-top: 18px; }
  .settings-section-card { padding: 20px; }

  .modal {
    top: var(--pwa-header-height, 56px);
    bottom: var(--app-bottom-inset, 0px);
    align-items: stretch;
    background: var(--bg-primary);
    backdrop-filter: none;
    padding: 0 !important;
  }
  .modal .modal-content {
    width: 100% !important;
    max-width: none !important;
    height: 100% !important;
    max-height: 100% !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: var(--bg-primary) !important;
    box-shadow: none;
    padding: 20px 16px max(20px, env(safe-area-inset-bottom)) !important;
    overflow-y: auto;
    transform: translateY(16px);
  }
  .modal .modal-header { flex-shrink: 0; background: transparent !important; }
  .modal .modal-close { min-width: 44px; min-height: 44px; }
  .modal .modal-body { flex: 1; overscroll-behavior: contain; }
  .modal .modal-footer { flex-shrink: 0; margin-top: auto; padding-top: 16px; }

  #vmList .mobile-stack {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    --stack-step: 44px;
    margin-bottom: 0;
    padding-top: var(--stack-space-before, 0px);
    padding-bottom: calc(var(--stack-count) * var(--stack-step));
  }
  #vmList .mobile-stack .vm-card {
    grid-area: 1 / 1;
    z-index: calc(var(--stack-index) + 1);
    transform: translateY(calc(var(--stack-index) * var(--stack-step))) !important;
    transition: border-color 180ms ease;
    background: linear-gradient(var(--surface-strong), var(--surface-strong)), var(--bg-primary) !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 0 16px 16px !important;
    min-height: 0;
    height: var(--stack-height, 65dvh);
    overflow: hidden !important;
    overscroll-behavior: contain;
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.15);
  }
  #vmList .mobile-stack.is-switching .vm-card { transition: transform 160ms ease-out, border-color 180ms ease; will-change: transform; }
  #vmList .mobile-stack .vm-card:not(.stack-front) > .vm-card-loading-overlay,
  #vmList .mobile-stack .vm-card:not(.stack-front) > .vm-menu { visibility: hidden; }
  #vmList .mobile-stack .vm-card:not(.stack-front) .vm-card-body { opacity: 0.75; }
  #vmList .mobile-stack .vm-card-body { transition: opacity 180ms ease; }
  #vmList .mobile-stack .vm-stack-select {
    display: flex;
    min-width: 0;
    height: 44px;
    flex: 1 1 auto;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: transparent;
    border: 0;
    color: var(--text-primary);
    font: inherit;
    font-weight: 650;
    cursor: pointer;
    text-align: left;
  }
  .vm-stack-select span { color: var(--text-secondary); font-size: 11px; font-weight: 400; }
  #vmList .mobile-stack .stack-front { border-color: var(--accent) !important; }
  #vmList .mobile-stack .vm-card-header {
    flex-wrap: nowrap;
    flex: 0 0 44px;
    min-height: 44px;
    border-bottom: 1px solid color-mix(in srgb, var(--text-secondary) 14%, transparent);
    position: relative;
    z-index: 10002;
  }
  #vmList .mobile-stack .vm-card-pills { display: none; }
  #vmList .mobile-stack .vm-header-actions > :not(.vm-menu-toggle):not(.vm-header-update) { display: none; }
  /* While a card's loading overlay is active, its header controls stay inert;
     the mobile stack floats the header above the overlay so it stayed tappable. */
  #vmList .vm-header-actions[data-loading="true"] .btn {
    pointer-events: none;
    opacity: 0.55;
    cursor: default;
  }
  #vmList .mobile-stack .vm-menu.vm-menu-mobile {
    position: absolute !important;
    inset: 0;
    transform: none;
    width: 100%;
    min-width: 0 !important;
    max-width: none;
    height: 100%;
    max-height: none;
    border-radius: inherit !important;
    padding: 52px 8px 12px;
    background: var(--bg-primary) !important;
    box-shadow: none;
  }
  #vmList .mobile-stack .vm-menu-shell-header { display: none; }
  #vmList .mobile-stack .vm-menu-items { max-height: none; min-height: 0; overflow-y: auto; }

  #vmList .mobile-stack .vm-card-title { display: none; }
  #vmList .mobile-stack .vm-header-actions { margin-left: auto; }
  #vmList .mobile-stack .vm-card-body { margin: 0; padding-top: 8px; overflow-y: auto; overscroll-behavior: contain; }
  #vmList .mobile-stack .vm-sandbox-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; margin-top: 0; padding-top: 0; border-top: 0; }
  #vmList .mobile-stack .vm-agents-col { gap: 6px; }
  #vmList .mobile-stack .vm-side-col { padding-top: 8px; }
  #vmList .mobile-stack .vm-quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-row: 3;
    gap: 8px;
    margin-top: 10px;
  }
  #vmList .mobile-stack .vm-quick-btn {
    max-width: none;
    height: 48px;
    min-height: 48px;
    display: block;
    padding: 0;
    text-align: right;
  }
  #vmList .mobile-stack .vm-quick-label {
    top: 8px;
    bottom: auto;
    font-size: 13px;
  }
  #vmList .mobile-stack .vm-quick-description {
    display: block;
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 7px;
    z-index: 1;
    color: var(--text-secondary);
    font-size: 10.5px;
    font-weight: 400;
    line-height: 1.3;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #vmList .mobile-stack .vm-agent-spotlight { grid-template-columns: clamp(100px, 30cqw, 150px) minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  #vmList .mobile-stack .vm-card, #vmList .mobile-stack.is-switching .vm-card, #vmList .mobile-stack .vm-card-body, .modal .modal-content { transition: none; }
}

@media (max-width: 700px) {
  #vmList .mobile-stack .vm-card.menu-open { overflow: hidden !important; }
  #vmList .mobile-stack .vm-agent-description { font-size: 14px; line-height: 1.55; height: auto; min-height: 3.1em; }
}

/* Sandbox activity occupies a reserved inline slot rather than another row. */
.vm-card-heading { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.vm-card-heading .vm-card-title { flex: 0 1 auto; max-width: 50%; }
.sandbox-operation-status { display: flex; align-items: center; gap: 5px; flex: 1; min-width: 0; opacity: 0; transition: opacity 180ms ease; font-size: 11px; font-weight: 400; font-style: italic; color: var(--text-secondary); }
.sandbox-operation-status.is-visible { opacity: 1; }
.sandbox-operation-message { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sandbox-operation-refresh { flex: 0 0 14px; width: 14px; height: 14px; display: grid; place-items: center; font-style: normal; line-height: 1; transform-origin: center; animation: sandboxActivitySpin 1.2s linear infinite; animation-play-state: paused; }
.sandbox-operation-refresh svg { display: block; width: 14px; height: 14px; transform-origin: center; }
.sandbox-operation-status.is-visible .sandbox-operation-refresh { animation-play-state: running; }
@keyframes sandboxActivitySpin { to { transform: rotate(360deg); } }
@media (max-width: 700px) {
  #vmList .mobile-stack .vm-stack-select { display: block; flex: 0 1 auto; max-width: 45%; }
  #vmList .mobile-stack .vm-card-body { min-height: 0; }
  #vmList .mobile-stack .vm-sandbox-grid { flex: 1; min-height: 0; grid-template-rows: max-content max-content minmax(0, 1fr); }
  #vmList .mobile-stack .vm-agents-col { grid-row: 1; }
  #vmList .mobile-stack .vm-side-col { grid-row: 2; }
  #vmList .mobile-stack .vm-quick-actions { min-height: 0; align-self: stretch; align-content: stretch; grid-template-columns: repeat(var(--action-columns, 2), minmax(0, 1fr)); grid-auto-rows: minmax(44px, 1fr); }
  #vmList .mobile-stack .vm-quick-btn { height: 100%; min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .sandbox-operation-status { transition: none; }
  .sandbox-operation-refresh { animation: none; }
}

@media (max-width: 700px) {
  #vmList .mobile-stack .vm-quick-btn { container-type: size; }
  #vmList .mobile-stack .vm-quick-label { font-size: clamp(13px, 14cqh, 22px); top: clamp(8px, 12cqh, 18px); }
  #vmList .mobile-stack .vm-quick-description { font-size: clamp(10.5px, 10cqh, 14px); bottom: clamp(7px, 12cqh, 18px); }
  #vmList .mobile-stack .vm-quick-cover { --quick-art-size: clamp(52px, 78cqh, 110px); top: calc(var(--quick-art-size) * -0.25); left: calc(var(--quick-art-size) * -0.35); }
  #vmList .mobile-stack .vm-quick-cover svg,
  #vmList .mobile-stack .vm-quick-cover .flat-icon { width: var(--quick-art-size); height: var(--quick-art-size); }
  #vmList .mobile-stack .vm-quick-cover:not(:has(svg)) { font-size: var(--quick-art-size); }
}

@media (max-width: 700px) {
  #systemCheckCard {
    transition: none !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  #systemCheckCard:hover { box-shadow: var(--panel-shadow); }
}

.settings-dashboard-button { display: none; }
.settings-main-actions [hidden], .settings-section-toolbar[hidden] { display: none !important; }
@media (max-width: 700px) {
  #mainLayout { padding-top: 0 !important; min-width: 0; max-width: 100%; }
  /* The flat mobile sections have no side padding for old card-bleed margins. */
  #mainLayout .config-section > h2:first-child { margin: 0 !important; padding: 0 0 8px !important; background: transparent !important; font-size: 23px !important; }
  #mainLayout .config-section > h2:first-child + p { margin: 0 0 22px !important; padding: 0 0 16px !important; background: transparent !important; }
  #mainLayout .config-section { min-width: 0; }
  #mainLayout input, #mainLayout select, #mainLayout textarea { min-width: 0; max-width: 100%; }
  #mainLayout .model-tabs-bar { scrollbar-width: none; }
  #mainLayout .model-tabs-bar::-webkit-scrollbar { display: none; }
  #mainLayout .settings-main-actions { padding: 4px 0; gap: 8px; align-items: center; }
  #mainLayout.config-home .settings-main-actions > .settings-all-button { display: none; }
  #mainLayout.config-home .settings-dashboard-button { display: flex; align-items: center; justify-content: center; min-height: 44px; }
  #mainLayout .settings-bottom-back { display: none; }
}

/* Keep settings grids inside the available width, including the vertical scrollbar. */
#mainLayout.container {
  min-width: 0;
  overflow-x: hidden;
}
#mainLayout .providers-grid,
#mainLayout .models-list {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)) !important;
}
#mainLayout .provider-card,
#mainLayout .model-list-item,
#mainLayout .model-item-main {
  min-width: 0;
}
#mainLayout .provider-name,
#mainLayout .model-item-name {
  overflow-wrap: anywhere;
}

/* Resource tooltip portal escapes card overflow and is positioned within the viewport. */
.resource-tooltips-ready #vmList .vm-orb-tip { display: none; }
.vm-orb-tip.vm-resource-tip {
  position: fixed;
  inset: auto;
  margin: 0;
  min-width: 0;
  box-sizing: border-box;
  transform: none;
  opacity: 1;
  pointer-events: auto;
  overflow: auto;
  overflow-wrap: anywhere;
  z-index: 1300;
  transition: none;
}
.vm-resource-tip[hidden] { display: none !important; }
.vm-resource-tip strong { color: var(--text-primary, #f0f0f0); }
.vm-resource-tip > span { color: var(--text-secondary, #c6c6cc); }
