:root {
  --bg: #0b0f1a;
  --panel: #121828;
  --panel-2: #0f1422;
  --border: #22304a;
  --text: #e6eaf2;
  --muted: #8b94a8;
  --accent: #6366f1;
  --accent-2: #818cf8;
  --client: #22d3ee;
  --switch: #f59e0b;
  --server: #a78bfa;
  --eapol: #22d3ee;
  --radius: #f59e0b;
  --inner: #f472b6;
  --good: #34d399;
}

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

body {
  font-family: "SF Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  background: radial-gradient(1200px 700px at 70% -10%, #16203a 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 15, 26, 0.7);
  backdrop-filter: blur(6px);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 14px; height: 14px; border-radius: 4px;
  background: linear-gradient(135deg, var(--client), var(--accent) 55%, var(--server));
  box-shadow: 0 0 14px rgba(99, 102, 241, 0.7);
}
.brand h1 { font-size: 16px; font-weight: 600; letter-spacing: 0.4px; }

.legend { display: flex; gap: 18px; color: var(--muted); font-size: 12px; }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.eapol  { background: var(--eapol); }
.dot.radius { background: var(--radius); }
.dot.inner  { background: var(--inner); }

.app {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  flex: 1;
  min-height: 0;
}

/* ---------- Sidebar ---------- */
.sidebar {
  border-right: 1px solid var(--border);
  background: var(--panel-2);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.method-tabs { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.tab {
  background: #171f33;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 9px 4px;
  border-radius: 8px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.tab:hover { color: var(--text); border-color: #33436b; }
.tab.active {
  color: #fff;
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.25), rgba(99, 102, 241, 0.08));
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.4), 0 0 16px rgba(99, 102, 241, 0.25);
}

.tagline { font-size: 12px; color: var(--muted); line-height: 1.55; }

/* inner method selector */
.inner-box { border: 1px solid var(--border); border-radius: 9px; padding: 10px; background: rgba(99, 102, 241, 0.05); }
.inner-head { font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--accent-2); margin-bottom: 7px; }
.inner-tabs { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.inner-tab {
  background: #171f33;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 7px 2px;
  border-radius: 7px;
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.inner-tab:hover { color: var(--text); border-color: #33436b; }
.inner-tab.active {
  color: #fff;
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.25);
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.4);
}
.inner-desc { font-size: 10.5px; color: var(--muted); line-height: 1.45; margin-top: 7px; }

.phase-legend { display: flex; flex-direction: column; gap: 4px; }
.ph { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.ph i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

.step-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.step-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 9px;
  border-radius: 7px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--muted);
  transition: all 0.15s ease;
}
.step-item:hover { background: rgba(99, 102, 241, 0.06); color: var(--text); }
.step-item.done { opacity: 0.65; }
.step-item.done .step-num { color: var(--good); border-color: rgba(52, 211, 153, 0.5); }
.step-item.current {
  color: #fff;
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.12);
  box-shadow: 0 0 14px rgba(99, 102, 241, 0.15);
}
.step-item .step-num {
  flex: 0 0 auto;
  width: 18px; height: 18px;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 10px;
  margin-top: 1px;
}
.phase-head {
  margin-top: 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--accent-2);
  padding: 4px 2px 2px;
  border-bottom: 1px dashed var(--border);
}

/* ---------- Main ---------- */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  flex-wrap: wrap;
}

.controls { display: flex; gap: 6px; }
.controls button {
  width: 38px; height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #171f33;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.controls button:hover { border-color: var(--accent); color: #fff; background: rgba(99, 102, 241, 0.18); }
#btn-play {
  width: 46px;
  background: linear-gradient(180deg, var(--accent), #4f46e5);
  border-color: var(--accent);
  color: #fff;
}
#btn-play:hover { filter: brightness(1.15); }

.speed { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.export { display: flex; gap: 6px; }
.export button {
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #171f33;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.export button:hover { border-color: var(--accent); color: #fff; background: rgba(99, 102, 241, 0.18); }
.seg { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button {
  background: #171f33;
  border: none;
  border-right: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 10px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.seg button:last-child { border-right: none; }
.seg button.active { background: rgba(99, 102, 241, 0.25); color: #fff; }

.progress {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  color: var(--muted);
  min-width: 200px;
}
.bar { flex: 1; height: 6px; background: #1a2340; border-radius: 3px; overflow: hidden; }
.fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--client), var(--accent) 60%, var(--server));
  border-radius: 3px;
  transition: width 0.35s ease;
}

/* ---------- Diagram / ladder ---------- */
.diagram {
  position: relative;
  flex: 1;
  min-height: 420px;
  overflow-y: auto;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.012), rgba(255,255,255,0.004)),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.02) 0 1px, transparent 1px 90px);
  scrollbar-width: thin;
}

