/* meet the cluster — databox explorer */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #d7e1ee;
  background: #0b1020;
  overflow: hidden;
  user-select: none;
}
:root {
  --panel: #141b2e;
  --panel2: #0f1526;
  --edge: #2a3654;
  --accent: #5ab0ff;
  --ok: #52d28e;
  --warn: #ffb347;
  --bad: #ff6b6b;
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
}

/* ---------------------------------------------------- top bar ------ */
#topbar {
  position: fixed; inset: 0 0 auto 0; height: 44px; z-index: 5000;
  display: flex; align-items: center; gap: 10px; padding: 0 14px;
  background: rgba(13, 18, 34, .92); border-bottom: 1px solid var(--edge);
  backdrop-filter: blur(6px);
}
#topbar .brand { font-weight: 700; letter-spacing: .3px; }
#topbar .brand em { color: var(--accent); font-style: normal; }
#topbar .brand small { color: #7f8db0; font-weight: 400; margin-left: 8px; }
#topbar .spacer { flex: 1; }
.tb-btn {
  background: var(--panel); color: #d7e1ee; border: 1px solid var(--edge);
  border-radius: 8px; padding: 5px 12px; cursor: pointer; font: inherit; font-size: 13px;
}
.tb-btn:hover { border-color: var(--accent); color: #fff; }
/* The github link wears the same button clothes as its <button> siblings. */
a.tb-btn { text-decoration: none; display: inline-block; }
.chip {
  font-size: 12px; padding: 4px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--edge); background: var(--panel);
}
.chip-ok { color: var(--ok); border-color: #2b5a41; }
.chip-warning { color: var(--warn); border-color: #6b512a; }
.chip-critical { color: var(--bad); border-color: #6b2a2a; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .55; } }

/* ---------------------------------------------------- map ---------- */
#map {
  position: fixed; inset: 44px 0 0 0; width: 100%; height: calc(100% - 44px);
  cursor: grab;
  background:
    radial-gradient(1200px 700px at 60% 20%, #101a35 0%, #0b1020 60%),
    #0b1020;
}
#map.grabbing { cursor: grabbing; }
#map::after { content: ''; }
#map-grid { position: fixed; inset: 44px 0 0 0; pointer-events: none; opacity: .5;
  background-image:
    linear-gradient(#16203a 1px, transparent 1px),
    linear-gradient(90deg, #16203a 1px, transparent 1px);
  background-size: 44px 44px; }

.edge { stroke: #27334f; stroke-width: 1.2; }
.edge-meta { stroke: #4a68a4; stroke-width: 1.8; stroke-dasharray: 4 4; }
.edge-shard { stroke: #223050; }
.edge-hot { stroke: var(--accent); stroke-width: 1.8; opacity: .8; }
.edge-hit { stroke: transparent; stroke-width: 12; fill: none; }
.edge-hit:hover + *, .edge-hit:hover { cursor: help; }
.edge-tip {
  position: fixed; display: none; z-index: 9200; max-width: 270px;
  background: var(--panel); border: 1px solid #33436f; border-radius: 8px;
  padding: 6px 10px; font-size: 12px; line-height: 1.5; color: #c3cfe5;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5); pointer-events: none; word-break: break-word;
}
.edge-tip b { color: #dfe9fa; }
.edge-tip .tip-meta { color: #6fd5ff; }
.pulse-line { stroke-width: 2; }

.gnode { cursor: pointer; }
.node-shape { fill: #1b2440; stroke: #3d4f7c; stroke-width: 1.5; }
.node-shape-meta { fill: #1d2a4a; stroke: #4a68a4; }
.node-meta-badge { fill: #6fd5ff; font-size: 16px; font-weight: 700; }
.node-meta-lead { fill: #ffd75e; }
.node-ring { fill: none; stroke: var(--ok); stroke-width: 2; opacity: .85; }
.st-down .node-ring { stroke: var(--bad); stroke-dasharray: 5 4; }
.st-down .node-shape { fill: #241722; stroke: #5c3040; }
.st-decom .node-ring { stroke: var(--warn); stroke-dasharray: 8 4; animation: spinring 3s linear infinite; }
@keyframes spinring { to { stroke-dashoffset: -24; } }
.gnode:hover .node-shape { stroke: var(--accent); }
.node-icon { fill: #aebbdb; font-size: 17px; dominant-baseline: middle; pointer-events: none; }
.st-down .node-icon { fill: var(--bad); }
.node-label { fill: #e7eefb; font-size: 13px; font-weight: 600; pointer-events: none; }
.node-sub { fill: #7f8db0; font-size: 10.5px; pointer-events: none; }
.node-warntxt { fill: var(--warn); }
.node-crown { fill: #ffd75e; font-size: 13px; pointer-events: none; }

#legend {
  position: fixed; left: 14px; bottom: 14px; z-index: 4000;
  background: rgba(15, 21, 38, .92); border: 1px solid var(--edge); border-radius: 10px;
  padding: 10px 14px; font-size: 12px; color: #9fb0d0; line-height: 1.8;
}
#legend b { color: #d7e1ee; font-weight: 600; }
#legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }

#zoomer { position: fixed; right: 14px; bottom: 14px; z-index: 4000; display: flex; flex-direction: column; gap: 6px; }
#zoomer button {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--edge);
  background: var(--panel); color: #d7e1ee; font-size: 16px; cursor: pointer;
}
#zoomer button:hover { border-color: var(--accent); }

/* ---------------------------------------------------- windows ------ */
#windows { position: fixed; inset: 0; pointer-events: none; z-index: 6000; }
.win {
  position: absolute; min-width: 280px; max-width: min(92vw, 780px);
  background: var(--panel); border: 1px solid #33405f; border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .55);
  pointer-events: auto; display: flex; flex-direction: column;
}
.win-header {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: #1a2340; border-radius: 12px 12px 0 0; cursor: move;
  border-bottom: 1px solid #2c3a5e; touch-action: none;
}
.win-icon { font-size: 14px; }
.win-title { flex: 1; font-size: 13px; font-weight: 600; color: #cfe0ff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-btn {
  width: 24px; height: 24px; border-radius: 6px; border: none; cursor: pointer;
  background: #263255; color: #b9c8ea; font-size: 14px; line-height: 1;
}
.win-btn:hover { background: #33436f; color: #fff; }
.win-close-btn:hover { background: #7a2f3a; }
.win-body { overflow: auto; max-height: min(72vh, 640px); }
.win-min .win-body { display: none; }
.win-min { min-width: 0; height: auto !important; }

/* manual resize — every edge and corner is a live handle, OS-style */
.win-resize {
  position: absolute; right: 0; bottom: 0; width: 16px; height: 16px;
  border-radius: 0 0 12px 0; pointer-events: none;
  background: linear-gradient(135deg, transparent 50%, #3d4f7c 50%);
}
.win-hdl { position: absolute; z-index: 5; }
.win-hdl-n  { top: -4px; left: 12px; right: 12px; height: 8px; cursor: ns-resize; }
.win-hdl-s  { bottom: -4px; left: 12px; right: 12px; height: 8px; cursor: ns-resize; }
.win-hdl-e  { right: -4px; top: 12px; bottom: 12px; width: 8px; cursor: ew-resize; }
.win-hdl-w  { left: -4px; top: 12px; bottom: 12px; width: 8px; cursor: ew-resize; }
.win-hdl-ne { top: -5px; right: -5px; width: 15px; height: 15px; cursor: nesw-resize; }
.win-hdl-nw { top: -5px; left: -5px; width: 15px; height: 15px; cursor: nwse-resize; }
.win-hdl-se { bottom: -5px; right: -5px; width: 17px; height: 17px; cursor: nwse-resize; }
.win-hdl-sw { bottom: -5px; left: -5px; width: 15px; height: 15px; cursor: nesw-resize; }
.win-min .win-resize, .win-min .win-hdl { display: none; }
.win-sized-w { max-width: none; }
.win-sized { max-width: none; }
.win-sized .win-body { flex: 1 1 0; min-height: 0; max-height: none; }
.win-term .win-body { display: flex; flex-direction: column; }

/* documents inside windows */
.doc { padding: 14px 18px; user-select: text; font-size: 13.5px; }
.doc h2 { margin: 2px 0 10px; font-size: 18px; }
.doc h2 em { color: var(--accent); font-style: normal; }
.doc h3 { margin: 16px 0 6px; font-size: 14px; color: #9fc4ff; }
.doc p, .doc li { color: #c3cfe5; }
.doc a {
  color: var(--accent); text-decoration: underline;
  text-decoration-color: #33436f; text-underline-offset: 2px;
}
.doc a:hover { color: #9fd0ff; text-decoration-color: var(--accent); }
.doc ul { margin: 6px 0; padding-left: 20px; }
.doc code {
  font-family: var(--mono); font-size: 12px; background: #0d1428;
  border: 1px solid #26335a; border-radius: 5px; padding: 1px 6px; color: #9fd0ff;
}
.doc code.copy { cursor: pointer; }
.doc code.copy:hover { border-color: var(--accent); }
.doc code.copy.copied { background: #14402b; border-color: var(--ok); color: var(--ok); }
.doc kbd { font-family: var(--mono); background: #0d1428; border: 1px solid #26335a; border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: 12px; }
.doc .dim, .doc-foot { color: #7f8db0; }
.doc-auto { display: block; margin-top: 14px; color: #7f8db0; font-size: 12.5px; cursor: pointer; }

/* tutorial */
.tut-head { display: flex; gap: 10px; align-items: baseline; padding: 12px 18px 0; }
.tut-count { color: var(--accent); font-family: var(--mono); font-size: 12px; }
.tut-title { font-weight: 700; font-size: 15px; }
.tut .tut-body { padding-top: 6px; }
.tut-nav { display: flex; align-items: center; gap: 8px; padding: 10px 16px 14px; }
.tut-nav button {
  background: #263255; border: 1px solid #33436f; color: #d7e1ee;
  border-radius: 8px; padding: 6px 14px; cursor: pointer; font: inherit; font-size: 13px;
}
.tut-nav button:hover:not(:disabled) { border-color: var(--accent); }
.tut-nav button:disabled { opacity: .4; cursor: default; }
.tut-dots { flex: 1; display: flex; justify-content: center; gap: 5px; flex-wrap: wrap; }
.tut-dot { width: 8px; height: 8px; border-radius: 50%; background: #2c3a5e; cursor: pointer; }
.tut-dot.on { background: var(--accent); }

/* inspector */
.insp-head { padding: 8px 10px; border-radius: 8px; background: #0d1428; margin-bottom: 8px; }
.insp-note {
  font-size: 12.5px; color: #ffd7a1; background: #221a10;
  border: 1px solid #6b512a; border-radius: 8px; padding: 8px 10px;
}
.insp-head.st-down { color: var(--bad); }
.insp-head.st-decom { color: var(--warn); }
.insp-btns { display: flex; gap: 8px; margin-bottom: 4px; }
.insp-btns button, .ctl-btns button {
  background: #263255; border: 1px solid #33436f; color: #d7e1ee;
  border-radius: 8px; padding: 5px 12px; cursor: pointer; font: inherit; font-size: 12.5px;
}
.insp-btns button:hover, .ctl-btns button:hover { border-color: var(--accent); }
.insp-t { border-collapse: collapse; width: 100%; font-size: 12.5px; margin: 4px 0; }
.insp-t th { text-align: left; color: #7f8db0; font-weight: 500; padding: 2px 8px 2px 0; }
.insp-t td { padding: 2px 8px 2px 0; border-top: 1px solid #222c49; font-family: var(--mono); font-size: 12px; }
.insp-keys { font-family: var(--mono); font-size: 11.5px; color: #9fb0d0; background: #0d1428; border-radius: 6px; padding: 8px 10px; max-height: 160px; overflow: auto; }
.bad { color: var(--bad); }

/* controls */
.ctl-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; }
.ctl-row input[type=number] { width: 64px; background: #0d1428; color: #d7e1ee; border: 1px solid #26335a; border-radius: 6px; padding: 4px 6px; font: inherit; }
.ctl-btns { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 6px; }
.ctl-btns .danger { border-color: #6b2a2a; color: #ff9c9c; }
.ctl-btns .danger:hover { border-color: var(--bad); }

/* ---------------------------------------------------- terminal ----- */
.win-term { width: min(94vw, 760px); }
.term-root { display: flex; flex-direction: column; height: 420px; flex: 1 1 auto; min-height: 0; }
.term-tabs { display: flex; gap: 4px; padding: 6px 8px 0; background: var(--panel2); overflow-x: auto; }
.term-tab {
  display: flex; align-items: center; gap: 8px; border: 1px solid #26335a; border-bottom: none;
  background: #101830; color: #9fb0d0; border-radius: 8px 8px 0 0; padding: 4px 10px;
  cursor: pointer; font: inherit; font-size: 12px; white-space: nowrap;
}
.term-tab-active { background: #0a0f1e; color: #dfe9fa; border-color: #33436f; }
.term-tab b { font-weight: 400; color: #66739b; padding: 0 2px; }
.term-tab b:hover { color: var(--bad); }
.term-newtab {
  border: 1px dashed #33436f; background: none; color: #7f8db0; border-radius: 8px 8px 0 0;
  width: 30px; cursor: pointer; font-size: 14px;
}
.term-newtab:hover { color: var(--accent); border-color: var(--accent); }
.term-panes { flex: 1; min-height: 0; background: #0a0f1e; border-radius: 0 0 12px 12px; }
.term-pane { display: none; height: 100%; flex-direction: column; }
.term-pane-active { display: flex; }
.term-out {
  flex: 1; overflow-y: auto; padding: 10px 12px; user-select: text;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.45;
}
.term-line { white-space: pre-wrap; word-break: break-word; color: #c8d4ea; }
.t-echo { color: #eef4ff; }
.t-err { color: var(--bad); }
.t-ok { color: var(--ok); }
.t-sys { color: var(--warn); }
.t-dim { color: #66739b; }
.t-watch { color: #9fd0ff; }
.term-input-row {
  display: flex; gap: 8px; padding: 8px 12px; border-top: 1px solid #1c2745; align-items: center;
}
.term-ps1 { font-family: var(--mono); font-size: 12.5px; color: var(--ok); }
.term-input {
  flex: 1; background: none; border: none; outline: none; color: #eef4ff;
  font-family: var(--mono); font-size: 12.5px; caret-color: var(--ok);
}
.term-filebox { color: #9fd0ff; }
.term-filebox input { font-size: 12px; color: #9fb0d0; max-width: 220px; }
.term-filebox button {
  background: #263255; border: 1px solid #33436f; color: #d7e1ee;
  border-radius: 6px; padding: 2px 10px; cursor: pointer; font-size: 12px;
}
.blob-img {
  max-width: 220px; max-height: 220px; border-radius: 8px; margin: 4px 0;
  border: 1px solid #33436f; display: block;
}

/* ---------------------------------------------------- scenario ----- */
.scen-idle .scen-start {
  display: block; margin: 12px auto 4px; font: inherit; font-size: 14px;
  background: #1d3a5f; border: 1px solid var(--accent); color: #dcefff;
  border-radius: 10px; padding: 9px 22px; cursor: pointer;
}
.scen-idle .scen-start:hover { background: #25507f; }
/* the caption feed absorbs any extra height when the window is resized */
.win-scen .win-body { display: flex; flex-direction: column; }
.scen { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.scen-idle { overflow-y: auto; }
.scen-run { padding: 10px 14px 14px; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.scen-banner, .scen-timeline, .scen-transport, .scen-end { flex-shrink: 0; }
.scen-banner {
  font-size: 12.5px; padding: 6px 10px; border-radius: 8px; margin-bottom: 8px;
  border: 1px solid var(--edge); color: #c3cfe5;
}
.scen-banner-live { border-color: #2b5a41; color: var(--ok); }
.scen-banner-review { border-color: #6b512a; color: var(--warn); }
.scen-banner-done { border-color: #33436f; color: #9fc4ff; }
.scen-feed {
  height: 92px; flex: 1 1 auto; min-height: 56px;
  overflow-y: auto; background: #0a0f1e; border: 1px solid #1c2745;
  border-radius: 8px; padding: 6px 10px; margin-bottom: 10px;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.6; color: #9fb0d0;
  user-select: text;
}
.scen-cap { white-space: pre-wrap; }
.scen-cap:last-child { color: #dfe9fa; }
.scen-timeline { position: relative; padding: 4px 0 10px; }
.scen-slider {
  width: 100%; appearance: none; height: 8px; border-radius: 4px; outline: none;
  background: linear-gradient(to right, #2f4a7d var(--rec, 0%), #1a2340 var(--rec, 0%));
  border: 1px solid #33436f; cursor: pointer;
}
.scen-slider::-webkit-slider-thumb {
  appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2px solid #0b1020; cursor: grab;
}
.scen-slider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid #0b1020; cursor: grab;
}
.scen-marks { position: absolute; left: 0; right: 0; top: 16px; height: 6px; pointer-events: auto; }
.scen-mark {
  position: absolute; width: 5px; height: 5px; border-radius: 50%;
  background: var(--warn); transform: translateX(-2px);
}
.scen-transport { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.scen-btn {
  background: #263255; border: 1px solid #33436f; color: #d7e1ee;
  border-radius: 8px; padding: 5px 12px; cursor: pointer; font: inherit; font-size: 13px;
}
.scen-btn:hover:not(:disabled) { border-color: var(--accent); }
.scen-btn:disabled { opacity: .4; cursor: default; }
.scen-time { font-family: var(--mono); font-size: 12.5px; color: #9fc4ff; }
.scen-spacer { flex: 1; }
.scen-speed { font-size: 12px; color: #7f8db0; }
.scen-speed select {
  background: #0d1428; color: #d7e1ee; border: 1px solid #26335a;
  border-radius: 6px; padding: 3px 6px; font: inherit; font-size: 12px;
}
.scen-end { display: flex; gap: 8px; margin-top: 10px; }
.scen-end .scen-restore { border-color: #6b512a; color: #ffd7a1; }

/* ---------------------------------------------------- misc --------- */
.ctx-menu {
  position: fixed; z-index: 9000; min-width: 200px;
  background: var(--panel); border: 1px solid #33436f; border-radius: 10px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .55); padding: 5px; font-size: 13px;
}
.ctx-item { padding: 7px 12px; border-radius: 7px; cursor: pointer; }
.ctx-item:hover { background: #263255; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 26px; z-index: 9500;
  background: #14402b; border: 1px solid var(--ok); color: #c9f2dc;
  padding: 8px 16px; border-radius: 10px; font-size: 13px; transition: opacity .4s;
}
.toast-err { background: #40141a; border-color: var(--bad); color: #ffd4d4; }
.toast.gone { opacity: 0; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #26335a; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }
