/* =========================================================
   WireGuard Topology · dark engineering console
   ========================================================= */

:root {
  /* Surfaces */
  --bg-0:        #080C17;
  --bg-1:        #0B1120;
  --bg-2:        #101A2F;
  --panel:       #0F172A;
  --panel-2:     #141E34;
  --panel-3:     #1B2742;
  --surface:     #141E30;
  --surface-hi:  #1D2A44;

  /* Strokes */
  --line:         #1E2A44;
  --line-2:       #253351;
  --line-3:       #334766;
  --line-focus:   #F97316;

  /* Text */
  --txt:          #E2E8F0;
  --txt-2:        #A9B4CB;
  --txt-3:        #6B7A94;
  --txt-faint:    #475067;

  /* Accents */
  --orange:       #F97316;
  --orange-2:     #FB923C;
  --orange-dim:   rgba(249,115,22,0.16);
  --blue:         #3B82F6;
  --blue-2:       #60A5FA;
  --blue-dim:     rgba(96,165,250,0.18);
  --green:        #22C55E;
  --green-2:      #4ADE80;
  --amber:        #F59E0B;
  --red:          #EF4444;

  --radius:       10px;
  --radius-sm:    6px;
  --shadow-card:  0 1px 0 rgba(255,255,255,0.02) inset, 0 8px 24px -10px rgba(0,0,0,0.4);
  --shadow-pop:   0 24px 60px -20px rgba(0,0,0,0.7), 0 0 0 1px var(--line-2);

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

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--txt);
  background:
    radial-gradient(1400px 900px at 70% -10%, rgba(249,115,22,0.05), transparent 60%),
    radial-gradient(1200px 1000px at -10% 120%, rgba(59,130,246,0.06), transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}

/* grid backdrop */
body::before {
  content: "";
  position: fixed; inset: 0;
  background-image:
    linear-gradient(to right, rgba(94,122,178,0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(94,122,178,0.04) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 0;
}

/* =========================================================
   Top bar
   ========================================================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 24px;
  background: rgba(11, 17, 32, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand__mark { width: 38px; height: 38px; }
.brand__name {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--txt);
  letter-spacing: -0.02em;
}
.brand__name span {
  color: var(--orange);
  font-weight: 400;
}
.brand__sub {
  margin: 1px 0 0;
  font-size: 11.5px;
  color: var(--txt-3);
  letter-spacing: 0.02em;
}

.topbar__nav {
  display: flex;
  align-items: center;
  gap: 18px;
}
.kbd-group {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: var(--txt-3);
}
.kbd-group span { display: inline-flex; align-items: center; gap: 4px; }
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--txt-2);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  line-height: 1.4;
}

.topbar__status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.25);
  color: var(--green-2);
  font-family: var(--font-mono);
  font-size: 11px;
  border-radius: 20px;
}
.topbar__status.is-dirty {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.25);
  color: var(--amber);
}
.pulse {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
  animation: pulse 2.2s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,0.6); }
  70%  { box-shadow: 0 0 0 8px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

.topbar__link {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--txt-3);
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  transition: all .18s;
}
.topbar__link:hover { color: var(--orange); border-color: var(--orange); }

/* =========================================================
   App stage : full-screen canvas, floating side panels
   ========================================================= */
html, body { height: 100%; overflow: hidden; }
.app {
  position: relative;
  z-index: 1;
  height: 100vh;
  padding: 0;
  display: block;
  overflow: hidden;
}
.app:fullscreen,
.app:-webkit-full-screen {
  height: 100vh;
  background: var(--bg-1);
}

/* =========================================================
   Floating brand chip (top-left of stage)
   ========================================================= */
.brandbar {
  position: absolute;
  top: 14px; left: 14px;
  z-index: 18;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 10px;
  background: rgba(10, 17, 33, 0.82);
  backdrop-filter: blur(10px) saturate(130%);
  -webkit-backdrop-filter: blur(10px) saturate(130%);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  transition: left .3s;
}
body.left-collapsed .brandbar { left: 14px; }
.brandbar__mark { width: 32px; height: 32px; flex-shrink: 0; }
.brandbar__text { display: flex; flex-direction: column; line-height: 1; }
.brandbar__name {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--txt);
  letter-spacing: -0.01em;
}
.brandbar__name span { color: var(--orange); font-weight: 400; }
.brandbar__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.brandbar__status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.25);
  color: var(--green-2);
  font-family: var(--font-mono);
  font-size: 9.5px;
  border-radius: 10px;
  letter-spacing: 0.02em;
}
.brandbar__status.is-dirty {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.25);
  color: var(--amber);
}
.brandbar__link {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--txt-3);
  text-decoration: none;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border: 1px solid var(--line-2);
  border-radius: 3px;
  transition: all .15s;
}
.brandbar__link:hover { color: var(--orange); border-color: var(--orange); }

