/* ST-BME 样式 */

/* --- Overlay --- */
#st-bme-panel-overlay {
  position: fixed;
  inset: 0;
  width: var(--bme-viewport-width, 100vw);
  height: var(--bme-viewport-height, 100vh);
  z-index: 9999;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

#st-bme-panel-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* --- Panel Container --- */
#st-bme-panel {
  width: 82vw;
  height: 72vh;
  min-width: 320px;
  min-height: 320px;
  max-width: 96vw;
  max-height: 92vh;
  background: var(--bme-surface, #131316);
  border: 1px solid var(--bme-border, rgba(255, 255, 255, 0.08));
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: auto;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  transform: translateY(12px) scale(0.98);
  transition: transform 0.25s ease;
  resize: both;
  /* 默认暗色表单范式；亮色主题见 :root[data-bme-color-scheme="light"] */
  color-scheme: dark;
}

:root[data-bme-color-scheme="light"] #st-bme-panel {
  color-scheme: light;
}

#st-bme-panel-overlay.active #st-bme-panel {
  transform: translateY(0) scale(1);
}

/* --- Header --- */
.bme-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bme-surface-container, #1f1f22);
  border-bottom: 1px solid var(--bme-border, rgba(255, 255, 255, 0.08));
  flex-shrink: 0;
}

.bme-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--bme-primary, #e94560);
  flex: 1;
  min-width: 0;
}

.bme-panel-title i {
  font-size: 16px;
}

.bme-panel-subtitle {
  font-size: 11px;
  color: var(--bme-on-surface-dim, rgba(228, 225, 230, 0.6));
  margin-left: 8px;
  font-weight: 400;
}

.bme-theme-picker {
  position: relative;
  margin-right: 4px;
}

.bme-fab-toggle-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--bme-on-surface-dim);
  cursor: pointer;
  border-radius: 4px;
  font-size: 14px;
  transition: all 0.15s;
  margin-right: 2px;
}

.bme-fab-toggle-btn:hover {
  background: var(--bme-surface-highest);
  color: var(--bme-primary);
}

.bme-fab-toggle-btn[data-active="true"] {
  color: var(--bme-primary);
}

.bme-fab-toggle-btn[data-active="false"] {
  opacity: 0.45;
}

.bme-theme-picker-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--bme-on-surface-dim);
  cursor: pointer;
  border-radius: 4px;
  font-size: 14px;
  transition: all 0.15s;
}

.bme-theme-picker-btn:hover {
  background: var(--bme-surface-highest);
  color: var(--bme-primary);
}

.bme-theme-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  background: var(--bme-surface-container, #1f1f22);
  border: 1px solid var(--bme-border);
  border-radius: 8px;
  padding: 4px;
  min-width: 130px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 100;
  animation: bme-dropdown-in 0.12s ease-out;
}

.bme-theme-dropdown.open {
  display: block;
}

@keyframes bme-dropdown-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bme-theme-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  background: transparent;
  color: var(--bme-on-surface);
  font-size: 12.5px;
  cursor: pointer;
  border-radius: 5px;
  transition: background 0.12s;
  white-space: nowrap;
}

.bme-theme-option:hover {
  background: var(--bme-surface-high);
}

.bme-theme-option.active {
  background: var(--bme-primary-dim);
  color: var(--bme-primary-text);
}

.bme-theme-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.bme-panel-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--bme-on-surface-dim);
  cursor: pointer;
  border-radius: 4px;
  font-size: 14px;
  transition: all 0.15s;
}

.bme-panel-close:hover {
  background: var(--bme-surface-highest);
  color: var(--bme-on-surface);
}

/* --- Body (Desktop twin-panel) --- */
.bme-panel-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.bme-resize-handle {
  width: 5px;
  cursor: col-resize;
  background: transparent;
  transition: background 0.15s;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.bme-resize-handle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 3px;
  height: 32px;
  border-radius: 2px;
  background: var(--bme-on-surface-dim, rgba(228, 225, 230, 0.3));
  opacity: 0;
  transition: opacity 0.15s;
}

.bme-resize-handle:hover,
.bme-resize-handle.dragging {
  background: var(--bme-primary-dim, rgba(233, 69, 96, 0.15));
}

.bme-resize-handle:hover::after,
.bme-resize-handle.dragging::after {
  opacity: 1;
}

/* --- Sidebar (Desktop) --- */
.bme-panel-sidebar {
  width: 280px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  background: var(--bme-surface-container, #1f1f22);
  border-right: 1px solid var(--bme-border);
  overflow: hidden;
}

/* --- Tab List (Sidebar vertical) --- */
.bme-tab-list {
  display: flex;
  gap: 2px;
  padding: 8px 8px 0;
  flex-shrink: 0;
}

.bme-tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  border: none;
  background: transparent;
  color: var(--bme-on-surface-dim);
  font-size: 11px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  border-radius: 4px 4px 0 0;
  transition: all 0.15s;
  white-space: nowrap;
}

.bme-tab-btn:hover {
  color: var(--bme-on-surface);
  background: var(--bme-surface-high);
}

.bme-tab-btn.active {
  color: var(--bme-primary);
  border-bottom-color: var(--bme-primary);
  background: var(--bme-surface-high);
}

.bme-tab-btn i {
  font-size: 12px;
}

/* --- Tab Content --- */
.bme-tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.bme-config-sidebar {
  display: none;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  padding: 18px 12px 16px;
  overflow-y: auto;
}

.bme-config-sidebar-header {
  padding: 0 2px;
}

.bme-config-sidebar-kicker,
.bme-config-workspace-kicker,
.bme-config-section-kicker {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--bme-primary);
  margin-bottom: 6px;
}

:root[data-bme-color-scheme="light"] .bme-config-sidebar-kicker,
:root[data-bme-color-scheme="light"] .bme-config-workspace-kicker,
:root[data-bme-color-scheme="light"] .bme-config-section-kicker {
  color: var(--bme-primary-text);
}

.bme-config-sidebar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--bme-on-surface);
  margin-bottom: 6px;
}

.bme-config-sidebar-help,
.bme-config-workspace-desc,
.bme-config-section-desc,
.bme-config-card-subtitle {
  font-size: 12px;
  line-height: 1.5;
  color: var(--bme-on-surface-dim);
}

.bme-config-nav {
  display: flex;
  gap: 8px;
}

.bme-config-nav-desktop {
  flex-direction: column;
}

.bme-config-nav-mobile {
  display: none;
}

.bme-config-nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--bme-border);
  background: var(--bme-surface-low);
  color: var(--bme-on-surface-dim);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s,
    color 0.15s,
    transform 0.15s;
  font-size: 12px;
  text-align: left;
}

.bme-config-nav-btn:hover {
  border-color: var(--bme-primary);
  color: var(--bme-on-surface);
  background: var(--bme-surface-high);
}

.bme-config-nav-btn.active {
  border-color: var(--bme-primary);
  color: var(--bme-primary);
  background: var(--bme-primary-dim);
}

.bme-config-nav-btn i {
  font-size: 13px;
}

.bme-tab-pane {
  display: none;
}

.bme-tab-pane.active {
  display: block;
}

/* --- Stats Grid --- */
.bme-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}

.bme-stat-card {
  background: var(--bme-surface-low, #1b1b1e);
  border: 1px solid var(--bme-border);
  border-radius: 6px;
  padding: 10px;
}

.bme-stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--bme-on-surface-dim);
  margin-bottom: 4px;
}

.bme-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--bme-primary);
  font-feature-settings: "tnum";
}

.bme-stat-value.warning {
  color: var(--bme-accent3, #ffc107);
}

/* --- Section Headers --- */
.bme-section-header {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--bme-on-surface-dim);
  margin: 12px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--bme-border);
}

/* --- Recent List --- */
.bme-recent-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.bme-recent-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.1s;
}

.bme-recent-item:hover {
  background: var(--bme-surface-high);
}

.bme-type-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
  margin-top: 2px;
}

.bme-type-badge.character {
  background: var(--bme-node-character);
  color: #000;
}
.bme-type-badge.event {
  background: var(--bme-node-event);
  color: #000;
}
.bme-type-badge.location {
  background: var(--bme-node-location);
  color: #000;
}
.bme-type-badge.thread {
  background: var(--bme-node-thread);
  color: #000;
}
.bme-type-badge.rule {
  background: var(--bme-node-rule);
  color: #fff;
}
.bme-type-badge.synopsis {
  background: var(--bme-node-synopsis);
  color: #000;
}

.bme-recent-text {
  font-size: 12px;
  color: var(--bme-on-surface);
  line-height: 1.3;
}

.bme-recent-meta {
  font-size: 10px;
  color: var(--bme-on-surface-dim);
  margin-top: 2px;
}

/* --- Main (Graph) Area --- */
.bme-panel-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bme-surface-lowest, #0e0e11);
  overflow: hidden;
}

.bme-graph-workspace {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

.bme-graph-overlay {
  position: absolute;
  inset: 58px 18px 52px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(6, 7, 10, 0.72);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  z-index: 3;
  pointer-events: none;
}

.bme-graph-overlay.active {
  display: flex;
}

.bme-graph-overlay__text {
  max-width: 320px;
  text-align: center;
  font-size: 12px;
  line-height: 1.6;
  color: var(--bme-on-surface);
}

.bme-mobile-graph-preview .bme-graph-overlay {
  inset: 0;
  border-radius: 0;
}

.bme-config-workspace {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  background:
    radial-gradient(
      circle at top right,
      var(--bme-primary-dim, rgba(233, 69, 96, 0.15)),
      transparent 32%
    ),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 20%),
    var(--bme-surface-lowest, #0e0e11);
}

#st-bme-panel.config-mode .bme-tab-content {
  display: none;
}

#st-bme-panel.config-mode .bme-config-sidebar {
  display: flex;
}

#st-bme-panel.config-mode .bme-graph-workspace {
  display: none;
}

#st-bme-panel.config-mode .bme-config-workspace {
  display: flex;
}

/* ==================== Task-Mode (对称 config-mode) ==================== */

#st-bme-panel.task-mode .bme-tab-content {
  display: none;
}

#st-bme-panel.task-mode .bme-task-sidebar {
  display: flex;
}

#st-bme-panel.task-mode .bme-graph-workspace {
  display: none;
}

#st-bme-panel.task-mode .bme-task-workspace {
  display: flex;
}

.bme-task-sidebar {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 12px 8px;
  overflow-y: auto;
}

.bme-task-sidebar-header {
  padding: 8px 10px 12px;
  margin-bottom: 4px;
}

.bme-task-sidebar-kicker {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--bme-primary);
  margin-bottom: 4px;
}

.bme-task-sidebar-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--bme-on-surface);
}

.bme-task-sidebar-help {
  font-size: 11px;
  color: var(--bme-on-surface-dim);
  margin-top: 4px;
  line-height: 1.4;
}

.bme-task-nav {
  display: flex;
  gap: 8px;
}

.bme-task-nav-desktop {
  flex-direction: column;
}

.bme-task-nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--bme-border);
  background: var(--bme-surface-low);
  color: var(--bme-on-surface-dim);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s,
    color 0.15s,
    transform 0.15s;
  white-space: nowrap;
}

.bme-task-nav-btn:hover {
  border-color: var(--bme-primary);
  color: var(--bme-on-surface);
  background: var(--bme-surface-high);
}

.bme-task-nav-btn.active {
  border-color: var(--bme-primary);
  color: var(--bme-primary);
  background: var(--bme-primary-dim);
}

.bme-task-nav-btn i {
  width: 16px;
  text-align: center;
  font-size: 13px;
}

.bme-task-nav-btn .bme-task-nav-badge {
  margin-left: auto;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--bme-primary-dim);
  color: var(--bme-primary);
  font-weight: 600;
}

.bme-task-workspace {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  background:
    radial-gradient(
      circle at top right,
      var(--bme-primary-dim, rgba(233, 69, 96, 0.15)),
      transparent 32%
    ),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 20%),
    var(--bme-surface-lowest, #0e0e11);
}

.bme-task-workspace-header {
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--bme-border);
  flex-shrink: 0;
}

.bme-task-workspace-kicker {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--bme-primary);
  margin-bottom: 4px;
}

.bme-task-workspace-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--bme-on-surface);
  margin-bottom: 4px;
}

.bme-task-workspace-desc {
  font-size: 12px;
  color: var(--bme-on-surface-dim);
  line-height: 1.5;
}

.bme-task-workspace-body {
  padding: 16px 24px 32px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.bme-task-section {
  display: none;
}

.bme-task-section.active {
  display: block;
}

#bme-task-memory.bme-task-section.active {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* --- Task nav mobile pill selector (visible only on mobile) --- */
.bme-task-nav-mobile {
  display: none;
  gap: 6px;
  padding: 8px 16px;
  overflow-x: auto;
  flex-shrink: 0;
  border-bottom: 1px solid var(--bme-border);
  -webkit-overflow-scrolling: touch;
}

.bme-task-nav-mobile .bme-task-nav-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--bme-border);
  background: transparent;
  color: var(--bme-on-surface-dim);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.bme-task-nav-mobile .bme-task-nav-pill:hover {
  border-color: var(--bme-primary);
  color: var(--bme-on-surface);
}

.bme-task-nav-mobile .bme-task-nav-pill.active {
  background: var(--bme-primary);
  border-color: var(--bme-primary);
  color: #fff;
  font-weight: 600;
}

/* ==================== Pipeline Overview ==================== */

.bme-pipeline-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.bme-pipeline-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bme-surface, #131316);
  border: 1px solid var(--bme-border);
  border-radius: 8px;
  border-left: 3px solid var(--bme-border);
  transition: border-color 0.2s;
}

.bme-pipeline-card[data-status="idle"],
.bme-pipeline-card[data-status="ready"] {
  border-left-color: #2ecc71;
}
.bme-pipeline-card[data-status="running"],
.bme-pipeline-card[data-status="building"] {
  border-left-color: #00d4ff;
}
.bme-pipeline-card[data-status="queued"],
.bme-pipeline-card[data-status="warning"] {
  border-left-color: #f39c12;
}
.bme-pipeline-card[data-status="error"],
.bme-pipeline-card[data-status="blocked"] {
  border-left-color: #e74c3c;
}

.bme-pipeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 3px;
  flex-shrink: 0;
}

