/* ============================================================
   小宿算力中心 · Token Matrix · 子系统操盘域 (v4.1)
   主题：浅色玻璃 + 深色中枢画布，对应父项目 design-spec v4.1
   ============================================================ */

:root {
  /* —— 基础色（与父项目 token-matrix 统一） —— */
  --bg: #F4F7FB;
  --bg-2: #E9EFF7;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --line: rgba(14, 143, 211, 0.18);
  --line-strong: rgba(14, 143, 211, 0.42);

  /* —— 文字 —— */
  --text: #142233;
  --text-2: #34465B;
  --muted: #7A8A9C;

  /* —— 状态/分身专属色 —— */
  --brand: #0E8FD3;
  --green: #00B27A;
  --violet: #6B5BD0;
  --purple: #815CFF;
  --amber: #E48F1F;
  --orange: #E5673A;
  --red: #D9364A;
  --cyan: #25D9FF;
  --blue: #2C8CFF;

  /* —— 中枢画布 —— */
  --dark: #06182D;
  --dark-2: #071F3C;
  --dark-3: #031324;

  /* —— 阴影/圆角/缓动 —— */
  --shadow-soft: 0 1px 2px rgba(20, 34, 51, 0.04), 0 6px 20px rgba(20, 34, 51, 0.06);
  --shadow-hover: 0 4px 10px rgba(20, 34, 51, 0.08), 0 12px 32px rgba(14, 143, 211, 0.16);
  --shadow-canvas: inset 0 0 0 1px rgba(105, 188, 255, 0.28), 0 24px 60px rgba(4, 20, 42, 0.28);

  --radius-xl: 18px;
  --radius-lg: 14px;
  --radius-md: 12px;
  --radius-sm: 10px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-body: 'Inter', 'PingFang SC', 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ============================================================
   Reset
   ============================================================ */

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at 8% 4%, rgba(14, 143, 211, 0.10), transparent 38%),
    radial-gradient(circle at 92% 8%, rgba(0, 178, 122, 0.06), transparent 32%),
    linear-gradient(180deg, #F4F7FB 0%, #E9EFF7 100%);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

.mono { font-family: var(--font-mono); }

/* ============================================================
   Panel shell (glass)
   ============================================================ */

.panel-shell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

/* ============================================================
   App layout
   ============================================================ */

.tm-app {
  width: min(1920px, 100vw);
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px 14px 22px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
}

/* ============================================================
   TopBar
   ============================================================ */

.tm-topbar {
  height: 64px;
  padding: 0 16px;
  display: grid;
  grid-template-columns: 280px 1fr auto;
  align-items: center;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}

.brand-mark svg { width: 28px; height: 28px; }

.brand-copy strong {
  display: block;
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

.brand-copy em {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-style: normal;
  color: var(--muted);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

/* —— 6 分身入口 —— */

.clones-bar {
  display: grid;
  grid-template-columns: repeat(6, minmax(60px, 1fr));
  gap: 8px;
  min-width: 0;
}

.clone-tab {
  --accent: var(--brand);
  position: relative;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(14, 143, 211, 0.18);
  transition: transform 0.18s var(--ease-out), border-color 0.18s var(--ease-out), background 0.18s var(--ease-out), box-shadow 0.18s var(--ease-out);
  overflow: hidden;
}

.clone-tab::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.18s var(--ease-out);
}

.clone-icon { width: 22px; height: 22px; color: var(--accent); flex-shrink: 0; }
.clone-tab span { font-size: 13px; font-weight: 700; color: var(--text); }

.clone-tab:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  background: color-mix(in srgb, var(--accent) 6%, white);
}

.clone-tab.is-active {
  color: var(--text);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, white), color-mix(in srgb, var(--accent) 6%, white));
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 22%, transparent);
}
.clone-tab.is-active::before { opacity: 1; }

/* —— 右上 KPI + 时钟 —— */

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, auto);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-soft);
}

.kpi-cell {
  display: grid;
  gap: 2px;
  padding: 8px 14px;
  border-right: 1px solid var(--line);
}
.kpi-cell:last-child { border-right: 0; }
.kpi-cell i { font-style: normal; font-size: 11px; color: var(--muted); }
.kpi-cell b { font-size: 14px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }

.clock {
  height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), #0B7BB8);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 8px 18px rgba(14, 143, 211, 0.32);
}

/* ============================================================
   Dashboard grid
   ============================================================ */

.dashboard-grid {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  gap: 12px;
  min-height: 0;
}

.left-rail,
.right-rail { padding: 14px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }

.right-rail { overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(80,156,255,.4) transparent; }
.right-rail::-webkit-scrollbar { width: 6px; }
.right-rail::-webkit-scrollbar-thumb { background: rgba(80,156,255,.4); border-radius: 3px; }

.center-area {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
  min-width: 0;
  min-height: 0;
}

/* ============================================================
   Panel head (left + right + center)
   ============================================================ */

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-head strong { font-size: 14px; font-weight: 800; color: var(--text); }
.panel-head em { font-style: normal; font-size: 11px; color: var(--muted); }

/* ============================================================
   Left rail: 分身节点
   ============================================================ */

.clones-list {
  display: grid;
  gap: 8px;
  min-height: 0;
}

.clone-card {
  --clone-color: var(--brand);
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(14, 143, 211, 0.16);
  box-shadow: 0 6px 18px rgba(20, 34, 51, 0.05);
  cursor: pointer;
  transition: transform 0.18s var(--ease-out), border-color 0.18s var(--ease-out), box-shadow 0.18s var(--ease-out), background 0.18s var(--ease-out);
  overflow: hidden;
  text-align: left;
}
.clone-card::before {
  content: '';
  position: absolute;
}
.clone-card > .clone-icon { width: 26px; height: 26px; color: var(--clone-color); }
.clone-card .clone-info { display: grid; gap: 3px; min-width: 0; }
.clone-card .clone-name { font-size: 13px; font-weight: 800; color: var(--text); }
.clone-card .clone-status-row { display: flex; align-items: center; gap: 5px; font-size: 10px; color: var(--muted); }
.clone-card .clone-status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--clone-color); box-shadow: 0 0 6px var(--clone-color); animation: dotPulse 2s ease-in-out infinite; }
.clone-card .clone-skill-name {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--muted);
  align-self: center;
}

.clone-card:hover { transform: translateX(2px); border-color: color-mix(in srgb, var(--clone-color) 50%, transparent); }
.clone-card.is-active {
  background: linear-gradient(135deg, color-mix(in srgb, var(--clone-color) 18%, white), color-mix(in srgb, var(--clone-color) 6%, white));
  border-color: color-mix(in srgb, var(--clone-color) 60%, transparent);
  box-shadow: 0 12px 28px color-mix(in srgb, var(--clone-color) 24%, transparent);
}
.clone-card.is-active .clone-name { color: var(--clone-color); }

.clones-summary {
  margin-top: auto;
  padding: 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(244, 249, 255, 0.9), rgba(255, 255, 255, 0.7));
  border: 1px solid var(--line);
}
.cs-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 11px;
  color: var(--muted);
  border-bottom: 1px dashed rgba(14, 143, 211, 0.12);
}
.cs-row:last-child { border-bottom: 0; }
.cs-row b { color: var(--text); font-weight: 800; font-variant-numeric: tabular-nums; }

/* ============================================================
   Center canvas
   ============================================================ */

.canvas-panel { padding: 0; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }

.canvas-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 18px 10px;
}
.canvas-head h2 { margin: 0; font-size: 18px; font-weight: 800; }
.canvas-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.canvas-tools { display: flex; align-items: center; gap: 6px; }
.tool-btn {
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(14, 143, 211, 0.08);
  color: var(--text-2);
  border: 1px solid rgba(14, 143, 211, 0.15);
  font-size: 12px;
  font-weight: 700;
}
.tool-btn:hover { background: rgba(14, 143, 211, 0.16); }
.btn-demo {
  height: 30px;
  padding: 0 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--purple), var(--violet));
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(129, 92, 255, 0.28);
}
.btn-demo:hover { filter: brightness(1.06); }

.orchestration-canvas {
  position: relative;
  flex: 1;
  min-height: 520px;
  margin: 0 14px 14px;
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 46%, rgba(26, 195, 255, 0.24), transparent 24%),
    radial-gradient(circle at 52% 56%, rgba(129, 92, 255, 0.14), transparent 36%),
    linear-gradient(145deg, var(--dark) 0%, var(--dark-2) 48%, var(--dark-3) 100%);
  box-shadow: var(--shadow-canvas);
}

