:root{
  --bg:#f3f1ec; --panel:#fff; --ink:#1f2a37; --muted:#6b7684; --line:#e3dfd6;
  --accent:#2563eb; --ok:#15803d; --okbg:#e7f6ec; --err:#b91c1c; --warn:#b45309; --navy:#14213d;
}
.t-pc{--c:#2563eb}.t-sw{--c:#0f766e}.t-rt{--c:#c2410c}.t-sv{--c:#7c3aed}
*{box-sizing:border-box}
html,body{height:100%;margin:0}
body{font:14px/1.45 system-ui,"Segoe UI",Roboto,sans-serif;color:var(--ink);background:var(--bg);display:grid;grid-template-rows:54px minmax(0,1fr);overflow:hidden}
button{font:inherit;cursor:pointer;color:inherit}
h2,h3,p{margin:0}

header{background:var(--navy);color:#fff;display:flex;align-items:center;gap:16px;padding:0 16px}
.brand{display:flex;align-items:center;gap:9px;font-weight:700;font-size:16px}
.tag{font-size:11px;font-weight:700;background:#fca311;color:var(--navy);border-radius:99px;padding:1px 8px}
#mtitle{flex:1;text-align:center;opacity:.85;font-size:13px}
header button{background:rgba(255,255,255,.12);border:0;color:#fff;border-radius:8px;padding:7px 12px}
header button:hover{background:rgba(255,255,255,.24)}

main{display:grid;grid-template-columns:208px minmax(0,1fr) 332px;min-height:0}
aside{background:var(--panel);overflow:auto;padding:14px;min-height:0}
#palette{border-right:1px solid var(--line)}
#side{border-left:1px solid var(--line);display:flex;flex-direction:column;gap:14px}
.cap{font-size:11.5px;font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);margin-bottom:10px}
.tool{display:grid;grid-template-columns:44px 1fr;gap:10px;align-items:center;width:100%;text-align:left;background:#fff;border:1px solid var(--line);border-radius:12px;padding:8px;margin-bottom:8px;transition:.12s}
.tool:hover{border-color:var(--c);box-shadow:0 3px 10px rgba(20,33,61,.1);transform:translateY(-1px)}
.ti{width:44px;height:44px;border-radius:10px;background:color-mix(in srgb,var(--c) 12%,#fff);color:var(--c);display:grid;place-items:center}
.tool b{display:block;font-size:13px}
.tool small{color:var(--muted);font-size:11.5px;line-height:1.25;display:block}
.tip{margin-top:14px;font-size:12px;color:var(--muted);background:var(--bg);border-radius:10px;padding:10px}

#work{display:grid;grid-template-rows:auto minmax(0,1fr) 150px;min-width:0;min-height:0}
#bar{display:flex;align-items:center;gap:8px;padding:8px 12px;background:#fff;border-bottom:1px solid var(--line)}
.mode,#bDelSel{border-radius:9px;padding:7px 12px;border:1px solid var(--line);background:#fff;white-space:nowrap}
.mode:hover{border-color:var(--accent)}
.mode.on{background:var(--accent);border-color:var(--accent);color:#fff;font-weight:600}
#bDelSel:disabled{opacity:.4;cursor:default}
#bDelSel:not(:disabled):hover{border-color:var(--err);color:var(--err)}
#hint{margin-left:auto;color:var(--muted);font-size:12.5px;text-align:right}
#stage{position:relative;min-height:0;background-color:#faf9f6;background-image:radial-gradient(#d9d4c8 1.2px,transparent 1.2px);background-size:22px 22px}
#cv{position:absolute;inset:0;width:100%;height:100%;touch-action:none;user-select:none;-webkit-user-select:none}

.zone{fill:rgba(37,99,235,.05);stroke:#9db4e8;stroke-width:1.5;stroke-dasharray:7 6}
.zl{font-size:12px;font-weight:700;fill:#5b74b3;letter-spacing:.05em}
.wire{stroke:#475569;stroke-width:4;stroke-linecap:round}
.hit{stroke:transparent;stroke-width:18;cursor:pointer}
.link.sel .wire{stroke:var(--accent);stroke-width:5}
.rub{stroke:var(--accent);stroke-width:3;stroke-dasharray:6 6;pointer-events:none}
.ifip,.nm,.ip{text-anchor:middle;pointer-events:none;paint-order:stroke;stroke:#faf9f6;stroke-width:4px;stroke-linejoin:round}
.ifip{font:600 11px ui-monospace,Consolas,monospace;fill:#c2410c;dominant-baseline:middle}
.node{cursor:grab}
.tile{fill:#fff;stroke:var(--c);stroke-width:2.5;filter:drop-shadow(0 2px 3px rgba(20,33,61,.16))}
.ico{color:var(--c)}
.ring{fill:none;stroke:var(--accent);stroke-width:2.5;opacity:.75}
.ring.pend{stroke:#f59e0b;stroke-dasharray:6 5}
.nm{font-size:12px;font-weight:700;fill:var(--ink)}
.ip{font:11px ui-monospace,Consolas,monospace;fill:#475569}
.ip.none{fill:var(--warn);font-family:inherit;font-style:italic}
.ip.dup{fill:var(--err);font-weight:700}
.pkt circle{fill:var(--accent);stroke:#fff;stroke-width:2.5}
.pkt.back circle{fill:var(--ok)}
.pkt.bad circle{fill:var(--err)}
.pkt path{fill:none;stroke:#fff;stroke-width:1.8;stroke-linejoin:round;stroke-linecap:round}

#log{background:#fff;border-top:1px solid var(--line);display:grid;grid-template-columns:118px minmax(0,1fr);min-height:0}
.lcol{display:flex;flex-direction:column;min-height:0;min-width:0}
#guide{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;border-right:1px solid var(--line);font-size:11px;font-weight:700;color:var(--muted)}
#face,#hface{border-radius:50%;background:#dbe6ff;flex:none}
#face{width:98px;height:98px}#face.bravo{background:#dcfce7}#face.alert{background:#ffedd5}
#hface{width:96px;height:96px}
.hh{display:flex;gap:16px;align-items:center;margin-bottom:18px}.hh p{color:var(--muted)}
#lesson{position:fixed;inset:0;background:rgba(20,33,61,.74);backdrop-filter:blur(4px);display:grid;place-items:center;z-index:9;padding:20px}
#lesson.hide{display:none}
.lbox{width:min(1000px,100%,calc((100vh - 40px)*1000/520));border-radius:22px;overflow:hidden;background:#fff;box-shadow:0 20px 50px rgba(0,0,0,.35)}
.lbox svg{display:block;width:100%;height:auto}
.hand{font-family:"Segoe Print","Comic Sans MS",cursive}
.bub{fill:#fff;stroke:#d9d4c8;stroke-width:1.5;filter:drop-shadow(0 3px 6px rgba(20,33,61,.14))}
#bGo{cursor:pointer}#bGo:hover rect{fill:#ffb733}
.lh{display:flex;justify-content:space-between;align-items:center;padding:7px 12px 4px}
.lh .cap{margin:0}
.lh button{border:0;background:none;color:var(--muted);font-size:12px}
#logs{overflow:auto;padding:0 12px 8px;flex:1}
.le{display:flex;gap:8px;padding:3px 0;font-size:13px}
.li{flex:none;width:18px;height:18px;border-radius:50%;display:grid;place-items:center;font-size:11px;font-weight:700;color:#fff;background:#94a3b8;margin-top:1px}
.le.ok .li{background:var(--ok)}.le.err .li{background:var(--err)}.le.warn .li{background:#d97706}.le.send .li{background:var(--accent)}
.le.err{color:var(--err)}.le.ok{color:var(--ok);font-weight:600}

.box{border:1px solid var(--line);border-radius:14px;padding:14px;background:#fff}
#mission{background:linear-gradient(#f2f6ff,#fff 70%)}
.badge{display:inline-block;font-size:11px;font-weight:700;background:var(--navy);color:#fff;border-radius:99px;padding:2px 9px;margin-bottom:6px}
#mission h2{font-size:18px;margin-bottom:6px}
.intro{color:#475569;font-size:13px}
.goals{list-style:none;padding:0;margin:12px 0 0;display:grid;gap:8px}
.goals li{display:grid;grid-template-columns:24px 1fr;gap:8px;font-size:13px;color:var(--muted)}
.goals li.cur{color:var(--ink);font-weight:600}
.goals li.ok{color:var(--ok)}
.ck{width:22px;height:22px;border-radius:50%;border:2px solid #cbd5e1;display:grid;place-items:center;font-size:11px;font-weight:700}
li.cur .ck{border-color:var(--accent);color:var(--accent)}
li.ok .ck{background:var(--ok);border-color:var(--ok);color:#fff}
.win{margin-top:12px;background:var(--okbg);border:1px solid #b7e2c3;border-radius:12px;padding:12px;font-size:13px}
.win b{color:var(--ok);font-size:15px}
.win p{margin:6px 0 10px}
.win button{background:var(--ok);color:#fff;border:0;border-radius:9px;padding:8px 12px;font-weight:600}
#props h3{font-size:15px;display:flex;align-items:center;gap:8px}
.dot{width:10px;height:10px;border-radius:50%;background:var(--c)}
.desc{color:var(--muted);font-size:12.5px;margin:4px 0 10px}
.empty{color:var(--muted);font-size:13px;text-align:center;padding:10px 0}
#props label{display:block;font-size:12px;font-weight:700;margin-top:10px}
#props label i{font-weight:400;color:var(--muted)}
#props input{display:block;width:100%;margin-top:4px;padding:8px 10px;border:1.5px solid #cbd5e1;border-radius:9px;font:14px ui-monospace,Consolas,monospace;color:var(--ink)}
#props input[data-f=name]{font-family:inherit}
#props input:focus{outline:0;border-color:var(--accent);box-shadow:0 0 0 3px rgba(37,99,235,.15)}
#props small{display:block;font-weight:400;font-size:11.5px;color:var(--muted);margin-top:3px;min-height:16px}
#props small.bad{color:var(--err)}#props small.good{color:var(--ok)}
.del{margin-top:14px;width:100%;border:1px solid var(--line);background:#fff;border-radius:9px;padding:7px;color:var(--err)}
.del:hover{border-color:var(--err)}

#home{position:fixed;inset:0;background:rgba(20,33,61,.74);backdrop-filter:blur(4px);display:grid;place-items:center;z-index:10;padding:20px}
#home.hide{display:none}
.hbox{background:var(--bg);border-radius:22px;padding:28px;max-width:960px;width:100%;max-height:100%;overflow:auto}
.hbox h1{margin:0 0 4px;font-size:26px}
#cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:14px}
.card{text-align:left;background:#fff;border:1px solid var(--line);border-top:5px solid var(--k);border-radius:16px;padding:16px;display:flex;flex-direction:column;gap:6px;min-height:176px;transition:.12s}
.card:hover{transform:translateY(-3px);box-shadow:0 10px 24px rgba(20,33,61,.14)}
.cn{font-size:11px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--k)}
.card b{font-size:17px}
.cd{color:var(--muted);font-size:13px;flex:1}
.ct{font-size:11.5px;background:var(--bg);border-radius:99px;padding:2px 9px;align-self:flex-start}
.star{color:var(--ok);font-weight:700;font-size:12px}
@media(max-width:1100px){
  main{grid-template-columns:78px minmax(0,1fr) 286px}
  #palette{padding:10px}
  .tool{grid-template-columns:1fr;justify-items:center;padding:6px}
  .tool>span:last-child,.tip,#palette .cap,#hint{display:none}
  #bar{flex-wrap:wrap}
  #log{grid-template-columns:82px minmax(0,1fr)}#face{width:66px;height:66px}
}