/* Offset panels so they don't overlap the floating brand/ctrls at the top */
.panel--left  { top: 72px; }
.panel--right { top: 58px; }
.legend       { bottom: 84px; }   /* sit above toolbar */

/* =========================================================
   Panels — floating glass plates above the canvas
   ========================================================= */
.canvas,
.modal__sheet {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel {
  position: absolute;
  top: 14px;
  bottom: 78px;            /* clear the bottom toolbar */
  width: 300px;
  z-index: 20;
  background: rgba(11, 17, 32, 0.82);
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.03) inset,
    0 20px 60px -20px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform .3s cubic-bezier(.2,.9,.3,1.1), opacity .2s;
}
.panel--left  { left: 14px; }
.panel--right { right: 14px; }

.panel.is-collapsed { transform: translateX(calc(-100% - 20px)); opacity: 0; pointer-events: none; }
.panel--right.is-collapsed { transform: translateX(calc(100% + 20px)); }

.panel__collapse {
  margin-left: 6px;
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--txt-3);
  font-size: 12px;
  width: 22px; height: 22px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  transition: all .15s;
}
.panel__collapse:hover {
  color: var(--orange);
  border-color: var(--orange);
}

.panel-handle {
  position: absolute;
  top: 50%;
  width: 32px;
  height: 110px;
  z-index: 15;
  background: rgba(11, 17, 32, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line-2);
  color: var(--txt-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(-50%);
  padding: 0;
  transition: color .15s, border-color .15s, background .15s;
  animation: handleIn .25s ease-out;
}
.panel-handle span {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.28em;
  writing-mode: vertical-rl;
  text-orientation: mixed;
}
.panel-handle--left  { left: 0; border-left: 0; border-radius: 0 8px 8px 0; }
.panel-handle--right { right: 0; border-right: 0; border-radius: 8px 0 0 8px; }
.panel-handle:hover { color: var(--orange); border-color: var(--orange); }
.panel-handle[hidden] { display: none; }
@keyframes handleIn {
  from { opacity: 0; transform: translate(-12px, -50%); }
  to   { opacity: 1; transform: translate(0, -50%); }
}
.panel-handle--right { animation: handleInRight .25s ease-out; }
@keyframes handleInRight {
  from { opacity: 0; transform: translate(12px, -50%); }
  to   { opacity: 1; transform: translate(0, -50%); }
}

.panel__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.015), transparent);
}
.panel__head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--txt);
  letter-spacing: -0.01em;
}
.panel__num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--orange);
  padding: 2px 6px;
  background: var(--orange-dim);
  border-radius: 4px;
  letter-spacing: 0.04em;
}
.panel__tag {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--txt-3);
  letter-spacing: 0.1em;
}

.panel__body {
  flex: 1;
  padding: 10px 12px;
  overflow-y: auto;
  min-height: 0;
}

/* =========================================================
   Form fields (compact)
   ========================================================= */
.field { margin-bottom: 8px; }
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.field-row .field { margin-bottom: 0; }

.field label {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-size: 11.5px;
  color: var(--txt-2);
  margin-bottom: 3px;
  font-weight: 500;
}
.field .hint {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--txt-faint);
  font-weight: 400;
}

input[type="text"],
input[type="number"],
input[type="password"],
textarea,
select {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--txt);
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 42px; line-height: 1.45; padding: 6px 8px; }

input:focus, textarea:focus, select:focus {
  border-color: var(--orange);
  background: var(--panel-3);
  box-shadow: 0 0 0 3px var(--orange-dim);
}
input::placeholder, textarea::placeholder { color: var(--txt-faint); }
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--txt-2) 50%), linear-gradient(135deg, var(--txt-2) 50%, transparent 50%);
  background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}

input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--orange);
  margin-right: 6px;
  vertical-align: middle;
}

