/* =============================================================================
 * 网络拓扑工坊 · Topology Studio
 * 文件：css/style.css  —— 深色专业工作台主题（零依赖，无外部字体/图片）
 * ========================================================================== */

/* ---------------------------------------------------------------------------
 * 设计令牌
 * ------------------------------------------------------------------------ */
:root {
  --bg: #0b0f17;
  --bg-2: #0e1522;
  --bg-3: #121b2a;
  --panel: #0e1522;
  --panel-2: #111a28;
  --border: #1e2c40;
  --border-2: #24344b;
  --text: #dbe4f0;
  --text-2: #9fb0c8;
  --muted: #7186a0;
  --accent: #38bdf8;
  --accent-2: #22d3ee;
  --online: #34d399;
  --alarm: #fbbf24;
  --offline: #64748b;
  --danger: #f43f5e;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 8px 28px rgba(0, 0, 0, .45);
  --mono: ui-monospace, "Cascadia Mono", "Consolas", "JetBrains Mono", "Courier New", monospace;
  --sans: "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", Arial, sans-serif;
}

/* 浅色主题（可选，工具栏「主题」切换） */
body.theme-light {
  --bg: #eef2f8;
  --bg-2: #ffffff;
  --bg-3: #f4f7fc;
  --panel: #ffffff;
  --panel-2: #f7fafd;
  --border: #d6dfea;
  --border-2: #c3d0e0;
  --text: #16202f;
  --text-2: #44556e;
  --muted: #6b7c93;
  --shadow: 0 8px 24px rgba(20, 40, 70, .12);
}
body.theme-light #svg-root { background: #f7fafd; }

/* ---------------------------------------------------------------------------
 * 基础
 * ------------------------------------------------------------------------ */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #223148; border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #2f4360; background-clip: padding-box; }

/* ---------------------------------------------------------------------------
 * 顶部工具栏
 * ------------------------------------------------------------------------ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  height: 54px;
  flex: 0 0 54px;
  background: linear-gradient(180deg, #0d1624, #0b121e);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-logo { color: var(--accent); display: flex; }
.brand-text { font-weight: 700; letter-spacing: .3px; display: flex; flex-direction: column; line-height: 1.15; }
.brand-text small { font-weight: 400; font-size: 10px; color: var(--muted); letter-spacing: 1.2px; }
.project-name {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  width: 190px;
  outline: none;
}
.project-name:focus { border-color: var(--accent); }
.tool-group { display: flex; gap: 6px; align-items: center; }
.tool-group.right { margin-left: auto; }
.tbtn {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: .15s;
}
.tbtn:hover { border-color: var(--accent); color: #fff; }
.tbtn:disabled { opacity: .38; cursor: not-allowed; }
.tbtn:disabled:hover { border-color: var(--border); color: inherit; }
.tbtn.primary { background: linear-gradient(180deg, #1b6fa8, #155e8f); border-color: #2a86c4; color: #eaf6ff; }
.tbtn.primary:hover { background: linear-gradient(180deg, #2280bd, #17699e); }
.tbtn.icon { min-width: 34px; text-align: center; font-size: 15px; padding: 5px 8px; }
.tbtn.small { padding: 3px 9px; font-size: 12px; }
.tbtn.active { border-color: var(--accent); color: #fff; box-shadow: inset 0 0 0 1px rgba(56,189,248,.35); }

/* ---------------------------------------------------------------------------
 * 工作区三栏
 * ------------------------------------------------------------------------ */
.workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 330px;
}
.panel-left, .panel-right {
  background: var(--panel);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel-left { border-right: 1px solid var(--border); }
.panel-right { border-left: 1px solid var(--border); }

.panel-section {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  scroll-margin-top: 8px;
}
.section-title {
  margin: 0 0 9px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 7px;
  letter-spacing: .3px;
}
.section-title .idx {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 5px;
  background: #16283c; color: var(--accent); font-size: 11px;
}

/* ---------------------------------------------------------------------------
 * 左栏 ① 文件与设定
 * ------------------------------------------------------------------------ */
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sbtn {
  background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 6px; cursor: pointer; transition: .15s;
}
.sbtn:hover { border-color: var(--accent); color: #fff; }
.res-list { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.res-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 9px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,.02); cursor: pointer; transition: .15s;
  border: 1px solid transparent;
}
.res-row:hover { background: rgba(56,189,248,.08); border-color: var(--border-2); }
.res-name { color: var(--text-2); }
.res-count {
  background: #16283c; color: var(--accent-2); font-weight: 700;
  border-radius: 20px; padding: 1px 9px; font-size: 12px; min-width: 26px; text-align: center;
}

/* ---------------------------------------------------------------------------
 * 左栏 ② 设备面板
 * ------------------------------------------------------------------------ */
.search-input {
  width: 100%; background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 7px 9px; outline: none; margin-bottom: 9px;
}
.search-input:focus { border-color: var(--accent); }
.device-groups { display: flex; flex-direction: column; gap: 11px; max-height: 340px; overflow-y: auto; padding-right: 3px; }
.device-group-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--text-2); font-weight: 700; margin-bottom: 6px;
}
.device-group-head .dot { width: 8px; height: 8px; border-radius: 50%; }
.device-group-head .count { margin-left: auto; color: var(--muted); font-weight: 400; }
.device-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.device-card {
  background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 7px 4px; display: flex; flex-direction: column; align-items: center; gap: 5px;
  cursor: grab; transition: .15s; text-align: center;
}
.device-card:hover { border-color: var(--accent); background: #17253a; transform: translateY(-1px); }
.device-card:active { cursor: grabbing; }
.device-icon { line-height: 0; }
.device-label { font-size: 10.5px; color: var(--text-2); line-height: 1.25; }

/* ---------------------------------------------------------------------------
 * 左栏 ③ 分区
 * ------------------------------------------------------------------------ */
.zone-new { display: flex; gap: 6px; margin-bottom: 8px; align-items: stretch; }
.mini-select {
  background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 5px 6px; outline: none; max-width: 140px;
}
.zone-chip {
  flex: 1; display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--border-2); border-radius: var(--radius-sm);
  color: var(--accent); cursor: grab; font-size: 11.5px; padding: 5px;
  transition: .15s;
}
.zone-chip:hover { border-color: var(--accent); background: rgba(56,189,248,.08); }
.zone-list { display: flex; flex-direction: column; gap: 4px; max-height: 190px; overflow-y: auto; }
.zone-row {
  display: flex; align-items: center; gap: 7px; padding: 5px 8px;
  border-radius: var(--radius-sm); cursor: pointer; border: 1px solid transparent;
}
.zone-row:hover { background: rgba(56,189,248,.08); }
.zone-row.selected { border-color: var(--accent); background: rgba(56,189,248,.12); }
.zone-dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; }
.zone-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zone-count { color: var(--muted); font-size: 11px; }
.zone-empty { color: var(--muted); font-size: 11.5px; padding: 6px 2px; }

/* ---------------------------------------------------------------------------
 * 左栏 ④ 场景
 * ------------------------------------------------------------------------ */
