:root {
  --page-scale: 0.7;
  --bg: #020713;
  --panel: rgba(5, 17, 30, 0.78);
  --line: rgba(100, 220, 255, 0.26);
  --line-strong: rgba(100, 235, 255, 0.72);
  --text: #eafaff;
  --muted: #8caec0;
  --cyan: #66efff;
  --green: #64f6a5;
  --amber: #ffcf65;
  --red: #ff5c77;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  color: var(--text);
  font-size: 12px;
  font-family: "Microsoft YaHei UI", "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 50% 45%, rgba(46, 119, 209, 0.26), transparent 34%),
    linear-gradient(rgba(100, 220, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(100, 220, 255, 0.03) 1px, transparent 1px),
    #020713;
  background-size: auto, 42px 42px, 42px 42px, auto;
  overflow: hidden;
}

.twin-app {
  width: calc(100vw / var(--page-scale));
  height: calc(100vh / var(--page-scale));
  display: grid;
  grid-template-rows: 68px 1fr 42px;
  transform: scale(var(--page-scale));
  transform-origin: left top;
}

.top-hud {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(3, 12, 23, 0.96), rgba(8, 28, 48, 0.82), rgba(3, 12, 23, 0.96));
}

.top-hud::after {
  content: "";
  position: absolute;
  left: 2%;
  right: 52%;
  bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), transparent);
  box-shadow: 0 0 20px rgba(100, 235, 255, 0.7);
}

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

.brand-emblem {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(100, 235, 255, 0.2), transparent),
    repeating-linear-gradient(90deg, transparent 0 8px, rgba(100, 235, 255, 0.28) 8px 9px);
  box-shadow: 0 0 24px rgba(100, 235, 255, 0.38);
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
}

.status-strip strong {
  color: var(--green);
}

.status-strip .warn {
  color: var(--amber);
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: clamp(220px, 18vw, 286px) minmax(560px, 1fr) clamp(250px, 20vw, 320px);
  gap: 12px;
  padding: 12px 14px;
}

.panel,
.scene-panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(100, 235, 255, 0.08), transparent 32%),
    var(--panel);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.42), inset 0 0 32px rgba(100, 235, 255, 0.035);
  overflow: hidden;
}

.panel-title {
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 18px;
  border-bottom: 1px solid rgba(100, 235, 255, 0.16);
  font-size: 15px;
  font-weight: 700;
}

.metric-list {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.metric {
  min-height: 92px;
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(100, 235, 255, 0.16);
  border-radius: 8px;
  background: rgba(4, 15, 27, 0.62);
}

.metric i {
  grid-row: 1 / 3;
  width: 48px;
  height: 48px;
  border: 1px solid var(--cyan);
  border-radius: 16px;
  background: rgba(100, 235, 255, 0.12);
  box-shadow: 0 0 18px rgba(100, 235, 255, 0.26);
}

.metric span {
  color: var(--muted);
}

.metric strong {
  color: var(--cyan);
  font-size: 28px;
}

.metric.amber i,
.metric.amber strong {
  color: var(--amber);
  border-color: var(--amber);
}

.metric.red i,
.metric.red strong {
  color: var(--red);
  border-color: var(--red);
}

.metric.green i,
.metric.green strong {
  color: var(--green);
  border-color: var(--green);
}

.scene-panel {
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(circle at 50% 50%, rgba(100, 235, 255, 0.2), transparent 34%),
    radial-gradient(circle at 46% 62%, rgba(100, 246, 165, 0.08), transparent 30%),
    rgba(3, 13, 24, 0.78);
}

#twin-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.line-cards {
  position: absolute;
  z-index: 5;
  top: 16px;
  left: 24px;
  right: 24px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  pointer-events: auto;
}

.drill-nav {
  position: absolute;
  z-index: 8;
  top: 104px;
  left: 24px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid rgba(100, 235, 255, 0.2);
  border-radius: 6px;
  background: rgba(5, 17, 30, 0.66);
  backdrop-filter: blur(10px);
}