.bme-pipeline-dot.green { background: #2ecc71; box-shadow: 0 0 6px rgba(46,204,113,.4); }
.bme-pipeline-dot.cyan { background: #00d4ff; box-shadow: 0 0 6px rgba(0,212,255,.4); animation: bme-pulse-dot 1.5s ease-in-out infinite; }
.bme-pipeline-dot.amber { background: #f39c12; box-shadow: 0 0 6px rgba(243,156,18,.4); }
.bme-pipeline-dot.red { background: #e74c3c; box-shadow: 0 0 6px rgba(231,76,60,.4); }

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

.bme-pipeline-info {
  flex: 1;
  min-width: 0;
}

.bme-pipeline-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--bme-on-surface);
  margin-bottom: 2px;
}

.bme-pipeline-status {
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 2px;
}

.bme-pipeline-status.green { color: #2ecc71; }
.bme-pipeline-status.cyan { color: #00d4ff; }
.bme-pipeline-status.amber { color: #f39c12; }
.bme-pipeline-status.red { color: #e74c3c; }

.bme-pipeline-detail {
  font-size: 10px;
  color: var(--bme-on-surface-dim);
}

/* --- Batch Progress --- */

.bme-batch-progress {
  background: var(--bme-surface, #131316);
  border: 1px solid var(--bme-border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.bme-batch-stages {
  display: flex;
  align-items: flex-start;
  gap: 0;
  margin-bottom: 12px;
}

.bme-batch-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
}

.bme-batch-stage-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  z-index: 1;
  border: 2px solid var(--bme-border);
  background: var(--bme-surface-lowest, #0e0e11);
  color: var(--bme-on-surface-dim);
}

.bme-batch-stage-dot.done {
  background: #2ecc71;
  border-color: #2ecc71;
  color: #fff;
}

.bme-batch-stage-dot.running {
  background: #00d4ff;
  border-color: #00d4ff;
  color: #fff;
  animation: bme-pulse-dot 1.5s ease-in-out infinite;
}

.bme-batch-stage-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--bme-on-surface-dim);
  text-align: center;
}

.bme-batch-stage-detail {
  font-size: 10px;
  color: var(--bme-on-surface-dim);
  text-align: center;
  max-width: 100px;
  opacity: 0.7;
}

.bme-batch-stage-line {
  position: absolute;
  top: 14px;
  left: calc(50% + 18px);
  width: calc(100% - 36px);
  height: 2px;
  background: var(--bme-border);
  z-index: 0;
}

.bme-batch-stage-line.done { background: #2ecc71; }
.bme-batch-stage-line.running { background: linear-gradient(90deg, #2ecc71, #00d4ff); }

.bme-batch-stage:last-child .bme-batch-stage-line { display: none; }

.bme-batch-meta {
  display: flex;
  gap: 16px;
  font-size: 11px;
  color: var(--bme-on-surface-dim);
  padding-top: 10px;
  border-top: 1px solid var(--bme-border);
}

.bme-batch-meta i {
  font-size: 10px;
  color: var(--bme-primary);
  opacity: 0.6;
  margin-right: 4px;
}

/* --- Status Summary --- */

.bme-status-summary {
  background: var(--bme-surface, #131316);
  border: 1px solid var(--bme-border);
  border-radius: 8px;
  padding: 12px 16px;
}

.bme-status-summary-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--bme-on-surface);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.bme-status-summary-title i {
  color: var(--bme-primary);
  font-size: 11px;
}

.bme-status-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.bme-status-row:last-child { border-bottom: none; }

.bme-status-row-label {
  font-size: 11px;
  font-weight: 600;
  width: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--bme-on-surface);
}

.bme-status-row-label .bme-sdot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.bme-status-row-value {
  font-size: 11px;
  color: var(--bme-on-surface-dim);
  flex: 1;
  min-width: 0;
}

/* ==================== Task Timeline ==================== */

.bme-timeline-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bme-surface, #131316);
  border: 1px solid var(--bme-border);
  border-radius: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 5;
}

.bme-timeline-filter {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--bme-border);
  background: transparent;
  color: var(--bme-on-surface-dim);
  font-size: 11px;
  cursor: pointer;
}

.bme-timeline-filter:hover {
  border-color: var(--bme-primary);
  color: var(--bme-on-surface);
}

.bme-timeline-search {
  flex: 1;
  min-width: 100px;
  border: none;
  background: transparent;
  color: var(--bme-on-surface);
  font-size: 12px;
  outline: none;
}

.bme-timeline-search::placeholder {
  color: var(--bme-on-surface-dim);
  opacity: 0.5;
}

.bme-timeline-divider {
  width: 1px;
  height: 16px;
  background: var(--bme-border);
}

.bme-timeline-action {
  padding: 4px 8px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--bme-on-surface-dim);
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.bme-timeline-action:hover { color: var(--bme-on-surface); }
.bme-timeline-action.active { color: var(--bme-primary); }

.bme-timeline-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.bme-timeline-entry {
  position: relative;
  padding: 12px 14px;
  background: var(--bme-surface, #131316);
  border: 1px solid var(--bme-border);
  border-radius: 8px;
  margin-bottom: 2px;
  transition: border-color 0.15s;
}

.bme-timeline-entry:hover {
  border-color: rgba(255, 255, 255, 0.1);
}

.bme-timeline-entry__head {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.bme-timeline-entry__title {
  font-size: 12px;
  font-weight: 600;
  color: var(--bme-on-surface);
  flex: 1;
  min-width: 0;
}

.bme-timeline-entry__meta {
  font-size: 10px;
  color: var(--bme-on-surface-dim);
}

.bme-timeline-entry__toggle {
  background: transparent;
  border: none;
  color: var(--bme-on-surface-dim);
  cursor: pointer;
  padding: 2px;
  font-size: 11px;
  transition: transform 0.2s;
}

.bme-timeline-entry.is-collapsed .bme-timeline-entry__toggle {
  transform: rotate(-90deg);
}

.bme-timeline-entry__detail {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--bme-border);
}

.bme-timeline-entry__line,
.bme-timeline-entry__empty {
  font-size: 11px;
  color: var(--bme-on-surface-dim);
  line-height: 1.55;
}

.bme-timeline-entry__line + .bme-timeline-entry__line {
  margin-top: 6px;
}

.bme-timeline-entry__preview {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--bme-border);
  background: rgba(255, 255, 255, 0.035);
  color: var(--bme-on-surface-dim);
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow: auto;
}

.bme-timeline-entry.is-collapsed .bme-timeline-entry__detail {
  display: none;
}

.bme-timeline-substage {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 0;
  font-size: 11px;
  color: var(--bme-on-surface-dim);
}

.bme-timeline-substage i {
  font-size: 10px;
  width: 14px;
  text-align: center;
}

.bme-timeline-connector {
  width: 2px;
  height: 6px;
  background: var(--bme-border);
  margin: 0 auto;
}

.bme-timeline-bottom-bar {
  padding: 8px 14px;
  font-size: 11px;
  color: var(--bme-on-surface-dim);
  text-align: center;
}

/* ==================== Memory Browser Master-Detail ==================== */

.bme-memory-master-detail {
  display: flex;
  height: 100%;
  min-height: 400px;
  gap: 0;
  overflow: hidden;
}

.bme-memory-list-panel {
  width: 40%;
  min-width: 200px;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--bme-border);
  overflow: hidden;
}

.bme-memory-list-filters {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-bottom: 1px solid var(--bme-border);
  flex-shrink: 0;
}

.bme-memory-list-filters .bme-filter-select {
  flex: 0 0 auto;
}

.bme-memory-list-filters .bme-task-memory-search-btn {
  width: 100%;
}

.bme-memory-list-filters .bme-floor-input {
  max-width: 120px;
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.bme-memory-list-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.bme-memory-node-item {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: all 0.12s;
}

.bme-memory-node-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.bme-memory-node-item.selected {
  border-left-color: var(--bme-primary);
  background: var(--bme-primary-dim);
}

.bme-memory-node-item__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.bme-memory-node-item__type {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.bme-memory-node-item__type.type-character { background: rgba(155,89,182,.2); color: #c084fc; }
.bme-memory-node-item__type.type-event { background: rgba(0,212,255,.15); color: #00d4ff; }
.bme-memory-node-item__type.type-location { background: rgba(46,204,113,.15); color: #2ecc71; }
.bme-memory-node-item__type.type-rule { background: rgba(243,156,18,.15); color: #f39c12; }
.bme-memory-node-item__type.type-thread { background: rgba(59,130,246,.15); color: #3b82f6; }
.bme-memory-node-item__type.type-default { background: rgba(255,255,255,.08); color: var(--bme-on-surface-dim); }

.bme-memory-node-item__imp {
  font-size: 10px;
  font-family: monospace;
  color: var(--bme-primary);
}

.bme-memory-node-item__title {
  font-size: 12px;
  font-weight: 600;
  color: var(--bme-on-surface);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bme-memory-node-item__preview {
  font-size: 11px;
  color: var(--bme-on-surface-dim);
  line-height: 1.4;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}

.bme-memory-node-item__meta {
  display: flex;
  gap: 8px;
  font-size: 10px;
  color: var(--bme-on-surface-dim);
  opacity: 0.6;
}

.bme-memory-detail-panel {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  min-width: 0;
  min-height: 0;
}

.bme-memory-detail-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--bme-on-surface-dim);
  font-size: 12px;
}

.bme-memory-detail__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.bme-memory-detail__header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.bme-memory-detail__title {
  font-size: 18px;
  font-weight: 700;
  color: var(--bme-on-surface);
  min-width: 0;
  word-break: break-word;
}

.bme-memory-detail__badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.bme-memory-detail__desc {
  font-size: 12px;
  line-height: 1.6;
  color: var(--bme-on-surface);
  margin-bottom: 16px;
  white-space: pre-wrap;
}

.bme-memory-detail__fields {
  margin-bottom: 16px;
}

.bme-memory-detail__field-row {
  display: flex;
  gap: 8px;
  padding: 4px 0;
  font-size: 11px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.bme-memory-detail__field-key {
  color: var(--bme-on-surface-dim);
  min-width: 80px;
  font-weight: 600;
}

.bme-memory-detail__field-val {
  color: var(--bme-on-surface);
}

.bme-memory-detail__stats {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--bme-on-surface-dim);
  margin-bottom: 16px;
  padding: 10px 0;
  border-top: 1px solid var(--bme-border);
  border-bottom: 1px solid var(--bme-border);
}

.bme-memory-detail__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ==================== Memory Popup (Mobile) ==================== */

.bme-memory-popup-scrim {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  cursor: pointer;
}

.bme-memory-popup-scrim[hidden] {
  display: none !important;
}

.bme-memory-popup {
  display: none;
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  width: min(460px, calc(100vw - 24px));
  max-height: min(82vh, 680px);
  background: var(--bme-surface, #131316);
  border: 1px solid var(--bme-border);
  border-radius: 14px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.65);
  z-index: 1000;
  overflow-y: auto;
  padding: 18px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.18s ease, opacity 0.18s ease, visibility 0.18s ease;
}

.bme-memory-popup.open {
  display: block;
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.bme-memory-popup__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.bme-memory-popup__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--bme-on-surface);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bme-memory-popup__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.bme-memory-popup__badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.bme-memory-popup__body {
  font-size: 12px;
  color: var(--bme-on-surface);
}

.bme-memory-popup::-webkit-scrollbar {
  width: 4px;
}

.bme-memory-popup::-webkit-scrollbar-track {
  background: transparent;
}

.bme-memory-popup::-webkit-scrollbar-thumb {
  background: var(--bme-surface-highest);
  border-radius: 2px;
}

/* ==================== Injection Preview ==================== */

.bme-injection-token-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bme-surface, #131316);
  border: 1px solid var(--bme-border);
  border-radius: 8px;
  margin-bottom: 12px;
}

.bme-injection-token-bar__label {
  font-size: 13px;
  font-weight: 700;
  color: var(--bme-on-surface);
  white-space: nowrap;
}

.bme-injection-token-bar__track {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--bme-border);
  overflow: hidden;
}

.bme-injection-token-bar__fill {
  height: 100%;
  border-radius: 3px;
  background: var(--bme-primary);
  transition: width 0.3s;
}

.bme-injection-token-bar__breakdown {
  font-size: 10px;
  color: var(--bme-on-surface-dim);
  white-space: nowrap;
}

.bme-injection-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.bme-injection-card {
  background: var(--bme-surface, #131316);
  border: 1px solid var(--bme-border);
  border-radius: 8px;
  padding: 14px;
  border-top: 2px solid var(--bme-border);
}

.bme-injection-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.bme-injection-card__type {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.bme-injection-card__tokens {
  font-size: 10px;
  color: var(--bme-on-surface-dim);
}

.bme-injection-card__body {
  font-size: 11px;
  line-height: 1.5;
  color: var(--bme-on-surface-dim);
  max-height: 120px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* ==================== Persistence Status ==================== */

.bme-persist-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.bme-persist-kv {
  background: var(--bme-surface, #131316);
  border: 1px solid var(--bme-border);
  border-radius: 8px;
  padding: 14px 16px;
}

.bme-persist-kv__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  font-size: 11px;
}

.bme-persist-kv__row:last-child { border-bottom: none; }
.bme-persist-kv__row span { color: var(--bme-on-surface-dim); }
.bme-persist-kv__row strong { color: var(--bme-on-surface); font-weight: 600; }

.bme-persist-kv-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.bme-persist-kv-column {
  min-width: 0;
}

.bme-persist-guide {
  margin-top: 4px;
  padding: 14px 16px;
  background: var(--bme-surface, #131316);
  border: 1px solid var(--bme-border);
  border-radius: 8px;
}

.bme-persist-guide__title {
  font-size: 12px;
  font-weight: 700;
  color: var(--bme-on-surface);
  margin-bottom: 10px;
}

.bme-persist-guide__item {
  display: flex;
  gap: 8px;
  font-size: 11px;
  line-height: 1.5;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.bme-persist-guide__item:last-child {
  border-bottom: none;
}

.bme-persist-guide__item strong {
  color: var(--bme-on-surface);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 90px;
}

.bme-persist-guide__item span {
  color: var(--bme-on-surface-dim);
}

@media (max-width: 900px) {
  .bme-persist-kv-columns {
    grid-template-columns: minmax(0, 1fr);
  }
}

.bme-persist-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.bme-graph-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--bme-surface, #131316);
  border-bottom: 1px solid var(--bme-border);
  flex-shrink: 0;
}

.bme-graph-toolbar-title {
  font-size: 11px;
  color: var(--bme-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* --- Graph View Tab Switcher --- */
.bme-graph-view-tabs {
  display: flex;
  gap: 2px;
}

.bme-graph-view-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--bme-on-surface-dim);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.bme-graph-view-tab:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--bme-on-surface);
}

.bme-graph-view-tab.active {
  color: var(--bme-primary);
  background: var(--bme-primary-dim);
  border-color: rgba(255, 255, 255, 0.08);
}

.bme-graph-view-tab i {
  font-size: 11px;
  opacity: 0.8;
}

.bme-graph-view-tab.active i {
  opacity: 1;
}


.bme-graph-controls {
  display: flex;
  gap: 4px;
}

.bme-graph-controls button {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--bme-border);
  border-radius: 4px;
  background: var(--bme-surface-container);
  color: var(--bme-on-surface-dim);
  cursor: pointer;
  font-size: 11px;
  transition: all 0.15s;
}

.bme-graph-controls button:hover {
  border-color: var(--bme-primary);
  color: var(--bme-primary);
}

.bme-graph-controls button.is-paused {
  border-color: rgba(255, 181, 71, 0.55);
  color: #ffb347;
}

.bme-graph-controls button.is-active {
  border-color: rgba(87, 199, 255, 0.55);
  color: #57c7ff;
}

#bme-graph-canvas,
#bme-mobile-graph-canvas,
#bme-fullscreen-graph-canvas {
  touch-action: none;
}

#bme-graph-canvas {
  flex: 1;
  width: 100%;
  cursor: grab;
}

#bme-graph-canvas:active {
  cursor: grabbing;
}

/* --- Graph Legend --- */
.bme-graph-legend {
  display: flex;
  gap: 12px;
  padding: 6px 12px;
  background: var(--bme-surface, #131316);
  border-top: 1px solid var(--bme-border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.bme-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--bme-on-surface-dim);
}

.bme-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* --- Status Bar --- */
.bme-graph-statusbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 4px 12px;
  background: var(--bme-surface-container);
  border-top: 1px solid var(--bme-border);
  font-size: 10px;
  color: var(--bme-on-surface-dim);
  flex-shrink: 0;
}

.bme-graph-layout-meta {
  margin-left: auto;
  color: var(--bme-on-surface-dim);
  opacity: 0.88;
  white-space: nowrap;
}

.bme-status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bme-accent2, #4edea3);
  margin-right: 4px;
}

/* --- Memory Browser Tab --- */
.bme-search-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.bme-search-input {
  flex: 1;
  background: var(--bme-surface-lowest);
  border: 1px solid var(--bme-border);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--bme-on-surface);
  outline: none;
  transition: border-color 0.15s;
}

.bme-search-input:focus {
  border-color: var(--bme-primary);
  box-shadow: 0 0 4px var(--bme-primary-dim);
}

.bme-search-input::placeholder {
  color: var(--bme-on-surface-dim);
}

.bme-filter-select {
  background: var(--bme-surface-lowest);
  border: 1px solid var(--bme-border);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--bme-on-surface);
  outline: none;
  min-width: 7rem;
  flex: 1 1 8rem;
}

.bme-memory-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bme-memory-item {
  display: block;
  margin: 0;
  padding: 0;
  cursor: pointer;
  list-style: none;
}

.bme-memory-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 11px 12px;
  border-radius: 10px;
  background: var(--bme-surface-low, #1b1b1e);
  border: 1px solid var(--bme-border);
  transition:
    background 0.15s,
    border-color 0.15s,
    box-shadow 0.15s;
}

.bme-memory-item:hover .bme-memory-card {
  background: var(--bme-surface-container, #1f1f22);
  border-color: var(--bme-border-active);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.bme-memory-item.selected .bme-memory-card {
  background: var(--bme-primary-dim);
  border-color: var(--bme-primary);
  box-shadow: 0 0 0 1px var(--bme-border-active);
}

.bme-memory-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.bme-memory-card-head .bme-type-badge {
  margin-top: 0;
  flex-shrink: 0;
}

.bme-memory-scope-chip {
  display: inline-block;
  font-size: 9px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  color: var(--bme-on-surface-dim);
  background: var(--bme-surface-high, #2a2a2d);
  border: 1px solid var(--bme-border);
  line-height: 1.3;
  max-width: 100%;
  word-break: break-word;
}

.bme-memory-name {
  font-size: 13px;
  font-weight: 650;
  color: var(--bme-on-surface);
  line-height: 1.4;
  letter-spacing: 0.01em;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.bme-memory-content {
  font-size: 11.5px;
  color: var(--bme-on-surface-dim);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.bme-memory-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px solid var(--bme-border);
}

.bme-memory-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.bme-memory-stat-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  color: var(--bme-on-surface-dim);
  background: var(--bme-surface-lowest, #0e0e11);
  border: 1px solid var(--bme-border);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bme-memory-region {
  font-size: 10px;
  line-height: 1.45;
  color: var(--bme-on-surface-dim);
  opacity: 0.95;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.bme-cognition-owner-row {
  list-style: none;
}

.bme-cognition-owner-btn {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--bme-border);
  background: var(--bme-surface-lowest);
  color: var(--bme-on-surface);
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    transform 0.15s ease;
}

.bme-cognition-owner-btn:hover {
  border-color: var(--bme-border-active);
  background: var(--bme-surface-high);
  transform: translateY(-1px);
}

.bme-cognition-owner-btn.is-selected {
  border-color: var(--bme-primary);
  background: var(--bme-primary-dim);
}

.bme-cognition-owner-btn.is-active-anchor {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.bme-cognition-owner-btn__title {
  font-size: 12px;
  font-weight: 700;
  color: var(--bme-on-surface);
  word-break: break-word;
}

.bme-cognition-owner-btn__meta {
  font-size: 10px;
  line-height: 1.45;
  color: var(--bme-on-surface-dim);
}

.bme-cognition-detail {
  margin-top: 12px;
}

.bme-cognition-empty {
  padding: 12px;
  border-radius: 10px;
  border: 1px dashed var(--bme-border);
  background: rgba(255, 255, 255, 0.02);
  color: var(--bme-on-surface-dim);
  font-size: 11px;
  line-height: 1.6;
}

.bme-cognition-detail-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--bme-border);
}

.bme-cognition-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.bme-cognition-metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bme-surface-lowest);
  border: 1px solid var(--bme-border);
}

.bme-cognition-metric__label {
  font-size: 10px;
  color: var(--bme-on-surface-dim);
}

.bme-cognition-metric__value {
  font-size: 18px;
  line-height: 1;
  color: var(--bme-on-surface);
}

.bme-cognition-line-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bme-cognition-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  line-height: 1.5;
}

.bme-cognition-line span {
  color: var(--bme-on-surface-dim);
}

.bme-cognition-line strong {
  color: var(--bme-on-surface);
  text-align: right;
  word-break: break-word;
}

.bme-cognition-chip-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bme-cognition-chip-group__label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bme-on-surface-dim);
}

.bme-cognition-chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bme-cognition-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--bme-border);
  background: var(--bme-surface-lowest);
  color: var(--bme-on-surface);
  font-size: 10px;
  line-height: 1.4;
}

.bme-cognition-chip.is-muted,
.bme-cognition-chip.is-empty {
  color: var(--bme-on-surface-dim);
}

.bme-cognition-node-override {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--bme-border);
  background: rgba(255, 255, 255, 0.02);
}

.bme-cognition-node-override__title {
  font-size: 12px;
  font-weight: 700;
  color: var(--bme-on-surface);
}

.bme-cognition-node-actions,
.bme-cognition-tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bme-cognition-tools {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--bme-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bme-ai-monitor-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bme-ai-monitor-entry {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--bme-border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.015));
}