.scene-list { display: flex; flex-direction: column; gap: 6px; }
.scene-btn {
  text-align: left; background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px; cursor: pointer; transition: .15s;
}
.scene-btn:hover { border-color: var(--accent-2); background: #17253a; color: #fff; }
.scene-btn.danger:hover { border-color: var(--danger); background: rgba(244,63,94,.12); }

/* ---------------------------------------------------------------------------
 * 左栏 ⑤ 可视化
 * ------------------------------------------------------------------------ */
.play-btn {
  width: 100%; padding: 11px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid #2a86c4; background: linear-gradient(180deg, #1b6fa8, #155e8f);
  color: #eaf6ff; font-weight: 700; letter-spacing: .5px; transition: .18s;
}
.play-btn:hover { filter: brightness(1.08); }
.play-btn.playing { background: linear-gradient(180deg, #1f8a5b, #166b46); border-color: #2bb37a; color: #eafff5; }
.anim-row { display: flex; align-items: center; gap: 9px; margin-top: 9px; flex-wrap: wrap; }
.anim-label { color: var(--text-2); font-size: 11.5px; }
.seg { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg-btn {
  background: var(--bg-3); border: 0; padding: 5px 10px; cursor: pointer; transition: .15s;
  border-right: 1px solid var(--border);
}
.seg-btn:last-child { border-right: 0; }
.seg-btn.active { background: #1b6fa8; color: #eaf6ff; }
.chk { display: flex; align-items: center; gap: 5px; color: var(--text-2); font-size: 11.5px; cursor: pointer; }
.chk input { accent-color: var(--accent); }
.sliders { margin-top: 10px; display: flex; flex-direction: column; gap: 7px; }
.slider-row { display: grid; grid-template-columns: 68px 1fr 30px; align-items: center; gap: 7px; }
.slider-row span { color: var(--text-2); font-size: 11.5px; }
.slider-row b { color: var(--accent-2); font-size: 11.5px; text-align: right; font-weight: 600; }
input[type="range"] { -webkit-appearance: none; appearance: none; height: 4px; border-radius: 3px; background: #20334c; outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%; background: var(--accent); cursor: pointer; border: 2px solid #0b1220; }
input[type="range"]::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: var(--accent); cursor: pointer; border: 2px solid #0b1220; }

/* ---------------------------------------------------------------------------
 * 中央画布
 * ------------------------------------------------------------------------ */
.canvas-wrap { position: relative; overflow: hidden; background: var(--bg); }
#svg-root { width: 100%; height: 100%; display: block; background: var(--bg); touch-action: none; }

/* 图例 */
.legend {
  position: absolute; left: 14px; top: 14px; width: 360px; max-width: 46%;
  background: rgba(12, 19, 31, .93); border: 1px solid var(--border);
  border-radius: var(--radius); backdrop-filter: blur(6px); box-shadow: var(--shadow);
  overflow: hidden;
}
.legend-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 11px; border-bottom: 1px solid var(--border);
  font-size: 11.5px; font-weight: 700; letter-spacing: 1px; color: var(--text-2);
}
.legend-toggle { background: transparent; border: 0; color: var(--accent); cursor: pointer; font-size: 11.5px; }
.legend-body { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px 11px; max-height: 260px; overflow-y: auto; }
.legend-col-title { font-size: 11px; color: var(--muted); margin-bottom: 6px; letter-spacing: .5px; }
.legend-list { display: flex; flex-direction: column; gap: 5px; }
.legend-row { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-2); }
.legend-swatch { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; }
.legend-icon { line-height: 0; display: flex; }
.legend-line { flex: 0 0 auto; }
.legend-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 空态 */
.canvas-empty {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  text-align: center; pointer-events: none; color: var(--muted);
}
.empty-icon { font-size: 40px; margin-bottom: 8px; }
.empty-title { font-size: 15px; color: var(--text-2); font-weight: 600; }
.empty-sub { font-size: 12px; margin-top: 6px; }

/* 缩放条 */
.zoom-bar {
  position: absolute; right: 16px; bottom: 16px; display: flex; align-items: center; gap: 4px;
  background: rgba(12, 19, 31, .93); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 4px; box-shadow: var(--shadow);
}
.zbtn { background: transparent; border: 0; color: var(--text-2); cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.zbtn:hover { background: #17253a; color: #fff; }
.zbtn.fit { font-size: 11.5px; }
.zoom-label { min-width: 46px; text-align: center; color: var(--accent-2); font-size: 12px; }

/* ---------------------------------------------------------------------------
 * SVG 元素样式
 * ------------------------------------------------------------------------ */
.nts-node { cursor: move; }
.nts-node .node-glow { opacity: 0; transition: opacity .15s; filter: drop-shadow(0 0 6px currentColor); }
.nts-node.selected .node-glow { opacity: .9; }
.nts-node .node-accent { pointer-events: none; }
.nts-node .node-name, .nts-node .node-ip { pointer-events: none; user-select: none; }
.nts-node .node-status { stroke: #0b1220; stroke-width: 1.4; }
.nts-node .node-risk { stroke: #0b1220; stroke-width: 1.4; }
.nts-node text { font-family: var(--sans); }

.nts-domain { cursor: move; }
.domain-fill { fill-opacity: .10; stroke-opacity: .5; stroke-dasharray: 8 6; stroke-width: 1.5; }
.nts-domain.selected .domain-fill { fill-opacity: .18; stroke-opacity: .9; }
.domain-title { font-family: var(--sans); font-size: 13px; font-weight: 700; pointer-events: none; user-select: none; }
.domain-handle { cursor: nwse-resize; }

.nts-link { cursor: pointer; }
.link-hit { pointer-events: stroke; }
.link-path { transition: filter .15s; }
.nts-link.selected .link-path { filter: drop-shadow(0 0 5px currentColor) brightness(1.3); }
.link-label { cursor: pointer; }
.link-label text { font-family: var(--sans); }
.link-preview { pointer-events: none; }
.port-hot { cursor: crosshair; }
.marquee { pointer-events: none; }
.sel-bounds { pointer-events: none; }
.ghost-node { pointer-events: none; }
#layer-anim circle { pointer-events: none; }

/* ---------------------------------------------------------------------------
 * 数据流动画
 * ------------------------------------------------------------------------ */
.canvas-wrap.anim-playing #layer-links .link-sweep { animation: nts-sweep calc(var(--nts-flow-dur, 4s) * 1.4) linear infinite; }

.canvas-wrap.anim-playing[data-anim-mode="flow"] #layer-links .link-path {
  stroke-dasharray: var(--nts-gran, 14) 12;
  animation: nts-flow var(--nts-flow-dur, 4s) linear infinite;
  filter: brightness(var(--nts-bright, .8)) hue-rotate(var(--nts-hue, 0deg));
}
.canvas-wrap.anim-playing[data-anim-mode="flow"][data-anim-bidir="1"] #layer-links .link-path { animation-direction: alternate; }

.canvas-wrap.anim-playing[data-anim-mode="pulse"] #layer-links .link-path {
  animation: nts-pulse calc(var(--nts-flow-dur, 4s) * .62) ease-in-out infinite;
  filter: brightness(var(--nts-bright, .8)) hue-rotate(var(--nts-hue, 0deg));
}

.canvas-wrap.anim-playing[data-anim-mode="particle"] #layer-links .link-path {
  filter: brightness(var(--nts-bright, .8)) hue-rotate(var(--nts-hue, 0deg)) opacity(var(--nts-range, .8));
}

@keyframes nts-flow { from { stroke-dashoffset: 0; } to { stroke-dashoffset: -72; } }
@keyframes nts-pulse { 0%, 100% { opacity: calc(var(--nts-intensity, .6) * .28); } 50% { opacity: 1; } }
@keyframes nts-sweep { 0%, 100% { opacity: .04; } 50% { opacity: calc(var(--nts-intensity, .6) * .55); } }

/* ---------------------------------------------------------------------------
 * 右栏 · 摘要卡 / 属性 / 配置
 * ------------------------------------------------------------------------ */
.meta-card { display: flex; flex-direction: column; gap: 6px; }
.meta-row { display: grid; grid-template-columns: 76px 1fr; align-items: center; gap: 8px; }
.meta-row label { color: var(--text-2); font-size: 12px; }
.meta-row input {
  background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 5px 8px; outline: none; width: 100%;
}
.meta-row input:focus { border-color: var(--accent); }
.meta-readonly { color: var(--accent-2); font-weight: 700; }
.sync-hint {
  margin-left: auto; font-size: 10.5px; font-weight: 400; color: var(--online);
  opacity: 0; transition: opacity .25s;
}
.sync-hint.show { opacity: 1; }
.empty-state { color: var(--muted); padding: 16px 4px; text-align: center; font-size: 12px; }
.props-form { display: flex; flex-direction: column; gap: 8px; }
.pf-row { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 8px; }
.pf-row.two { grid-template-columns: 62px 1fr 46px 1fr; }
.pf-row.three { grid-template-columns: 62px 1fr 56px 1fr 56px 1fr; }
.pf-row label { color: var(--text-2); font-size: 12px; }
.pf-row input, .pf-row select, .pf-row textarea {
  background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 5px 8px; outline: none; width: 100%; resize: vertical;
}
.pf-row input:focus, .pf-row select:focus, .pf-row textarea:focus { border-color: var(--accent); }
.pf-row textarea { grid-column: 2 / -1; }
.pf-hint {
  display: none; margin: 2px 0 8px; padding: 6px 8px; border-radius: 6px;
  font-size: 11px; line-height: 1.55; color: var(--text-2);
  background: rgba(56, 189, 248, .08); border-left: 2px solid rgba(56, 189, 248, .45);
}
.pf-hint.show { display: block; }

.cfg-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.cfg-field label { color: var(--text-2); font-size: 11.5px; }
.cfg-field select, .cfg-field input, .cfg-field textarea {
  background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px 8px; outline: none; width: 100%; resize: vertical;
}
.cfg-field select:focus, .cfg-field input:focus, .cfg-field textarea:focus { border-color: var(--accent); }
.cfg-params { display: flex; flex-direction: column; gap: 7px; margin-bottom: 8px; }
.cfg-hint { color: var(--muted); font-size: 11.5px; }
.cfg-options-wrap { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 9px; }
.cfg-options-wrap summary { cursor: pointer; padding: 7px 9px; color: var(--text-2); font-size: 12px; }
.cfg-options { padding: 4px 10px 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 5px 10px; }
.opt-row { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text-2); cursor: pointer; }
.opt-row input { accent-color: var(--accent); }
.opt-template {
  grid-column: 1 / -1; background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 5px 8px; outline: none; font-size: 11.5px;
}
.cfg-actions { display: flex; gap: 7px; margin-bottom: 9px; }
.cfg-actions .tbtn { flex: 1; }
.cfg-output-head { font-size: 11px; color: var(--muted); margin-bottom: 5px; word-break: break-all; }
.cfg-output-actions { display: flex; gap: 6px; margin-bottom: 6px; }
.cfg-output {
  background: #070c14; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px; max-height: 320px; overflow: auto; margin: 0;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.55; color: #b8d9f0;
  white-space: pre; tab-size: 4;
}

/* ---------------------------------------------------------------------------
 * 底部状态栏
 * ------------------------------------------------------------------------ */
.statusbar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 14px;
  padding: 7px 14px; background: linear-gradient(180deg, #0c1421, #0a111c);
  border-top: 1px solid var(--border);
}
.status-desc {
  flex: 0 1 340px; background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 5px 9px; outline: none; resize: none;
  min-height: 28px; max-height: 28px; overflow: auto;
}
.status-desc:focus { border-color: var(--accent); max-height: 90px; }
.status-stats { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.stat { display: flex; align-items: center; gap: 5px; color: var(--text-2); font-size: 12px; }
.stat b { color: var(--accent-2); font-weight: 700; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--offline); display: inline-block; }
.dot.online { background: var(--online); }
.dot.alarm { background: var(--alarm); }
.dot.offline { background: var(--offline); }
.status-hint { margin-left: auto; color: var(--muted); font-size: 11.5px; text-align: right; }

/* ---------------------------------------------------------------------------
 * 右键菜单 / Toast / 弹窗
 * ------------------------------------------------------------------------ */
.context-menu {
  position: fixed; z-index: 900; display: none; min-width: 170px; padding: 5px;
  background: #0e1725; border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.ctx-item {
  display: block; width: 100%; text-align: left; background: transparent; border: 0;
  padding: 7px 10px; border-radius: 5px; cursor: pointer; color: var(--text-2); font-size: 12px;
}
.ctx-item:hover { background: #17253a; color: #fff; }
.ctx-item.danger { color: #fb7185; }
.ctx-item.danger:hover { background: rgba(244,63,94,.16); }
.ctx-sep { height: 1px; background: var(--border); margin: 4px 6px; }

.toast-container { position: fixed; right: 18px; bottom: 62px; z-index: 950; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  background: #142338; border: 1px solid var(--border-2); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 9px 13px; font-size: 12px; color: var(--text);
  box-shadow: var(--shadow); opacity: 0; transform: translateX(16px); transition: .25s; max-width: 320px;
}
.toast.show { opacity: 1; transform: translateX(0); }

.modal { position: fixed; inset: 0; z-index: 1000; display: none; align-items: center; justify-content: center; background: rgba(4, 8, 14, .68); }
.modal-box { width: 620px; max-width: 92vw; max-height: 82vh; overflow: hidden; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border-2); border-radius: var(--radius); box-shadow: var(--shadow); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 11px 14px; border-bottom: 1px solid var(--border); font-weight: 700; }
.modal-body { padding: 14px 18px; overflow-y: auto; }
.modal-body h4 { margin: 12px 0 6px; color: var(--accent); font-size: 12.5px; }
.modal-body ul { margin: 0; padding-left: 20px; color: var(--text-2); line-height: 1.85; }
.modal-body b { color: var(--text); }

/* ---------------------------------------------------------------------------
 * 响应式（窄屏时收窄右栏）
 * ------------------------------------------------------------------------ */
@media (max-width: 1440px) {
  .workspace { grid-template-columns: 280px minmax(0, 1fr) 310px; }
  .legend { width: 320px; }
}
@media (max-width: 1180px) {
  .workspace { grid-template-columns: 250px minmax(0, 1fr) 290px; }
  .legend-body { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------------------
 * 场景标题行固定「清空画布」按钮（Phase A2）
 *   始终显示在「场景 / 拓扑预设」标题行右侧，不随场景列表滚动沉底。
 * ------------------------------------------------------------------------ */
.section-title .title-btn { margin-left: auto; }

/* 危险样式按钮（清空类操作） */
.tbtn.danger { border-color: rgba(244, 63, 94, .5); color: #ffd7de; }
.tbtn.danger:hover { border-color: var(--danger); background: rgba(244, 63, 94, .16); color: #fff; }

/* ---------------------------------------------------------------------------
 * 命令生成 · 生成条件自检区（Phase A1）
 *   逐项列出「是否选中设备 / 类型是否有 CLI 模板 / 厂商是否具体 / 模板与平台是否匹配」
 * ------------------------------------------------------------------------ */
.cfg-diag {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 2px 0 6px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-3);
  font-size: 11.5px;
  color: var(--text-2);
  line-height: 1.5;
}
.cfg-diag .diag-item { display: flex; gap: 6px; align-items: flex-start; }
.cfg-diag .diag-item .mk { flex: 0 0 auto; }
.cfg-diag .diag-item.ok { color: #34d399; }
.cfg-diag .diag-item.warn { color: #fbbf24; }
.cfg-diag .diag-item.bad { color: #fb7185; }
.cfg-diag .diag-sum { font-weight: 700; }


/* ---------------------------------------------------------------------------
 * 键盘可达性与动效偏好
 * ------------------------------------------------------------------------ */
/* 各处 outline:none 之后仅靠 1px 边框变色，键盘用户看不出焦点在哪；统一补焦点环。 */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tbtn:focus-visible, .sbtn:focus-visible, .zbtn:focus-visible,
.scene-btn:focus-visible, .device-card:focus-visible, .seg-btn:focus-visible,
.zone-chip:focus-visible, .zone-row:focus-visible, .res-row:focus-visible,
.legend-toggle:focus-visible, .title-btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 1px solid var(--accent); outline-offset: 1px;
}

/* 系统要求「减少动态效果」时停掉流光 / 脉冲 / 粒子等持续动画：
   这三类动画是无限循环的，对晕动症用户不友好，此前无任何降级。 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .link-sweep { display: none; }
}
