
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url(../fonts/inter-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #0b1017;
  --panel: rgba(13, 18, 26, 0.92);
  --panel-solid: #0f151e;
  --panel-2: #151d29;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #e8edf3;
  --text-2: #9aa6b5;
  --text-3: #66727f;
  --accent: #3b82f6;
  --accent-2: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --mine: #22c55e;
  --trusted: #38bdf8;
  --other: #f59e0b;
  --sale: #eab308;
  --server: #a78bfa;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --top-h: 52px;
  --side-w: 320px;
  --detail-w: 380px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.5; overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

#app { position: fixed; inset: 0; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }

.topbar {
  position: absolute; top: 0; left: 0; right: 0; min-height: var(--top-h); z-index: 20;
  display: flex; align-items: center; gap: 14px; padding: 0 14px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand img { border-radius: 6px; flex: none; }
.brand-name { font-weight: 700; letter-spacing: .02em; }
.brand-sep { width: 1px; min-height: 16px; background: var(--line-2); }
.brand-sub { color: var(--text-2); }
.status { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-2); padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; flex: none; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); flex: none; }
.status[data-state="ok"] i { background: var(--ok); }
.status[data-state="down"] i { background: var(--danger); }
.status[data-state="offline"] i { background: var(--text-3); }
.spacer { flex: 1; }
.wallet { display: flex; gap: 8px; align-items: baseline; color: var(--text-2); font-size: 13px; flex: none; }
.wallet b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.me { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border: 1px solid var(--line); border-radius: var(--radius); flex: none; }
.me canvas { width: 24px; height: 24px; image-rendering: pixelated; border-radius: 3px; background: var(--panel-2); flex: none; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; min-height: 34px; border-radius: var(--radius); color: var(--text-2); border: 1px solid transparent; flex: none; }
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,.06); }
.icon-btn.on { color: var(--accent); border-color: rgba(59,130,246,.35); background: var(--accent-soft); }
#btn-sidebar { display: none; }

.sidebar {
  position: absolute; z-index: 15; top: calc(var(--top-h) + 12px); left: 12px; bottom: 12px; width: var(--side-w);
  display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); overflow: hidden;
}
.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.tabs button { flex: 1; min-height: 42px; padding: 0 6px; color: var(--text-2); font-size: 13px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tab-body { flex: 1; overflow-y: auto; padding: 8px; }
.sidebar-foot { flex: none; padding: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.limits { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 12px; color: var(--text-2); }
.limits b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.group-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); padding: 10px 8px 6px; }
.res-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 9px 10px; border-radius: var(--radius); border: 1px solid transparent; }
.res-item:hover { background: rgba(255,255,255,.04); border-color: var(--line); }
.res-item.active { background: var(--accent-soft); border-color: rgba(59,130,246,.35); }
.res-item .sw { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.res-item .main { flex: 1; min-width: 0; }
.res-item .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res-item .meta { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res-item .tag { font-size: 11px; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line-2); color: var(--text-2); flex: none; }
.res-item .tag.gold { color: var(--sale); border-color: rgba(234,179,8,.35); }
.empty { color: var(--text-3); text-align: center; padding: 28px 12px; font-size: 13px; }
.empty b { display: block; color: var(--text-2); font-weight: 600; margin-bottom: 4px; }

.detail, .tool {
  position: absolute; z-index: 16; top: calc(var(--top-h) + 12px); right: 12px; bottom: 12px; width: var(--detail-w);
  display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); overflow: hidden;
}
.tool { bottom: auto; max-height: calc(100% - var(--top-h) - 24px); }
.panel-head { display: flex; align-items: flex-start; gap: 10px; padding: 14px 14px 12px; border-bottom: 1px solid var(--line); flex: none; }
.panel-head .title { flex: 1; min-width: 0; }
.panel-head h2 { font-size: 16px; font-weight: 700; line-height: 1.3; word-break: break-all; }
.panel-head .sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.panel-tabs { display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--line); overflow-x: auto; flex: none; scrollbar-width: none; }
.panel-tabs::-webkit-scrollbar { display: none; }
.panel-tabs button { white-space: nowrap; padding: 10px 10px; color: var(--text-2); font-size: 13px; border-bottom: 2px solid transparent; margin-bottom: -1px; flex: none; }
.panel-tabs button.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.panel-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.panel-foot { flex: none; padding: 12px 14px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--text-2); }
.kv dd { text-align: right; font-variant-numeric: tabular-nums; word-break: break-all; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; background: rgba(255,255,255,.015); }
.card h4 { font-size: 13px; font-weight: 600; }
.card p, .hint { font-size: 12px; color: var(--text-2); }
.hint.warn { color: var(--warn); }
.hint.err { color: #fca5a5; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 0; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; padding: 2px 8px; border-radius: 4px; border: 1px solid var(--line-2); color: var(--text-2); white-space: nowrap; }
.badge.mine { color: var(--mine); border-color: rgba(34,197,94,.35); }
.badge.trusted { color: var(--trusted); border-color: rgba(56,189,248,.35); }
.badge.sale { color: var(--sale); border-color: rgba(234,179,8,.35); }
.badge.server { color: var(--server); border-color: rgba(167,139,250,.35); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--text-2); }
.input, select.input, textarea.input {
  width: 100%; min-height: 34px; padding: 6px 10px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--radius); outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 64px; }