.bme-ai-monitor-entry__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.bme-ai-monitor-entry__title {
  font-size: 13px;
  font-weight: 700;
  color: var(--bme-on-surface);
}

.bme-ai-monitor-entry__meta {
  margin-top: 4px;
  font-size: 10px;
  line-height: 1.45;
  color: var(--bme-on-surface-dim);
}

.bme-ai-monitor-entry__summary {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
  line-height: 1.55;
  color: var(--bme-on-surface-dim);
}

.bme-ai-monitor-kv {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.bme-ai-monitor-kv__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 11px;
  line-height: 1.5;
}

.bme-ai-monitor-kv__row:last-child {
  border-bottom: none;
}

.bme-ai-monitor-kv__row span {
  color: var(--bme-on-surface-dim);
}

.bme-ai-monitor-kv__row strong {
  color: var(--bme-on-surface);
  text-align: right;
  word-break: break-word;
}

/* --- Injection Preview Tab --- */
.bme-injection-preview {
  font-family: "Cascadia Code", "Fira Code", monospace;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  background: var(--bme-surface-lowest);
  border: 1px solid var(--bme-border);
  border-radius: 4px;
  padding: 12px;
  color: var(--bme-on-surface);
  max-height: 100%;
  overflow-y: auto;
}

.bme-injection-rich {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 100%;
  overflow-y: auto;
}

.bme-injection-rich__hint {
  font-size: 11px;
  line-height: 1.5;
  color: var(--bme-on-surface-dim);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 10px 12px;
}

.bme-injection-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.015));
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 12px;
}

.bme-injection-card.character-pov {
  border-color: rgba(255, 113, 145, 0.26);
  background: linear-gradient(180deg, rgba(255, 113, 145, 0.08), rgba(255, 255, 255, 0.02));
}

.bme-injection-card.user-pov {
  border-color: rgba(104, 183, 255, 0.24);
  background: linear-gradient(180deg, rgba(104, 183, 255, 0.08), rgba(255, 255, 255, 0.02));
}

.bme-injection-card.objective-current {
  border-color: rgba(111, 230, 179, 0.22);
  background: linear-gradient(180deg, rgba(111, 230, 179, 0.07), rgba(255, 255, 255, 0.02));
}

.bme-injection-card.objective-global {
  border-color: rgba(255, 211, 102, 0.18);
  background: linear-gradient(180deg, rgba(255, 211, 102, 0.06), rgba(255, 255, 255, 0.02));
}

.bme-injection-card__title {
  font-size: 13px;
  line-height: 1.35;
  font-weight: 800;
  color: var(--bme-on-surface);
}

.bme-injection-card__note {
  font-size: 11px;
  line-height: 1.55;
  color: var(--bme-on-surface-dim);
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.bme-injection-card__text {
  font-size: 12px;
  line-height: 1.65;
  color: var(--bme-on-surface);
  white-space: pre-wrap;
  word-break: break-word;
}

.bme-injection-table-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-x: auto;
}

.bme-injection-table-name {
  font-family: "Cascadia Code", "Fira Code", monospace;
  font-size: 10px;
  line-height: 1.4;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bme-on-surface-dim);
}

.bme-injection-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  table-layout: fixed;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  overflow: hidden;
}

.bme-injection-table th,
.bme-injection-table td {
  padding: 8px 9px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 11px;
  line-height: 1.55;
  color: var(--bme-on-surface);
  word-break: break-word;
  overflow-wrap: anywhere;
}

.bme-injection-table th:last-child,
.bme-injection-table td:last-child {
  border-right: none;
}

.bme-injection-table tr:last-child td {
  border-bottom: none;
}

.bme-injection-table th {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bme-on-surface-dim);
  background: rgba(255, 255, 255, 0.05);
}

.bme-injection-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 3px;
  display: inline-block;
  margin-bottom: 6px;
}

.bme-injection-section-label.core {
  background: var(--bme-primary-dim);
  color: var(--bme-primary);
}

.bme-injection-section-label.recall {
  background: rgba(76, 175, 80, 0.15);
  color: var(--bme-accent2);
}

.bme-injection-token-count {
  font-size: 11px;
  color: var(--bme-on-surface-dim);
  margin-top: 8px;
  text-align: right;
}

/* --- Actions Tab --- */
.bme-action-groups {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.bme-action-group {
  padding: 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.bme-action-group-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}

.bme-action-group-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--bme-on-surface);
}

.bme-action-group-sub {
  font-size: 11px;
  color: var(--bme-on-surface-dim);
}

.bme-action-group-extra {
  margin-top: 10px;
}

.bme-action-range-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

.bme-action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.bme-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  background: var(--bme-surface-low);
  border: 1px solid var(--bme-border);
  border-radius: 6px;
  color: var(--bme-on-surface-dim);
  cursor: pointer;
  font-size: 11px;
  transition: all 0.15s;
}

.bme-action-btn:hover {
  border-color: var(--bme-primary);
  color: var(--bme-primary);
  background: var(--bme-primary-dim);
}

.bme-action-btn i {
  font-size: 18px;
}

.bme-action-btn:disabled,
.bme-action-btn.is-runtime-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: rgba(255, 255, 255, 0.06);
  color: var(--bme-on-surface-dim);
  background: rgba(255, 255, 255, 0.02);
}

.bme-action-btn:disabled:hover,
.bme-action-btn.is-runtime-disabled:hover {
  border-color: rgba(255, 255, 255, 0.06);
  color: var(--bme-on-surface-dim);
  background: rgba(255, 255, 255, 0.02);
}

.bme-action-guard-banner {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 197, 79, 0.25);
  background: rgba(255, 197, 79, 0.08);
  color: #ffd27a;
  font-size: 11px;
  line-height: 1.5;
}

.bme-action-btn.danger:hover {
  border-color: #ff5252;
  color: #ff5252;
  background: rgba(255, 82, 82, 0.1);
}

/* --- Config Workspace --- */
.bme-config-workspace-header {
  padding: 20px 22px 10px;
  border-bottom: 1px solid var(--bme-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

.bme-config-workspace-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.bme-config-launch-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--bme-border);
  background: var(--bme-surface-high);
  color: var(--bme-on-surface);
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    background 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease;
}

.bme-config-launch-btn:hover {
  border-color: var(--bme-primary);
  color: var(--bme-primary);
  background: var(--bme-primary-dim);
  transform: translateY(-1px);
}

.bme-config-launch-btn:disabled,
.bme-config-launch-btn.is-runtime-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  color: var(--bme-on-surface-dim);
  border-color: var(--bme-border);
  background: var(--bme-surface-low);
  transform: none;
}

.bme-config-launch-hint {
  font-size: 12px;
  line-height: 1.4;
  color: var(--bme-on-surface-dim);
  text-align: right;
  max-width: 220px;
}

.bme-config-workspace-title,
.bme-config-section-title {
  margin: 0;
  color: var(--bme-on-surface);
}

.bme-config-workspace-title {
  font-size: 24px;
  line-height: 1.2;
  margin-bottom: 8px;
}

.bme-config-sections {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 22px;
}

.bme-config-section {
  display: none;
}

.bme-config-section.active {
  display: block;
}

.bme-config-section-head {
  margin-bottom: 18px;
}

.bme-config-section-title {
  font-size: 20px;
  line-height: 1.25;
  margin-bottom: 8px;
}

.bme-config-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

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

.bme-config-card,
.bme-prompt-card {
  background: var(--bme-surface-container);
  border: 1px solid var(--bme-border);
  border-radius: 14px;
  padding: 16px;
}

.bme-config-card-head,
.bme-prompt-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.bme-collapsible-card > summary {
  list-style: none;
  cursor: pointer;
}

.bme-collapsible-card > summary::-webkit-details-marker {
  display: none;
}

.bme-collapsible-summary {
  align-items: center;
}

.bme-collapsible-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 999px;
  border: 1px solid var(--bme-border);
  background: var(--bme-surface-high);
  color: var(--bme-on-surface-dim);
  transition:
    transform 0.2s ease,
    color 0.2s ease,
    background 0.2s ease;
}


.bme-collapsible-card[open] .bme-collapsible-indicator {
  transform: rotate(180deg);
  color: var(--bme-primary);
  background: var(--bme-primary-dim);
}

.bme-config-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--bme-on-surface);
  margin-bottom: 4px;
}

.bme-config-help {
  font-size: 11px;
  line-height: 1.5;
  color: var(--bme-on-surface-dim);
  margin-bottom: 10px;
}

.bme-cleanup-warning-text {
  color: #ffc54f;
  border-left: 3px solid #ffc54f;
  padding-left: 10px;
  margin-top: 12px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.bme-cleanup-warning-text i {
  flex-shrink: 0;
  margin-top: 1px;
}

.bme-config-subgroup + .bme-config-subgroup {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--bme-border);
}

.bme-config-subgroup-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--bme-on-surface);
  margin-bottom: 4px;
}

.bme-config-subgroup-desc {
  font-size: 11px;
  line-height: 1.5;
  color: var(--bme-on-surface-dim);
  margin-bottom: 12px;
}

.bme-config-subdetails {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--bme-border);
}

.bme-config-subdetails-summary {
  margin-bottom: 0;
}

.bme-config-subdetails[open] > summary {
  margin-bottom: 12px;
}

.bme-config-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.bme-config-row:last-child {
  margin-bottom: 0;
}

.bme-config-row.inline {
  flex-direction: row;
  align-items: center;
}

.bme-config-row label {
  font-size: 12px;
  color: var(--bme-on-surface);
}

.bme-config-input,
.bme-config-textarea {
  width: 100%;
  box-sizing: border-box;
  background-color: var(--bme-surface-high);
  border: 1px solid var(--bme-border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--bme-on-surface);
  font-size: 12px;
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s,
    background-color 0.15s;
}

.bme-config-input:focus,
.bme-config-textarea:focus {
  border-color: var(--bme-primary);
  box-shadow: 0 0 0 2px var(--bme-primary-dim);
}

.bme-config-input:disabled,
.bme-config-textarea:disabled {
  background-color: var(--bme-surface-low);
  color: var(--bme-on-surface-dim);
  border-color: var(--bme-border);
  opacity: 0.85;
  cursor: not-allowed;
}

/* 宿主样式 / WebKit 默认易把 select、自动填充 input 画成黑底 — 在面板内强制用主题色 */
#st-bme-panel input.bme-config-input,
#st-bme-panel textarea.bme-config-textarea,
#st-bme-panel input.bme-search-input,
#st-bme-panel .bme-node-detail-input,
#st-bme-panel .bme-node-detail-textarea,
#st-bme-panel .bme-task-editor-preset-select {
  background-color: var(--bme-surface-high) !important;
  color: var(--bme-on-surface) !important;
}

#st-bme-panel input.bme-search-input {
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid var(--bme-border);
}

#st-bme-panel select.bme-config-input,
#st-bme-panel select.bme-filter-select,
#st-bme-panel select.bme-task-builtin-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  box-sizing: border-box;
  background-color: var(--bme-surface-high) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px 14px;
  color: var(--bme-on-surface) !important;
  cursor: pointer;
  padding-right: 36px;
  /* 影响原生下拉列表用亮色还是暗色绘制（否则在浅色面板下 option 可能出现黑底） */
  color-scheme: dark;
}

:root[data-bme-color-scheme="light"]
  #st-bme-panel
  :is(select.bme-config-input, select.bme-filter-select, select.bme-task-builtin-select) {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23334155' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") !important;
  color-scheme: light;
}

#st-bme-panel select.bme-config-input option,
#st-bme-panel select.bme-filter-select option,
#st-bme-panel select.bme-task-builtin-select option {
  background-color: var(--bme-surface-container);
  color: var(--bme-on-surface);
}

/* 原生 option 在部分浏览器/系统上不用 CSS 变量；亮色主题用实色保证每项都是浅底深字 */
:root[data-bme-color-scheme="light"] #st-bme-panel select option {
  background-color: #ffffff !important;
  color: #1c1917 !important;
}

:root[data-bme-color-scheme="light"] #st-bme-panel select option:checked,
:root[data-bme-color-scheme="light"] #st-bme-panel select option:hover,
:root[data-bme-color-scheme="light"] #st-bme-panel select option:focus {
  background-color: #e7e5e4 !important;
  color: #1c1917 !important;
}

:root[data-bme-color-scheme="dark"] #st-bme-panel select option {
  background-color: #2a2a2d !important;
  color: #e4e1e6 !important;
}

:root[data-bme-color-scheme="dark"] #st-bme-panel select option:checked,
:root[data-bme-color-scheme="dark"] #st-bme-panel select option:hover,
:root[data-bme-color-scheme="dark"] #st-bme-panel select option:focus {
  background-color: #3d3d42 !important;
  color: #f4f4f5 !important;
}