.drill-nav button {
  height: 28px;
  border: 1px solid rgba(100, 235, 255, 0.28);
  border-radius: 5px;
  color: var(--text);
  background: rgba(8, 28, 48, 0.78);
  cursor: pointer;
}

.drill-nav button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.drill-nav strong {
  color: var(--cyan);
  font-size: 13px;
}

.scene-view-switch {
  position: absolute;
  z-index: 22;
  top: 16px;
  right: 18px;
  display: inline-flex;
  gap: 5px;
  padding: 4px;
  border: 1px solid rgba(100, 235, 255, 0.2);
  border-radius: 7px;
  background: rgba(5, 17, 30, 0.72);
  backdrop-filter: blur(10px);
}

.scene-view-switch button {
  height: 30px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.scene-view-switch button.active {
  border-color: rgba(100, 235, 255, 0.42);
  color: var(--text);
  background: rgba(100, 235, 255, 0.14);
}

.line-card {
  height: 66px;
  padding: 10px 12px;
  border: 1px solid rgba(100, 235, 255, 0.24);
  border-radius: 7px;
  background: rgba(5, 17, 30, 0.78);
  box-shadow: inset 0 0 22px rgba(100, 235, 255, 0.05), 0 0 20px rgba(100, 235, 255, 0.08);
}

.line-card.active {
  border-color: var(--cyan);
  box-shadow: 0 0 24px rgba(100, 235, 255, 0.42), inset 0 0 26px rgba(100, 235, 255, 0.12);
}

.line-card span,
.line-card strong,
.line-card em {
  display: block;
}

.line-card span {
  font-weight: 700;
}

.line-card strong {
  margin-top: 6px;
  color: var(--cyan);
  font-size: 13px;
}

.line-card em {
  color: var(--amber);
  font-size: 12px;
  font-style: normal;
}

.scene-tip {
  position: absolute;
  z-index: 7;
  min-width: 150px;
  display: none;
  padding: 8px 10px;
  border: 1px solid rgba(100, 235, 255, 0.36);
  border-radius: 5px;
  color: var(--text);
  background: rgba(2, 9, 17, 0.84);
  box-shadow: 0 0 18px rgba(100, 235, 255, 0.18);
  pointer-events: none;
  font-size: 12px;
}

.camera-tools {
  position: absolute;
  z-index: 6;
  right: 18px;
  bottom: 114px;
  display: flex;
  gap: 8px;
  opacity: 0.45;
  transition: opacity 0.16s ease;
}

.camera-tools:hover {
  opacity: 1;
}

.camera-tools button {
  height: 30px;
  border: 1px solid rgba(100, 235, 255, 0.24);
  border-radius: 5px;
  color: var(--text);
  background: rgba(5, 17, 30, 0.78);
  cursor: pointer;
}

.psu-graph-view {
  position: absolute;
  z-index: 18;
  inset: 0;
  display: none;
  grid-template-rows: auto auto minmax(0, 1fr);
  background:
    radial-gradient(circle at 50% 52%, rgba(100, 235, 255, 0.12), transparent 48%),
    rgba(1, 8, 16, 0.94);
}

.scene-panel.psu-mode .psu-graph-view {
  display: grid;
}

.scene-panel.psu-mode #twin-canvas,
.scene-panel.psu-mode .line-cards,
.scene-panel.psu-mode .drill-nav,
.scene-panel.psu-mode .camera-tools,
.scene-panel.psu-mode .thread-toolbar,
.scene-panel.psu-mode .thread-panel,
.scene-panel.psu-mode .scene-tip {
  display: none;
}

.psu-graph-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px 12px;
  border-bottom: 1px solid rgba(100, 235, 255, 0.14);
  background: rgba(4, 15, 27, 0.7);
  padding-right: 190px;
}

.psu-graph-brand {
  display: grid;
  gap: 4px;
  min-width: 220px;
}

.psu-graph-brand strong {
  color: var(--cyan);
  font-size: 15px;
}

