:root {
  color-scheme: light;
  --page: #eef2f8;
  --page-2: #f8fafc;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-solid: #ffffff;
  --surface-soft: rgba(248, 250, 252, 0.86);
  --ink: #111827;
  --ink-soft: #334155;
  --muted: #64748b;
  --line: rgba(148, 163, 184, 0.28);
  --line-strong: rgba(100, 116, 139, 0.36);
  --blue: #2563eb;
  --cyan: #0891b2;
  --teal: #0f766e;
  --green: #15803d;
  --amber: #b45309;
  --red: #be123c;
  --violet: #6d28d9;
  --graph: #0ea5e9;
  --shadow: 0 24px 70px rgba(15, 23, 42, 0.12);
  --shadow-soft: 0 12px 34px rgba(15, 23, 42, 0.08);
  --radius: 8px;
}

* { box-sizing: border-box; }

html { background: var(--page); }

body {
  margin: 0;
  overflow: hidden;
  min-width: 320px;
  background:
    linear-gradient(115deg, rgba(37, 99, 235, 0.12), transparent 34%),
    linear-gradient(245deg, rgba(8, 145, 178, 0.10), transparent 38%),
    linear-gradient(180deg, var(--page-2), var(--page));
  color: var(--ink);
  font-family: Geist, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(rgba(15, 23, 42, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.026) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.52), transparent 72%);
}

body.map-dragging,
body.map-dragging * {
  cursor: grabbing !important;
  user-select: none !important;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin-top: 0; }

.workspace-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 14px;
  gap: 12px;
}

.appbar,
.left-panel,
.inspector,
.board-wrap {
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: linear-gradient(180deg, rgba(255,255,255,0.88), rgba(255,255,255,0.74));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.88);
  backdrop-filter: blur(22px) saturate(1.22);
  border-radius: var(--radius);
}

.appbar {
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) auto auto;
  gap: 16px;
  align-items: center;
  padding: 13px 14px;
}

.brand-block { min-width: 0; }

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  color: #0f172a;
  font-size: 24px;
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  color: #0f172a;
  font-size: 15px;
  font-weight: 750;
  letter-spacing: 0;
}

h3 {
  margin: 16px 0 8px;
  color: #0f172a;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
}

.status-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: end;
}

.app-actions {
  display: flex;
  gap: 7px;
  align-items: center;
}

.icon-btn,
.seg-btn,
.tab-btn,
.soul-open-btn {
  min-height: 36px;
  border: 1px solid rgba(148, 163, 184, 0.36);
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  color: #172033;
  border-radius: var(--radius);
  padding: 0 11px;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.04), inset 0 1px 0 rgba(255,255,255,0.95);
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.icon-btn:hover,
.seg-btn:hover,
.tab-btn:hover,
.soul-open-btn:hover {
  border-color: rgba(37, 99, 235, 0.42);
  background: linear-gradient(180deg, #ffffff, #eef6ff);
  box-shadow: 0 7px 18px rgba(37, 99, 235, 0.12), inset 0 1px 0 rgba(255,255,255,0.98);
  transform: translateY(-1px);
}

.icon-btn:active,
.seg-btn:active,
.tab-btn:active,
.soul-open-btn:active { transform: translateY(0); }

.map-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr) 376px;
  gap: 12px;
}

.left-panel {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-section {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-section.grow {
  border-bottom: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.section-headline {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.section-headline span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.seg-btn,
.tab-btn { background: rgba(248, 250, 252, 0.78); }

.seg-btn.active,
.tab-btn.active {
  color: #ffffff;
  border-color: rgba(37, 99, 235, 0.12);
  background: linear-gradient(135deg, #111827, #2563eb 86%);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.22), inset 0 1px 0 rgba(255,255,255,0.16);
}

.field-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  margin-bottom: 7px;
}

.search-input {
  width: 100%;
  height: 40px;
  border: 1px solid rgba(148, 163, 184, 0.34);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.76);
  color: var(--ink);
  padding: 0 11px;
  outline: none;
  font-weight: 600;
}

.search-input::placeholder { color: #94a3b8; }

.search-input:focus {
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}

.check-row {
  display: flex;
  gap: 9px;
  align-items: center;
  margin-top: 10px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 620;
}

.check-row input { accent-color: var(--blue); }

.navigator-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 8px;
  padding-right: 2px;
}

.navigator-list::-webkit-scrollbar,
.inspector-body::-webkit-scrollbar,
.soul-modal-content::-webkit-scrollbar { width: 8px; height: 8px; }

.navigator-list::-webkit-scrollbar-thumb,
.inspector-body::-webkit-scrollbar-thumb,
.soul-modal-content::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.22);
  border-radius: 999px;
}

.nav-item {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(255,255,255,0.64);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 10px 11px;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255,255,255,0.75) inset;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.nav-item:hover,
.nav-item.active {
  border-color: rgba(37, 99, 235, 0.45);
  background: rgba(255,255,255,0.92);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08), 0 0 0 4px rgba(37, 99, 235, 0.08);
}

.nav-item:hover { transform: translateY(-1px); }

.nav-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 780;
  font-size: 13px;
}

.nav-subtitle {
  color: var(--muted);
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-wrap {
  min-height: 0;
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
}

.board-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 54px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.56);
}

#boardHint {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  margin-top: 2px;
}

.zoom-label {
  color: #0f172a;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
  border: 1px solid rgba(148, 163, 184, 0.30);
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(255,255,255,0.78);
}

.board-viewport {
  position: relative;
  min-height: 0;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  background:
    radial-gradient(circle at 1px 1px, rgba(15, 23, 42, 0.15) 1px, transparent 0),
    linear-gradient(140deg, rgba(37, 99, 235, 0.08), transparent 44%, rgba(8, 145, 178, 0.07)),
    #f8fafc;
  background-size: 24px 24px, 100% 100%, 100% 100%;
}

.board-viewport.dragging { cursor: grabbing; }

.board-canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 3000px;
  height: 900px;
  transform-origin: 0 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

.edge-layer,
.lane-layer,
.node-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.edge-layer { overflow: visible; pointer-events: none; z-index: 1; }
.lane-layer { z-index: 0; pointer-events: none; }
.node-layer { z-index: 2; }

.lane {
  position: absolute;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(255,255,255,0.38);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.80);
}

.lane-label {
  position: absolute;
  top: 9px;
  left: 11px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 780;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.82);
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: 0 5px 14px rgba(15, 23, 42, 0.05);
}

.edge-path {
  fill: none;
  stroke: var(--graph);
  stroke-width: 2.15;
  marker-end: url(#arrow);
  opacity: 0.34;
}

.edge-path.dim { opacity: 0.08; }
.edge-path.hot { stroke: #0f766e; opacity: 0.88; stroke-width: 2.7; }

.edge-label {
  fill: #0f172a;
  font-size: 11px;
  font-weight: 700;
  paint-order: stroke;
  stroke: rgba(255,255,255,0.92);
  stroke-width: 5px;
  stroke-linejoin: round;
  opacity: 0.82;
}

.edge-label.dim { opacity: 0.08; }

.node-card {
  position: absolute;
  width: 180px;
  min-height: 78px;
  border: 1px solid rgba(148, 163, 184, 0.30);
  border-left: 4px solid var(--muted);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255,255,255,0.94), rgba(248,250,252,0.88));
  color: var(--ink);
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255,255,255,0.96);
  padding: 10px 11px 9px;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  transition: transform 160ms ease, opacity 160ms ease, filter 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
  animation: nodeIn 220ms ease both;
}