/* --- 压制宿主注入的原生对号 (SillyTavern 全局 checkbox::before) --- */
#st-bme-panel input[type="checkbox"]::before,
#st-bme-panel-overlay input[type="checkbox"]::before {
  content: "" !important;
  display: none !important;
  background: none !important;
  background-image: none !important;
  -webkit-mask-image: none !important;
  mask-image: none !important;
  width: 0 !important;
  height: 0 !important;
  visibility: hidden !important;
}

#st-bme-panel input.bme-config-input:-webkit-autofill,
#st-bme-panel input.bme-config-input:-webkit-autofill:hover,
#st-bme-panel input.bme-config-input:-webkit-autofill:focus,
#st-bme-panel input.bme-search-input:-webkit-autofill,
#st-bme-panel input.bme-search-input:-webkit-autofill:hover,
#st-bme-panel input.bme-search-input:-webkit-autofill:focus,
#st-bme-panel .bme-node-detail-input:-webkit-autofill,
#st-bme-panel .bme-node-detail-input:-webkit-autofill:hover,
#st-bme-panel .bme-node-detail-input:-webkit-autofill:focus,
#st-bme-panel .bme-node-detail-textarea:-webkit-autofill,
#st-bme-panel .bme-node-detail-textarea:-webkit-autofill:hover,
#st-bme-panel .bme-node-detail-textarea:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--bme-on-surface) !important;
  caret-color: var(--bme-on-surface);
  border: 1px solid var(--bme-border) !important;
  box-shadow: 0 0 0 1000px var(--bme-surface-high) inset !important;
  transition: background-color 99999s ease-out;
}

.bme-config-textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.55;
  font-family: "Cascadia Code", "Fira Code", monospace;
}

.bme-config-actions {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.bme-model-fetch-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: -2px;
  margin-bottom: 12px;
}

.bme-llm-preset-controls {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.bme-llm-preset-controls select {
  min-width: 0;
  width: 100%;
}

.bme-llm-preset-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.bme-llm-preset-actions .bme-config-secondary-btn {
  flex-shrink: 0;
}

.bme-config-secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: fit-content;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--bme-border);
  background: var(--bme-surface-high);
  color: var(--bme-on-surface);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  transition:
    border-color 0.15s,
    background 0.15s,
    color 0.15s;
}

.bme-config-secondary-btn:hover {
  border-color: var(--bme-primary);
  background: var(--bme-primary-dim);
  color: var(--bme-primary);
}

.bme-config-secondary-btn i {
  font-size: 12px;
}

.bme-model-select {
  max-width: 100%;
}

.bme-config-test-btn {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 164px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--bme-border);
  background: var(--bme-surface-high);
  color: var(--bme-on-surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap !important;
  writing-mode: horizontal-tb !important;
  text-orientation: mixed !important;
  transition:
    border-color 0.15s,
    background 0.15s,
    color 0.15s,
    transform 0.15s,
    box-shadow 0.15s;
}

.bme-config-test-btn:hover {
  border-color: var(--bme-primary);
  background: var(--bme-primary-dim);
  color: var(--bme-primary-text, var(--bme-on-surface));
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.bme-config-test-btn:active {
  transform: translateY(0);
}

.bme-config-test-btn i {
  color: var(--bme-primary);
  font-size: 14px;
  flex-shrink: 0;
}

.bme-config-test-btn span {
  display: block;
}

.bme-config-guard-note {
  display: none;
  align-self: center;
  font-size: 11px;
  color: var(--bme-accent3, #ffc107);
  background: rgba(255, 193, 7, 0.12);
  border: 1px solid rgba(255, 193, 7, 0.18);
  border-radius: 999px;
  padding: 5px 10px;
}

.bme-config-guard-note.visible {
  display: inline-flex;
}

.bme-guarded-card.is-disabled {
  opacity: 0.72;
}

.bme-stage-card.stage-disabled {
  border-color: rgba(255, 255, 255, 0.08);
}

.bme-inline-checkbox {
  display: inline-flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--bme-on-surface);
  cursor: pointer;
  user-select: none;
}

.bme-inline-checkbox input {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  position: relative;
  width: 18px;
  height: 18px;
  min-width: 18px;
  margin: 0;
  margin-top: 1px;
  border-radius: 5px;
  border: 1px solid color-mix(in srgb, var(--bme-border, rgba(255, 255, 255, 0.14)) 82%, white 18%);
  background: color-mix(in srgb, var(--bme-surface-high, #2a2a2d) 90%, black 10%);
  cursor: pointer;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.12s ease;
  overflow: hidden;
  flex-shrink: 0;
}

.bme-inline-checkbox input::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border-right: 2px solid transparent;
  border-bottom: 2px solid transparent;
  transform: rotate(45deg) scale(0.65);
  opacity: 0;
  transition:
    opacity 0.16s ease,
    transform 0.16s ease,
    border-color 0.16s ease;
}

.bme-inline-checkbox input:hover {
  border-color: color-mix(in srgb, var(--bme-primary, #e94560) 50%, white 50%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.bme-inline-checkbox input:focus-visible {
  outline: none;
  border-color: color-mix(in srgb, var(--bme-primary, #e94560) 60%, white 40%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--bme-primary-dim, rgba(233, 69, 96, 0.18)) 75%, transparent);
}

.bme-inline-checkbox input:checked {
  background: color-mix(in srgb, var(--bme-primary, #e94560) 38%, var(--bme-surface-high, #2a2a2d));
  border-color: color-mix(in srgb, var(--bme-primary, #e94560) 70%, transparent);
}

.bme-inline-checkbox input:checked::after {
  opacity: 1;
  transform: rotate(45deg) scale(1);
  border-right-color: var(--bme-primary-text, #ffd9dd);
  border-bottom-color: var(--bme-primary-text, #ffd9dd);
}

.bme-inline-checkbox span {
  line-height: 1.5;
  min-width: 0;
}

.bme-stage-card.stage-disabled .bme-stage-param {
  opacity: 0.6;
}

.bme-config-placeholder {
  background: var(--bme-surface-low);
  border: 1px dashed var(--bme-border);
  border-radius: 12px;
  padding: 16px;
}

.bme-config-placeholder-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--bme-on-surface);
  margin-bottom: 6px;
}

.bme-config-placeholder-help {
  font-size: 11px;
  color: var(--bme-on-surface-dim);
  line-height: 1.5;
}

.bme-toggle-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bme-toggle-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.bme-toggle-item:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.035);
}

.bme-toggle-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.bme-toggle-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--bme-on-surface);
}

.bme-toggle-desc {
  font-size: 11px;
  line-height: 1.45;
  color: var(--bme-on-surface-dim);
}

.bme-toggle-item input[type="checkbox"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 40px;
  height: 22px;
  min-width: 40px;
  margin-top: 2px;
  flex-shrink: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  color: transparent;
  overflow: hidden;
}

.bme-toggle-item input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transition: transform 0.2s ease, background 0.2s ease;
}

.bme-toggle-item input[type="checkbox"]:checked {
  background: color-mix(in srgb, var(--bme-primary) 45%, var(--bme-surface-high, #2a2a2d));
  border-color: color-mix(in srgb, var(--bme-primary) 55%, transparent);
}

.bme-toggle-item input[type="checkbox"]:checked::after {
  transform: translateX(18px);
  background: var(--bme-primary-text, #ffb2b7);
}

/* --- CAPABILITY CARD GRID (Feature Toggles) --- */

.bme-capability-master {
  margin-bottom: 14px;
}

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

.bme-capability-card {
  display: flex;
  flex-direction: column;
  background: var(--bme-surface-container);
  border: 1px solid var(--bme-border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  position: relative;
}

.bme-capability-card:hover {
  border-color: var(--bme-primary);
  box-shadow: 0 0 0 1px var(--bme-primary), 0 4px 12px rgba(0, 0, 0, 0.15);
}

.bme-capability-card-master {
  min-height: 0;
}

.bme-capability-card-master .bme-cap-desc {
  max-width: 820px;
}

.bme-capability-card.is-disabled {
  opacity: 0.56;
}

.bme-cap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.bme-cap-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bme-primary);
  color: #fff;
  font-size: 15px;
  flex-shrink: 0;
}

.bme-cap-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--bme-on-surface);
  margin-bottom: 4px;
  line-height: 1.3;
}

.bme-cap-desc {
  font-size: 11.5px;
  color: var(--bme-on-surface-dim);
  line-height: 1.45;
}

.bme-capability-card input[type="checkbox"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 40px;
  height: 22px;
  background: var(--bme-surface-high);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
  border: 1px solid var(--bme-border);
  color: transparent;
  overflow: hidden;
}

.bme-capability-card input[type="checkbox"]::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bme-on-surface-dim);
  top: 2px;
  left: 3px;
  transition: transform 0.2s, background 0.2s;
}

.bme-capability-card input[type="checkbox"]:checked {
  background: color-mix(in srgb, var(--bme-primary) 45%, var(--bme-surface-high));
  border-color: color-mix(in srgb, var(--bme-primary) 55%, transparent);
}

.bme-capability-card input[type="checkbox"]:checked::after {
  transform: translateX(18px);
  background: var(--bme-primary-text, #ffb2b7);
}

.bme-capability-card-mode {
  cursor: default;
}

.bme-mode-gauge {
  position: relative;
  overflow: hidden;
}

.bme-mode-gauge::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 8px;
  width: 20px;
  height: 12px;
  box-sizing: border-box;
  border: 3px solid #fff;
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  background: radial-gradient(
    circle at 50% 100%,
    #fff 0 2.5px,
    transparent 3px
  );
  opacity: 1;
}

.bme-mode-gauge::after {
  content: "";
  position: absolute;
  left: 16px;
  top: 18px;
  width: 9px;
  height: 3px;
  border-radius: 999px;
  background: #fff;
  box-shadow: none;
  transform: rotate(-135deg);
  transform-origin: 1px 50%;
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.bme-capability-card-mode[data-mode="balanced"] .bme-mode-gauge::after {
  transform: rotate(-90deg);
}

.bme-capability-card-mode[data-mode="fast"] .bme-mode-gauge::after {
  transform: rotate(-45deg);
}

.bme-mode-segmented {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--bme-border);
  border-radius: 999px;
  background: var(--bme-surface-high);
  flex-shrink: 0;
  isolation: isolate;
}

.bme-mode-segmented::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: 2px;
  top: 2px;
  width: 24px;
  height: 20px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bme-primary) 72%, var(--bme-surface-high));
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--bme-primary) 55%, transparent),
    0 6px 14px color-mix(in srgb, var(--bme-primary) 26%, transparent);
  transform: translateX(0);
  transition:
    transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1),
    background 0.16s,
    box-shadow 0.16s;
}

.bme-mode-segmented[data-mode="balanced"]::before {
  transform: translateX(26px);
}

.bme-mode-segmented[data-mode="fast"]::before {
  transform: translateX(52px);
}

.bme-mode-segmented button {
  position: relative;
  z-index: 1;
  width: 24px;
  height: 20px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--bme-on-surface-dim);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  transition: background 0.16s, color 0.16s, box-shadow 0.16s;
}

.bme-mode-segmented button:hover {
  color: var(--bme-on-surface);
  background: var(--bme-surface-highest);
}

.bme-mode-segmented button.is-active {
  background: transparent;
  color: var(--bme-primary-text, #fff);
  box-shadow: none;
}

/* --- STRIPE ROW LAYOUT (Advanced Settings) --- */

.bme-stripe-section {
  display: flex;
  flex-direction: column;
}

.bme-stripe-row {
  display: flex;
  gap: 32px;
  padding: 20px 0;
  border-bottom: 1px solid var(--bme-border);
}

.bme-stripe-row:last-child {
  border-bottom: none;
}

.bme-stripe-label {
  flex: 0 0 28%;
  max-width: 28%;
  padding-top: 4px;
}

.bme-stripe-label-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--bme-on-surface);
  margin-bottom: 6px;
  line-height: 1.3;
}

.bme-stripe-label-desc {
  font-size: 12px;
  color: var(--bme-on-surface-dim);
  line-height: 1.55;
}

.bme-stripe-content {
  flex: 1;
  min-width: 0;
}

.bme-stripe-content > .bme-config-card {
  margin-bottom: 0;
}

.bme-prompt-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bme-prompt-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--bme-on-surface-dim);
  font-size: 11px;
  font-weight: 600;
}

.bme-prompt-status.is-custom {
  background: var(--bme-primary-dim);
  color: var(--bme-primary);
}

.bme-prompt-reset:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.bme-task-profile-workspace {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bme-task-shell {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bme-task-action-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.bme-task-action-bar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.bme-task-nav-groups {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.bme-task-segmented-control {
  display: inline-flex;
  background: var(--bme-surface-container);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--bme-border);
}

.bme-task-segmented-control .bme-task-type-btn {
  border: none;
  border-radius: 8px;
  min-height: 32px;
  padding: 0 14px;
  font-size: 12.5px;
  background: transparent;
  color: var(--bme-on-surface-dim);
  transition: background 0.15s, color 0.15s;
}

.bme-task-segmented-control .bme-task-type-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--bme-on-surface);
}

.bme-task-segmented-control .bme-task-type-btn.active {
  background: var(--bme-primary);
  color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.bme-task-segmented-control--solo {
  box-shadow: 0 0 0 1px rgba(255, 183, 0, 0.16);
}

.bme-task-master-detail {
  display: flex;
  gap: 0;
  border: 1px solid var(--bme-border);
  border-radius: 12px;
  overflow: hidden;
  min-height: 480px;
  background: var(--bme-surface-container);
}

.bme-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.bme-task-editor-kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bme-on-surface-dim);
  line-height: 1.2;
}

.bme-task-editor-preset-select {
  flex: 1;
  min-width: 200px;
  min-height: 40px;
  font-size: 16px;
  font-weight: 600;
  padding: 6px 32px 6px 12px;
  line-height: 1.35;
  border-radius: 8px;
  border: 1px solid var(--bme-border);
  cursor: pointer;
}

.bme-task-profile-editor {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.bme-task-editor-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--bme-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bme-task-editor-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.bme-task-editor-preset-select:hover,
.bme-task-editor-preset-select:focus {
  border-color: var(--bme-primary);
  outline: none;
}

.bme-task-editor-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.bme-task-editor-actions .bme-config-secondary-btn {
  font-size: 12px;
  min-height: 28px;
  padding: 0 10px;
  gap: 4px;
}

.bme-task-profile-editor > .bme-task-subtabs {
  padding: 0 20px;
  border-bottom: 1px solid var(--bme-border);
}

.bme-task-profile-editor > .bme-task-tab-body {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
}

.bme-task-header {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bme-task-type-tabs,
.bme-task-subtabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.bme-bulk-profile-btn {
  font-size: 12px;
  padding: 0 10px;
  min-height: 28px;
  opacity: 0.72;
  transition: opacity 0.15s;
}

.bme-bulk-profile-btn:hover {
  opacity: 1;
}

.bme-task-type-btn,
.bme-task-subtab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--bme-on-surface-dim);
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s,
    color 0.15s;
}

.bme-task-type-btn:hover,
.bme-task-subtab-btn:hover {
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--bme-on-surface);
}

.bme-task-type-btn.active,
.bme-task-subtab-btn.active {
  border-color: var(--bme-primary);
  background: var(--bme-primary-dim);
  color: var(--bme-primary);
}

.bme-task-header-card {
  gap: 16px;
}

.bme-task-profile-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bme-task-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--bme-on-surface-dim);
  font-size: 11px;
  font-weight: 600;
}

.bme-task-pill.is-builtin {
  background: var(--bme-primary-dim);
  color: var(--bme-primary);
}

.bme-task-header-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bme-task-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.bme-task-header-actions,
.bme-task-inline-actions,
.bme-task-toolbar-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.bme-task-action-sep {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.bme-task-btn-danger {
  color: var(--bme-on-surface-dim);
}

.bme-task-btn-danger:hover {
  border-color: #e94560;
  color: #e94560;
  background: rgba(233, 69, 96, 0.08);
}

.bme-task-tab-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bme-task-editor-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: start;
}

.bme-task-editor-grid > .bme-config-card:last-child {
  position: static;
  top: auto;
}

