:root {
  color-scheme: light;
  --ink: #172b48;
  --muted: #506482;
  --blue: #1856c2;
  --blue-strong: #164cab;
  --blue-tint: #eaf4ff;
  --line: #dce8f6;
  --page: #f4f8fe;
  --white: #fff;
  --danger: #a12031;
  --mono: "Cascadia Code", Consolas, ui-monospace, monospace;
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--page);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; }
button, select, textarea, input { font: inherit; color: inherit; }
button, select, input, textarea { border: 1px solid #cbdbee; border-radius: 8px; background: var(--white); }
button, select { cursor: pointer; }
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 6px 11px; font-size: 13px; font-weight: 650; white-space: nowrap;
}
button:hover:not(:disabled), select:hover { background: #f4f8ff; border-color: #92b3e3; }
button:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible, summary:focus-visible, pre:focus-visible {
  outline: 2px solid #2866c8; outline-offset: 2px;
}
select { min-height: 36px; padding: 5px 8px; font-size: 13px; }
input { min-width: 0; min-height: 34px; padding: 5px 8px; font-size: 13px; }
textarea { width: 100%; padding: 10px 11px; resize: vertical; font-size: 13px; line-height: 1.65; }
textarea::placeholder { color: #637792; }
h1, h2, p { margin: 0; }
h2 { font-size: 16px; letter-spacing: .01em; }
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.top { background: var(--white); border-bottom: 1px solid var(--line); }
.top-inner, main { max-width: 1600px; margin-inline: auto; padding-inline: clamp(14px, 3vw, 44px); }
.top-inner { min-height: 66px; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-block: 10px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand strong { display: block; font-size: 16px; letter-spacing: .01em; }
.brand small, .device-option small { display: block; color: var(--muted); font-size: 11px; margin-top: 1px; }
.brand-icon, .device-icon {
  display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 10px;
  color: var(--blue); background: var(--blue-tint);
}
.brand-icon { background: var(--blue); color: var(--white); }
.brand-icon .icon, .device-icon .icon { width: 20px; height: 20px; }
.device-option .device-icon { background: #eff7ff; }
.device-option .device-icon .icon { width: 33px; height: 28px; stroke: none; }
.device-icon.switch { color: #0b6484; background: #e9f7ff; }
.device-icon.pc { color: #3c549d; background: #eff2ff; }
.device-icon.firewall { color: #88442d; background: #fff1e8; }
.device-icon.controller { color: #2551a3; background: #eaf0ff; }
.device-icon.ap { color: #176f68; background: #e9f8f5; }
.actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.intro { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin: 26px 0 20px; }
.eyebrow { color: var(--blue); font-size: 12px; font-weight: 700; letter-spacing: .09em; }
.release { margin-left: 4px; padding: 2px 5px; border: 1px solid #cfe2fb; border-radius: 4px; background: #eaf4ff; }
h1 { font-size: clamp(25px, 3vw, 35px); line-height: 1.22; margin: 5px 0 6px; }
.intro p { font-size: 14px; color: var(--muted); }
.version { background: #eaf3ff; color: #29476d; border: 1px solid #d5e5fa; border-radius: 20px; padding: 6px 11px; font-size: 12px; white-space: nowrap; }
.version strong { font-family: var(--mono); font-size: 11px; margin-left: 4px; }
.workspace { display: grid; grid-template-columns: minmax(166px, .8fr) minmax(0, 2.8fr) minmax(270px, 1.25fr); gap: 14px; align-items: start; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--white); box-shadow: 0 3px 12px #1e4c8d08; }
.device-panel, .plan-panel { padding: 16px; }
.panel-heading { display: flex; align-items: center; gap: 8px; min-width: max-content; }
.step { color: #245da9; font: 700 11px var(--mono); background: var(--blue-tint); padding: 4px 6px; border-radius: 5px; }
.muted { color: var(--muted); font-size: 12px; line-height: 1.55; margin-top: 6px; }
.catalog { display: grid; gap: 7px; margin: 13px 0 17px; }
.device-option { justify-content: flex-start; min-width: 0; text-align: left; padding: 7px; gap: 8px; border-color: var(--line); }
.device-option .add { margin-left: auto; width: 14px; color: var(--blue); }
.section-label { display: flex; gap: 6px; align-items: center; font-size: 13px; font-weight: 700; }
.count { font: 600 11px var(--mono); color: #3c618e; background: #eaf2fe; border-radius: 10px; padding: 2px 6px; }
.inventory { border-top: 1px solid var(--line); padding-top: 12px; }
.device-list { display: grid; gap: 4px; margin-top: 8px; max-height: 212px; overflow: auto; }
.device-list button { justify-content: space-between; padding: 5px 8px; min-width: 0; min-height: 30px; border-color: transparent; font-size: 12px; gap: 4px; }
.device-list button[aria-pressed="true"] { border-color: #b8d3f7; background: #edf5ff; }
.device-list button strong { min-width: 0; text-overflow: ellipsis; overflow: hidden; }
.device-list button small { color: var(--muted); font-size: 10px; }
#device-form { margin-top: 9px; font-size: 12px; }
.rename { display: flex; gap: 5px; margin: 5px 0; }
.rename input { width: 100%; }
.text-danger { color: var(--danger); border-color: transparent; padding-inline: 4px; }
.text-danger:hover:not(:disabled) { border-color: #efc6cb; background: #fff5f6; }
.canvas-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 9px; padding: 13px; flex-wrap: wrap; }
.canvas-scroll { overflow: hidden; }
.canvas-surface {
  position: relative; background-color: #eef6ff;
  background-image: radial-gradient(circle, #b7d1ed 1px, transparent 1.1px);
  background-size: 18px 18px; border-block: 1px solid #d9e8fa;
}
#canvas { display: block; width: 100%; height: clamp(340px, 53vh, 570px); user-select: none; touch-action: none; cursor: grab; }
#canvas.panning { cursor: grabbing; }
#canvas:focus-visible { outline: 2px solid #2866c8; outline-offset: -2px; }
.canvas-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; text-align: center; gap: 6px; pointer-events: none; }
.canvas-empty .device-icon { width: 48px; height: 48px; background: #fff; border: 1px solid var(--line); }
.canvas-empty small { color: var(--muted); }
.edge { stroke: #5f8cc0; stroke-width: 2.3; }
.edge-dot { fill: #4384cd; stroke: #fff; stroke-width: 1.4; }
.edge-text { fill: #335c88; font: 12px var(--mono); text-anchor: middle; paint-order: stroke; stroke: #f5faff; stroke-width: 4px; stroke-linejoin: round; pointer-events: none; }
.node { cursor: grab; outline: none; touch-action: none; }
.node:active { cursor: grabbing; }
.node-box { fill: transparent; stroke: transparent; stroke-width: 1.5; }
.node:hover .node-box, .node:focus-visible .node-box, .node.selected .node-box { fill: #ffffff9c; stroke: #2867c9; }
.node.link-source .node-box { fill: #e1f8f1cc; stroke: #147e64; stroke-width: 2.2; stroke-dasharray: 5 3; }
.node-name, .node-model { text-anchor: middle; pointer-events: none; }
.node-name { fill: #172b48; font: 700 13px var(--mono); }
.node-model { fill: #506482; font-size: 10px; }
.port-menu {
  position: absolute; z-index: 3; display: flex; flex-direction: column;
  width: min(220px, calc(100% - 12px)); max-height: min(305px, calc(100% - 12px));
  padding: 7px; gap: 5px; border: 1px solid #bad0eb; border-radius: 10px;
  background: #fff; box-shadow: 0 8px 25px #274f7c30;
}
.port-title { padding: 4px 7px; color: #24476f; font-size: 12px; overflow-wrap: anywhere; }
.port-list { display: grid; gap: 3px; min-height: 0; overflow: auto; padding: 3px; }
.port-option { width: 100%; min-height: 29px; justify-content: space-between; border-color: transparent; font: 600 12px var(--mono); }
.port-option small { font: 11px system-ui, sans-serif; color: #48648b; }
.pending-link { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 3px 12px; font-size: 12px; color: #15574d; background: #e9f8f4; border-bottom: 1px solid #c9e9e3; }
.pending-link .plain { background: transparent; }
.canvas-footer { padding: 8px 13px; display: flex; align-items: center; justify-content: space-between; gap: 7px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.canvas-help { color: var(--muted); padding: 0 13px 8px; font-size: 11px; }
.view-controls output { min-width: 45px; text-align: center; font-family: var(--mono); }
.view-controls button[aria-label] { min-width: 29px; }
.dot { display: inline-block; background: #4387d3; border-radius: 100%; width: 7px; height: 7px; margin-right: 6px; }
.plain { border-color: transparent; color: var(--blue); min-height: 29px; }
.link-details { border-top: 1px solid var(--line); margin: 0; padding: 9px 13px 12px; }
summary { cursor: pointer; font-size: 12px; color: #335980; font-weight: 650; }
.link-row { display: flex; align-items: center; justify-content: space-between; gap: 7px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 12px; overflow-wrap: anywhere; }
.link-row:last-child { border: 0; }
.link-row small { color: var(--muted); }
.pill { width: fit-content; margin: 10px 0 13px; padding: 3px 8px; border-radius: 20px; font-size: 11px; background: #edf3fb; color: #3b587c; }
.pill.ready { background: #e4f6ef; color: #13634f; }
.plan-panel #description { margin: 6px 0 5px; }
.accent { background: #edf5ff; color: var(--blue); border-color: #cbdff9; }
.primary { background: var(--blue); color: white; border-color: var(--blue); }
.primary:hover:not(:disabled) { color: white; background: var(--blue-strong); border-color: var(--blue-strong); }
.wide { width: 100%; }
#generate { margin-top: 12px; }
.mono, pre, code { font-family: var(--mono); }
.notice { font-size: 12px; line-height: 1.55; overflow-wrap: anywhere; background: #eef6ff; color: #254d7d; border: 1px solid #d8e9fd; border-radius: 7px; margin-top: 8px; padding: 7px 9px; }
.notice.warn { background: #fff7e8; color: #74460d; border-color: #f5e1ba; }
.notice.error, .error { color: var(--danger); }
.notice.error { background: #fff2f4; border-color: #f0d4d9; }
.error { font-size: 13px; }
.output-panel { margin-top: 15px; padding: 16px; }
.output-header, .code-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.output-overview { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 9px; margin-top: 12px; }
.overview-section { background: #f2f7ff; border: 1px solid #dbe9fa; border-radius: 8px; padding: 9px 12px; font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.overview-section h3 { font-size: 13px; margin: 0 0 4px; }
.overview-section ul { margin: 0; padding-left: 20px; }
#output-warnings { max-height: 215px; overflow: auto; }
.output-empty { margin-top: 12px; color: var(--muted); border: 1px dashed #cbdbef; border-radius: 8px; padding: 14px; font-size: 13px; }
.output-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0 10px; }
.output-tabs button[aria-pressed="true"] { color: var(--blue); background: var(--blue-tint); border-color: #b9d3f5; }
.code-head { background: #edf5ff; border: 1px solid #d8e8fa; border-radius: 8px 8px 0 0; padding: 7px 11px; font-size: 13px; }
.small { min-height: 28px; font-size: 12px; padding: 3px 7px; }
pre { margin: 0; line-height: 1.55; white-space: pre; font-size: 13px; }
#config { padding: 12px; overflow: auto; max-height: 320px; color: #203c62; background: #f8fbff; border: 1px solid #d8e8fa; border-top: 0; border-radius: 0 0 8px 8px; }
.verify { display: flex; gap: 10px; align-items: flex-start; padding-top: 10px; font-size: 12px; color: var(--muted); }
.verify pre { white-space: pre-wrap; }
footer { display: flex; justify-content: space-between; gap: 12px; padding: 14px 0; font-size: 12px; color: var(--muted); }
dialog { width: min(470px, calc(100vw - 22px)); padding: 17px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); box-shadow: 0 12px 55px #15365c33; }
dialog::backdrop { background: #18305266; }
.dialog-title { display: flex; justify-content: space-between; align-items: center; }
.endpoint { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.endpoint label { display: grid; gap: 4px; font-size: 12px; }
.endpoint select { width: 100%; }
.dialog-actions { justify-content: flex-end; }
.visually-hidden, .sr-status { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
body.canvas-expanded { overflow: hidden; }
.workspace.expanded {
  position: fixed; inset: 0; z-index: 10; width: 100%; height: 100%; padding: 12px;
  grid-template-columns: clamp(160px, 17vw, 220px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr); align-items: stretch; background: var(--page);
}
.expanded .device-panel { overflow: auto; }
.expanded .plan-panel { display: none; }
.expanded .canvas-panel { display: flex; flex-direction: column; overflow: hidden; }
.expanded .canvas-scroll { flex: 1 1 0; min-height: 0; }
.expanded .canvas-surface, .expanded #canvas { height: 100%; }
.expanded #link-list { max-height: 18vh; overflow: auto; }
@media (max-width: 1080px) {
  .workspace { grid-template-columns: 170px minmax(0, 1fr); }
  .plan-panel { grid-column: 1 / -1; }
}
@media (max-width: 620px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .intro { flex-direction: column; align-items: flex-start; }
  .catalog { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .device-option .add { display: none; }
  .catalog .device-icon { width: 25px; height: 25px; }
  .catalog .device-icon .icon { width: 24px; height: 21px; }
  .top .actions .icon { display: none; }
  .top .actions button { padding-inline: 7px; }
  .workspace.expanded { padding: 6px; gap: 6px; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .expanded .device-panel { max-height: 30vh; padding: 8px; }
  .expanded .catalog { margin: 8px 0; }
  .expanded .canvas-toolbar { padding: 8px; }
  .expanded .canvas-help { display: none; }
}
@media (max-width: 420px) {
  .catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