.canvas-grid {
  position: absolute;
  inset: 0;
  opacity: 0.5;
  background:
    linear-gradient(rgba(66, 176, 255, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(66, 176, 255, 0.12) 1px, transparent 1px);
  background-size: 54px 54px;
  transform: perspective(780px) rotateX(61deg) translateY(60px) scale(1.35);
  transform-origin: center bottom;
}

.canvas-hud {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 50%, transparent 0 16%, rgba(53, 169, 255, 0.16) 16.2% 16.6%, transparent 17%),
    radial-gradient(circle at 50% 50%, transparent 0 29%, rgba(53, 169, 255, 0.14) 29.2% 29.5%, transparent 30%),
    radial-gradient(circle at 50% 50%, transparent 0 43%, rgba(53, 169, 255, 0.08) 43.2% 43.6%, transparent 44%);
  animation: slowRotate 36s linear infinite;
  pointer-events: none;
}

.flow-svg {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.flow-path {
  fill: none;
  stroke: url(#flowLine);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-dasharray: 10 12;
  filter: url(#lineGlow);
  opacity: 0.78;
  animation: dashFlow 2.6s linear infinite;
}
.flow-path.is-active { opacity: 1; stroke-width: 3; }

.packet { fill: #78f7ff; filter: drop-shadow(0 0 8px rgba(78, 222, 255, 0.95)); opacity: 0.95; }

/* ============================================================
   5 屏子系统
   ============================================================ */

.screen-frame {
  --accent: var(--brand);
  position: absolute;
  z-index: 5;
  width: 280px;
  transition: transform 0.4s var(--ease-spring), filter 0.4s var(--ease-out);
}

.screen-bezel {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(132, 211, 255, 0.55);
  background: #04101F;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.14) inset,
    0 0 0 4px rgba(132, 211, 255, 0.06),
    0 12px 28px rgba(0, 0, 0, 0.6),
    0 0 22px rgba(110, 217, 255, 0.18);
}

.screen-img {
  height: 148px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  /* 新截图本身就黑底监控界面，提亮+提饱和让仪表盘元素可读 */
  filter: brightness(1.18) contrast(1.08) saturate(1.18);
  transition: filter 0.3s var(--ease-out);
}

.screen-frame.is-active .screen-img { filter: brightness(1.05) contrast(1.1); }

.screen-overlay {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  font-size: 10px;
}

.screen-status {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0, 178, 122, 0.78);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.04em;
  backdrop-filter: blur(4px);
}
.screen-status.good { background: rgba(0, 178, 122, 0.78); }
.screen-status.warn { background: rgba(229, 103, 58, 0.85); }

.screen-tag {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(7, 26, 50, 0.78);
  color: #dff8ff;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  backdrop-filter: blur(4px);
}

.screen-meta {
  position: absolute;
  top: 36px;
  right: 8px;
  display: grid;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
}
.screen-meta span {
  display: grid;
  grid-template-columns: auto auto;
  gap: 4px;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(7, 26, 50, 0.78);
  color: #bfe7ff;
  backdrop-filter: blur(4px);
}
.screen-meta i { font-style: normal; color: #7eb6d4; }
.screen-meta b { color: #fff; font-weight: 800; }

.screen-foot {
  padding: 8px 12px 10px;
  background: linear-gradient(180deg, rgba(7, 26, 50, 0.95), rgba(7, 26, 50, 0.85));
  border-top: 1px solid rgba(110, 217, 255, 0.16);
}
.screen-foot strong {
  display: block;
  color: #eafaff;
  font-size: 13px;
  font-weight: 800;
}
.screen-foot em {
  display: block;
  margin-top: 2px;
  color: #8eb4cb;
  font-style: normal;
  font-size: 11px;
}

/* AI 焦点框（active 状态） */
.screen-frame.is-active .screen-bezel {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--accent) 50%, transparent),
    0 0 38px color-mix(in srgb, var(--accent) 65%, transparent),
    0 16px 36px rgba(0, 0, 0, 0.5);
}
.screen-frame.is-active {
  transform: translateY(-6px) scale(1.02);
  z-index: 7;
}

/* 屏幕顶部加一条高光线，模拟显示器 */
.screen-bezel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(151, 238, 255, 0.6), transparent);
  z-index: 2;
  pointer-events: none;
}

/* 5 个屏的位置 (围绕中枢呈五边形分布) */
.screen-frame[data-node="ba"]   { --accent: #00E5FF; left: 50%; top: 0;    transform: translateX(-50%); }
.screen-frame[data-node="dcim"] { --accent: #FF7A00; left: 1%;  top: 25%; }
.screen-frame[data-node="cctv"] { --accent: #3B82F6; right: 1%; top: 30%; }
.screen-frame[data-node="fire"] { --accent: #FF2E4F; left: 1%;  bottom: 6%; }
.screen-frame[data-node="bms"]  { --accent: #10B9A0; right: 1%; top: 8%;  }

.screen-frame[data-node="ba"].is-active   { transform: translateX(-50%) translateY(-6px) scale(1.02); }

/* ============================================================
   Token Matrix 中枢（主分身）
   ============================================================ */

.agent-core {
  position: absolute;
  z-index: 8;
  left: 50%;
  top: 50%;
  width: 200px;
  height: 200px;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  text-align: center;
  color: #eafaff;
  pointer-events: none;
}

.core-rings,
.core-rings::before,
.core-rings::after {
  position: absolute;
  content: '';
  border-radius: 50%;
  border: 1px solid rgba(89, 229, 255, 0.36);
  box-shadow: 0 0 28px rgba(55, 207, 255, 0.32), inset 0 0 24px rgba(55, 207, 255, 0.14);
}
.core-rings { inset: 0; animation: rotateCore 14s linear infinite; }
.core-rings::before { inset: 18px; border-style: dashed; }
.core-rings::after { inset: 36px; border-color: rgba(129, 92, 255, 0.5); }

.core-avatar {
  position: relative;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  border: 2px solid rgba(151, 238, 255, 0.85);
  box-shadow:
    0 0 32px rgba(47, 212, 255, 0.72),
    0 0 64px rgba(129, 92, 255, 0.42),
    inset 0 0 22px rgba(151, 238, 255, 0.18);
  display: grid;
  place-items: center;
  overflow: hidden;
  animation: agentFloat 6s ease-in-out infinite;
  background: rgba(6, 21, 45, 0.55);
}
.core-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* 只露头部：图片比例 1122x1402，head 在上 0~30% 区 */
  object-position: center 8%;
  transform: scale(1.15);
  mix-blend-mode: screen;
  opacity: 0.96;
  filter: contrast(1.06) saturate(1.08);
}
.core-halo {
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  background: conic-gradient(from 0deg,
    rgba(47, 212, 255, 0) 0deg,
    rgba(47, 212, 255, 0.55) 60deg,
    rgba(129, 92, 255, 0.55) 180deg,
    rgba(47, 212, 255, 0) 240deg,
    rgba(129, 92, 255, 0.45) 320deg,
    rgba(47, 212, 255, 0) 360deg);
  filter: blur(14px);
  opacity: 0.7;
  animation: rotateCore 12s linear infinite;
  pointer-events: none;
  z-index: -1;
  -webkit-mask-image: radial-gradient(circle, transparent 56%, #000 60%, #000 76%, transparent 82%);
          mask-image: radial-gradient(circle, transparent 56%, #000 60%, #000 76%, transparent 82%);
}

.agent-core strong {
  position: absolute;
  bottom: 28px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.agent-core em {
  position: absolute;
  bottom: 12px;
  font-size: 11px;
  font-style: normal;
  color: #9aeaff;
  letter-spacing: 0.04em;
}
.agent-core .core-id {
  position: absolute;
  bottom: -4px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: #6cd0f4;
  background: rgba(7, 26, 50, 0.78);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(110, 217, 255, 0.28);
  letter-spacing: 0.06em;
}

/* ============================================================
   Mini widgets (画布角落)
   ============================================================ */

.mini-widget {
  position: absolute;
  z-index: 9;
  border-radius: 14px;
  border: 1px solid rgba(132, 211, 255, 0.22);
  background: rgba(5, 22, 43, 0.58);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 14px 30px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(14px);
  color: #dff8ff;
  padding: 10px 12px;
}
.mini-widget header { color: #d7f7ff; font-weight: 800; font-size: 11px; margin-bottom: 6px; letter-spacing: 0.02em; }
.energy-widget  { left: 12px; top: 12px; width: 152px; }
.posture-widget { right: 12px; bottom: 8px; width: 162px; }

.widget-row { display: flex; align-items: center; justify-content: space-between; font-size: 10px; color: #94bcd1; padding: 3px 0; }
.widget-row strong { color: #d6fbff; font-size: 14px; font-variant-numeric: tabular-nums; }
.mini-chart { width: 100%; height: 28px; overflow: visible; }
.mini-chart path { fill: none; stroke: #4aaaff; stroke-width: 2.6; stroke-linecap: round; filter: drop-shadow(0 0 5px rgba(72, 183, 255, 0.75)); }
.mini-chart.green path { stroke: var(--green); }

.posture-widget p { display: flex; justify-content: space-between; align-items: center; margin: 6px 0; color: #a6c9de; font-size: 11px; }
.posture-widget b { color: #8efbd0; }

.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot.good, .dot.green { background: var(--green); box-shadow: 0 0 10px rgba(0, 178, 122, 0.9); }
.dot.warn { background: var(--orange); box-shadow: 0 0 10px rgba(229, 103, 58, 0.9); }
.dot.info, .dot.blue { background: var(--cyan); box-shadow: 0 0 10px rgba(37, 217, 255, 0.9); }
.dot.purple { background: var(--purple); box-shadow: 0 0 10px rgba(129, 92, 255, 0.9); }

.kg-widget { display: none; }
.flow-legend { display: none; }

/* ============================================================
   Skill 流水线 (6 阶段)
   ============================================================ */

.pipeline-panel {
  padding: 14px 16px;
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 10px;
}

.pipeline-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pipeline-title { display: flex; align-items: center; gap: 10px; }
.pipeline-icon { font-size: 16px; }
.pipeline-title > span:nth-child(2) { font-size: 15px; font-weight: 800; color: var(--text); }
.pipeline-skill {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  padding: 4px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(129, 92, 255, 0.16), rgba(107, 91, 208, 0.16));
  border: 1px solid rgba(129, 92, 255, 0.32);
}
.pipeline-tag {
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  color: #fff;
  background: var(--accent, var(--brand));
}

.pipeline-meta { font-size: 12px; color: var(--muted); }
.pipeline-meta strong { color: var(--text); font-family: var(--font-mono); margin-left: 4px; }
.pipe-sep { margin: 0 8px; color: var(--line-strong); }

.pipeline-canvas {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
}

.stage-block {
  --stage-color: var(--muted);
  position: relative;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(244, 249, 255, 0.78));
  border: 1px solid rgba(14, 143, 211, 0.16);
  box-shadow: 0 8px 18px rgba(20, 34, 51, 0.05);
  min-height: 84px;
}
.stage-block::after {
  content: '';
  position: absolute;
  right: -8px;
  top: 50%;
  width: 8px;
  height: 2px;
  background: linear-gradient(90deg, var(--stage-color), transparent);
  transform: translateY(-50%);
  opacity: 0.6;
}
.stage-block:last-child::after { display: none; }

.stage-head {
  display: flex;
  align-items: center;
  gap: 6px;
}
.stage-num {
  width: 22px;
  height: 22px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 11px;
  background: rgba(14, 143, 211, 0.1);
  color: #2476d2;
}
.stage-name { font-size: 12px; font-weight: 800; color: var(--text); }
.stage-state {
  margin-left: auto;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(122, 138, 156, 0.16);
  color: var(--muted);
}
.stage-state.done { background: rgba(0, 178, 122, 0.14); color: #0a8c61; }
.stage-state.run   { background: rgba(129, 92, 255, 0.16); color: #6d4eff; }
.stage-state.wait  { background: rgba(122, 138, 156, 0.16); color: var(--muted); }
.stage-state.fail  { background: rgba(217, 54, 74, 0.16); color: var(--red); }

.stage-meta { font-size: 10px; color: var(--muted); font-family: var(--font-mono); }
.stage-progress { position: relative; height: 4px; border-radius: 999px; background: rgba(14, 143, 211, 0.12); overflow: hidden; }
.stage-progress i {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, var(--stage-color), color-mix(in srgb, var(--stage-color) 60%, white));
  width: 0%;
  transition: width 0.4s var(--ease-out);
}

.stage-block.is-done .stage-num { background: rgba(0, 178, 122, 0.18); color: #0a8c61; }
.stage-block.is-done { --stage-color: var(--green); }
.stage-block.is-active {
  --stage-color: var(--purple);
  border-color: rgba(129, 92, 255, 0.42);
  box-shadow: 0 0 0 3px rgba(129, 92, 255, 0.12), 0 14px 26px rgba(129, 92, 255, 0.18);
}
.stage-block.is-active .stage-num { background: rgba(129, 92, 255, 0.18); color: var(--purple); }
.stage-block.is-active .stage-progress i { animation: stageRun 1.6s ease-in-out infinite; }
.stage-block.is-wait { --stage-color: rgba(122, 138, 156, 0.5); opacity: 0.78; }

/* —— 详情区 —— */
.pipeline-detail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(244, 249, 255, 0.9), rgba(255, 255, 255, 0.7));
  border: 1px solid var(--line);
  font-size: 12px;
}
.pd-cell { display: grid; gap: 4px; min-width: 0; }
.pd-cell label { font-size: 10px; color: var(--muted); letter-spacing: 0.04em; }
.pd-cell .pd-val {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(14, 143, 211, 0.06);
  border: 1px solid rgba(14, 143, 211, 0.12);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pd-cell.model .pd-val { color: var(--purple); background: rgba(129, 92, 255, 0.08); border-color: rgba(129, 92, 255, 0.18); }

/* ============================================================
   Right rail: 主分身
   ============================================================ */

.right-rail .panel-head em { color: var(--purple); font-weight: 700; }

.main-avatar-wrap {
  position: relative;
  height: 260px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(180deg, #eaf2ff 0%, #f4f8ff 60%, #dde9ff 100%);
  border: 1px solid rgba(80, 156, 255, 0.18);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
.main-avatar-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 60%, rgba(102, 145, 220, 0.18) 100%);
  pointer-events: none;
  z-index: 1;
}
.main-avatar-img {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  /* 全身像：从头顶到膝盖以下都看到，比例 1122x1402 */
  object-fit: cover;
  object-position: center 35%;
  pointer-events: none;
  animation: agentFloat 6s ease-in-out infinite;
}

/* 粒子 */
.avatar-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.avatar-particles span {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: radial-gradient(circle, #6ff9ff 0%, rgba(111, 249, 255, 0) 70%);
  box-shadow: 0 0 8px rgba(111, 249, 255, 0.9);
  animation: particleDrift 9s ease-in-out infinite;
}
.avatar-particles span:nth-child(1) { top: 14%; left: 18%; animation-delay: -0.4s; }
.avatar-particles span:nth-child(2) { top: 28%; right: 14%; animation-delay: -1.6s; }
.avatar-particles span:nth-child(3) { top: 56%; left: 12%; animation-delay: -3.2s; }
.avatar-particles span:nth-child(4) { top: 70%; right: 20%; animation-delay: -2.4s; }
.avatar-particles span:nth-child(5) { top: 42%; left: 6%; animation-delay: -5.2s; width: 3px; height: 3px; }
.avatar-particles span:nth-child(6) { top: 86%; left: 38%; animation-delay: -6.8s; width: 3px; height: 3px; }
.avatar-particles span:nth-child(7) { top: 12%; right: 30%; animation-delay: -7.6s; width: 5px; height: 5px; }
.avatar-particles span:nth-child(8) { top: 60%; right: 8%; animation-delay: -4.4s; width: 3px; height: 3px; }

/* 数据光柱 */
.avatar-data-stream {
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 24%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(111, 249, 255, 0.7), transparent);
  opacity: 0.6;
  pointer-events: none;
  z-index: 1;
}
.avatar-data-stream i {
  position: absolute;
  top: 0;
  left: -1px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #6ff9ff;
  box-shadow: 0 0 8px #6ff9ff;
  animation: dataStreamDown 2.4s ease-in infinite;
  animation-delay: var(--d, 0s);
}

.avatar-pulse {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(14, 143, 211, 0.32) 0%, transparent 60%);
  opacity: 0;
  pointer-events: none;
  z-index: 4;
}
.avatar-pulse.active { animation: avatarPulse 1.3s var(--ease-out); }

.avatar-placeholder-tag {
  position: absolute;
  bottom: 10px;
  right: 12px;
  z-index: 5;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
}

.ai-main-info {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(74, 139, 220, 0.16);
  box-shadow: 0 8px 22px rgba(43, 94, 160, 0.06);
}
.info-row { display: grid; grid-template-columns: 70px 1fr; gap: 8px; align-items: center; font-size: 11px; }
.info-label { color: var(--muted); }
.info-val { color: var(--text); font-weight: 600; }
.info-val.mono { font-family: var(--font-mono); font-size: 11px; color: var(--text-2); }
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 5px;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: dotPulse 2s ease-in-out infinite;
}
.status-dot.running { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-dot.warn { background: var(--orange); box-shadow: 0 0 8px var(--orange); }

.info-progress {
  position: relative;
  height: 18px;
  border-radius: 999px;
  background: rgba(14, 143, 211, 0.1);
  overflow: hidden;
}
.info-progress-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, var(--brand), var(--purple));
  transition: width 0.5s var(--ease-out);
}
.info-progress-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  color: var(--text);
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.7);
}

.ai-mini-stats {
  display: grid;
  gap: 3px;
  padding: 8px 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(244, 249, 255, 0.9), rgba(255, 255, 255, 0.7));
  border: 1px solid var(--line);
}
.ms-row {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
  padding: 2px 0;
}
.ms-row b { color: var(--text); font-family: var(--font-mono); }

/* ============================================================
   Right rail: 工具矩阵 / SOP 矩阵 / 算法汇总
   ============================================================ */

.tools-matrix {
  border-radius: 12px;
  padding: 8px 10px;
  background: linear-gradient(180deg, rgba(244, 249, 255, 0.92), rgba(255, 255, 255, 0.74));
  border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(20, 34, 51, 0.05);
}

.tm-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.tm-section-head strong {
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
}
.tm-section-head em {
  font-style: normal;
  font-size: 9px;
  color: var(--muted);
}

.tm-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 10px;
}
.tm-table th,
.tm-table td {
  padding: 3px 2px;
  text-align: center;
  border-bottom: 1px dashed rgba(14, 143, 211, 0.12);
}
.tm-table thead th {
  font-weight: 700;
  color: var(--muted);
  background: rgba(14, 143, 211, 0.06);
  font-size: 10px;
  letter-spacing: 0.04em;
}
.tm-table thead th:first-child { background: transparent; }
.tm-table tbody td:first-child {
  text-align: left;
  color: var(--text);
  font-weight: 800;
  font-size: 10px;
}
.tm-table tbody td:first-child::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
  background: var(--row-color, var(--brand));
  box-shadow: 0 0 6px var(--row-color, var(--brand));
}
.tm-table tbody td {
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.tm-table tbody tr.active td { background: rgba(129, 92, 255, 0.08); }
.tm-table tbody tr.active td:not(:first-child) { color: var(--purple); font-weight: 800; }
.tm-table tbody tr:last-child td { border-bottom: 0; }
.tm-table tfoot td {
  font-weight: 800;
  color: var(--text);
  background: rgba(14, 143, 211, 0.04);
  border-top: 1px solid var(--line);
  border-bottom: 0;
}
.tm-table tfoot td:first-child { color: var(--muted); font-weight: 700; }

.algo-summary {
  border-radius: 12px;
  padding: 8px 10px;
  background: linear-gradient(180deg, rgba(244, 249, 255, 0.92), rgba(255, 255, 255, 0.74));
  border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(20, 34, 51, 0.05);
}
.algo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
  margin-top: 4px;
}
.algo-tile {
  display: grid;
  gap: 0px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(14, 143, 211, 0.14);
  text-align: left;
  position: relative;
  overflow: hidden;
}
.algo-tile::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--purple);
  opacity: 0.6;
}
.algo-tile b {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
}
.algo-tile em {
  font-style: normal;
  font-size: 10px;
  color: var(--muted);
}

/* ============================================================
   Activity stream
   ============================================================ */

.activity-bar {
  padding: 10px 14px 12px;
  display: grid;
  grid-template-rows: auto auto;
  gap: 6px;
  min-height: 0;
}

.activity-head { display: flex; justify-content: space-between; align-items: center; }
.activity-head strong { font-size: 13px; font-weight: 800; color: var(--text); }
.activity-head em { font-style: normal; font-size: 11px; color: var(--muted); }

.activity-list {
  display: grid;
  gap: 4px;
  max-height: 110px;
  overflow: hidden;
  position: relative;
}

.activity-item {
  display: grid;
  grid-template-columns: 78px 96px 1fr 90px;
  align-items: center;
  gap: 10px;
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(14, 143, 211, 0.1);
  font-size: 12px;
  animation: activityIn 0.4s var(--ease-out);
}

.activity-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  background: rgba(14, 143, 211, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  text-align: center;
}
.activity-agent {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--agent-color, var(--text-2));
  padding-left: 4px;
  border-left: 3px solid var(--agent-color, var(--brand));
}
.activity-text { color: var(--text); font-size: 12px; }
.activity-stage {
  font-size: 11px;
  font-weight: 800;
  text-align: right;
  padding: 2px 8px;
  border-radius: 999px;
}
.activity-stage.run   { background: rgba(129, 92, 255, 0.14); color: var(--purple); }
.activity-stage.done  { background: rgba(0, 178, 122, 0.14);  color: #0a8c61; }
.activity-stage.wait  { background: rgba(122, 138, 156, 0.16); color: var(--muted); }
.activity-stage.fail  { background: rgba(217, 54, 74, 0.16);   color: var(--red); }

/* ============================================================
   Animations
   ============================================================ */

@keyframes slowRotate   { to { transform: rotate(360deg); } }
@keyframes rotateCore   { to { transform: rotate(360deg); } }
@keyframes dashFlow     { to { stroke-dashoffset: -44; } }
@keyframes nodePulse    { 0%, 100% { opacity: 0.7; transform: scale(1); } 50% { opacity: 1; transform: scale(1.12); } }
@keyframes agentFloat   { 0%, 100% { transform: translateY(4px); } 50% { transform: translateY(-6px); } }
@keyframes dotPulse     { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
@keyframes avatarPulse  { 0% { opacity: 0; transform: scale(0.6); } 50% { opacity: 0.85; } 100% { opacity: 0; transform: scale(1.4); } }
@keyframes stageRun     { 0% { width: 18%; } 50% { width: 92%; } 100% { width: 18%; } }
@keyframes activityIn   { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes breathGlow   { 0%, 100% { opacity: 0.55; transform: scale(0.92); } 50% { opacity: 1; transform: scale(1.08); } }
@keyframes particleDrift {
  0%   { transform: translate(0, 0) scale(1); opacity: 0.4; }
  25%  { transform: translate(8px, -10px) scale(1.1); opacity: 0.85; }
  50%  { transform: translate(-4px, -16px) scale(0.9); opacity: 0.6; }
  75%  { transform: translate(6px, -8px) scale(1.05); opacity: 0.85; }
  100% { transform: translate(0, 0) scale(1); opacity: 0.4; }
}
@keyframes dataStreamDown {
  0%   { top: 0%; opacity: 0; }
  20%  { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1500px) {
  .tm-topbar { grid-template-columns: 240px 1fr; height: auto; padding: 10px 14px; }
  .topbar-right { grid-column: 1 / -1; justify-content: space-between; }
  .dashboard-grid { grid-template-columns: 260px minmax(0, 1fr); }
  .right-rail { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; }
  .right-rail .panel-head { flex: 1 1 100%; }
  .main-avatar-wrap { flex: 1 1 280px; min-width: 240px; height: 220px; }
  .ai-main-info, .ai-mini-stats { flex: 1 1 280px; }
}

@media (max-width: 1100px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .clones-bar { grid-template-columns: repeat(3, 1fr); }
  .left-rail .clones-list { grid-template-columns: repeat(2, 1fr); }
  .pipeline-canvas { grid-template-columns: repeat(3, 1fr); }
  .pipeline-detail { grid-template-columns: 1fr; }
  .screen-frame { width: 220px; }
}