/* =============================================================
   声谱 Studio · 前台视觉系统
   深色工作台：近黑画布 + 磨砂卡片 + 单一信号色 + 节点类型功能色
   ============================================================= */

:root {
  /* 界面中性色 */
  --bg-canvas: #0F0F11;
  --bg-panel: #1A1A1A;
  --bg-card: #242424;
  --bg-elev: #2A2A2E;
  --bg-hover: #2E2E33;
  --border: #262626;
  --border-soft: #3D3D3D;
  --border-line: #1F1F23;

  /* 文字层级 */
  --t1: #FFFFFF;
  --t2: #E5E5E5;
  --t3: #B4B4B8;
  --t4: #A0A0A6;
  --t5: #8A8A8F;
  --t6: #6B6B70;
  --t7: #5A5A60;

  /* 品牌与语义 */
  --accent: #9EFF00;
  --accent-ink: #0F0F11;
  --accent-soft: rgba(158, 255, 0, .16);
  --success: #22C55E;
  --warn: #F59E0B;
  --danger: #EF4444;
  --violet: #7C5CFF;

  /* 节点类型色 */
  --n-text: #60A5FA;
  --n-audio: #F59E0B;
  --n-tts: #A78BFA;
  --n-role: #F472B6;
  --n-voice: #22D3EE;
  --n-story: #FBBF24;

  /* 圆角 */
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 12px;
  --r-xl: 14px;
  --r-2xl: 20px;
  --r-pill: 999px;

  /* 阴影 */
  --sh-1: 0 2px 8px rgba(0, 0, 0, .35);
  --sh-2: 0 8px 18px -4px rgba(0, 0, 0, .45);
  --sh-3: 0 12px 28px -6px rgba(0, 0, 0, .55);
  --glow-accent: 0 0 18px rgba(158, 255, 0, .25);

  /* 字体 */
  --font-sans: "Noto Sans SC", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --font-display: "Inter Tight", "Inter", "Segoe UI", var(--font-sans);
  --font-mono: "JetBrains Mono", "SFMono-Regular", "Cascadia Mono", Consolas, monospace;

  --topbar-h: 52px;
  --statusbar-h: 30px;
  --sidebar-w: 240px;
  --inspector-w: 300px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.6;
  color: var(--t2);
  background: var(--bg-canvas);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
::selection { background: rgba(158, 255, 0, .28); }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #444; }

/* =============================================================
   通用原子
   ============================================================= */
.sp-mono { font-family: var(--font-mono); }
.sp-row { display: flex; align-items: center; }
.sp-gap6 { gap: 6px; }
.sp-gap8 { gap: 8px; }
.sp-grow { flex: 1 1 auto; min-width: 0; }
.sp-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-hidden { display: none !important; }

.sp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--t2);
  font-size: 12px;
  font-weight: 500;
  transition: background .2s, transform .2s, border-color .2s;
  white-space: nowrap;
}
.sp-btn:hover  { background: var(--bg-elev); }
.sp-btn:active { transform: scale(.96); }

.sp-btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}
.sp-btn--primary:hover { background: #AEFF33; }

.sp-btn--ghost { background: transparent; border-color: transparent; color: var(--t4); }
.sp-btn--ghost:hover { background: var(--bg-card); color: var(--t1); }

.sp-btn--danger { color: #FCA5A5; border-color: rgba(239, 68, 68, .35); }
.sp-btn--danger:hover { background: rgba(239, 68, 68, .12); }

.sp-btn--block { width: 100%; }
.sp-btn[disabled] { opacity: .45; pointer-events: none; }

.sp-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--bg-elev);
  color: var(--t4);
  font-size: 10px;
  letter-spacing: .3px;
}
.sp-chip--accent { background: var(--accent-soft); color: var(--accent); }
.sp-chip--ok     { background: rgba(34, 197, 94, .16); color: var(--success); }
.sp-chip--warn   { background: rgba(245, 158, 11, .16); color: var(--warn); }
.sp-chip--danger { background: rgba(239, 68, 68, .16); color: #FCA5A5; }

.sp-dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }

.sp-input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  outline: none;
  transition: border-color .2s;
}
.sp-input:focus { border-color: var(--accent); }
.sp-input::placeholder { color: var(--t7); }

textarea.sp-input { height: auto; padding: 10px; line-height: 1.7; resize: vertical; }

.sp-label { font-size: 10px; color: var(--t6); letter-spacing: .5px; }