.bme-task-block-count {
  font-size: 11px;
  color: var(--bme-on-surface-dim);
  white-space: nowrap;
  flex-shrink: 0;
}

.bme-task-builtin-select {
  width: auto;
  min-width: 0;
  max-width: 200px;
  flex: 0 1 200px;
}

.bme-task-toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: nowrap;
}

.bme-task-toolbar-inline {
  flex: 1 1 auto;
  min-width: 0;
}

.bme-task-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bme-task-list-entry {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bme-task-list-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.025);
  color: var(--bme-on-surface);
  text-align: left;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s,
    transform 0.15s;
}

.bme-task-list-item:hover {
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.bme-task-list-item.active {
  border-color: var(--bme-primary);
  background: rgba(255, 255, 255, 0.055);
}

.bme-task-list-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--bme-on-surface-dim);
  font-size: 11px;
  font-weight: 700;
}

.bme-task-list-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.bme-task-list-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--bme-on-surface);
}

.bme-task-list-meta {
  font-size: 11px;
  line-height: 1.45;
  color: var(--bme-on-surface-dim);
}

.bme-task-mini-btn {
  min-width: 0;
  min-height: 30px;
  padding: 0 10px;
  font-size: 11px;
  border-radius: 8px;
}

.bme-task-empty,
.bme-task-note {
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.08);
  color: var(--bme-on-surface-dim);
  font-size: 12px;
  line-height: 1.55;
}

/* ═══════ Single-column Block Row (EW-style) ═══════ */

.bme-task-block-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bme-task-block-row {
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.bme-task-block-row:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

.bme-task-block-row.is-expanded {
  border-color: var(--bme-primary);
  box-shadow: 0 0 0 1px var(--bme-primary);
}

.bme-task-block-row.is-disabled {
  opacity: 0.5;
}

.bme-task-block-row.dragging {
  opacity: 0.35;
}

.bme-task-block-row.drag-over-top {
  border-top: 2px solid var(--bme-primary);
  margin-top: -1px;
}

.bme-task-block-row.drag-over-bottom {
  border-bottom: 2px solid var(--bme-primary);
  margin-bottom: -1px;
}

/* Row header */
.bme-task-block-row-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  min-height: 44px;
  cursor: pointer;
  user-select: none;
  flex-wrap: wrap;
}

/* Drag handle */
.bme-task-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  color: var(--bme-on-surface-dim);
  opacity: 0.45;
  cursor: grab;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.bme-task-drag-handle:hover {
  opacity: 1;
}

.bme-task-drag-handle:active {
  cursor: grabbing;
}

/* Block type icon */
.bme-task-block-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  font-size: 14px;
  flex-shrink: 0;
  color: var(--bme-on-surface-dim);
}

/* Block name */
.bme-task-block-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--bme-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Badges (role / inject) */
.bme-task-block-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--bme-on-surface-dim);
  white-space: nowrap;
  flex-shrink: 0;
  text-transform: lowercase;
}

.bme-badge-role-system {
  background: rgba(140, 140, 160, 0.18);
  color: #b0b0c0;
}

.bme-badge-role-user {
  background: rgba(160, 100, 220, 0.2);
  color: #c8a0f0;
}

.bme-badge-role-assistant {
  background: rgba(80, 180, 120, 0.2);
  color: #80d0a0;
}

/* Row spacer */
.bme-task-block-row-spacer {
  flex: 1;
}

/* Row action buttons (edit / delete) */
.bme-task-row-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--bme-on-surface-dim);
  cursor: pointer;
  flex-shrink: 0;
  font-size: 13px;
  transition: background 0.12s, color 0.12s;
}

.bme-task-row-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--bme-on-surface);
}

.bme-task-row-btn-danger:hover {
  background: rgba(220, 80, 80, 0.15);
  color: #f08080;
}

/* Inline toggle switch (EW-style yellow) */
.bme-task-row-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
}

.bme-task-row-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.bme-task-row-toggle-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  transition: background 0.2s;
}

.bme-task-row-toggle-slider::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #888;
  transition: transform 0.2s, background 0.2s;
}

.bme-task-row-toggle input:checked + .bme-task-row-toggle-slider {
  background: rgba(220, 180, 50, 0.35);
}

.bme-task-row-toggle input:checked + .bme-task-row-toggle-slider::before {
  transform: translateX(16px);
  background: #e0b830;
}

/* Expand editor area */
.bme-task-block-expand {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 12px;
  animation: bme-block-expand-in 0.2s ease;
}

.bme-task-expand-row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.bme-task-block-expand .bme-config-row {
  margin-bottom: 8px;
}

.bme-task-block-expand .bme-config-row:last-child {
  margin-bottom: 0;
}

.bme-task-block-expand .bme-config-textarea {
  min-height: 120px;
  max-height: 400px;
  resize: vertical;
}

.bme-task-expand-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

/* ═══════ Single-column Regex Editor ═══════ */

.bme-regex-settings-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bme-regex-settings-card .bme-task-section-label {
  margin-top: 0;
  margin-bottom: 10px;
}

.bme-regex-rule-card .bme-task-empty,
.bme-regex-rule-card .bme-task-note {
  margin: 0;
}

.bme-regex-rule-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bme-regex-rule-row {
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.bme-regex-rule-row:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

.bme-regex-rule-row.is-expanded {
  border-color: var(--bme-primary);
  box-shadow: 0 0 0 1px var(--bme-primary);
}

.bme-regex-rule-row.is-disabled {
  opacity: 0.56;
}

.bme-regex-rule-row.dragging {
  opacity: 0.35;
}

.bme-regex-rule-row.drag-over-top {
  border-top: 2px solid var(--bme-primary);
  margin-top: -1px;
}

.bme-regex-rule-row.drag-over-bottom {
  border-bottom: 2px solid var(--bme-primary);
  margin-bottom: -1px;
}

.bme-regex-rule-row-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  min-height: 44px;
  cursor: pointer;
  user-select: none;
  flex-wrap: wrap;
}

.bme-regex-rule-name {
  flex: 0 1 220px;
  min-width: 120px;
  font-size: 13px;
  font-weight: 600;
  color: var(--bme-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bme-regex-rule-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.bme-regex-rule-status.is-enabled {
  background: rgba(80, 180, 120, 0.18);
  color: #80d0a0;
}

.bme-regex-rule-status.is-disabled {
  background: rgba(160, 160, 180, 0.14);
  color: var(--bme-on-surface-dim);
}

.bme-regex-rule-preview {
  flex: 1 1 260px;
  min-width: 0;
  font-size: 11px;
  line-height: 1.45;
  color: var(--bme-on-surface-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bme-regex-rule-expand {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 12px;
  animation: bme-block-expand-in 0.2s ease;
}

@keyframes bme-block-expand-in {
  from {
    opacity: 0;
    max-height: 0;
  }
  to {
    opacity: 1;
    max-height: 800px;
  }
}


.bme-regex-preview-screen {
  gap: 14px;
}

.bme-regex-preview-hero,
.bme-regex-preview-panel,
.bme-regex-preview-source {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 16px;
}

.bme-regex-preview-hero__title,
.bme-regex-preview-panel__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--bme-on-surface);
}

.bme-regex-preview-hero__subtitle,
.bme-regex-preview-panel__subtitle,
.bme-regex-preview-source__meta,
.bme-regex-preview-item__meta {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--bme-on-surface-dim);
}

.bme-regex-preview-summary {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.bme-regex-preview-summary__item {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.bme-regex-preview-summary__label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--bme-on-surface-dim);
}

.bme-regex-preview-summary__value {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--bme-on-surface);
  word-break: break-word;
}

.bme-regex-preview-panel__head,
.bme-regex-preview-source__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.bme-regex-preview-source__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--bme-on-surface);
}

.bme-regex-preview-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bme-regex-preview-list .bme-task-empty {
  margin: 0;
}

.bme-regex-preview-item {
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.bme-regex-preview-item.is-muted {
  opacity: 0.82;
}

.bme-regex-preview-item__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.bme-regex-preview-item__title-group,
.bme-regex-preview-item__badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bme-regex-preview-item__index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--bme-on-surface-dim);
  font-size: 11px;
  font-weight: 700;
}

.bme-regex-preview-item__name {
  font-size: 13px;
  font-weight: 700;
  color: var(--bme-on-surface);
  line-height: 1.4;
}

.bme-regex-preview-item__badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid transparent;
}

.bme-regex-preview-item__badge.is-transform {
  background: rgba(76, 175, 80, 0.12);
  color: #9fe6a1;
  border-color: rgba(76, 175, 80, 0.25);
}

.bme-regex-preview-item__badge.is-clear {
  background: rgba(255, 193, 7, 0.13);
  color: #ffd777;
  border-color: rgba(255, 193, 7, 0.26);
}

.bme-regex-preview-item__badge.is-skip {
  background: rgba(255, 255, 255, 0.08);
  color: var(--bme-on-surface-dim);
  border-color: rgba(255, 255, 255, 0.1);
}

.bme-regex-preview-item__badge.is-prompt {
  background: rgba(33, 150, 243, 0.13);
  color: #88d0ff;
  border-color: rgba(33, 150, 243, 0.26);
}

.bme-regex-preview-item__details {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.bme-regex-preview-item__row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  font-size: 12px;
  line-height: 1.55;
  color: var(--bme-on-surface);
}

.bme-regex-preview-item__label {
  color: var(--bme-on-surface-dim);
  font-weight: 700;
}

.bme-regex-preview-item__row code {
  white-space: pre-wrap;
  word-break: break-word;
}

.bme-regex-preview-details > summary {
  padding: 12px 14px;
}

.bme-regex-preview-details__body {
  padding: 0 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bme-task-editor-toggle {
  margin-bottom: 12px;
}

/* ── 滑动条组件 ── */

.bme-range-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bme-range-input {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--bme-border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.bme-range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--bme-primary);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid rgba(0, 0, 0, 0.3);
  transition: box-shadow 0.15s ease;
}

.bme-range-input::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 4px var(--bme-primary-dim);
}

.bme-range-input::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--bme-primary);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid rgba(0, 0, 0, 0.3);
}

.bme-range-input::-moz-range-track {
  height: 4px;
  background: var(--bme-border);
  border-radius: 2px;
}

.bme-range-number {
  width: 72px;
  flex-shrink: 0;
  text-align: center;
}

.bme-range-value {
  font-size: 11px;
  font-weight: 400;
  color: var(--bme-primary);
  margin-left: 6px;
}

.bme-task-section-label {
  margin: 16px 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bme-on-surface-dim);
}

.bme-task-toggle-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bme-task-profile-workspace .bme-config-textarea {
  min-height: 160px;
}

.bme-task-debug-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.bme-debug-kv-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bme-debug-kv-item {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.bme-debug-kv-key {
  font-size: 11px;
  color: var(--bme-on-surface-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bme-debug-kv-value {
  font-size: 12px;
  line-height: 1.5;
  color: var(--bme-on-surface);
  word-break: break-word;
}

.bme-debug-capability-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bme-debug-capability-item {
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.bme-debug-capability-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.bme-debug-capability-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--bme-on-surface);
}

.bme-debug-capability-desc {
  font-size: 12px;
  line-height: 1.5;
  color: var(--bme-on-surface-dim);
}

.bme-debug-details {
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
}

.bme-debug-details summary {
  cursor: pointer;
  padding: 12px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--bme-on-surface);
  list-style: none;
}

.bme-debug-details summary::-webkit-details-marker {
  display: none;
}

.bme-debug-pre {
  margin: 0;
  padding: 0 14px 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.55;
  color: var(--bme-on-surface);
  font-family:
    "JetBrains Mono",
    "Cascadia Code",
    "Fira Code",
    Consolas,
    monospace;
}

.bme-debug-empty {
  padding: 0 14px 14px;
  font-size: 12px;
  color: var(--bme-on-surface-dim);
}

.bme-theme-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.bme-theme-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.025);
  color: var(--bme-on-surface);
  text-align: left;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s,
    transform 0.15s;
}

.bme-theme-card:hover {
  border-color: var(--bme-primary);
  transform: translateY(-1px);
}

.bme-theme-card.active {
  border-color: var(--bme-primary);
  background: var(--bme-primary-dim);
}

.bme-theme-card-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.14);
}

.bme-theme-card-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.bme-theme-card-title {
  font-size: 13px;
  font-weight: 700;
}

.bme-theme-card-desc {
  font-size: 11px;
  line-height: 1.45;
  color: var(--bme-on-surface-dim);
}

.bme-theme-card.active .bme-theme-card-desc {
  color: var(--bme-primary-text, var(--bme-on-surface));
}

.bme-theme-card-check {
  opacity: 0;
  color: var(--bme-primary);
}

.bme-theme-card.active .bme-theme-card-check {
  opacity: 1;
}

/* --- Mobile Bottom Tab Bar --- */
.bme-panel-tabbar {
  display: none;
  border-top: 1px solid var(--bme-border);
  background: var(--bme-surface-container);
  flex-shrink: 0;
}

.bme-panel-tabbar .bme-tab-btn {
  flex: 1;
  flex-direction: column;
  padding: 6px 4px;
  font-size: 10px;
  border-bottom: none;
  border-radius: 0;
  border-top: 2px solid transparent;
  min-height: 48px;
}

.bme-panel-tabbar .bme-tab-btn.active {
  border-top-color: var(--bme-primary);
  border-bottom-color: transparent;
}

.bme-panel-tabbar .bme-tab-btn i {
  font-size: 16px;
  margin-bottom: 2px;
}

/* --- Node detail：桌面右侧抽屉 / 移动端图谱内居中悬浮 + 遮罩 --- */
.bme-node-detail-scrim {
  position: absolute;
  inset: 0;
  z-index: 9;
  margin: 0;
  padding: 0;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  cursor: pointer;
}

.bme-node-detail-scrim[hidden] {
  display: none !important;
}

/* 桌面图谱工作区（主画布）：节点详情仍为右侧滑出面板 */
#bme-node-detail {
  position: absolute;
  top: 0;
  right: 0;
  left: auto;
  width: 280px;
  height: 100%;
  max-height: none;
  background: var(--bme-surface-container);
  border-left: 1px solid var(--bme-border);
  border-radius: 0;
  padding: 12px;
  overflow-y: auto;
  box-shadow: none;
  transform: translateX(100%);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: transform 0.2s ease;
  z-index: 10;
}

#bme-node-detail.open {
  transform: translateX(0);
}

/* 移动端「图谱」Tab：节点详情居中悬浮窗 */
#bme-mobile-node-detail {
  position: absolute;
  left: 50%;
  top: 50%;
  right: auto;
  width: min(400px, calc(100% - 24px));
  max-height: min(78vh, 640px);
  height: auto;
  background: var(--bme-surface-container);
  border: 1px solid var(--bme-border);
  border-radius: 14px;
  padding: 12px;
  overflow-y: auto;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.5);
  transform: translate(-50%, -48%) scale(0.96);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.22s ease,
    transform 0.22s ease,
    visibility 0.22s;
  z-index: 10;
}

#bme-mobile-node-detail.open {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

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

.bme-node-detail-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.bme-detail-action-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--bme-primary);
  cursor: pointer;
  border-radius: 4px;
  font-size: 13px;
  transition: all 0.15s;
}

.bme-detail-action-btn:hover:not(:disabled) {
  background: var(--bme-primary-dim, rgba(233, 69, 96, 0.15));
  color: var(--bme-primary);
}

.bme-detail-action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.bme-detail-action-danger {
  color: var(--bme-accent3, #ffc107);
}

.bme-detail-action-danger:hover:not(:disabled) {
  background: rgba(255, 193, 7, 0.12);
  color: var(--bme-accent3, #ffc107);
}

.bme-node-detail h3 {
  font-size: 14px;
  color: var(--bme-on-surface);
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bme-node-detail-section {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--bme-on-surface-dim);
  margin: 14px 0 8px;
  padding-top: 10px;
  border-top: 1px solid var(--bme-border);
}

.bme-node-detail-input,
.bme-node-detail-textarea {
  width: 100%;
  box-sizing: border-box;
  background-color: var(--bme-surface-high);
  border: 1px solid var(--bme-border);
  border-radius: 6px;
  color: var(--bme-on-surface);
  font-size: 11px;
  padding: 6px 8px;
  -webkit-appearance: none;
  appearance: none;
}

.bme-node-detail-textarea {
  resize: vertical;
  min-height: 52px;
  line-height: 1.45;
  font-family: inherit;
}

.bme-node-detail-field {
  margin-bottom: 8px;
}

.bme-node-detail-field label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--bme-on-surface-dim);
  margin-bottom: 3px;
}