/* advanced */
.advanced {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px dashed var(--line-2);
}
.advanced summary {
  list-style: none;
  cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--txt-3);
  padding: 4px 0;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary i {
  font-style: normal;
  color: var(--orange);
  font-size: 14px;
  font-weight: 600;
  transition: transform .2s;
}
.advanced[open] summary i { transform: rotate(45deg); }
.advanced .field { margin-top: 10px; margin-bottom: 10px; }

/* =========================================================
   Canvas (full-bleed beneath floating panels)
   ========================================================= */
.canvas {
  position: absolute;
  inset: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}
.canvas__stage {
  position: relative;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(1400px 900px at 50% 35%, rgba(59,130,246,0.06), transparent 65%),
    linear-gradient(180deg, #0A1224, #060B18);
  overflow: hidden;
  cursor: grab;
}
.canvas__stage.is-panning { cursor: grabbing; }
#topology {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  user-select: none;
  -webkit-user-select: none;
}
#topology * { user-select: none; }

/* Empty state */
.empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  padding: 32px;
  gap: 10px;
}
.empty__svg { width: 88px; height: 88px; opacity: .8; margin-bottom: 8px; }
.empty__title {
  font-size: 22px;
  font-weight: 600;
  color: var(--txt);
  margin: 0;
  letter-spacing: -0.01em;
}
.empty__body {
  font-size: 13px;
  color: var(--txt-3);
  max-width: 400px;
  margin: 0 0 20px;
  line-height: 1.7;
}
.empty__body em { color: var(--orange); font-style: normal; font-weight: 500; }
.pill {
  display: inline-block;
  padding: 1px 7px;
  font-size: 11px;
  border-radius: 3px;
  font-family: var(--font-mono);
  margin: 0 1px;
}
.pill--pub  { color: var(--orange); background: var(--orange-dim); }
.pill--priv { color: var(--blue-2); background: var(--blue-dim); }

