:root{--bg:#0b1020;--panel:#121a2e;--line:#24304d;--text:#e5e9f2;--muted:#94a3b8;--accent:#f5a524}
*{box-sizing:border-box}
html,body{margin:0;height:100%;background:var(--bg);color:var(--text);font-family:"PingFang HK","Noto Sans TC","Noto Sans CJK TC","Microsoft JhengHei",system-ui,sans-serif;overflow:hidden;-webkit-tap-highlight-color:transparent}
button,input,select,textarea{font:inherit;color:inherit}
.top{display:flex;align-items:center;gap:16px;padding:10px 14px;background:linear-gradient(180deg,#121a2e,#0e1528);border-bottom:1px solid var(--line);flex-wrap:wrap}
.brand{font-weight:700;letter-spacing:.04em;display:flex;align-items:center;gap:8px;white-space:nowrap}
.dot{width:10px;height:10px;border-radius:50%;background:var(--accent);box-shadow:0 0 10px var(--accent)}
.tabs{display:flex;gap:6px;overflow-x:auto;flex:1;min-width:0}
.tabs button{background:transparent;border:1px solid var(--line);border-radius:999px;padding:6px 14px;white-space:nowrap;color:var(--muted);cursor:pointer}
.tabs button.on{background:#1e2a47;color:var(--text);border-color:#3b4d78}
.toolbar{display:flex;gap:6px;padding:8px 14px;overflow-x:auto;border-bottom:1px solid var(--line);background:#0e1528}
.toolbar button{background:#16203a;border:1px solid var(--line);border-radius:8px;padding:6px 12px;white-space:nowrap;cursor:pointer}
.toolbar button:hover{border-color:#3b4d78}
.toolbar button.on{background:var(--accent);color:#1a1300;border-color:var(--accent)}
.toolbar .warn{color:#fca5a5}
.legend{display:flex;gap:12px;padding:6px 14px;font-size:12px;color:var(--muted);overflow-x:auto;white-space:nowrap;border-bottom:1px solid var(--line)}
.legend span{display:inline-flex;align-items:center;gap:5px}
.legend i{width:10px;height:10px;border-radius:3px;display:inline-block}
#viewport{position:absolute;left:0;right:0;bottom:0;overflow:hidden;touch-action:none;cursor:grab;
  background-image:radial-gradient(#1c2640 1px,transparent 1px);background-size:22px 22px}
#world{position:absolute;left:0;top:0;transform-origin:0 0}
#edges{position:absolute;left:0;top:0;overflow:visible;pointer-events:none}
#edges path{fill:none;stroke:#475569;stroke-width:2;pointer-events:stroke;cursor:pointer}
#edges path.hit{stroke:transparent;stroke-width:16}
#edges path.flow{stroke-dasharray:6 6;animation:flow 1.2s linear infinite}
#edges path.sel{stroke:var(--accent)}
@keyframes flow{to{stroke-dashoffset:-12}}
.node{position:absolute;width:200px;background:var(--panel);border:1px solid var(--line);border-left:4px solid var(--c);border-radius:12px;padding:10px 12px 10px 11px;box-shadow:0 6px 18px rgba(0,0,0,.35);cursor:pointer;user-select:none;-webkit-user-select:none;touch-action:none}
.node:hover{border-color:#3b4d78;border-left-color:var(--c)}
.node.pick{outline:2px solid var(--accent);outline-offset:2px}
.node .chip{display:inline-block;font-size:11px;padding:1px 7px;border-radius:999px;color:var(--c);background:color-mix(in srgb,var(--c) 16%,transparent);margin-bottom:5px}
.node h3{margin:0 0 6px;font-size:14px;line-height:1.35}
.node .row{font-size:12px;color:var(--muted);line-height:1.45;margin-top:2px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.node .row b{color:#cbd5e1;font-weight:500}
.hint{position:absolute;left:50%;top:10px;transform:translateX(-50%);background:#1e2a47;border:1px solid #3b4d78;padding:6px 12px;border-radius:999px;font-size:13px;display:none}
.hint.show{display:block}
.empty{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:var(--muted)}
.sheet{position:fixed;inset:0;background:rgba(3,6,15,.6);display:flex;align-items:flex-end;justify-content:center;z-index:10}
.sheet form{width:100%;max-width:520px;background:var(--panel);border:1px solid var(--line);border-radius:16px 16px 0 0;padding:14px 16px 18px;max-height:88vh;overflow:auto}
@media(min-width:700px){.sheet{align-items:center}.sheet form{border-radius:16px}}
.sheet-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px}
.sheet-head button{background:none;border:0;font-size:18px;cursor:pointer}
.sheet label{display:block;font-size:12px;color:var(--muted);margin:8px 0 0}
.sheet input,.sheet select,.sheet textarea{display:block;width:100%;margin-top:4px;background:#0b1020;border:1px solid var(--line);border-radius:8px;padding:8px 10px;font-size:15px;resize:vertical}
.sheet-actions{display:flex;justify-content:space-between;margin-top:14px}
.sheet-actions button{border-radius:8px;padding:8px 16px;border:1px solid var(--line);background:#16203a;cursor:pointer}
.sheet-actions .primary{background:var(--accent);color:#1a1300;border-color:var(--accent);font-weight:600}
.sheet-actions .warn{color:#fca5a5}
.toast{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);background:#1e2a47;border:1px solid #3b4d78;padding:8px 14px;border-radius:10px;font-size:13px;z-index:20}
[hidden]{display:none!important}
body.phone .node{width:180px;padding:9px 10px 9px 10px}
body.phone .node h3{font-size:13.5px}
.node{width:180px}
@media(max-width:699px){
  .top{gap:8px;padding:8px 10px}
  .tabs{flex-wrap:wrap;overflow:visible;flex-basis:100%}
  .tabs button{padding:5px 11px;font-size:13px}
  .toolbar{flex-wrap:wrap;overflow:visible;padding:6px 10px;gap:5px}
  .toolbar button{padding:5px 9px;font-size:13px;flex:1 0 auto}
  .legend{flex-wrap:wrap;overflow:visible;gap:4px 10px;padding:5px 10px;font-size:11.5px}
}