.psu-graph-brand span,
.psu-graph-controls label,
.psu-graph-meta,
.psu-layout-note {
  color: var(--muted);
  font-size: 12px;
}

.psu-graph-controls {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 9px;
  flex-wrap: wrap;
}

.psu-graph-controls label {
  display: grid;
  gap: 4px;
}

.psu-graph-controls select,
.psu-graph-controls input,
.psu-graph-controls button {
  height: 32px;
  border: 1px solid rgba(100, 235, 255, 0.22);
  border-radius: 6px;
  color: var(--text);
  background: rgba(5, 17, 30, 0.88);
}

.psu-graph-controls select {
  width: 126px;
  padding: 0 8px;
}

.psu-graph-controls input {
  width: 172px;
  padding: 0 10px;
}

.psu-graph-controls button {
  padding: 0 12px;
  cursor: pointer;
}

.psu-check {
  height: 32px;
  display: flex !important;
  align-items: center;
  gap: 6px !important;
}

.psu-check input {
  width: 15px;
  height: 15px;
}

.psu-graph-legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding: 8px 18px;
  border-bottom: 1px solid rgba(100, 235, 255, 0.1);
  background: rgba(2, 9, 17, 0.42);
}

.psu-graph-legend strong {
  color: var(--cyan);
  font-size: 12px;
}

.psu-graph-legend span,
.psu-graph-legend button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border: 1px solid rgba(100, 235, 255, 0.14);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.psu-graph-legend button {
  color: var(--text);
  background: rgba(5, 17, 30, 0.78);
  cursor: pointer;
}

.psu-graph-legend button.active {
  border-color: rgba(100, 235, 255, 0.48);
  box-shadow: 0 0 14px rgba(100, 235, 255, 0.16), inset 0 0 12px rgba(100, 235, 255, 0.08);
}

.psu-graph-legend button.off {
  opacity: 0.36;
}

.psu-graph-legend i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.psu-graph-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

#psu-graph-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

#psu-graph-canvas.dragging {
  cursor: grabbing;
}

.psu-layout-note {
  position: absolute;
  top: 14px;
  left: 18px;
  max-width: min(560px, calc(100% - 420px));
  padding: 7px 10px;
  border: 1px solid rgba(100, 235, 255, 0.2);
  border-radius: 6px;
  background: rgba(3, 13, 24, 0.78);
  pointer-events: none;
}

.psu-graph-meta {
  position: absolute;
  left: 18px;
  bottom: 16px;
  padding: 7px 10px;
  border: 1px solid rgba(100, 235, 255, 0.16);
  border-radius: 6px;
  background: rgba(3, 13, 24, 0.74);
  pointer-events: none;
}

.psu-graph-detail {
  position: absolute;
  top: 14px;
  right: 18px;
  width: min(340px, 34%);
  max-height: calc(100% - 36px);
  overflow: auto;
  padding: 12px;
  border: 1px solid rgba(100, 235, 255, 0.18);
  border-radius: 7px;
  color: var(--text);
  background: rgba(3, 13, 24, 0.82);
  font-size: 12px;
  line-height: 1.55;
  backdrop-filter: blur(12px);
}

.psu-graph-detail strong,
.psu-graph-detail span,
.psu-graph-detail em {
  display: block;
}

.psu-graph-detail strong {
  margin-bottom: 6px;
  color: var(--cyan);
  font-size: 14px;
}