/* Legend (floating, bottom-left of stage, above panels) */
.legend {
  position: absolute;
  left: 328px;
  z-index: 18;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 14px;
  background: rgba(10, 17, 33, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  font-size: 11.5px;
  color: var(--txt-2);
  transition: left .3s;
}
body.left-collapsed .legend { left: 60px; }
.legend__item { display: flex; align-items: center; gap: 8px; }
.line {
  display: inline-block;
  width: 32px;
  height: 2px;
  position: relative;
}
.line--pub {
  background: var(--orange);
  box-shadow: 0 0 8px rgba(249,115,22,0.5);
}
.line--priv {
  height: 0;
  border-top: 2px dashed var(--blue-2);
  box-sizing: content-box;
}
.swatch {
  display: inline-block;
  width: 14px; height: 14px;
  border: 1px solid var(--line-3);
  border-radius: 3px;
}
.swatch--cloud { border-color: var(--blue); background: linear-gradient(90deg, var(--blue), var(--blue-2)); }
.swatch--nat   { border-color: var(--amber); background: linear-gradient(90deg, var(--amber), #FBBF24); }

/* SVG node card & group region */
.topo-region {
  fill: rgba(59,130,246,0.05);
  stroke: var(--blue);
  stroke-width: 1;
  stroke-dasharray: 6 4;
  opacity: .85;
}
.topo-region.is-nat {
  fill: rgba(245,158,11,0.05);
  stroke: var(--amber);
}
.topo-region.is-selected {
  fill: rgba(249,115,22,0.08);
  stroke: var(--orange);
  stroke-dasharray: none;
  stroke-width: 1.5;
}
.topo-region-title {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  fill: var(--blue-2);
}
.topo-region-title.is-nat { fill: var(--amber); }
.topo-region-title.is-selected { fill: var(--orange); }
.topo-region-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--txt-3);
  letter-spacing: 0.08em;
}

/* Node card */
.node-card { cursor: pointer; }
.node-card__body {
  fill: var(--surface);
  stroke: var(--blue);
  stroke-width: 1.5;
  transition: stroke-width .15s, filter .15s;
}
.node-card.is-nat .node-card__body { stroke: var(--amber); }
.node-card:hover .node-card__body {
  stroke-width: 2;
  filter: drop-shadow(0 0 6px rgba(96,165,250,0.35));
}
.node-card.is-nat:hover .node-card__body { filter: drop-shadow(0 0 6px rgba(245,158,11,0.35)); }
.node-card.is-selected .node-card__body {
  stroke: var(--orange);
  stroke-width: 2.5;
  filter: drop-shadow(0 0 8px rgba(249,115,22,0.5));
}
.node-card__stripe { fill: url(#cloudGrad); }
.node-card.is-nat .node-card__stripe { fill: url(#natGrad); }

/* Hub (center) */
.hub-pulse {
  fill: rgba(249, 115, 22, 0.10);
  transform-origin: center;
  transform-box: fill-box;
  animation: hubPulse 3s ease-in-out infinite;
}
.hub-pulse-2 {
  fill: rgba(249, 115, 22, 0.06);
  transform-origin: center;
  transform-box: fill-box;
  animation: hubPulse 3s ease-in-out infinite;
  animation-delay: 1s;
}
@keyframes hubPulse {
  0%, 100% { transform: scale(0.85); opacity: .9; }
  50%      { transform: scale(1.25); opacity: 0; }
}
.hub-ring {
  fill: none;
  stroke: var(--orange);
  stroke-width: 1;
  opacity: 0.55;
  stroke-dasharray: 3 3;
}
.hub-ring-solid {
  fill: rgba(15, 23, 42, 0.9);
  stroke: var(--orange);
  stroke-width: 1.2;
}
.hub-core {
  fill: var(--orange);
  filter: drop-shadow(0 0 10px rgba(249,115,22,0.7));
}
.hub-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  fill: var(--orange);
  letter-spacing: 0.28em;
  pointer-events: none;
}
.hub-sublabel {
  font-family: var(--font-mono);
  font-size: 9px;
  fill: var(--txt-3);
  letter-spacing: 0.18em;
  pointer-events: none;
}

.node-card__host {
  font-size: 17px;
  font-weight: 700;
  fill: var(--txt);
  letter-spacing: -0.01em;
  font-family: var(--font-sans);
}
.node-card.is-selected .node-card__host { fill: var(--orange-2); }

.node-card__vtype {
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 600;
  fill: rgba(11, 17, 32, 0.9);
  letter-spacing: 0.18em;
  pointer-events: none;
}

.node-card__line {
  font-family: var(--font-mono);
  font-size: 13px;
  fill: var(--txt);
  letter-spacing: 0.005em;
}
.node-card__line.is-empty {
  fill: var(--txt-faint);
  font-style: italic;
  letter-spacing: 0;
}
.node-card__line--priv { fill: var(--blue-2); }
.node-card__line--key {
  font-size: 12px;
  fill: var(--green-2);
  letter-spacing: 0.03em;
}
.node-card__line--empty {
  font-family: var(--font-mono);
  font-size: 12px;
  fill: var(--amber);
  letter-spacing: 0.04em;
}

.node-card__icon {
  color: var(--txt-3);
  fill: none;
  stroke-width: 1.15;
  pointer-events: none;
}
.node-card__icon--priv { color: var(--blue-2); }
.node-card__icon--ok   { color: var(--green-2); }
.node-card__icon--warn { color: var(--amber); }

.node-card__led {
  fill: rgba(100, 116, 139, 0.35);
  stroke: rgba(100, 116, 139, 0.55);
  stroke-width: 0.8;
}
.node-card__led.is-on {
  fill: var(--green-2);
  stroke: var(--green-2);
  filter: drop-shadow(0 0 4px rgba(74, 222, 128, 0.75));
}
.node-card__led-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  fill: var(--txt-faint);
  letter-spacing: 0.18em;
  pointer-events: none;
}
.node-card__led-label.is-on { fill: var(--green-2); }

.node-card__badge {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--txt-3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  pointer-events: none;
}

/* Delete button (shows on node hover / selection) */
.node-card__del {
  opacity: 0;
  cursor: pointer;
  transition: opacity .12s ease, transform .12s ease;
  pointer-events: none;
}
.node-card:hover .node-card__del,
.node-card.is-selected .node-card__del {
  opacity: 1;
  pointer-events: auto;
}
.node-card:hover .node-card__led,
.node-card:hover .node-card__led-label,
.node-card.is-selected .node-card__led,
.node-card.is-selected .node-card__led-label {
  opacity: 0;
  transition: opacity .12s ease;
}
.node-card__del-bg {
  fill: rgba(239, 68, 68, 0.12);
  stroke: var(--red);
  stroke-width: 1;
  transition: fill .12s;
}
.node-card__del:hover .node-card__del-bg {
  fill: rgba(239, 68, 68, 0.95);
}
.node-card__del-x {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  fill: var(--red);
  pointer-events: none;
  transition: fill .12s;
}
.node-card__del:hover .node-card__del-x {
  fill: #fff;
}

/* Edges */
.edge-pub {
  stroke: var(--orange);
  stroke-width: 1.1;
  fill: none;
  opacity: 0.28;
  transition: opacity .2s, stroke-width .2s;
}
.edge-pub.is-highlight {
  opacity: 0.95;
  stroke-width: 1.8;
  filter: drop-shadow(0 0 4px rgba(249,115,22,0.6));
}
.edge-priv {
  stroke: var(--blue-2);
  stroke-width: 1.6;
  stroke-dasharray: 6 4;
  fill: none;
  opacity: 0.65;
}
.edge-priv.is-highlight {
  opacity: 1;
  stroke-width: 2.2;
  animation: dash 1.1s linear infinite;
}
@keyframes dash {
  from { stroke-dashoffset: 20; }
  to   { stroke-dashoffset: 0; }
}

/* =========================================================
   Top-right floating controls (zoom / fit / fullscreen)
   ========================================================= */
.ctrls {
  position: absolute;
  top: 14px; right: 14px;
  z-index: 18;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: rgba(10, 17, 33, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  transition: right .3s;
}
body.right-collapsed .ctrls { right: 14px; }
.ctrls__btn {
  width: 28px; height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 5px;
  color: var(--txt-2);
  font-family: var(--font-mono);
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}
.ctrls__btn:hover { background: var(--panel-3); color: var(--orange); }
.ctrls__pct {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--txt-3);
  padding: 0 8px;
  min-width: 42px;
  text-align: center;
  letter-spacing: 0.02em;
  border-left: 1px solid var(--line-2);
  border-right: 1px solid var(--line-2);
  margin: 0 2px;
}

/* =========================================================
   Bottom-center floating toolbar (stats + actions)
   ========================================================= */
.toolbar {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 18;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 10px 18px;
  background: rgba(10, 17, 33, 0.85);
  backdrop-filter: blur(12px) saturate(130%);
  -webkit-backdrop-filter: blur(12px) saturate(130%);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  box-shadow: 0 20px 50px -20px rgba(0,0,0,0.6);
  max-width: calc(100vw - 40px);
  flex-wrap: wrap;
  justify-content: center;
}
.toolbar__stats {
  display: flex;
  gap: 20px;
  padding-right: 18px;
  border-right: 1px solid var(--line-2);
}
.toolbar__stats > div { display: flex; flex-direction: column; line-height: 1; }
.toolbar__stats .num {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  color: var(--txt);
  letter-spacing: -0.01em;
}
.toolbar__stats .lbl {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--txt-3);
  letter-spacing: 0.18em;
  margin-top: 4px;
  text-transform: uppercase;
}
.toolbar__actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* =========================================================
   Buttons
   ========================================================= */
.btn {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 13px;
  background: var(--panel-2);
  color: var(--txt-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn:hover {
  background: var(--panel-3);
  color: var(--txt);
  border-color: var(--line-3);
}
.btn i { font-style: normal; font-family: var(--font-mono); font-weight: 600; }
.btn--primary {
  background: var(--orange);
  border-color: var(--orange);
  color: #0B1120;
  font-weight: 600;
  padding: 8px 16px;
  box-shadow: 0 2px 0 rgba(249,115,22,0.25), 0 0 18px -4px rgba(249,115,22,0.6);
}
.btn--primary:hover {
  background: var(--orange-2);
  border-color: var(--orange-2);
  color: #0B1120;
  box-shadow: 0 2px 0 rgba(249,115,22,0.4), 0 0 24px -4px rgba(249,115,22,0.8);
}
.btn--primary:disabled { opacity: .6; cursor: wait; }
.btn--block {
  display: flex;
  width: 100%;
  justify-content: center;
  margin: 10px 0;
  padding: 8px 14px;
  border-style: dashed;
  color: var(--txt-2);
}
.btn--block:hover { color: var(--orange); border-color: var(--orange); border-style: solid; }
.btn--small { font-size: 12px; padding: 5px 9px; }
.btn--sm    { font-size: 12px; padding: 6px 11px; }
.btn--danger-ghost { color: var(--red); }
.btn--danger-ghost:hover { background: rgba(239,68,68,0.1); border-color: var(--red); color: var(--red); }

/* =========================================================
   Foldable section (global config in left panel)
   ========================================================= */
.fold {
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  margin-bottom: 10px;
  overflow: hidden;
}
.fold[open] { background: var(--panel-2); }
.fold__head {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  user-select: none;
}
.fold__head::-webkit-details-marker { display: none; }
.fold__head:hover { background: var(--panel-3); }
.fold__num {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--orange);
  padding: 2px 5px;
  background: var(--orange-dim);
  border-radius: 3px;
  letter-spacing: 0.06em;
}
.fold__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--txt);
}
.fold__sub {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--txt-3);
  letter-spacing: 0.1em;
}
.fold__head i {
  font-style: normal;
  color: var(--orange);
  font-size: 16px;
  font-weight: 600;
  transition: transform .2s;
  width: 16px;
  text-align: center;
}
.fold[open] .fold__head i { transform: rotate(45deg); }
.fold__body {
  padding: 10px;
  border-top: 1px solid var(--line);
  background: var(--bg-1);
}