.bme-node-detail-field .value {
  font-size: 12px;
  color: var(--bme-on-surface);
  line-height: 1.4;
}

.bme-node-detail-collapse {
  margin: 6px 0 8px;
}

.bme-node-detail-collapse > summary {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--bme-on-surface-dim);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.bme-node-detail-collapse > summary::-webkit-details-marker {
  display: none;
}

.bme-node-detail-collapse > summary::before {
  content: "▶";
  font-size: 8px;
  transition: transform 0.15s;
}

.bme-node-detail-collapse[open] > summary::before {
  transform: rotate(90deg);
}

.bme-node-detail-collapse > .bme-node-detail-field:first-of-type {
  margin-top: 6px;
}

/* --- Scrollbar --- */
.bme-tab-content::-webkit-scrollbar,
.bme-config-sidebar::-webkit-scrollbar,
.bme-config-sections::-webkit-scrollbar,
.bme-injection-preview::-webkit-scrollbar,
.bme-node-detail::-webkit-scrollbar {
  width: 4px;
}

.bme-tab-content::-webkit-scrollbar-track,
.bme-config-sidebar::-webkit-scrollbar-track,
.bme-config-sections::-webkit-scrollbar-track,
.bme-injection-preview::-webkit-scrollbar-track,
.bme-node-detail::-webkit-scrollbar-track {
  background: transparent;
}

.bme-tab-content::-webkit-scrollbar-thumb,
.bme-config-sidebar::-webkit-scrollbar-thumb,
.bme-config-sections::-webkit-scrollbar-thumb,
.bme-injection-preview::-webkit-scrollbar-thumb,
.bme-node-detail::-webkit-scrollbar-thumb {
  background: var(--bme-surface-highest);
  border-radius: 2px;
}

/* 移动端图谱预览 - 桌面端默认隐藏（旧组件已移除） */
.bme-mobile-graph-preview,
.bme-mobile-graph-status {
  display: none;
}

/* --- Graph Sub-Tabs (Mobile Graph Pane) --- */

.bme-graph-subtabs {
  display: flex;
  gap: 4px;
  padding: 10px 12px 6px;
  background: var(--bme-surface-container);
  border-bottom: 1px solid var(--bme-border);
  flex-shrink: 0;
}

.bme-graph-subtab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 10px;
  border: none;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--bme-on-surface-dim);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.bme-graph-subtab i {
  font-size: 12px;
}

.bme-graph-subtab:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--bme-on-surface);
}

.bme-graph-subtab.active {
  background: var(--bme-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(233, 69, 96, 0.35);
}

.bme-graph-view-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.bme-mobile-graph-pane {
  display: none;
  width: 100%;
  height: 100%;
  flex-direction: column;
  overflow: auto;
}

#bme-mobile-graph-pane {
  overflow: hidden;
  overscroll-behavior: contain;
}

.bme-mobile-graph-pane.active {
  display: flex;
}

.bme-mobile-canvas-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
}

.bme-mobile-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.bme-mobile-graph-float-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 5;
}

.bme-mobile-graph-float-controls button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(10, 10, 15, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--bme-on-surface);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.bme-mobile-graph-float-controls button:hover {
  background: rgba(233, 69, 96, 0.25);
  border-color: var(--bme-primary);
  color: var(--bme-primary);
}

.bme-mobile-graph-float-controls button.is-paused {
  border-color: rgba(255, 181, 71, 0.62);
  color: #ffb347;
}

.bme-mobile-graph-float-controls button.is-active {
  border-color: rgba(87, 199, 255, 0.62);
  color: #57c7ff;
}

/* Graph pane layout */
#bme-pane-graph {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
}

#bme-pane-graph.active {
  display: flex;
}

#bme-pane-graph .bme-graph-legend {
  flex-shrink: 0;
  padding: 6px 12px;
}

#bme-pane-graph .bme-graph-statusbar {
  flex-shrink: 0;
  padding: 4px 12px;
  font-size: 10px;
}

#bme-pane-graph .bme-cognition-workspace {
  padding: 12px;
  overflow-y: auto;
}

/* ═══════ ⑤ 高级设置折叠 (desktop+mobile) ═══════ */

.bme-advanced-settings {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.bme-advanced-settings > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--bme-on-surface-dim);
  padding: 8px 0;
  list-style: none;
  user-select: none;
  transition: color 0.15s;
}

.bme-advanced-settings > summary:hover {
  color: var(--bme-on-surface);
}

.bme-advanced-settings > summary::-webkit-details-marker {
  display: none;
}

.bme-advanced-settings > summary::after {
  content: "▸";
  font-size: 12px;
  transition: transform 0.2s ease;
  color: var(--bme-on-surface-dim);
}

.bme-advanced-settings[open] > summary::after {
  transform: rotate(90deg);
  color: var(--bme-primary);
}

/* ==================== 响应式 ==================== */

@media (max-width: 768px) {
  #st-bme-panel {
    width: var(--bme-viewport-width, 100vw);
    height: var(--bme-viewport-height, 100vh);
    max-width: none;
    max-height: none;
    border-radius: 0;
    resize: none;
  }

  .bme-panel-body {
    flex-direction: column;
  }

  .bme-panel-sidebar {
    width: 100%;
    min-width: unset;
    flex: 1;
    border-right: none;
  }

  .bme-panel-sidebar > .bme-tab-list {
    display: none;
  }

  .bme-tab-content {
    padding: 12px 14px;
  }

  .bme-panel-main {
    display: none;
  }

  .bme-regex-preview-hero,
  .bme-regex-preview-panel,
  .bme-regex-preview-source {
    padding: 14px;
    border-radius: 14px;
  }

  .bme-regex-preview-summary {
    grid-template-columns: 1fr;
  }

  .bme-regex-preview-item__head,
  .bme-regex-preview-source__head {
    flex-direction: column;
    align-items: stretch;
  }

  .bme-regex-preview-item__row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  /* ② 底部 Tabbar safe-area + 6 列 icon-only */
  .bme-panel-tabbar {
    display: flex;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .bme-panel-tabbar .bme-tab-btn {
    min-height: 44px;
    gap: 2px;
    font-size: 0;
    padding: 6px 2px;
  }

  .bme-panel-tabbar .bme-tab-btn span {
    display: none;
  }

  .bme-panel-tabbar .bme-tab-btn i {
    font-size: 18px;
  }

  .bme-resize-handle,
  .bme-config-sidebar {
    display: none !important;
  }

  /* ④ 设置导航 pill + scroll-snap */
  .bme-config-nav-mobile {
    display: flex;
    overflow-x: auto;
    padding: 0 14px 8px;
    margin-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .bme-config-nav-mobile::-webkit-scrollbar {
    display: none;
  }

  .bme-config-nav-mobile .bme-config-nav-btn {
    flex: 0 0 auto;
    white-space: nowrap;
    scroll-snap-align: start;
    padding: 10px 14px;
    min-height: 44px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
  }

  /* ⑦ Config mode 移动端 */
  .bme-config-workspace-header {
    padding: 14px 14px 8px;
    flex-direction: column;
    align-items: stretch;
  }

  .bme-config-workspace-title {
    font-size: 18px;
  }

  .bme-config-workspace-actions {
    align-items: stretch;
  }

  .bme-config-launch-hint {
    max-width: none;
    text-align: left;
  }

  .bme-config-sections {
    padding: 14px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }

  .bme-config-section-title {
    font-size: 16px;
  }

  .bme-config-grid-2,
  .bme-theme-card-grid,
  .bme-task-field-grid,
  .bme-task-expand-row2,
  .bme-task-debug-grid {
    grid-template-columns: 1fr;
  }

  .bme-config-card,
  .bme-prompt-card {
    padding: 14px;
    border-radius: 12px;
  }

  .bme-config-card-title {
    font-size: 13px;
  }

  .bme-debug-kv-item {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .bme-config-card-head,
  .bme-prompt-card-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .bme-prompt-card-actions {
    width: 100%;
    justify-content: space-between;
  }

  #st-bme-panel.config-mode .bme-panel-sidebar {
    display: none;
  }

  #st-bme-panel.config-mode .bme-panel-main {
    display: flex;
    flex: 1;
  }

  #st-bme-panel.task-mode .bme-panel-sidebar {
    display: none;
  }

  #st-bme-panel.task-mode .bme-panel-main {
    display: flex;
    flex: 1;
  }

  .bme-config-workspace {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* ③ 通用触控目标 44px */
  .bme-config-input,
  .bme-config-textarea,
  .bme-filter-select {
    min-height: 44px;
    font-size: 14px;
    border-radius: 10px;
  }

  .bme-config-secondary-btn {
    width: 100%;
    min-height: 44px;
    font-size: 13px;
  }

  .bme-config-test-btn {
    width: 100%;
    min-height: 46px;
  }

  .bme-config-actions {
    width: 100%;
  }

  .bme-llm-preset-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .bme-llm-preset-actions .bme-config-secondary-btn {
    width: 100%;
  }

  .bme-inline-checkbox {
    min-height: 44px;
    gap: 12px;
    padding: 6px 0;
    font-size: 13px;
  }

  .bme-inline-checkbox input {
    width: 20px;
    height: 20px;
    min-width: 20px;
    margin-top: 0;
  }

  .bme-inline-checkbox input::after {
    left: 6px;
    top: 1px;
  }

  .bme-toggle-item {
    padding: 14px;
  }

  .bme-toggle-item input[type="checkbox"] {
    width: 44px;
    height: 24px;
    min-width: 44px;
  }

  .bme-toggle-item input[type="checkbox"]::after {
    width: 18px;
    height: 18px;
  }

  .bme-toggle-item input[type="checkbox"]:checked::after {
    transform: translateX(20px);
  }

  .bme-config-row label {
    font-size: 13px;
  }

  .bme-config-row {
    gap: 8px;
    margin-bottom: 14px;
  }

  /* ⑧ 任务预设工作区触控优化 */
  .bme-task-toolbar-row,
  .bme-task-header-actions,
  .bme-task-inline-actions,
  .bme-task-toolbar-inline {
    width: 100%;
  }

  .bme-task-toolbar-row,
  .bme-task-toolbar-inline {
    flex-wrap: wrap;
  }

  .bme-task-type-tabs,
  .bme-task-subtabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
    gap: 6px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .bme-task-type-tabs::-webkit-scrollbar,
  .bme-task-subtabs::-webkit-scrollbar {
    display: none;
  }

  .bme-task-type-btn,
  .bme-task-subtab-btn {
    flex: 0 0 auto;
    white-space: nowrap;
    scroll-snap-align: start;
    min-height: 40px;
    padding: 0 16px;
    font-size: 13px;
  }

  .bme-bulk-profile-btn {
    min-height: 36px;
    padding: 0 12px;
    font-size: 11px;
  }

  .bme-task-list-item {
    padding: 14px;
    gap: 10px;
  }

  .bme-task-list-index {
    min-width: 40px;
    height: 32px;
  }

  .bme-task-field-grid {
    gap: 10px;
  }

  .bme-task-header-actions {
    gap: 6px;
  }

  .bme-task-header-actions .bme-config-secondary-btn {
    flex: 1;
    min-width: 0;
    padding: 0 10px;
    font-size: 11px;
  }

  .bme-task-builtin-select {
    max-width: 100%;
  }

  .bme-regex-rule-preview {
    flex: 1 1 100%;
    order: 10;
    margin-left: 28px;
  }

  /* Dashboard 统计卡片横向滚动 */
  .bme-stats-grid {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: none;
  }

  .bme-stats-grid::-webkit-scrollbar {
    display: none;
  }

  .bme-stats-grid .bme-stat-card {
    min-width: 105px;
    flex-shrink: 0;
  }

  /* 搜索栏 */
  .bme-search-bar {
    flex-direction: column;
  }

  .bme-filter-select {
    width: 100%;
  }

  /* 操作按钮增大 */
  .bme-action-btn {
    padding: 18px 8px;
    font-size: 12px;
    min-height: 80px;
  }

  .bme-action-btn i {
    font-size: 22px;
  }

  /* 移动端图谱内悬浮窗略收窄（桌面 #bme-node-detail 在窄屏下不可见） */
  #bme-mobile-node-detail {
    width: min(400px, calc(100% - 16px));
    max-height: min(82vh, 680px);
  }

  /* 图例 */
  .bme-graph-legend {
    font-size: 9px;
  }

}

/* ═══════ Help Tip (? 图标 + 气泡) ═══════ */
.bme-help-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  margin-left: 4px;
}

.bme-help-tip__trigger {
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 999px;
  border: 1px solid rgba(160, 140, 200, 0.35);
  background: rgba(160, 140, 200, 0.18);
  color: rgba(240, 230, 252, 0.9);
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
  padding: 0;
  line-height: 1;
}

.bme-help-tip__trigger:hover,
.bme-help-tip__trigger:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(180, 160, 220, 0.6);
  background: rgba(180, 160, 220, 0.35);
  outline: none;
}

.bme-help-tip__bubble {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 99999;
  width: min(20rem, calc(100vw - 2rem));
  border-radius: 10px;
  border: 1px solid rgba(160, 140, 200, 0.3);
  background: rgba(18, 14, 28, 0.92);
  color: rgba(240, 235, 250, 0.95);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
  backdrop-filter: blur(16px) saturate(125%);
  -webkit-backdrop-filter: blur(16px) saturate(125%);
  padding: 10px 12px;
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: normal;
  display: none;
  pointer-events: none;
}

.bme-help-tip:hover .bme-help-tip__bubble,
.bme-help-tip__trigger:focus + .bme-help-tip__bubble {
  display: block;
  pointer-events: auto;
}

/* --- Floating Ball (悬浮球) --- */
#bme-floating-ball {
  position: fixed;
  z-index: 9998;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(30, 30, 40, 0.75);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255,255,255,0.05) inset;
  cursor: grab;
  user-select: none;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.3s ease, transform 0.15s ease, border-color 0.3s ease;
}

#bme-floating-ball:hover {
  transform: scale(1.08);
  border-color: var(--bme-accent, #e1415d);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 12px var(--bme-accent, #e1415d40);
}

#bme-floating-ball:active {
  cursor: grabbing;
  transform: scale(0.95);
}

#bme-floating-ball .bme-fab-icon {
  font-size: 18px;
  color: rgba(255, 255, 255, 0.85);
  pointer-events: none;
  transition: color 0.3s ease;
}

#bme-floating-ball:hover .bme-fab-icon {
  color: var(--bme-accent, #e1415d);
}

/* Status ring */
#bme-floating-ball::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: border-color 0.3s ease;
  pointer-events: none;
}

#bme-floating-ball[data-status="running"]::after {
  border-color: var(--bme-accent, #e1415d);
  animation: bme-fab-pulse 1.5s ease-in-out infinite;
}

#bme-floating-ball[data-status="success"]::after {
  border-color: var(--bme-accent2, #4edea3);
}

#bme-floating-ball[data-status="cloud-success"]::after {
  border-color: #60a5fa;
}

#bme-floating-ball[data-status="error"]::after {
  border-color: #f44336;
}

#bme-floating-ball[data-status="warning"]::after {
  border-color: #ffc107;
}

#bme-floating-ball[data-status="cloud-success"] .bme-fab-icon,
#bme-floating-ball[data-status="cloud-success"]:hover .bme-fab-icon {
  color: #60a5fa;
}

@keyframes bme-fab-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* Tooltip */
#bme-floating-ball .bme-fab-tooltip {
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: rgba(20, 20, 28, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.8);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

#bme-floating-ball:hover .bme-fab-tooltip {
  opacity: 1;
}

@media (max-width: 768px) {
  #bme-floating-ball {
    width: 54px;
    height: 54px;
    border-width: 2px;
    box-shadow:
      0 8px 24px rgba(0, 0, 0, 0.42),
      0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  }

  #bme-floating-ball .bme-fab-icon {
    font-size: 21px;
  }

  #bme-floating-ball .bme-fab-tooltip {
    display: none;
  }
}


/* --- Recall Message Card --- */