.psu-graph-detail span,
.psu-graph-detail em {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.psu-graph-detail .psu-detail-id {
  margin-bottom: 10px;
  font-size: 11px;
}

.psu-detail-section {
  display: grid;
  gap: 7px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(100, 235, 255, 0.12);
}

.psu-detail-section b {
  color: var(--text);
  font-weight: 600;
}

.psu-detail-section span b {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.psu-detail-section em {
  position: relative;
  padding-left: 14px;
  font-style: normal;
}

.psu-detail-section em i {
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.thread-toolbar {
  position: absolute;
  z-index: 5;
  left: 24px;
  right: 24px;
  bottom: 18px;
  display: grid;
  grid-template-columns: repeat(9, minmax(68px, 1fr));
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(100, 235, 255, 0.18);
  border-radius: 8px;
  background: rgba(2, 9, 17, 0.58);
  backdrop-filter: blur(12px);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 190px minmax(420px, 1fr) 220px;
    gap: 8px;
    padding: 8px;
  }

  .brand h1 {
    font-size: 18px;
  }

  .status-strip {
    gap: 10px;
    font-size: 11px;
  }

  .line-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    left: 14px;
    right: 14px;
    gap: 8px;
  }

  .line-card {
    height: 56px;
    padding: 8px 10px;
  }

  .thread-toolbar {
    left: 14px;
    right: 14px;
    gap: 6px;
  }
}

.thread-toolbar button {
  min-height: 58px;
  display: grid;
  place-items: center;
  gap: 5px;
  padding: 8px 5px;
  border: 1px solid rgba(100, 235, 255, 0.2);
  border-radius: 6px;
  color: var(--text);
  background: linear-gradient(180deg, rgba(100, 235, 255, 0.12), rgba(5, 17, 30, 0.76));
  cursor: pointer;
}

.thread-toolbar button:hover,
.thread-toolbar button.active {
  border-color: var(--cyan);
  box-shadow: 0 0 18px rgba(100, 235, 255, 0.28), inset 0 0 16px rgba(100, 235, 255, 0.1);
}

.thread-toolbar i {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(100, 235, 255, 0.36);
  border-radius: 50%;
  color: var(--cyan);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
  background: rgba(100, 235, 255, 0.08);
}

.thread-toolbar span {
  color: var(--text);
  font-size: 11px;
}

.thread-panel {
  position: absolute;
  z-index: 10;
  right: 22px;
  bottom: 96px;
  width: min(680px, calc(100% - 72px));
  height: min(520px, calc(100% - 180px));
  max-height: min(560px, calc(100% - 180px));
  display: none;
  border: 1px solid rgba(100, 235, 255, 0.34);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(100, 235, 255, 0.1), transparent 34%),
    rgba(3, 13, 24, 0.94);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.54), 0 0 24px rgba(100, 235, 255, 0.18);
  backdrop-filter: blur(14px);
  overflow: hidden;
}

.thread-panel.open {
  display: grid;
  grid-template-rows: 10px auto minmax(0, 1fr);
}

.thread-panel-resize {
  height: 10px;
  cursor: ns-resize;
  background: linear-gradient(90deg, transparent, rgba(100, 235, 255, 0.35), transparent);
  touch-action: none;
}

.thread-panel-resize::after {
  content: "";
  display: block;
  width: 54px;
  height: 3px;
  margin: 3px auto 0;
  border-radius: 999px;
  background: rgba(100, 235, 255, 0.48);
}

.thread-panel-resizing {
  cursor: ns-resize;
  user-select: none;
}

.thread-panel-head {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(100, 235, 255, 0.18);
}

.thread-panel-head span,
.thread-empty,
.thread-card span,
.thread-table td,
.thread-flow em {
  color: var(--muted);
  font-size: 12px;
}

.thread-panel-head strong {
  display: block;
  margin-top: 5px;
  color: var(--cyan);
  font-size: 15px;
}

.thread-panel-head button {
  height: 30px;
  padding: 0 12px;
  border: 1px solid rgba(100, 235, 255, 0.28);
  border-radius: 5px;
  color: var(--text);
  background: rgba(5, 17, 30, 0.82);
  cursor: pointer;
}

.thread-panel-body {
  min-height: 0;
  padding: 14px;
  overflow: auto;
}

.thread-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.thread-card {
  min-height: 96px;
  padding: 12px;
  border: 1px solid rgba(100, 235, 255, 0.14);
  border-radius: 7px;
  background: rgba(4, 15, 27, 0.66);
}