.subhead {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 4px 2px 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--txt-2);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.subhead__sub {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--txt-3);
  letter-spacing: 0.12em;
  font-weight: 400;
}

/* =========================================================
   Left panel: groups cards (no node list below)
   ========================================================= */
.groups { display: flex; flex-direction: column; gap: 5px; }

.group-card {
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
  cursor: pointer;
}
.group-card.is-selected {
  border-color: var(--orange);
  box-shadow: 0 0 0 2px var(--orange-dim);
}
.group-card:hover { border-color: var(--line-3); }
.group-card.is-selected:hover { border-color: var(--orange); }
.group-card__head {
  display: flex;
  align-items: center;
  padding: 5px 8px;
  gap: 6px;
  cursor: pointer;
}
.group-card__head:hover { background: var(--panel-3); }
.group-card__name {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--txt);
  outline: none;
}
.group-card__name:focus {
  border-bottom: 1px dotted var(--orange);
}
.group-card__type {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.08em;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}
.group-card__type.is-cloud {
  color: var(--blue-2);
  background: var(--blue-dim);
  border: 1px solid rgba(59,130,246,0.35);
}
.group-card__type.is-nat {
  color: var(--amber);
  background: rgba(245,158,11,0.12);
  border: 1px solid rgba(245,158,11,0.35);
}
.group-card__del {
  background: none;
  border: 0;
  font-size: 12px;
  color: var(--txt-faint);
  cursor: pointer;
  padding: 2px 3px;
  line-height: 1;
  flex-shrink: 0;
}
.group-card__del:hover { color: var(--red); }