.nodebar {
  position: sticky;
  top: 0;
  z-index: 6;
  height: 158px;
  background: linear-gradient(180deg, rgba(13, 18, 32, 0.98), rgba(13, 18, 32, 0.92));
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(6px);
}

.node {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 152px;
  padding: 13px 12px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: linear-gradient(180deg, #151d31, #10172a);
  text-align: center;
  z-index: 2;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}
.node-client { border-color: rgba(34, 211, 238, 0.35); }
.node-switch { border-color: rgba(245, 158, 11, 0.35); }
.node-proxy  { border-color: rgba(99, 102, 241, 0.45); }
.node-server { border-color: rgba(167, 139, 250, 0.35); }

.node.pulse { animation: nodepulse 0.7s ease; }
@keyframes nodepulse {
  0% { box-shadow: 0 10px 30px rgba(0,0,0,0.35), 0 0 0 0 var(--glow, var(--accent)); }
  100% { box-shadow: 0 10px 30px rgba(0,0,0,0.35), 0 0 0 24px transparent; }
}

.node-icon {
  width: 38px; height: 38px;
  margin: 0 auto 8px;
  border-radius: 11px;
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
}
.node-client .node-icon { background: rgba(34, 211, 238, 0.14); color: var(--client); box-shadow: inset 0 0 0 1px rgba(34,211,238,0.4); }
.node-switch .node-icon { background: rgba(245, 158, 11, 0.14); color: var(--switch); box-shadow: inset 0 0 0 1px rgba(245,158,11,0.4); }
.node-proxy  .node-icon { background: rgba(99, 102, 241, 0.16); color: var(--accent-2); box-shadow: inset 0 0 0 1px rgba(99,102,241,0.5); }
.node-server .node-icon { background: rgba(167, 139, 250, 0.14); color: var(--server); box-shadow: inset 0 0 0 1px rgba(167,139,250,0.4); }

.node-name { font-size: 12.5px; font-weight: 700; }
.node-role { font-size: 10.5px; color: var(--muted); margin: 2px 0 8px; }

.node-status, .node-port {
  display: inline-block;
  font-size: 10px;
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: rgba(0,0,0,0.25);
  transition: all 0.4s ease;
}
.node-status.good, .node-port.good { color: #052e1f; background: var(--good); border-color: var(--good); font-weight: 700; }
.node-status.busy { color: var(--client); border-color: rgba(34, 211, 238, 0.5); }
.node-status.warn { color: var(--switch); border-color: rgba(245, 158, 11, 0.5); }
.node-status.bad { color: #f87171; border-color: rgba(248, 113, 113, 0.5); }
.node-port.bad { color: var(--switch); border-color: rgba(245, 158, 11, 0.5); }

/* ladder content */
.ladder { position: relative; }
.ladder-svg {
  position: absolute;
  top: 0; left: 0;
  display: block;
  pointer-events: none;
}
.lifeline {
  stroke: #2c3b5c;
  stroke-dasharray: 4 6;
  stroke-width: 1;
}
line.msg {
  stroke-width: 2;
  filter: drop-shadow(0 0 5px currentColor);
  opacity: 0;
}
line.msg.eapol  { stroke: var(--eapol); }
line.msg.radius { stroke: var(--radius); }
line.msg.inner  { stroke: var(--inner); }
line.msg.done { opacity: 0.4; filter: none; }
line.msg.cur  { opacity: 1; }

.tunnel {
  position: absolute;
  left: 0; right: 0;
  border: 1.5px dashed rgba(244, 114, 182, 0.55);
  border-radius: 16px;
  background: radial-gradient(ellipse at center, rgba(244, 114, 182, 0.07), rgba(244, 114, 182, 0.02));
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
}
.tunnel.on { opacity: 1; }
.tunnel-label {
  position: absolute;
  top: 6px; left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--inner);
  background: var(--panel);
  border: 1px solid rgba(244, 114, 182, 0.4);
  border-radius: 6px;
  padding: 2px 10px;
  white-space: nowrap;
}

.label-layer { position: absolute; top: 0; left: 0; right: 0; pointer-events: none; }
.lpill {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 7px;
  font-size: 11px;
  line-height: 1.3;
  text-align: left;
  white-space: nowrap;
  transform: translate(-50%, -100%);
  opacity: 0;
  border: 1px solid;
  transition: opacity 0.25s ease;
  max-width: 42%;
}
.lpill .ptag {
  flex: 0 0 auto;
  font-size: 8.5px;
  letter-spacing: 0.6px;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 700;
}
.lpill.eapol  { color: var(--eapol);  border-color: rgba(34, 211, 238, 0.5); background: rgba(8, 30, 40, 0.92); box-shadow: 0 0 16px rgba(34,211,238,0.25); }
.lpill.eapol  .ptag { background: rgba(34, 211, 238, 0.16); color: var(--eapol); }
.lpill.radius { color: var(--radius); border-color: rgba(245, 158, 11, 0.5); background: rgba(40, 30, 8, 0.92); box-shadow: 0 0 16px rgba(245,158,11,0.25); }
.lpill.radius .ptag { background: rgba(245, 158, 11, 0.16); color: var(--radius); }
.lpill.inner  { color: var(--inner);  border-color: rgba(244, 114, 182, 0.5); background: rgba(40, 8, 30, 0.92); box-shadow: 0 0 16px rgba(244,114,182,0.25); }
.lpill.inner  .ptag { background: rgba(244, 114, 182, 0.16); color: var(--inner); }
.lpill.done { opacity: 0.55; box-shadow: none; filter: saturate(0.85); }

.lpill.note {
  transform: translate(-50%, -50%);
  border-style: dashed;
  color: var(--muted);
  background: rgba(18, 24, 40, 0.92);
  border-color: #3a4a6e;
  box-shadow: 0 0 16px rgba(0,0,0,0.4);
  text-align: center;
  justify-content: center;
}
.lpill.note .ptag.ntag { color: var(--accent-2); background: rgba(129, 140, 248, 0.15); border: 1px solid rgba(129,140,248,0.35); }

.vchip {
  flex: 0 0 auto;
  font-size: 8px;
  letter-spacing: 0.6px;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 700;
  color: var(--good);
  border: 1px solid rgba(52, 211, 153, 0.5);
  background: rgba(52, 211, 153, 0.1);
}

.vwrap { margin-top: 7px; }
.vhead {
  display: inline-block;
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent-2);
  border: 1px solid rgba(99, 102, 241, 0.35);
  background: rgba(99, 102, 241, 0.1);
  border-radius: 5px;
  padding: 1px 7px;
  margin-bottom: 4px;
}
.notes { list-style: none; }
.notes li {
  position: relative;
  padding-left: 15px;
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.6;
}
.notes li::before {
  content: '\2713';
  position: absolute;
  left: 0;
  color: var(--good);
  font-size: 10px;
}

/* ---------- Detail / log ---------- */
.detail {
  border-top: 1px solid var(--border);
  background: var(--panel-2);
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.detail-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 46px;
}
.step-no {
  flex: 0 0 auto;
  font-size: 22px;
  font-weight: 800;
  color: var(--accent-2);
  line-height: 1;
  padding-top: 2px;
}
.detail-label { font-size: 13.5px; font-weight: 700; margin-bottom: 3px; }
.detail-desc { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.tag {
  flex: 0 0 auto;
  margin-left: auto;
  font-size: 9.5px;
  letter-spacing: 0.8px;
  padding: 2px 8px;
  border-radius: 5px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.log {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 150px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0b101d;
}
.log-entry {
  display: flex;
  gap: 10px;
  padding: 5px 10px;
  font-size: 11px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  animation: logslide 0.25s ease;
}
.log-entry:last-child { border-bottom: none; }
.log-entry .ln { color: var(--muted); flex: 0 0 26px; }
.log-entry .ld { color: var(--text); }
@keyframes logslide {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: none; }
}

/* scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #2a3a5c; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); max-height: 260px; }
  .lpill { max-width: 60%; }
}