.sp-select {
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border-radius: 7px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  outline: none;
}
.sp-select:focus { border-color: var(--accent); }
.sp-select option { background: #1A1A1A; }

/* Toast */
#sp-toasts {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9000;
  pointer-events: none;
}
.sp-toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 16px;
  border-radius: var(--r-pill);
  background: rgba(26, 26, 26, .96);
  border: 1px solid var(--border-soft);
  box-shadow: var(--sh-3);
  font-size: 12px;
  color: var(--t2);
  animation: sp-toast-in .24s ease;
  backdrop-filter: blur(12px);
}
.sp-toast--ok    { border-color: rgba(34, 197, 94, .4); }
.sp-toast--err   { border-color: rgba(239, 68, 68, .4); }
@keyframes sp-toast-in { from { opacity: 0; transform: translateY(10px); } }

/* =============================================================
   应用外壳
   ============================================================= */
.sp-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* --- 顶栏 --- */
.sp-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--topbar-h);
  padding: 0 20px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex: none;
}
.sp-brand { display: flex; align-items: center; gap: 8px; flex: none; }
.sp-brand__mark { width: 26px; height: 26px; border-radius: 8px; flex: none; }
.sp-brand__name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--t1);
  letter-spacing: .2px;
}
.sp-topbar__divider { width: 1px; height: 18px; background: var(--border-soft); flex: none; }

.sp-wf-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.sp-wf-title__name {
  font-size: 14px;
  font-weight: 500;
  color: var(--t2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 3px 7px;
  min-width: 60px;
  max-width: 320px;
  outline: none;
}
.sp-wf-title__name:hover { background: var(--bg-card); }
.sp-wf-title__name:focus { background: var(--bg-card); border-color: var(--accent); }

.sp-save-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--bg-card);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--t5);
  white-space: nowrap;
}
.sp-save-chip--saving { color: var(--accent); }
.sp-save-chip--error  { color: #FCA5A5; }

.sp-topbar__right { display: flex; align-items: center; gap: 12px; margin-left: auto; flex: none; }

.sp-avatars { display: flex; }
.sp-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
  color: #fff;
  border: 2px solid var(--bg-panel);
  margin-left: -4px;
  flex: none;
}
.sp-avatar:first-child { margin-left: 0; }

.sp-credits {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  white-space: nowrap;
}

/* --- 主体三栏 --- */
.sp-body { display: flex; flex: 1 1 auto; min-height: 0; }