.group-card__count {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--txt-3);
  padding: 1px 5px;
  background: var(--panel-3);
  border-radius: 3px;
  border: 1px solid var(--line-2);
  flex-shrink: 0;
}
.group-card__addnode {
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--txt-3);
  font-family: var(--font-mono);
  font-size: 11px;
  width: 18px; height: 18px;
  border-radius: 3px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  transition: all .15s;
  flex-shrink: 0;
}
.group-card__addnode:hover {
  color: var(--orange);
  border-color: var(--orange);
  background: var(--orange-dim);
}

.group-card__nodes { padding: 4px 6px 6px; }
.node-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border-radius: 4px;
  cursor: pointer;
  position: relative;
}
.node-row:hover { background: rgba(255,255,255,0.03); }
.node-row.is-selected {
  background: var(--orange-dim);
}
.node-row.is-selected::before {
  content: "";
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 2px;
  background: var(--orange);
  border-radius: 2px;
}
.node-row__dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--blue-2);
  flex-shrink: 0;
}
.node-row.is-selected .node-row__dot { background: var(--orange); box-shadow: 0 0 0 3px var(--orange-dim); }
.node-row__text {
  flex: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}
.node-row__name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--txt);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.node-row__ip {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--txt-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.node-row__del {
  background: none;
  border: 0;
  font-size: 12px;
  color: var(--txt-faint);
  cursor: pointer;
  padding: 2px 4px;
}
.node-row__del:hover { color: var(--red); }

.add-node {
  display: block;
  width: 100%;
  padding: 5px 8px;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--txt-3);
  background: transparent;
  border: 1px dashed var(--line-2);
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
  text-transform: uppercase;
}
.add-node:hover { color: var(--orange); border-color: var(--orange); }