@keyframes nodeIn {
  from { opacity: 0; transform: translateY(4px) scale(0.992); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.node-card * {
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.node-card.profile { width: 190px; }
.node-card.mcp { width: 210px; min-height: 86px; }
.node-card.system { width: 170px; }
.node-card.external,
.node-card.gateway { width: 154px; }

.node-card:hover,
.node-card.active {
  transform: translateY(-2px);
  border-color: rgba(37, 99, 235, 0.42);
  box-shadow: 0 18px 42px rgba(37, 99, 235, 0.14), 0 0 0 4px rgba(37, 99, 235, 0.08), inset 0 1px 0 rgba(255,255,255,0.98);
}

.node-card.active {
  background: linear-gradient(180deg, #ffffff, #eef6ff);
}

.node-card.dim {
  opacity: 0.22;
  filter: saturate(0.75);
}

.node-card.director { border-left-color: var(--blue); }
.node-card.council { border-left-color: var(--cyan); }
.node-card.execution { border-left-color: var(--green); }
.node-card.control { border-left-color: var(--amber); }
.node-card.output { border-left-color: var(--violet); }
.node-card.storage,
.node-card.ingress { border-left-color: #475569; }
.node-card.auxiliary { border-left-color: #9f4560; }
.node-card.healthy { border-left-color: var(--green); }
.node-card.partial,
.node-card.gated { border-left-color: var(--amber); }
.node-card.failed,
.node-card.removed { border-left-color: var(--red); }

.node-kicker {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 800;
}

.node-title {
  margin-top: 2px;
  font-size: 14px;
  font-weight: 820;
  overflow-wrap: anywhere;
}

.node-subtitle {
  color: var(--muted);
  margin-top: 3px;
  font-size: 11px;
  font-weight: 620;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-badges {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.pill {
  display: inline-flex;
  min-height: 21px;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(241, 245, 249, 0.86);
  color: #475569;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.pill.tiny {
  font-size: 10px;
  max-width: 92px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-mini-list {
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.28;
  font-weight: 600;
  max-height: 27px;
  overflow: hidden;
}

.pill.director { background: #dbeafe; color: #1d4ed8; }
.pill.council { background: #cffafe; color: #0e7490; }
.pill.execution { background: #dcfce7; color: #166534; }
.pill.control { background: #fef3c7; color: #92400e; }
.pill.output { background: #ede9fe; color: #5b21b6; }
.pill.auxiliary { background: #ffe4e6; color: #9f1239; }
.pill.healthy { background: #dcfce7; color: #166534; }
.pill.partial,
.pill.gated { background: #fef3c7; color: #92400e; }
.pill.failed,
.pill.removed { background: #ffe4e6; color: #9f1239; }

.minimap-wrap {
  position: absolute;
  right: 13px;
  bottom: 13px;
  padding: 6px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.78);
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.10), inset 0 1px 0 rgba(255,255,255,0.86);
  backdrop-filter: blur(16px);
}

#minimap {
  display: block;
  width: 180px;
  height: 110px;
  cursor: pointer;
}

.inspector {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.inspector-head {
  min-height: 78px;
  padding: 15px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.inspector-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.inspector-body {
  min-height: 0;
  overflow: auto;
  padding: 15px 15px 18px;
}

.summary-text {
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 620;
}

.summary-text.lead {
  color: #172033;
  font-size: 14px;
  line-height: 1.52;
}

.role-grid {
  display: grid;
  gap: 8px;
  margin: 12px 0 12px;
}

.role-block {
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.70);
  padding: 10px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.82);
}

.role-block h3 {
  margin: 0 0 5px;
  color: #0f172a;
}

.role-block p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 13px 0;
}

.stat-box {
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.66);
  padding: 9px;
}

.stat-box span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 680;
}

.stat-box strong {
  display: block;
  margin-top: 3px;
  color: #0f172a;
  font-size: 13px;
  font-weight: 780;
  overflow-wrap: anywhere;
}

.chip-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mcp-list {
  display: grid;
  gap: 8px;
}

.mcp-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: var(--radius);
  padding: 9px 10px;
  background: rgba(255,255,255,0.68);
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.mcp-row:hover {
  border-color: rgba(37, 99, 235, 0.44);
  background: #ffffff;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.mcp-row.off { opacity: 0.55; }

.mcp-name { font-weight: 760; font-size: 13px; }
.mcp-note { color: var(--muted); font-size: 11px; font-weight: 600; margin-top: 2px; }

.flow-list {
  display: grid;
  gap: 8px;
}

.flow-item {
  border-left: 3px solid var(--blue);
  background: rgba(255,255,255,0.64);
  border-radius: var(--radius);
  padding: 8px 9px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 620;
}

.empty-state {
  color: var(--muted);
  font-size: 13px;
  padding: 10px 0;
  font-weight: 620;
}

.soul-open-btn {
  width: 100%;
  min-height: 40px;
  color: #ffffff;
  border-color: rgba(17, 24, 39, 0.10);
  background: linear-gradient(135deg, #111827, #2563eb 86%);
  box-shadow: 0 16px 28px rgba(37, 99, 235, 0.18), inset 0 1px 0 rgba(255,255,255,0.16);
}

.modal-backdrop[hidden] { display: none; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.26);
  backdrop-filter: blur(18px) saturate(1.12);
}

.soul-modal {
  width: min(980px, calc(100vw - 48px));
  max-height: min(820px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.78);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.92);
  box-shadow: 0 40px 110px rgba(15, 23, 42, 0.26), inset 0 1px 0 rgba(255,255,255,0.92);
  animation: modalIn 170ms ease both;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.soul-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.soul-modal-head h2 {
  max-width: 760px;
  overflow-wrap: anywhere;
  font-size: 18px;
}

.soul-modal-content {
  margin: 0;
  overflow: auto;
  padding: 18px;
  color: #172033;
  white-space: pre-wrap;
  word-break: break-word;
  font: 13px/1.58 "Geist Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  background: rgba(248, 250, 252, 0.82);
}

@media (max-width: 1220px) {
  body { overflow: auto; }
  .workspace-shell { height: auto; min-height: 100vh; }
  .appbar { grid-template-columns: 1fr; align-items: start; }
  .status-row, .app-actions { justify-content: start; }
  .map-layout { grid-template-columns: 260px minmax(0, 1fr); }
  .inspector { grid-column: 1 / -1; min-height: 460px; }
  .board-wrap { min-height: 690px; }
}

@media (max-width: 760px) {
  .workspace-shell { padding: 8px; }
  .map-layout { grid-template-columns: 1fr; }
  .left-panel { max-height: 390px; }
  .board-wrap { min-height: 650px; }
  .board-canvas { width: 1800px; height: 1500px; }
  .minimap-wrap { display: none; }
  .stat-grid { grid-template-columns: 1fr; }
  .soul-modal { width: calc(100vw - 24px); max-height: calc(100vh - 24px); }
  .modal-backdrop { padding: 12px; }
}