.bme-recall-card {
  margin-top: 8px;
  background: var(--bme-surface-container, #1f1f22);
  border: 1px solid var(--bme-border, rgba(255, 255, 255, 0.08));
  border-left: 3px solid var(--bme-primary, #e94560);
  border-radius: 8px;
  overflow: hidden;
  font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
}

.bme-recall-user-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 10px 14px 4px;
  font-size: 12px;
  color: var(--bme-on-surface-dim, rgba(228, 225, 230, 0.6));
  font-weight: 500;
}

.bme-recall-user-label-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.bme-recall-user-label-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.bme-recall-user-edit-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border: 1px solid var(--bme-border, rgba(255, 255, 255, 0.08));
  border-radius: 999px;
  background: transparent;
  color: var(--bme-on-surface-dim, rgba(228, 225, 230, 0.6));
  font-size: 11px;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}

.bme-recall-user-edit-btn:hover:not(:disabled) {
  background: var(--bme-surface-high, #2a2a2d);
  border-color: var(--bme-border-active, rgba(233, 69, 96, 0.4));
  color: var(--bme-on-surface, #e4e1e6);
}

.bme-recall-user-edit-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.bme-recall-user-text {
  padding: 4px 14px 10px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--bme-on-surface, #e4e1e6);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.bme-recall-user-edit-wrap {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 4px 14px 10px;
}

.bme-recall-card.bme-recall-user-input-editing .bme-recall-user-edit-wrap {
  display: flex;
}

.bme-recall-card.bme-recall-user-input-editing .bme-recall-user-text {
  display: none;
}

.bme-recall-user-edit-textarea {
  width: 100%;
  min-height: 72px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--bme-border, rgba(255, 255, 255, 0.08));
  background: var(--bme-surface-low, #1b1b1e);
  color: var(--bme-on-surface, #e4e1e6);
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.15s;
}

.bme-recall-user-edit-textarea:focus {
  outline: none;
  border-color: var(--bme-border-active, rgba(233, 69, 96, 0.4));
}

.bme-recall-user-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.bme-recall-user-edit-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--bme-border, rgba(255, 255, 255, 0.08));
  background: transparent;
  color: var(--bme-on-surface-dim, rgba(228, 225, 230, 0.6));
  font-size: 11px;
  cursor: pointer;
}

.bme-recall-user-edit-action.primary {
  background: var(--bme-primary-dim, rgba(233, 69, 96, 0.15));
  border-color: var(--bme-primary, #e94560);
  color: var(--bme-primary-text, #ffb2b7);
}

.bme-recall-user-edit-action.secondary:hover,
.bme-recall-user-edit-action.primary:hover {
  filter: brightness(1.06);
}

.bme-recall-card.bme-recall-hide-user-input .bme-recall-user-label,
.bme-recall-card.bme-recall-hide-user-input .bme-recall-user-text {
  display: none;
}

.bme-recall-card.bme-recall-hide-user-input .bme-recall-bar {
  border-top: none;
}

.bme-hide-original-user-text {
  display: none !important;
}

/* --- Recall Bar (collapse/expand trigger) --- */

.bme-recall-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bme-surface-low, #1b1b1e);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
  border-top: 1px solid var(--bme-border, rgba(255, 255, 255, 0.08));
}

.bme-recall-bar:hover {
  background: var(--bme-surface-high, #2a2a2d);
}

.bme-recall-bar-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.bme-recall-bar-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--bme-on-surface, #e4e1e6);
  flex-shrink: 0;
}

.bme-recall-count-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
  background: var(--bme-primary-dim, rgba(233, 69, 96, 0.15));
  color: var(--bme-primary-text, #ffb2b7);
  flex-shrink: 0;
}

.bme-recall-token-hint {
  font-size: 11px;
  color: var(--bme-on-surface-dim, rgba(228, 225, 230, 0.6));
  margin-left: auto;
  flex-shrink: 0;
}

.bme-recall-expand-arrow {
  font-size: 12px;
  color: var(--bme-on-surface-dim, rgba(228, 225, 230, 0.6));
  transition: transform 0.25s ease;
  flex-shrink: 0;
  margin-left: 4px;
}

.bme-recall-card.expanded .bme-recall-expand-arrow {
  transform: rotate(90deg);
}

/* --- Recall Body (expanded content) --- */

.bme-recall-body {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition:
    max-height 0.3s ease,
    opacity 0.25s ease;
}

.bme-recall-card.expanded .bme-recall-body {
  max-height: 600px;
  opacity: 1;
}

.bme-recall-canvas-wrap {
  width: 100%;
  height: 250px;
  position: relative;
  background: var(--bme-surface-lowest, #0e0e11);
  border-radius: 0;
}

.bme-recall-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.bme-recall-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 120px;
  font-size: 12px;
  color: var(--bme-on-surface-dim, rgba(228, 225, 230, 0.6));
  font-style: italic;
}

/* --- Recall Meta --- */

.bme-recall-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 11px;
  color: var(--bme-on-surface-dim, rgba(228, 225, 230, 0.6));
  border-top: 1px solid var(--bme-border, rgba(255, 255, 255, 0.08));
}

.bme-recall-meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 4px;
  background: var(--bme-accent3, #ffc107);
  color: #000;
}

.bme-recall-meta-tag.is-ena {
  background: rgba(111, 194, 255, 0.16);
  color: #9dd6ff;
  border: 1px solid rgba(111, 194, 255, 0.28);
}

.bme-recall-meta-text {
  min-width: 0;
}

.bme-recall-injection-preview {
  margin: 0 14px 8px;
  border: 1px solid var(--bme-border, rgba(255, 255, 255, 0.08));
  border-radius: 8px;
  overflow: hidden;
  background: var(--bme-surface-low, #1b1b1e);
}

.bme-recall-injection-preview.is-ena {
  border-left: 3px solid #6fc2ff;
}

.bme-recall-injection-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--bme-on-surface, #e4e1e6);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.bme-recall-injection-toggle-arrow {
  color: var(--bme-on-surface-dim, rgba(228, 225, 230, 0.6));
  transition: transform 0.2s ease;
}

.bme-recall-injection-preview.expanded .bme-recall-injection-toggle-arrow {
  transform: rotate(90deg);
}

.bme-recall-injection-content {
  display: none;
  padding: 0 10px 10px;
  border-top: 1px solid var(--bme-border, rgba(255, 255, 255, 0.08));
}

.bme-recall-injection-preview.expanded .bme-recall-injection-content {
  display: block;
}

.bme-recall-injection-note {
  padding-top: 10px;
  font-size: 11px;
  color: #9dd6ff;
}

.bme-recall-injection-section-title {
  margin-top: 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--bme-primary-text, #ffb2b7);
}

.bme-recall-injection-subsection {
  margin-top: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--bme-on-surface, #e4e1e6);
}

.bme-recall-injection-line,
.bme-recall-injection-table {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--bme-on-surface-dim, rgba(228, 225, 230, 0.78));
  white-space: pre-wrap;
  word-break: break-word;
}

.bme-recall-injection-table {
  padding: 8px;
  border-radius: 6px;
  background: var(--bme-surface-lowest, #0e0e11);
  overflow-x: auto;
}

.bme-recall-injection-spacer {
  height: 6px;
}

/* --- Recall Actions --- */

.bme-recall-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px 10px;
}

.bme-recall-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--bme-border, rgba(255, 255, 255, 0.08));
  border-radius: 6px;
  background: var(--bme-surface-low, #1b1b1e);
  color: var(--bme-on-surface-dim, rgba(228, 225, 230, 0.6));
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
  white-space: nowrap;
}

.bme-recall-action-btn:hover {
  background: var(--bme-surface-high, #2a2a2d);
  border-color: var(--bme-border-active, rgba(233, 69, 96, 0.4));
  color: var(--bme-on-surface, #e4e1e6);
}

.bme-recall-action-btn.danger {
  background: rgba(233, 69, 96, 0.2);
  border-color: var(--bme-primary, #e94560);
  color: var(--bme-primary, #e94560);
}

.bme-recall-action-btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

@keyframes bme-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.bme-recall-action-btn.loading .bme-recall-btn-icon {
  animation: bme-spin 1s linear infinite;
}

/* --- Recall Sidebar --- */

.bme-recall-sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.bme-recall-sidebar-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.bme-recall-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: min(400px, 90vw);
  height: 100vh;
  z-index: 10001;
  background: var(--bme-surface-container, #1f1f22);
  border-left: 1px solid var(--bme-border, rgba(255, 255, 255, 0.08));
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.4);
}

.bme-recall-sidebar.open {
  transform: translateX(0);
}

.bme-recall-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--bme-border, rgba(255, 255, 255, 0.08));
  flex-shrink: 0;
}

.bme-recall-sidebar-header-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--bme-primary, #e94560);
  display: flex;
  align-items: center;
  gap: 6px;
}

.bme-recall-sidebar-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--bme-on-surface-dim, rgba(228, 225, 230, 0.6));
  cursor: pointer;
  border-radius: 4px;
  font-size: 14px;
  transition: all 0.15s;
}

.bme-recall-sidebar-close:hover {
  background: var(--bme-surface-highest, #353438);
  color: var(--bme-on-surface, #e4e1e6);
}

.bme-recall-sidebar-node-info {
  padding: 12px 16px;
  border-bottom: 1px solid var(--bme-border, rgba(255, 255, 255, 0.08));
  font-size: 12px;
  color: var(--bme-on-surface-dim, rgba(228, 225, 230, 0.6));
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bme-recall-sidebar-node-info-row {
  display: flex;
  gap: 8px;
}

.bme-recall-sidebar-node-info-label {
  font-weight: 600;
  color: var(--bme-on-surface, #e4e1e6);
  min-width: 48px;
}

.bme-recall-sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bme-recall-sidebar-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--bme-on-surface-dim, rgba(228, 225, 230, 0.6));
}

.bme-recall-sidebar-textarea {
  width: 100%;
  min-height: 200px;
  padding: 10px;
  font-family: 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  background: var(--bme-surface-low, #1b1b1e);
  border: 1px solid var(--bme-border, rgba(255, 255, 255, 0.08));
  border-radius: 6px;
  color: var(--bme-on-surface, #e4e1e6);
  resize: vertical;
  transition: border-color 0.15s;
}

.bme-recall-sidebar-textarea:focus {
  outline: none;
  border-color: var(--bme-border-active, rgba(233, 69, 96, 0.4));
}

.bme-recall-sidebar-readonly {
  width: 100%;
  min-height: 120px;
  padding: 10px;
  font-family: 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  background: var(--bme-surface-low, #1b1b1e);
  border: 1px solid var(--bme-border, rgba(255, 255, 255, 0.08));
  border-radius: 6px;
  color: var(--bme-on-surface, #e4e1e6);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  max-height: 40vh;
}

.bme-recall-sidebar-token-hint {
  font-size: 11px;
  color: var(--bme-on-surface-dim, rgba(228, 225, 230, 0.6));
  font-feature-settings: 'tnum';
}

.bme-recall-sidebar-footer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--bme-border, rgba(255, 255, 255, 0.08));
  flex-shrink: 0;
}

.bme-recall-sidebar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
  white-space: nowrap;
}

.bme-recall-sidebar-btn.primary {
  background: var(--bme-primary-dim, rgba(233, 69, 96, 0.15));
  border: 1px solid var(--bme-primary, #e94560);
  color: var(--bme-primary-text, #ffb2b7);
}

.bme-recall-sidebar-btn.primary:hover {
  background: var(--bme-primary-glow, rgba(233, 69, 96, 0.35));
}

.bme-recall-sidebar-btn.secondary {
  background: transparent;
  border: 1px solid var(--bme-border, rgba(255, 255, 255, 0.08));
  color: var(--bme-on-surface-dim, rgba(228, 225, 230, 0.6));
}

.bme-recall-sidebar-btn.secondary:hover {
  background: var(--bme-surface-high, #2a2a2d);
  color: var(--bme-on-surface, #e4e1e6);
}

/* --- Recall Card Responsive --- */

@media (max-width: 768px) {
  .bme-recall-canvas-wrap {
    height: 180px;
  }

  .bme-recall-user-label {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .bme-recall-user-label-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .bme-recall-injection-preview {
    margin-left: 10px;
    margin-right: 10px;
  }

  .bme-recall-sidebar {
    width: 100vw;
  }

  .bme-recall-actions {
    gap: 4px;
  }

  .bme-recall-action-btn {
    padding: 4px 8px;
    font-size: 10px;
  }
}

/* --- RESPONSIVE: New Layout Components --- */

@media (max-width: 768px) {
  .bme-capability-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  /* P1: 能力卡片 toggle 移动端放大 */
  .bme-capability-card input[type="checkbox"] {
    width: 44px;
    height: 24px;
    border-radius: 12px;
  }

  .bme-capability-card input[type="checkbox"]::after {
    width: 18px;
    height: 18px;
  }

  .bme-capability-card input[type="checkbox"]:checked::after {
    transform: translateX(20px);
  }

  /* P2: 能力卡片文字 / icon 移动端微调 */
  .bme-cap-icon {
    width: 38px;
    height: 38px;
    font-size: 17px;
    border-radius: 10px;
  }

  .bme-cap-title {
    font-size: 14px;
  }

  .bme-cap-desc {
    font-size: 12px;
  }

  .bme-capability-card {
    padding: 14px;
  }

  .bme-stripe-row {
    flex-direction: column;
    gap: 12px;
  }

  .bme-stripe-label {
    flex: none;
    max-width: 100%;
  }

  .bme-task-master-detail {
    flex-direction: column;
    min-height: auto;
  }

  .bme-task-editor-preset-select {
    min-width: 0;
    width: 100%;
    flex: 1 1 100%;
  }

  .bme-task-editor-title-row {
    flex-direction: column;
    align-items: stretch;
  }

  .bme-task-profile-badges {
    justify-content: flex-start;
  }

  .bme-task-segmented-control {
    flex-wrap: wrap;
  }

  .bme-task-nav-groups {
    width: 100%;
  }

  .bme-task-action-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .bme-task-action-bar-right {
    margin-left: 0;
    justify-content: flex-end;
  }
}

@media (max-width: 520px) {
  .bme-capability-grid {
    grid-template-columns: 1fr;
  }
}


/* ═══════════════════════════════════════════════════════════
   Cognition Workspace (Desktop)
   ═══════════════════════════════════════════════════════════ */

.bme-cognition-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  background: var(--bme-surface-lowest);
  gap: 16px;
}

.bme-cognition-workspace[hidden] {
  display: none !important;
}

.bme-cog-status-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.bme-cog-status-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--bme-border);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.015));
}

.bme-cog-status-card__label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--bme-on-surface-dim);
}

.bme-cog-status-card__label i {
  font-size: 10px;
  opacity: 0.6;
}

.bme-cog-status-card__value {
  font-size: 14px;
  font-weight: 700;
  color: var(--bme-on-surface);
  word-break: break-word;
  line-height: 1.35;
}

.bme-cog-body {
  display: grid;
  grid-template-columns: 55% 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

.bme-cog-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.bme-cog-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bme-on-surface-dim);
}

.bme-cog-section-title i {
  font-size: 11px;
  opacity: 0.5;
}

/* --- Owner List --- */
.bme-cog-owner-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}

.bme-cog-owner-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 160px;
  max-width: 200px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--bme-border);
  background: var(--bme-surface-lowest);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.bme-cog-owner-card:hover {
  border-color: var(--bme-border-active);
  background: var(--bme-surface-high);
  transform: translateY(-1px);
}

.bme-cog-owner-card.is-selected {
  border-color: var(--bme-primary);
  background: var(--bme-primary-dim);
}

.bme-cog-owner-card.is-active-anchor::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
  flex-shrink: 0;
  animation: bme-pulse-dot 2s ease-in-out infinite;
}

@keyframes bme-pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.75); }
}

.bme-cog-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.bme-cog-owner-card__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.bme-cog-owner-card__name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.bme-cog-owner-card__name {
  font-size: 12px;
  font-weight: 700;
  color: var(--bme-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

.bme-cog-owner-card__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.4;
  background: rgba(255, 255, 255, 0.08);
  color: var(--bme-on-surface-dim);
  flex-shrink: 0;
}

.bme-cog-owner-card__stats {
  font-size: 10px;
  line-height: 1.4;
  color: var(--bme-on-surface-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Owner Detail --- */
.bme-cog-owner-detail {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  overflow-y: auto;
}

.bme-cog-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.bme-cog-detail-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.bme-cog-detail-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--bme-on-surface);
  word-break: break-word;
}

.bme-cog-detail-meta {
  font-size: 10px;
  line-height: 1.5;
  color: var(--bme-on-surface-dim);
  word-break: break-word;
}

.bme-cog-detail-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  background: var(--bme-primary-dim);
  color: var(--bme-primary);
  white-space: nowrap;
}