/* Selection editor (right panel) */
.selection__head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.selection__empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--txt-3);
}
.selection__empty svg {
  width: 60px;
  height: 60px;
  margin-bottom: 14px;
  opacity: .7;
}
.selection__empty h4 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--txt-2);
}
.selection__empty p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--txt-3);
}
.selection__empty em {
  font-style: normal;
  color: var(--orange);
}
.selection__head h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--txt);
  margin: 0;
}
.selection__head .sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--txt-3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.selection__head .badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  background: var(--blue-dim);
  color: var(--blue-2);
  border-radius: 3px;
  letter-spacing: 0.06em;
}
.keygen { display: flex; gap: 6px; margin: 6px 0 10px; }
.keygen .btn { flex: 1; }

/* =========================================================
   Modal
   ========================================================= */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}
.modal[hidden] { display: none; }
.modal__scrim {
  position: absolute; inset: 0;
  background: rgba(4, 8, 18, 0.7);
  backdrop-filter: blur(4px);
}
.modal__sheet {
  position: relative;
  background: var(--panel);
  width: min(1100px, 92vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  animation: popIn .22s cubic-bezier(.2,.9,.3,1.2);
  box-shadow: var(--shadow-pop);
}
.modal__sheet--small { width: min(560px, 92vw); }
@keyframes popIn {
  from { transform: translateY(8px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.modal__head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal__head h2 { margin: 0; font-size: 15px; font-weight: 600; color: var(--txt); }
.modal__close {
  margin-left: auto;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  width: 28px; height: 28px;
  border-radius: 4px;
  color: var(--txt-3);
  font-size: 13px;
  cursor: pointer;
}
.modal__close:hover { color: var(--red); border-color: var(--red); }

.modal__body {
  display: grid;
  grid-template-columns: 240px 1fr;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}
.modal__body--col {
  display: flex;
  flex-direction: column;
  padding: 18px;
  gap: 12px;
}
.modal__hint { margin: 0; color: var(--txt-3); font-size: 13px; }
.modal__nav {
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 8px 0;
  background: var(--bg-1);
}
.modal__nav button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 16px;
  background: transparent;
  border: 0;
  border-left: 3px solid transparent;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--txt-2);
  cursor: pointer;
}
.modal__nav button:hover { background: rgba(255,255,255,0.03); color: var(--txt); }
.modal__nav button.is-active {
  background: var(--panel-2);
  border-left-color: var(--orange);
  color: var(--orange);
}
.modal__nav button small {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--txt-faint);
  letter-spacing: 0.04em;
  margin-top: 2px;
}
.modal__view { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.modal__toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
}
.modal__toolbar > div { margin-left: auto; display: flex; gap: 8px; }
.modal__file {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--txt-2);
  margin: 0;
  letter-spacing: 0.02em;
}

.ini {
  flex: 1;
  margin: 0;
  padding: 20px 24px;
  overflow: auto;
  background: var(--bg-0);
  color: var(--txt);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
  white-space: pre;
  tab-size: 2;
}
.ini .section { color: var(--orange); font-weight: 600; }
.ini .key     { color: var(--blue-2); }
.ini .val     { color: var(--txt); }
.ini .cmt     { color: var(--txt-faint); font-style: italic; }

/* =========================================================
   Toast
   ========================================================= */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translate(-50%, 16px);
  background: var(--panel-2);
  color: var(--txt);
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 200;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  box-shadow: var(--shadow-pop);
}
.toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast.is-error { border-color: var(--red); color: var(--red); background: rgba(239,68,68,0.08); }

/* =========================================================
   Scrollbar
   ========================================================= */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--line-3); }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1200px) {
  .panel { width: 280px; }
  .legend { left: 308px; }
}
@media (max-width: 900px) {
  .panel { width: calc(100vw - 28px); bottom: 84px; }
  .panel--right.is-collapsed, .panel--left.is-collapsed { opacity: 0; }
  .panel-handle { display: flex !important; }
  .legend { left: 14px; }
}