.coord-grid { display: grid; grid-template-columns: auto 1fr 1fr 1fr; gap: 6px; align-items: center; font-size: 12px; color: var(--text-2); }
.coord-grid .input { min-height: 30px; padding: 4px 6px; font-family: var(--mono); font-size: 12px; text-align: center; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; cursor: pointer; }
.check input { accent-color: var(--accent); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--line-2); background: rgba(255,255,255,.03); color: var(--text); font-size: 13px; font-weight: 500; white-space: nowrap; flex: none; }
.btn:hover { background: rgba(255,255,255,.07); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: #fca5a5; border-color: rgba(239,68,68,.4); }
.btn.danger:hover { background: rgba(239,68,68,.12); }
.btn.block { width: 100%; }
.btn.sm { min-height: 28px; padding: 0 10px; font-size: 12px; }

.flag-list { display: flex; flex-direction: column; }
.flag-row { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--line); }
.flag-row:last-child { border-bottom: 0; }
.flag-row .info { flex: 1; min-width: 0; }
.flag-row .fname { font-size: 13px; font-weight: 600; }
.flag-row .fen { font-family: var(--mono); font-size: 11px; font-weight: 400; color: var(--text-3); margin-left: 4px; }
.flag-row .fdesc { font-size: 12px; color: var(--text-2); }
.tri { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; flex: none; }
.tri button { min-width: 38px; min-height: 26px; padding: 0 8px; font-size: 12px; color: var(--text-2); border-left: 1px solid var(--line-2); }
.tri button:first-child { border-left: 0; }
.tri button:disabled { cursor: default; opacity: .6; }
.tri button.on[data-v="true"] { background: rgba(34,197,94,.18); color: #86efac; }
.tri button.on[data-v="false"] { background: rgba(239,68,68,.16); color: #fca5a5; }
.tri button.on[data-v="null"] { background: rgba(255,255,255,.08); color: var(--text); }
.search { position: relative; }
.search .input { padding-left: 32px; }
.search svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 16px; height: 16px; }

.member { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); }
.member canvas { width: 28px; height: 28px; image-rendering: pixelated; border-radius: 4px; background: var(--panel-2); flex: none; }
.member .grow { min-width: 0; }
.member .mname { font-weight: 600; }
.member .mflags { font-size: 11px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.hud { position: absolute; z-index: 10; left: calc(var(--side-w) + 24px); right: 12px; bottom: 12px; display: flex; align-items: flex-end; gap: 10px; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-info { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12px; color: var(--text-2); text-shadow: 0 1px 2px rgba(0,0,0,.8); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.hud-range { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); font-size: 12px; color: var(--text-2); flex: none; }
.hud-range[hidden] { display: none; }
.hud-range input { width: 110px; accent-color: var(--accent); }
.hud-range b { min-width: 18px; text-align: right; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.hud-actions { display: flex; gap: 4px; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.compass { width: 44px; height: 44px; border-radius: 50%; background: var(--panel); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; cursor: pointer; position: relative; flex: none; }
.compass span { font-size: 11px; font-weight: 700; color: #f87171; transform-origin: 50% 50%; display: block; position: absolute; inset: 0; text-align: center; padding-top: 3px; }
body.detail-open .hud { right: calc(var(--detail-w) + 24px); }

.toasts { position: absolute; z-index: 40; top: calc(var(--top-h) + 16px); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(460px, calc(100% - 32px)); }
.toast { pointer-events: auto; padding: 10px 14px; border-radius: var(--radius); background: var(--panel-solid); border: 1px solid var(--line-2); box-shadow: var(--shadow); font-size: 13px; display: flex; gap: 10px; align-items: flex-start; animation: toast-in .2s ease-out; max-width: 100%; }
.toast i { width: 6px; align-self: stretch; border-radius: 3px; background: var(--accent); flex: none; }
.toast.ok i { background: var(--ok); }
.toast.err i { background: var(--danger); }
.toast.out { opacity: 0; transform: translateY(-6px); transition: all .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

.overlay { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: var(--bg); transition: opacity .5s; }
.overlay.gone { opacity: 0; pointer-events: none; }
.loader { display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 260px; text-align: center; padding: 0 24px; }
.loader img { border-radius: 10px; margin-bottom: 6px; }
.loader p { font-weight: 600; font-size: 16px; }
.loader .sub { font-weight: 400; font-size: 13px; color: var(--text-2); max-width: 360px; }
.loader .bar { width: 220px; height: 3px; background: rgba(255,255,255,.08); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.loader .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }

.modal-mask { position: absolute; inset: 0; z-index: 45; background: rgba(3,7,12,.6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: min(420px, 100%); background: var(--panel-solid); border: 1px solid var(--line-2); border-radius: var(--radius-lg); box-shadow: var(--shadow); display: flex; flex-direction: column; max-height: calc(100% - 32px); }
.modal h3 { font-size: 15px; padding: 16px 18px 0; }
.modal-body { padding: 12px 18px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; font-size: 13px; color: var(--text-2); }
.modal-foot { padding: 12px 18px 16px; display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 900px) {
  :root { --side-w: 300px; --detail-w: 340px; }
  #btn-sidebar { display: inline-flex; }
  .brand-sub, .brand-sep { display: none; }
  .sidebar { transform: translateX(calc(-100% - 16px)); transition: transform .25s; }
  body.side-open .sidebar { transform: none; }
  .hud { left: 12px; }
}
@media (max-width: 640px) {
  :root { --top-h: 48px; }
  .topbar { gap: 8px; padding: 0 8px; }
  .status span, .wallet span, .me span { display: none; }
  .me { padding: 4px; }
  .sidebar { left: 8px; right: 8px; width: auto; bottom: 8px; }
  .detail, .tool { left: 8px; right: 8px; width: auto; top: auto; bottom: 8px; max-height: 62%; }
  body.detail-open .hud { right: 12px; bottom: calc(62% + 16px); }
  .hud-info { display: none; }
  .hud { flex-wrap: wrap; justify-content: flex-end; }
  .hud-range span { display: none; }
  .hud-range input { width: 88px; }
}