/* --- 左侧栏 --- */
.sp-side {
  width: var(--sidebar-w);
  flex: none;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sp-side__inner {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 14px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.sp-workspace {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 42px;
  padding: 0 8px 0 10px;
  border-radius: var(--r-md);
  background: var(--bg-card);
  border: 1px solid #2E2E33;
  flex: none;
}
.sp-workspace__mark { width: 24px; height: 24px; border-radius: 7px; flex: none; }
.sp-workspace__name { flex: 1 1 auto; font-size: 12px; font-weight: 500; color: var(--t1); }
.sp-workspace__chev { flex: none; opacity: .8; }

.sp-newbtn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  border-radius: 9px;
  background: var(--bg-elev);
  border: 1px dashed #3D3D42;
  color: var(--t2);
  font-size: 12px;
  font-weight: 500;
  transition: border-color .2s, background .2s;
  flex: none;
}
.sp-newbtn:hover { border-color: var(--accent); background: #2E2E33; }

.sp-group-title {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1px;
  color: var(--t6);
  flex: none;
}

.sp-wf-list { display: flex; flex-direction: column; gap: 2px; flex: none; }
.sp-wf-item {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 10px 0 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background .18s;
  position: relative;
}
.sp-wf-item:hover { background: var(--bg-card); }
.sp-wf-item--active { background: var(--bg-card); }
.sp-wf-item--active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 11px;
  width: 2px;
  height: 14px;
  border-radius: 1px;
  background: var(--accent);
}
.sp-wf-item__name { flex: 1 1 auto; font-size: 12px; color: var(--t4); }
.sp-wf-item--active .sp-wf-item__name { color: var(--t1); font-weight: 500; }
.sp-wf-item__count { font-family: var(--font-mono); font-size: 10px; color: var(--t6); }
.sp-wf-item--active .sp-wf-item__count { color: var(--accent); }
.sp-wf-item__del {
  display: none;
  width: 18px; height: 18px;
  border-radius: 4px;
  align-items: center; justify-content: center;
  color: var(--t5);
}
.sp-wf-item:hover .sp-wf-item__del { display: flex; }
.sp-wf-item__del:hover { background: rgba(239, 68, 68, .18); color: #FCA5A5; }

.sp-nav { display: flex; flex-direction: column; gap: 2px; flex: none; }
.sp-nav__item {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 34px;
  padding: 0 10px 0 8px;
  border-radius: var(--r-sm);
  color: var(--t4);
  font-size: 12px;
  cursor: pointer;
  transition: background .18s, color .18s;
}
.sp-nav__item:hover { background: var(--bg-card); color: var(--t2); }
.sp-nav__count { margin-left: auto; font-family: var(--font-mono); font-size: 10px; color: var(--t6); }

.sp-side__spacer { flex: 1 1 auto; min-height: 8px; }

.sp-usercard {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 46px;
  padding: 0 8px;
  border-radius: var(--r-md);
  background: var(--bg-card);
  flex: none;
}
.sp-usercard__av {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #fff; font-weight: 500;
  flex: none;
}
.sp-usercard__info { flex: 1 1 auto; min-width: 0; }
.sp-usercard__name { font-size: 12px; font-weight: 500; color: var(--t1); }
.sp-usercard__role { font-size: 10px; color: var(--t6); }
.sp-usercard__out {
  flex: none;
  width: 24px; height: 24px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--t5);
}
.sp-usercard__out:hover { background: var(--bg-elev); color: var(--t2); }

/* --- 画布 --- */
.sp-stage {
  flex: 1 1 auto;
  position: relative;
  min-width: 0;
  background: var(--bg-canvas);
  overflow: hidden;
  cursor: grab;
}
.sp-stage--panning { cursor: grabbing; }
.sp-stage--connecting { cursor: crosshair; }

.sp-world {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
  will-change: transform;
}

.sp-grid {
  position: absolute;
  left: -2000px;
  top: -2000px;
  width: 6000px;
  height: 6000px;
  background-image:
    linear-gradient(to right, var(--border-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--border-line) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}

.sp-edges { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.sp-edge { pointer-events: stroke; cursor: pointer; }
.sp-edge__hit { stroke: transparent; stroke-width: 14; fill: none; }
.sp-edge__line {
  stroke: rgba(158, 255, 0, .5);
  stroke-width: 1.5;
  fill: none;
  transition: stroke .2s;
}
.sp-edge--idle .sp-edge__line { stroke: #3D3D3D; }
.sp-edge:hover .sp-edge__line,
.sp-edge--hot .sp-edge__line { stroke: var(--danger); stroke-width: 2; }
.sp-edge__dot { fill: var(--accent); }
.sp-edge--idle .sp-edge__dot { fill: #5A5A60; }

.sp-nodes { position: absolute; left: 0; top: 0; }

.sp-hint {
  position: absolute;
  left: 0; right: 0;
  bottom: 88px;
  text-align: center;
  font-size: 11px;
  color: var(--t6);
  pointer-events: none;
}

/* --- 节点卡片 --- */
.sp-node {
  position: absolute;
  border-radius: var(--r-xl);
  background: var(--bg-card);
  border: 1px solid #333338;
  box-shadow: var(--sh-2);
  overflow: hidden;
  user-select: none;
  transition: border-color .2s, box-shadow .2s;
}
.sp-node:hover { border-color: #3F3F45; }
.sp-node--active {
  border-color: var(--accent);
  box-shadow: var(--sh-3), var(--glow-accent);
}
.sp-node--running { border-color: var(--accent); }
.sp-node--error   { border-color: rgba(239, 68, 68, .7); }
.sp-node--dragging { box-shadow: var(--sh-3), 0 0 0 1px rgba(158, 255, 0, .3); z-index: 50; }

/* 右下角拉伸手柄：所有节点均支持框架拉申 */
.sp-node__resize {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 16px;
  height: 16px;
  z-index: 6;
  cursor: nwse-resize;
  touch-action: none;
  opacity: 0;
  transition: opacity .15s ease;
}
.sp-node__resize::after {
  content: "";
  position: absolute;
  right: 2px;
  bottom: 2px;
  border-style: solid;
  border-width: 0 0 9px 9px;
  border-color: transparent transparent var(--node-color) transparent;
  opacity: .85;
}
.sp-node:hover .sp-node__resize,
.sp-node--active .sp-node__resize { opacity: .9; }
/* 高度被显式设定时，节点变为纵向 flex 容器，正文区可滚动 */
.sp-node--sized { display: flex; flex-direction: column; }
.sp-node--sized .sp-node__body { flex: 1 1 auto; min-height: 0; overflow: auto; }

.sp-node--text  { --node-color: var(--n-text); }
.sp-node--audio { --node-color: var(--n-audio); }
.sp-node--tts   { --node-color: var(--n-tts); }
.sp-node--role  { --node-color: var(--n-role); }
.sp-node--voice { --node-color: var(--n-voice); }
.sp-node--story { --node-color: var(--n-story); }

.sp-node__head {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 10px 0 12px;
  cursor: grab;
}
.sp-node--tts .sp-node__head { height: 38px; }
.sp-node__icon { flex: none; width: 14px; height: 14px; }
.sp-node__title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--t1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sp-node--tts .sp-node__title { font-weight: 600; }
.sp-node__grip { flex: none; opacity: .9; }
.sp-node__divider { height: 1px; background: var(--border); }
.sp-node__body {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 10px 12px;
}
.sp-node--tts .sp-node__body { padding: 11px 12px; }

.sp-node__para {
  font-size: 12px;
  line-height: 19px;
  color: var(--t3);
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 132px;
  overflow: hidden;
}
.sp-node__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--t5);
}
.sp-node__meta-spacer { flex: 1 1 auto; }

.sp-typetag {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .8px;
  background: color-mix(in srgb, var(--node-color) 16%, transparent);
  color: var(--node-color);
}

.sp-wave { display: flex; align-items: flex-end; gap: 3px; height: 44px; }
.sp-node--audio .sp-wave { height: 44px; }
.sp-wave__bar {
  flex: 1 1 auto;
  min-width: 2px;
  border-radius: 1.5px;
  background: var(--node-color);
  opacity: .6;
}

.sp-audiorow { display: flex; align-items: center; gap: 8px; }
.sp-playbtn { flex: none; width: 24px; height: 24px; }
.sp-audiorow__time { flex: 1 1 auto; font-family: var(--font-mono); font-size: 10px; font-weight: 500; color: var(--t2); }
.sp-audiorow__fmt  { font-family: var(--font-mono); font-size: 10px; color: var(--t6); }

/* ---------- 角色设定节点 ---------- */
.sp-rolecard { display: flex; align-items: center; gap: 9px; }
.sp-roleavatar {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
}
.sp-roleinfo { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.sp-rolename {
  font-size: 13px;
  font-weight: 600;
  color: var(--t1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sp-roleid {
  font-size: 10px;
  color: var(--t5);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sp-traits { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.sp-trait {
  display: inline-flex;
  align-items: center;
  height: 19px;
  padding: 0 7px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 500;
  background: color-mix(in srgb, var(--n-role) 15%, transparent);
  color: #F9A8D4;
}

.sp-node__para--role { max-height: 38px; }

.sp-rolequote {
  margin: 0;
  padding-left: 8px;
  border-left: 2px solid color-mix(in srgb, var(--n-role) 45%, transparent);
  font-size: 11px;
  line-height: 17px;
  color: var(--t4);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 属性面板 · 语气风格多选 */
.sp-traitrow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sp-traitbtn {
  height: 24px;
  padding: 0 9px;
  border-radius: 6px;
  background: var(--bg-elev);
  color: var(--t4);
  font-size: 11px;
  transition: background .2s, color .2s;
}
.sp-traitbtn:hover { background: #34343A; }
.sp-traitbtn--on {
  background: color-mix(in srgb, var(--n-role) 20%, transparent);
  color: #F9A8D4;
  font-weight: 500;
}

/* ---------- 音色设计节点 ---------- */
.sp-voicecard { display: flex; align-items: center; gap: 9px; }

.sp-vwave {
  flex: none;
  width: 40px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 5px;
  border-radius: 7px;
  background: color-mix(in srgb, var(--n-voice) 13%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--n-voice) 26%, transparent);
}
.sp-vwave__bar {
  width: 2px;
  border-radius: 1px;
  background: var(--n-voice);
  opacity: .85;
}

.sp-voiceinfo { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.sp-voicename {
  font-size: 13px;
  font-weight: 600;
  color: var(--t1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sp-voiceid {
  font-size: 10px;
  color: var(--t5);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sp-trait--voice {
  background: color-mix(in srgb, var(--n-voice) 15%, transparent);
  color: #67E8F9;
}

.sp-vspec {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--t5);
}
.sp-vspec__pitch { color: #67E8F9; font-weight: 600; }
.sp-vspec__div { flex: none; width: 1px; height: 9px; background: var(--border-soft); }
.sp-vpace {
  position: relative;
  flex: 0 0 44px;
  height: 3px;
  border-radius: 2px;
  background: var(--bg-hover);
  overflow: hidden;
}
.sp-vpace__fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 2px; background: var(--n-voice); }
.sp-vspec__val { margin-left: auto; color: var(--t4); }

.sp-node__para--voice { max-height: 38px; }

/* ---------- 属性面板 · 单选项 / 提示行 ---------- */
.sp-pickrow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sp-pickbtn {
  height: 24px;
  padding: 0 10px;
  border-radius: 6px;
  background: var(--bg-elev);
  color: var(--t4);
  font-size: 11px;
  transition: background .2s, color .2s;
}
.sp-pickbtn:hover { background: #34343A; }
.sp-pickbtn--on {
  background: color-mix(in srgb, var(--n-voice) 20%, transparent);
  color: #67E8F9;
  font-weight: 500;
}

/* 角色节点内置的「音色画像」迷你条：用粉色调，与青色 voice 节点区分 */
.sp-vspec--role {
  background: color-mix(in srgb, var(--n-role) 9%, transparent);
  border-radius: 7px;
  padding: 5px 8px;
  margin: 1px 0 2px;
}
.sp-vspec--role .sp-vspec__pitch {
  color: #F9A8D4;
}
.sp-trait--role {
  background: color-mix(in srgb, var(--n-role) 16%, transparent);
  color: #FBCFE8;
}
.sp-hintline--role {
  border-left-color: color-mix(in srgb, var(--n-role) 55%, transparent);
  background: color-mix(in srgb, var(--n-role) 7%, transparent);
}

/* 故事主题节点：琥珀黄调，区别于其它节点 */
.sp-storycard {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 2px 0 3px;
}
.sp-storybadge {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--n-story) 16%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--n-story) 34%, transparent);
}
.sp-storyinfo { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.sp-storyname {
  font-size: 13px;
  font-weight: 600;
  color: var(--t1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sp-storymood { font-size: 10px; color: var(--t5); }

.sp-genrerow { margin: 1px 0 2px; }
.sp-storyhook {
  margin: 2px 0 4px;
  font-size: 12px;
  line-height: 17px;
  color: #FDE68A;
  font-style: italic;
}
.sp-node__para--story { max-height: 38px; color: var(--t3); }

.sp-tagrow { margin-top: 2px; }
.sp-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--n-story) 12%, transparent);
  color: #FCD34D;
  font-size: 10px;
  line-height: 16px;
}
.sp-trait--story {
  background: color-mix(in srgb, var(--n-story) 16%, transparent);
  color: #FDE68A;
}
.sp-hintline--story {
  border-left-color: color-mix(in srgb, var(--n-story) 55%, transparent);
  background: color-mix(in srgb, var(--n-story) 8%, transparent);
}
.sp-paramval { color: var(--t3); font-size: 11px; }

.sp-hintline {
  padding: 7px 9px;
  border-radius: 7px;
  background: var(--bg-elev);
  border-left: 2px solid color-mix(in srgb, var(--n-voice) 55%, transparent);
  font-size: 10px;
  line-height: 15px;
  color: var(--t5);
}

.sp-paramrow { display: flex; align-items: center; gap: 8px; }
.sp-paramrow__label { flex: none; width: 34px; font-size: 10px; color: var(--t5); }
.sp-paramrow__value { font-family: var(--font-mono); font-size: 10px; color: var(--t5); }

.sp-slider { position: relative; flex: 1 1 auto; height: 12px; display: flex; align-items: center; }
.sp-slider__track { position: absolute; left: 0; right: 0; height: 4px; border-radius: 2px; background: var(--bg-hover); }
.sp-slider__fill { position: absolute; left: 0; height: 4px; border-radius: 2px; background: var(--node-color); }
.sp-slider__knob {
  position: absolute;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .5);
  transform: translateX(-50%);
}

.sp-progress { display: flex; flex-direction: column; gap: 7px; }
.sp-progress__row { display: flex; align-items: center; font-size: 10px; color: var(--t5); }
.sp-progress__row b { margin-left: auto; font-family: var(--font-mono); font-weight: 500; color: var(--accent); }
.sp-progress__track { height: 6px; border-radius: 3px; background: var(--bg-hover); overflow: hidden; }
.sp-progress__fill { height: 100%; border-radius: 3px; background: var(--accent); transition: width .3s ease; }

/* 端口 */
.sp-port {
  position: absolute;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--bg-canvas);
  border: 1.5px solid var(--node-color, var(--border-soft));
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity .18s, transform .18s, border-color .18s;
  z-index: 5;
}
.sp-node:hover .sp-port,
.sp-node--active .sp-port { opacity: 1; }
.sp-port--in  { left: -6px; }
.sp-port--out { right: -6px; }
.sp-port:hover { transform: translateY(-50%) scale(1.35); border-color: var(--accent); }
body.sp-connecting .sp-port--in {
  opacity: 1;
  border-color: var(--accent);
  background: var(--accent-soft);
  animation: sp-port-pulse 1.2s infinite;
}
body.sp-connecting .sp-port--out { opacity: 0; }
@keyframes sp-port-pulse {
  0%, 100% { transform: translateY(-50%) scale(1); }
  50%      { transform: translateY(-50%) scale(1.3); }
}

/* --- 底部添加节点浮条 --- */
.sp-addbar {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  height: 52px;
  padding: 0 10px;
  border-radius: var(--r-xl);
  background: rgba(36, 36, 36, .94);
  border: 1px solid var(--border-soft);
  box-shadow: var(--sh-3);
  backdrop-filter: blur(20px);
  z-index: 20;
  white-space: nowrap;
}
.sp-addbar__plus {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex: none;
  transition: transform .2s;
}
.sp-addbar__plus:hover { transform: scale(1.05); }
.sp-addbar__plus:active { transform: scale(.95); }
.sp-addbar__div { width: 1px; height: 24px; background: var(--border-soft); flex: none; }
.sp-addbtn {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 10px;
  border-radius: 9px;
  background: var(--bg-elev);
  font-size: 12px;
  font-weight: 500;
  color: var(--t2);
  transition: background .2s, transform .2s;
}
.sp-addbtn:hover { background: #34343A; }
.sp-addbtn:active { transform: scale(.96); }
.sp-addbtn__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* 移动端悬浮「添加节点」按钮（桌面端隐藏，见下方断点） */
.sp-mfab {
  display: none;
  position: absolute;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  box-shadow: 0 8px 22px -6px rgba(158, 255, 0, .5), var(--sh-3);
  transition: transform .2s;
}
.sp-mfab:active { transform: scale(.93); }

/* --- 画布浮动工具 --- */
.sp-zoombar {
  position: absolute;
  right: 16px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
  border-radius: var(--r-md);
  background: rgba(36, 36, 36, .94);
  border: 1px solid var(--border-soft);
  backdrop-filter: blur(20px);
  z-index: 20;
}
.sp-zoombar button {
  width: 28px; height: 28px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: var(--t4);
  transition: background .2s, color .2s;
}
.sp-zoombar button:hover { background: var(--bg-elev); color: var(--t1); }
.sp-zoombar__val {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--t6);
  text-align: center;
  padding: 2px 0;
}

/* --- 右侧属性面板 --- */
.sp-inspector {
  width: var(--inspector-w);
  flex: none;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sp-inspector__head {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  padding: 0 14px 0 16px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.sp-inspector__title { flex: 1 1 auto; font-size: 13px; font-weight: 600; color: var(--t1); }
.sp-inspector__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.sp-inspector__empty {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  color: var(--t6);
  font-size: 12px;
}

.sp-field { display: flex; flex-direction: column; gap: 8px; }
.sp-field__label { font-size: 10px; color: var(--t6); letter-spacing: .5px; }
.sp-field__value { font-size: 11px; font-weight: 500; color: var(--t2); }

.sp-inlinefield { display: flex; align-items: center; gap: 8px; }
.sp-inlinefield__label { flex: none; width: 44px; font-size: 11px; color: var(--t5); }

.sp-emorow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sp-emo {
  height: 24px;
  padding: 0 9px;
  border-radius: 6px;
  background: var(--bg-elev);
  color: var(--t4);
  font-size: 11px;
  transition: background .2s, color .2s;
}
.sp-emo--on { background: var(--accent-soft); color: var(--accent); font-weight: 500; }

.sp-inspector__foot {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
}
.sp-inspector__foot .sp-btn { flex: 1 1 0; height: 36px; }

.sp-log { display: flex; flex-direction: column; gap: 7px; }
.sp-log__row { display: flex; gap: 8px; font-size: 10px; }
.sp-log__time { flex: none; font-family: var(--font-mono); color: var(--t7); }
.sp-log__text { flex: 1 1 auto; color: var(--t4); word-break: break-word; }
.sp-log__text--accent { color: var(--accent); }
.sp-log__text--err { color: #FCA5A5; }

/* 结果预览 */
.sp-result {
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.85;
  color: var(--t3);
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.sp-result--empty { color: var(--t7); font-style: normal; }

/* --- 状态栏 --- */
.sp-statusbar {
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--statusbar-h);
  padding: 0 20px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--t5);
  flex: none;
}
.sp-statusbar__spacer { flex: 1 1 auto; }
.sp-statusbar__keys { color: var(--t6); }

/* =============================================================
   移动端专有（默认隐藏，≤991px 显示）
   ============================================================= */
.sp-appbar { display: none; }
.sp-mtabs  { display: none; }
.sp-sheet  { display: none; }
.sp-scrim  { display: none; }
.sp-mnode  { display: none; }

/* =============================================================
   响应式：≤991px 收成移动端单列
   ============================================================= */
@media (max-width: 991px) {
  :root { --topbar-h: 0px; --statusbar-h: 0px; }

  .sp-topbar, .sp-statusbar, .sp-side, .sp-inspector { display: none; }
  .sp-zoombar { display: none; }

  .sp-app { height: 100dvh; }

  .sp-appbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    min-height: 52px;
    background: var(--bg-panel);
    flex: none;
  }
  .sp-appbar__back {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    flex: none;
    margin-left: -4px;
  }
  .sp-appbar__col { flex: 1 1 auto; min-width: 0; }
  .sp-appbar__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--t1);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .sp-appbar__sub { font-size: 10px; color: var(--t6); }

  .sp-runbtn {
    display: flex;
    align-items: center;
    gap: 5px;
    height: 30px;
    padding: 0 12px 0 11px;
    border-radius: var(--r-pill);
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 12px;
    font-weight: 700;
    flex: none;
  }
  .sp-runbtn:active { transform: scale(.95); }

  .sp-mtabs {
    display: flex;
    gap: 24px;
    padding: 0 20px;
    height: 39px;
    align-items: center;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    flex: none;
  }
  .sp-mtab {
    display: flex;
    flex-direction: column;
    gap: 9px;
    align-items: center;
    font-size: 13px;
    color: var(--t5);
    height: 100%;
    justify-content: center;
  }
  .sp-mtab--on { color: var(--t1); font-weight: 600; }
  .sp-mtab__u { width: 34px; height: 2px; border-radius: 1px; background: transparent; }
  .sp-mtab--on .sp-mtab__u { background: var(--accent); }

  .sp-stage { border-radius: 0; }
  .sp-addbar { display: none; }
  .sp-mfab { display: flex; }
  .sp-hint { display: none; }

  .sp-node { box-shadow: var(--sh-2); }
  .sp-port { display: none; }

  /* 底部弹层 */
  .sp-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    z-index: 400;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
  }
  .sp-scrim--on { opacity: 1; pointer-events: auto; }

  .sp-sheet {
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 410;
    background: var(--bg-panel);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -12px 32px -8px rgba(0, 0, 0, .6);
    padding: 10px 20px calc(16px + env(safe-area-inset-bottom, 0px));
    gap: 12px;
    transform: translateY(101%);
    transition: transform .3s cubic-bezier(.32, .72, 0, 1);
    max-height: 88dvh;
  }
  .sp-sheet--on { transform: translateY(0); }
  .sp-sheet__grabbar { width: 36px; height: 4px; border-radius: 2px; background: var(--border-soft); align-self: center; flex: none; }
  .sp-sheet__head { display: flex; align-items: center; gap: 8px; flex: none; }
  .sp-sheet__title { flex: 1 1 auto; font-size: 14px; font-weight: 600; color: var(--t1); }
  .sp-sheet__hint { font-size: 10px; color: var(--t6); }
  .sp-sheet__body { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }

  .sp-option {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 54px;
    padding: 0 14px;
    border-radius: var(--r-lg);
    background: var(--bg-card);
    border: 1px solid #2E2E33;
    text-align: left;
    transition: border-color .2s, transform .2s;
  }
  .sp-option:active { transform: scale(.98); }
  .sp-option__box {
    width: 36px; height: 36px;
    border-radius: var(--r-md);
    display: flex; align-items: center; justify-content: center;
    flex: none;
  }
  .sp-option__col { flex: 1 1 auto; min-width: 0; }
  .sp-option__title { font-size: 13px; font-weight: 500; color: var(--t1); }
  .sp-option__sub { font-size: 10px; color: var(--t6); }

  .sp-homebar {
    width: 134px; height: 5px;
    border-radius: 3px;
    background: rgba(255, 255, 255, .28);
    align-self: center;
    flex: none;
  }

  /* 移动端节点列表 */
  .sp-mnode { display: none; }
  .sp-stage--list .sp-nodes, .sp-stage--list .sp-edges { display: none; }
  .sp-stage--list .sp-mnode {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: absolute;
    inset: 0;
    padding: 16px;
    overflow-y: auto;
  }
}

/* =============================================================
   登录页
   ============================================================= */
.sp-auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  background: var(--bg-canvas);
  overflow: auto;
}
.sp-auth__brand {
  position: relative;
  padding: 56px 56px 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    radial-gradient(900px 480px at 12% -10%, rgba(158, 255, 0, .10), transparent 62%),
    radial-gradient(700px 420px at 92% 108%, rgba(124, 92, 255, .12), transparent 60%),
    var(--bg-canvas);
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.sp-auth__brandgrid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, .028) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, .028) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}
.sp-auth__brandinner { position: relative; z-index: 1; }
.sp-auth__logo { display: flex; align-items: center; gap: 10px; margin-bottom: 48px; }
.sp-auth__h1 {
  font-family: var(--font-display);
  font-size: 42px;
  line-height: 1.2;
  font-weight: 700;
  color: var(--t1);
  margin: 0 0 16px;
  letter-spacing: -.5px;
}
.sp-auth__h1 em { font-style: normal; color: var(--accent); }
.sp-auth__p { font-size: 14px; line-height: 1.9; color: var(--t4); max-width: 420px; margin: 0; }

.sp-auth__nodes { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 10px; margin-top: 40px; }
.sp-auth__node {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--r-md);
  background: rgba(36, 36, 36, .72);
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
  max-width: 360px;
}
.sp-auth__node i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.sp-auth__node span { font-size: 12px; color: var(--t3); }
.sp-auth__node b { margin-left: auto; font-family: var(--font-mono); font-size: 10px; color: var(--t6); font-weight: 400; }

.sp-auth__foot { position: relative; z-index: 1; font-size: 11px; color: var(--t6); }

.sp-auth__panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
}
.sp-auth__card { width: 100%; max-width: 372px; }
.sp-auth__tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--r-md);
  background: var(--bg-card);
  margin-bottom: 24px;
}
.sp-auth__tab {
  flex: 1 1 0;
  height: 34px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--t5);
  transition: background .2s, color .2s;
}
.sp-auth__tab--on { background: var(--bg-elev); color: var(--t1); }
.sp-auth__title { font-size: 22px; font-weight: 600; color: var(--t1); margin: 0 0 6px; }
.sp-auth__sub { font-size: 12px; color: var(--t6); margin: 0 0 26px; }

.sp-form { display: flex; flex-direction: column; gap: 14px; }
.sp-form__item { display: flex; flex-direction: column; gap: 7px; }
.sp-form__label { font-size: 11px; color: var(--t4); }
.sp-form__row { display: flex; align-items: center; gap: 8px; }
.sp-form__check { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--t5); cursor: pointer; }
.sp-form__check input { accent-color: var(--accent); width: 14px; height: 14px; }
.sp-form__err {
  padding: 9px 12px;
  border-radius: var(--r-sm);
  background: rgba(239, 68, 68, .12);
  border: 1px solid rgba(239, 68, 68, .3);
  color: #FCA5A5;
  font-size: 12px;
}
.sp-form__hint { font-size: 11px; color: var(--t6); text-align: center; }

@media (max-width: 991px) {
  .sp-auth { grid-template-columns: 1fr; }
  .sp-auth__brand { display: none; }
  .sp-auth__panel { padding: 32px 22px; align-items: flex-start; padding-top: 12vh; }
}

/* 动画 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
