:root {
  --bg: #0f1115;
  --bg-2: #161a21;
  --bg-3: #1d222c;
  --panel: #181c24;
  --border: #2a2f3a;
  --text: #e8eaed;
  --muted: #9aa3b2;
  --accent: #8ab4f8;
  --accent-2: #669df6;
  --green: #4caf7d;
  --red: #e06c75;
  --gray: #6b7280;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  font-synthesis: none;
}

* { box-sizing: border-box; }

/* ensure elements with display rules still hide when [hidden] */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  overflow: hidden;
}

h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 16px; }
h3 { font-size: 13px; letter-spacing: .3px; color: #cdd3df; }
p { margin: 0; }
code { background: #0b0d12; padding: 1px 5px; border-radius: 4px; color: var(--accent); font-size: 12px; }
.muted { color: var(--muted); }

/* ===== top bar ===== */
.topbar {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: linear-gradient(180deg, #14171e, #101319);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent-2), #5b21b6);
  border-radius: 9px; font-size: 18px; color: #fff;
  box-shadow: 0 4px 12px rgba(102, 157, 246, .35);
}
.sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.top-actions { display: flex; align-items: center; gap: 10px; }
.btn {
  height: 34px; padding: 0 14px;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-3); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; cursor: pointer; transition: .15s;
  font-family: inherit;
}
.btn:hover:not(:disabled) { border-color: var(--accent); background: #222834; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent-2), #4f86e0);
  border-color: transparent; color: #fff; font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.08); }
select.btn { appearance: none; padding-right: 26px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 14px) 15px, calc(100% - 9px) 15px; background-size: 5px 5px; background-repeat: no-repeat; }

.checkbox { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }
.checkbox input { accent-color: var(--accent); }

/* ===== drop zone ===== */
.dropzone {
  position: absolute; inset: 60px 0 0 0;
  display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% 30%, #161b25, var(--bg) 70%);
}
.dz-card {
  text-align: center; padding: 48px 64px;
  border: 2px dashed var(--border); border-radius: 16px;
  background: rgba(24, 28, 36, .6); backdrop-filter: blur(4px);
  transition: .2s;
}
.dz-card.drag { border-color: var(--accent); background: rgba(138, 180, 248, .08); }
.dz-icon { font-size: 44px; color: var(--accent); margin-bottom: 8px; }
.dz-card h2 { font-size: 18px; margin-bottom: 6px; }
.dz-card p { color: var(--muted); }
.dz-card .hint { margin-top: 14px; font-size: 12px; opacity: .7; }

/* ===== workspace ===== */
.workspace { position: absolute; inset: 60px 0 0 0; display: flex; }
.sidebar {
  width: 290px; flex: 0 0 290px;
  background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.sidebar.right { border-right: none; border-left: 1px solid var(--border); }
.card {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.card.grow { flex: 1; min-height: 0; display: flex; flex-direction: column; padding-bottom: 8px; }
.card h3 { margin-bottom: 10px; display: flex; justify-content: space-between; align-items: baseline; }
.card h3 .muted { font-size: 11px; font-weight: 400; }

.meta { font-size: 12px; line-height: 1.9; }
.meta .row { display: flex; justify-content: space-between; gap: 10px; }
.meta .k { color: var(--muted); }
.meta .v { color: var(--text); text-align: right; word-break: break-all; }

.opstats { display: flex; flex-wrap: wrap; gap: 6px; }
.opstats .chip {
  font-size: 11px; padding: 3px 8px; border-radius: 12px;
  background: #21262f; border: 1px solid var(--border); cursor: pointer;
  transition: .15s; white-space: nowrap;
}
.opstats .chip:hover { border-color: var(--accent); }
.opstats .chip b { color: var(--accent); margin-left: 4px; }

.search {
  width: 100%; height: 32px; padding: 0 10px; margin-bottom: 8px;
  background: #0e1117; border: 1px solid var(--border); border-radius: 7px;
  color: var(--text); font-size: 12px; font-family: inherit;
}
.search:focus { outline: none; border-color: var(--accent); }

.nodelist { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.nodelist li {
  padding: 7px 10px; border-radius: 7px; cursor: pointer; font-size: 12px;
  display: flex; align-items: center; gap: 8px; margin-bottom: 2px;
  border: 1px solid transparent;
}
.nodelist li:hover { background: #1f2430; }
.nodelist li.active { background: rgba(138, 180, 248, .14); border-color: var(--accent); }
.nodelist li .swatch { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 9px; }
.nodelist li .nm { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nodelist li .op { font-weight: 600; }

/* ===== graph area ===== */
.graph-wrap { flex: 1; position: relative; background: #0b0e13; }
.graph { position: absolute; inset: 0; }
.legend {
  position: absolute; left: 12px; bottom: 22px;
  background: rgba(18, 22, 30, .85); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; display: flex; gap: 14px;
  font-size: 12px; color: var(--muted); backdrop-filter: blur(6px);
}
.legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.legend .dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .dot.in { background: var(--green); }
.legend .dot.out { background: var(--red); }
.legend .dot.init { background: var(--gray); }
.legend .dot.op { background: #5b6cff; }

.loading {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(11, 14, 19, .7); color: var(--muted); gap: 12px;
  font-size: 13px;
}
.spinner {
  width: 34px; height: 34px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Detail panel ===== */
.empty-details { padding: 30px 18px; text-align: center; }
#detailsContent { padding: 0; overflow-y: auto; }
.detail-head { padding: 14px 16px; border-bottom: 1px solid var(--border); background: #141821; }
.detail-head .op-type { font-size: 16px; font-weight: 700; color: var(--accent); display: flex; align-items: center; gap: 8px; }
.detail-head .op-name { color: var(--muted); font-size: 12px; margin-top: 4px; word-break: break-all; }
.detail-section { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.detail-section h4 { margin: 0 0 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.kv { font-size: 12px; line-height: 1.7; word-break: break-all; }
.kv .k { color: var(--muted); }
.kv .v { color: var(--text); }
.io-item {
  font-size: 12px; padding: 7px 9px; background: #0e1117; border-radius: 6px;
  margin-bottom: 5px; border: 1px solid var(--border);
}
.io-field { display: flex; gap: 8px; align-items: baseline; line-height: 1.6; }
.io-field + .io-field { margin-top: 1px; }
.io-item .iol { color: #6b7280; font-size: 11px; flex: 0 0 46px; text-transform: lowercase; }
.io-item .iov { flex: 1; word-break: break-all; }
.io-item .nm { color: var(--accent); font-family: ui-monospace, "SF Mono", Consolas, monospace; }
.io-item .sh { color: var(--muted); font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 11px; }
.attr-item { font-size: 12px; margin-bottom: 6px; }
.attr-item .an { color: #d6b65f; font-family: ui-monospace, monospace; }
.attr-item .av { color: var(--text); display: block; margin-left: 10px; word-break: break-all; font-family: ui-monospace, monospace; font-size: 11px; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #221717; color: #ffb4b4; border: 1px solid #5a2a2a;
  padding: 10px 18px; border-radius: 9px; font-size: 13px; z-index: 100;
  box-shadow: var(--shadow);
}

/* scrollbar */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #2c3340; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #3a424f; }
::-webkit-scrollbar-track { background: transparent; }

/* vis-network selection highlight */
div.vis-network { outline: none !important; }

/* ===== Custom graph scrollbars (drag to pan when graph is large) ===== */
.gscroll {
  position: absolute; z-index: 6;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 5px;
}
.gscroll.vs { right: 2px; top: 2px; bottom: 14px; width: 10px; }
.gscroll.hs { left: 2px; right: 14px; bottom: 2px; height: 10px; }
.gthumb {
  background: rgba(255, 255, 255, 0.32);
  border-radius: 5px;
  cursor: grab;
  transition: background .15s;
}
.gthumb:hover { background: rgba(255, 255, 255, 0.45); }
.gthumb:active { cursor: grabbing; background: rgba(255, 255, 255, 0.6); }
.gscroll.vs .gthumb { width: 100%; }
.gscroll.hs .gthumb { height: 100%; }