.bme-cog-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.bme-cog-metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bme-surface-lowest);
  border: 1px solid var(--bme-border);
}

.bme-cog-metric__label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--bme-on-surface-dim);
}

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

.bme-cog-metric-dot.dot-known { background: #4ade80; }
.bme-cog-metric-dot.dot-mistaken { background: #fbbf24; }
.bme-cog-metric-dot.dot-visible { background: #60a5fa; }
.bme-cog-metric-dot.dot-suppressed { background: #f87171; opacity: 0.7; }

.bme-cog-metric__value {
  font-size: 20px;
  line-height: 1;
  font-weight: 700;
  color: var(--bme-on-surface);
  font-variant-numeric: tabular-nums;
}

/* --- Chip Groups --- */
.bme-cog-chip-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bme-cog-chip-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bme-on-surface-dim);
}

.bme-cog-chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bme-cog-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--bme-border);
  background: var(--bme-surface-lowest);
  color: var(--bme-on-surface);
  font-size: 10px;
  line-height: 1.4;
  transition: border-color 0.12s ease;
}

.bme-cog-chip.is-visible {
  border-color: rgba(96, 165, 250, 0.35);
  color: #93c5fd;
}

.bme-cog-chip.is-suppressed {
  border-color: rgba(248, 113, 113, 0.25);
  color: var(--bme-on-surface-dim);
}

.bme-cog-chip.is-empty {
  color: var(--bme-on-surface-dim);
  border-style: dashed;
}

/* --- Manual Override Buttons --- */
.bme-cog-override-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--bme-border);
  background: rgba(255, 255, 255, 0.02);
}

.bme-cog-override-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--bme-on-surface);
}

.bme-cog-override-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--bme-on-surface-dim);
}

.bme-cog-status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
}

.bme-cog-status-pill.is-known { background: rgba(74, 222, 128, 0.15); color: #4ade80; }
.bme-cog-status-pill.is-hidden { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.bme-cog-status-pill.is-mistaken { background: rgba(248, 113, 113, 0.15); color: #f87171; }
.bme-cog-status-pill.is-none { background: rgba(255, 255, 255, 0.06); color: var(--bme-on-surface-dim); }

.bme-cog-override-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bme-cog-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid;
  background: transparent;
}

.bme-cog-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.bme-cog-btn--known {
  border-color: rgba(74, 222, 128, 0.4);
  color: #4ade80;
}
.bme-cog-btn--known:hover:not(:disabled) {
  background: rgba(74, 222, 128, 0.1);
  border-color: #4ade80;
}

.bme-cog-btn--hidden {
  border-color: rgba(251, 191, 36, 0.4);
  color: #fbbf24;
}
.bme-cog-btn--hidden:hover:not(:disabled) {
  background: rgba(251, 191, 36, 0.1);
  border-color: #fbbf24;
}

.bme-cog-btn--mistaken {
  border-color: rgba(248, 113, 113, 0.4);
  color: #f87171;
}
.bme-cog-btn--mistaken:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.1);
  border-color: #f87171;
}

.bme-cog-btn--clear {
  border-color: var(--bme-border);
  color: var(--bme-on-surface-dim);
}
.bme-cog-btn--clear:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  color: var(--bme-on-surface);
}

/* --- Space Tools (right column) --- */
.bme-cog-space-tools {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bme-cog-space-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bme-cog-space-row label {
  font-size: 11px;
  font-weight: 600;
  color: var(--bme-on-surface-dim);
}

.bme-cog-space-btn-row {
  display: flex;
  gap: 8px;
}

/* --- Monitor Mini List --- */
.bme-cog-monitor-mini {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bme-cog-monitor-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--bme-border);
  background: var(--bme-surface-lowest);
  border-left: 3px solid var(--bme-border);
  transition: border-color 0.12s ease;
}

.bme-cog-monitor-entry.is-success {
  border-left-color: #4ade80;
}

.bme-cog-monitor-entry.is-error {
  border-left-color: #f87171;
}

.bme-cog-monitor-entry.is-running {
  border-left-color: #60a5fa;
  animation: bme-pulse-border 1.5s ease-in-out infinite;
}

@keyframes bme-pulse-border {
  0%, 100% { border-left-color: #60a5fa; }
  50% { border-left-color: rgba(96, 165, 250, 0.3); }
}

.bme-cog-monitor-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: rgba(255, 255, 255, 0.06);
  color: var(--bme-on-surface-dim);
  white-space: nowrap;
  flex-shrink: 0;
}

.bme-cog-monitor-info {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  color: var(--bme-on-surface-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bme-cog-monitor-duration {
  font-size: 11px;
  font-family: "Cascadia Code", "Fira Code", monospace;
  color: var(--bme-on-surface);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.bme-cog-monitor-empty {
  padding: 16px 12px;
  font-size: 11px;
  color: var(--bme-on-surface-dim);
  text-align: center;
}

/* --- Dashboard Jump Button --- */
.bme-cognition-jump-btn {
  margin-top: 4px;
  width: 100%;
  justify-content: center;
  gap: 6px;
}

/* ═══════════════════════════════════════════════════════════
   Fullscreen Graph Overlay
   ═══════════════════════════════════════════════════════════ */

.bme-fullscreen-graph-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  background: var(--bme-surface-lowest, #0e0e11);
}

.bme-fullscreen-graph-overlay[hidden] {
  display: none;
}

.bme-fullscreen-graph-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bme-surface, #131316);
  border-bottom: 1px solid var(--bme-border);
  flex-shrink: 0;
}

.bme-fullscreen-graph-controls {
  display: flex;
  gap: 4px;
}

.bme-fullscreen-graph-controls button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--bme-border);
  background: var(--bme-surface);
  color: var(--bme-on-surface);
  cursor: pointer;
  transition: all 0.12s ease;
}

.bme-fullscreen-graph-controls button:hover {
  background: var(--bme-surface-high);
  border-color: var(--bme-border-active);
}

.bme-fullscreen-graph-overlay canvas {
  flex: 1;
  width: 100%;
}

/* ═══════════════════════════════════════════════════════════
   AI Monitor Trace Upgrades
   ═══════════════════════════════════════════════════════════ */

.bme-ai-monitor-entry.is-collapsed .bme-ai-monitor-entry__detail {
  display: none;
}

.bme-ai-monitor-entry__toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--bme-border);
  background: transparent;
  color: var(--bme-on-surface-dim);
  cursor: pointer;
  font-size: 10px;
  flex-shrink: 0;
  transition: all 0.12s ease;
}

.bme-ai-monitor-entry__toggle:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--bme-on-surface);
}

.bme-ai-monitor-entry.is-collapsed .bme-ai-monitor-entry__toggle i {
  transform: rotate(-90deg);
}

.bme-ai-monitor-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.bme-ai-monitor-status-dot.dot-success { background: #4ade80; }
.bme-ai-monitor-status-dot.dot-error { background: #f87171; }
.bme-ai-monitor-status-dot.dot-running {
  background: #60a5fa;
  animation: bme-pulse-dot 2s ease-in-out infinite;
}

.bme-ai-monitor-timeline-connector {
  width: 2px;
  height: 12px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 1px;
}

.bme-ai-monitor-governance-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.bme-ai-monitor-gov-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 600;
  white-space: nowrap;
}

.bme-ai-monitor-gov-tag.tag-worldinfo { background: rgba(74, 222, 128, 0.12); color: #4ade80; }
.bme-ai-monitor-gov-tag.tag-ejs { background: rgba(45, 212, 191, 0.12); color: #2dd4bf; }
.bme-ai-monitor-gov-tag.tag-regex { background: rgba(251, 191, 36, 0.12); color: #fbbf24; }
.bme-ai-monitor-gov-tag.tag-cleaning { background: rgba(96, 165, 250, 0.12); color: #60a5fa; }
.bme-ai-monitor-gov-tag.tag-error { background: rgba(248, 113, 113, 0.12); color: #f87171; }

/* --- Trace Cognition Snapshot Two-Column --- */
.bme-ai-monitor-snapshot-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.bme-ai-monitor-snapshot-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bme-ai-monitor-snapshot-col__title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--bme-on-surface-dim);
  margin-bottom: 6px;
}

/* ═══════════════════════════════════════════════════════════
   Mobile Cognition View Responsive
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .bme-cog-status-strip {
    grid-template-columns: repeat(2, 1fr);
  }
  .bme-cog-body {
    grid-template-columns: 1fr;
  }
  .bme-cog-owner-scroll {
    flex-direction: column;
  }
  .bme-cog-owner-card {
    min-width: unset;
    max-width: unset;
  }
  .bme-ai-monitor-snapshot-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .bme-cognition-line {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .bme-cognition-line strong {
    text-align: left;
  }

  .bme-cog-detail-header {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* ═══════════════════════════════════════════════════════════
   Task Monitor Mobile Responsive
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  #st-bme-panel.task-mode .bme-task-sidebar {
    display: none;
  }
  .bme-task-nav-mobile {
    display: flex;
  }
  .bme-task-workspace-header {
    padding: 14px 16px 10px;
  }
  .bme-task-workspace-body {
    padding: 12px 12px 24px;
  }
  .bme-pipeline-grid {
    grid-template-columns: 1fr;
  }
  .bme-injection-card-grid {
    grid-template-columns: 1fr;
  }
  .bme-persist-grid {
    grid-template-columns: 1fr;
  }
  .bme-memory-master-detail {
    flex-direction: column;
    min-height: 0;
  }
  .bme-memory-list-panel {
    width: 100%;
    max-width: none;
    border-right: none;
    border-bottom: none;
    max-height: none;
  }
  .bme-memory-detail-panel {
    display: none;
  }
  .bme-batch-stages {
    flex-wrap: wrap;
    gap: 4px;
  }
  .bme-batch-stage-line {
    display: none;
  }
}

/* ═══════════════════════════════════════════════════════════
   ENA Planner (native panel section)
   ═══════════════════════════════════════════════════════════ */

.bme-config-danger-btn {
  color: var(--bme-error, #d47380);
}

.bme-config-danger-btn:hover {
  border-color: var(--bme-error, #d47380);
  background: rgba(212, 115, 128, 0.14);
  color: var(--bme-error, #d47380);
}

.bme-planner-status-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.bme-planner-status-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid var(--bme-border);
  background: var(--bme-surface-container);
  color: var(--bme-on-surface-dim);
}

.bme-planner-status-chip[data-tone="active"] {
  border-color: var(--bme-primary);
  background: var(--bme-primary-dim);
  color: var(--bme-primary);
}

.bme-planner-status-chip[data-tone="success"] {
  border-color: rgba(53, 179, 119, 0.4);
  background: rgba(53, 179, 119, 0.14);
  color: var(--bme-success, #35b377);
}

.bme-planner-status-chip[data-tone="error"] {
  border-color: rgba(212, 115, 128, 0.4);
  background: rgba(212, 115, 128, 0.14);
  color: var(--bme-error, #d47380);
}

.bme-planner-status-chip[data-tone="loading"] {
  border-color: rgba(234, 181, 67, 0.4);
  background: rgba(234, 181, 67, 0.12);
  color: var(--bme-warning, #eab543);
}

.bme-planner-status-text {
  font-size: 12px;
  line-height: 1.5;
  color: var(--bme-on-surface-dim);
  margin-top: 8px;
  min-height: 1em;
}

.bme-planner-status-text[data-tone="loading"] {
  color: var(--bme-warning, #eab543);
}

.bme-planner-status-text[data-tone="success"] {
  color: var(--bme-success, #35b377);
}

.bme-planner-status-text[data-tone="error"] {
  color: var(--bme-error, #d47380);
}

.bme-planner-textarea {
  resize: vertical;
  min-height: 72px;
  font-family: inherit;
  line-height: 1.5;
}

.bme-planner-inline-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.bme-planner-inline-row .bme-config-input {
  flex: 1;
}

.bme-planner-param-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.bme-planner-undo-bar {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--bme-warning, #eab543);
  background: rgba(234, 181, 67, 0.1);
  color: var(--bme-on-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}

.bme-planner-undo-bar[hidden] {
  display: none;
}

.bme-planner-prompt-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bme-planner-prompt-empty {
  padding: 18px;
  text-align: center;
  font-size: 12px;
  color: var(--bme-on-surface-dim);
  border: 1px dashed var(--bme-border);
  border-radius: 10px;
}

.bme-planner-prompt-empty[hidden] {
  display: none;
}

.bme-planner-prompt-block {
  border: 1px solid var(--bme-border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--bme-surface-container);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bme-planner-prompt-head {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
}

.bme-planner-prompt-head-left {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.bme-planner-prompt-head-left .bme-config-input {
  flex: 1;
  min-width: 100px;
}

.bme-planner-prompt-head-left select.bme-config-input {
  flex: 0 0 auto;
  width: 110px;
}

.bme-planner-prompt-head-right {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.bme-planner-icon-btn {
  width: 32px !important;
  padding: 0 !important;
  flex: 0 0 auto;
}

.bme-planner-icon-btn i {
  font-size: 12px;
}

.bme-planner-debug-output {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--bme-border);
  background: var(--bme-surface-low);
  font-family: "Cascadia Code", "Fira Code", monospace;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow-y: auto;
  color: var(--bme-on-surface);
}

.bme-planner-debug-output[hidden] {
  display: none;
}

.bme-planner-log-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 2px;
}

.bme-planner-log-empty {
  padding: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--bme-on-surface-dim);
  border: 1px dashed var(--bme-border);
  border-radius: 10px;
}

.bme-planner-log-item {
  border: 1px solid var(--bme-border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--bme-surface-container);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bme-planner-log-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--bme-on-surface-dim);
  flex-wrap: wrap;
}

.bme-planner-log-meta .success {
  color: var(--bme-success, #35b377);
  font-weight: 600;
}

.bme-planner-log-meta .error {
  color: var(--bme-error, #d47380);
  font-weight: 600;
}

.bme-planner-log-error {
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(212, 115, 128, 0.12);
  color: var(--bme-error, #d47380);
  font-size: 11px;
  word-break: break-word;
}

.bme-planner-log-item details > summary {
  cursor: pointer;
  font-size: 11px;
  color: var(--bme-on-surface-dim);
  padding: 4px 0;
  list-style: none;
}

.bme-planner-log-item details > summary::-webkit-details-marker {
  display: none;
}

.bme-planner-log-item details[open] > summary {
  color: var(--bme-primary);
}

.bme-planner-log-pre {
  margin: 4px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bme-surface-low);
  color: var(--bme-on-surface);
  font-family: "Cascadia Code", "Fira Code", monospace;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
}

.bme-planner-msg-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bme-planner-msg-card {
  border-left: 3px solid var(--bme-border);
  padding: 6px 10px;
  background: var(--bme-surface-low);
  border-radius: 0 8px 8px 0;
}

.bme-planner-msg-card.msg-system {
  border-left-color: var(--bme-primary);
}

.bme-planner-msg-card.msg-user {
  border-left-color: var(--bme-success, #35b377);
}

.bme-planner-msg-card.msg-assistant {
  border-left-color: var(--bme-warning, #eab543);
}

.bme-planner-msg-role {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bme-on-surface-dim);
  margin-bottom: 4px;
}

.bme-planner-msg-content {
  margin: 0;
  font-family: "Cascadia Code", "Fira Code", monospace;
  font-size: 11px;
  line-height: 1.5;
  color: var(--bme-on-surface);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow-y: auto;
}

@media (max-width: 768px) {
  .bme-planner-prompt-head-left {
    flex-wrap: wrap;
  }

  .bme-planner-prompt-head-left select.bme-config-input {
    width: 100%;
  }

  .bme-planner-icon-btn {
    width: 44px !important;
    min-height: 44px;
  }

  .bme-planner-inline-row {
    flex-wrap: wrap;
  }

  .bme-planner-param-grid {
    grid-template-columns: 1fr 1fr;
  }
}