.thread-card strong,
.thread-flow strong {
  display: block;
  margin-bottom: 8px;
}

.thread-card p,
.thread-card ul {
  margin: 0;
  padding: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.65;
}

.thread-card li {
  list-style: none;
}

.thread-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid rgba(100, 235, 255, 0.14);
  border-radius: 7px;
  background: rgba(4, 15, 27, 0.66);
  margin-bottom: 12px;
}

.thread-table th,
.thread-table td {
  padding: 10px;
  border-bottom: 1px solid rgba(100, 235, 255, 0.1);
  text-align: left;
  font-size: 12px;
}

.thread-table th {
  color: var(--cyan);
  font-weight: 700;
}

.thread-flow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.thread-flow div {
  min-height: 76px;
  padding: 10px;
  border: 1px solid rgba(100, 235, 255, 0.18);
  border-radius: 7px;
  background: rgba(100, 235, 255, 0.07);
}

.thread-diagram {
  padding: 12px;
  border: 1px solid rgba(100, 235, 255, 0.16);
  border-radius: 7px;
  background: rgba(4, 15, 27, 0.66);
  margin-bottom: 12px;
}

.thread-diagram header {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.thread-diagram header strong {
  color: var(--cyan);
}

.thread-diagram header span,
.thread-diagram-node span,
.thread-diagram-node em,
.thread-diagram-edges em {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.thread-diagram-stages {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.thread-diagram-stages article,
.thread-diagram-node {
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(100, 235, 255, 0.14);
  border-radius: 7px;
  background: rgba(100, 235, 255, 0.06);
}

.thread-diagram-stages article strong,
.thread-diagram-node strong {
  display: block;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

.thread-diagram-stages article span,
.thread-diagram-node span,
.thread-diagram-node em {
  display: block;
  overflow-wrap: anywhere;
}

.thread-diagram-nodes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.thread-diagram-node[data-role="input"],
.thread-diagram-node[data-role="output"] {
  background: rgba(255, 203, 107, 0.08);
  border-color: rgba(255, 203, 107, 0.24);
}

.thread-diagram-node[data-role="control"],
.thread-diagram-node[data-role="feedback"] {
  background: rgba(120, 190, 255, 0.09);
  border-color: rgba(120, 190, 255, 0.24);
}

.thread-diagram-edges {
  display: grid;
  gap: 6px;
}

.thread-diagram-edges div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18px minmax(0, 1fr) minmax(80px, 0.8fr);
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid rgba(100, 235, 255, 0.1);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.14);
}

.thread-diagram-edges strong,
.thread-diagram-edges em {
  overflow-wrap: anywhere;
}

.thread-diagram-edges span {
  color: var(--cyan);
  text-align: center;
}

@media (max-width: 900px) {
  .thread-grid,
  .thread-flow,
  .thread-diagram-stages,
  .thread-diagram-nodes {
    grid-template-columns: 1fr;
  }

  .thread-diagram-edges div {
    grid-template-columns: 1fr;
  }

  .thread-diagram-edges span {
    text-align: left;
  }

}

.thread-empty {
  padding: 18px;
  border: 1px dashed rgba(100, 235, 255, 0.2);
  border-radius: 7px;
  background: rgba(4, 15, 27, 0.5);
  margin-bottom: 12px;
}

.thread-panel-body > :last-child {
  margin-bottom: 0;
}

.detail-box,
.system-list {
  padding: 16px;
}

.detail-box dl {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 10px;
  margin: 0;
  font-size: 13px;
}

.detail-box dt {
  color: var(--muted);
}

.detail-box dd {
  margin: 0;
}

.system-card {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(100, 235, 255, 0.14);
  border-radius: 7px;
  background: rgba(4, 15, 27, 0.58);
}

.system-card strong,
.system-card span {
  display: block;
}

.system-card span {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  padding: 0 24px;
  color: var(--muted);
  border-top: 1px solid rgba(100, 235, 255, 0.1);
  background: rgba(2, 9, 17, 0.72);
}
