:root {
  --bg: #f4f0e8;
  --panel: #fffdf8;
  --panel-2: #ebe4d8;
  --ink: #1d2824;
  --muted: #68756f;
  --line: rgba(29, 40, 36, 0.14);
  --content: #426d87;
  --runtime: #24715e;
  --ops: #8d5a2f;
  --interface: #785b92;
  --alert: #b54e3f;
  --shadow: 0 18px 42px rgba(29, 40, 36, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    linear-gradient(180deg, rgba(36, 113, 94, 0.09), transparent 260px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app {
  min-height: 100vh;
  padding: 20px;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin: 0 auto 18px;
  max-width: 1520px;
}

.topbar h1,
.map-toolbar h2 {
  letter-spacing: 0;
  line-height: 1.05;
  margin: 0;
}

.topbar h1 {
  font-size: 28px;
}

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

.topbar-actions,
.map-toolbar,
.button-row {
  align-items: center;
  display: flex;
  gap: 10px;
}

.status-pill {
  background: #dce9e4;
  border: 1px solid rgba(36, 113, 94, 0.2);
  border-radius: 999px;
  color: #174b3f;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  padding: 7px 10px;
}

.ghost-link {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.workspace {
  display: grid;
  gap: 16px;
  grid-template-columns: 276px minmax(0, 1fr) 360px;
  margin: 0 auto;
  max-width: 1520px;
}

.panel,
.map-panel {
  background: rgba(255, 253, 248, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  margin-bottom: 16px;
  padding: 14px;
}

.panel-heading {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.panel-heading strong {
  color: var(--runtime);
  font-size: 12px;
}

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

.flow-button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: block;
  min-height: 58px;
  padding: 10px;
  text-align: left;
  width: 100%;
}

.flow-button:hover,
.flow-button.active {
  border-color: rgba(36, 113, 94, 0.42);
  box-shadow: inset 3px 0 0 var(--runtime);
}

.flow-button strong {
  display: block;
  font-size: 13px;
  line-height: 1.25;
}

.flow-button span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  line-height: 1.4;
  margin-top: 5px;
}

.search-input {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 42px;
  outline: none;
  padding: 0 12px;
  width: 100%;
}

.search-input:focus {
  border-color: rgba(36, 113, 94, 0.52);
  box-shadow: 0 0 0 3px rgba(36, 113, 94, 0.12);
}

.legend {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.legend span {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  font-weight: 700;
  gap: 8px;
}

.dot {
  border-radius: 999px;
  display: inline-block;
  height: 10px;
  width: 10px;
}

.dot-content {
  background: var(--content);
}

.dot-runtime {
  background: var(--runtime);
}

.dot-ops {
  background: var(--ops);
}

.dot-interface {
  background: var(--interface);
}

.map-panel {
  min-height: 680px;
  overflow: hidden;
}

.map-toolbar {
  border-bottom: 1px solid var(--line);
  justify-content: space-between;
  padding: 16px;
}

.map-toolbar button {
  background: var(--ink);
  border-radius: 8px;
  color: #fffdf8;
  font-size: 12px;
  font-weight: 800;
  min-height: 36px;
  padding: 0 13px;
}

#moduleGraph {
  display: block;
  height: 610px;
  width: 100%;
}

.graph-edge {
  fill: none;
  opacity: 0.35;
  stroke: #7a857f;
  stroke-linecap: round;
  stroke-width: 2;
}

.graph-edge.active {
  opacity: 0.95;
  stroke: var(--alert);
  stroke-width: 3.5;
}

.graph-node {
  cursor: pointer;
}

.graph-node rect {
  fill: #fff;
  stroke: var(--line);
  stroke-width: 1.5;
}

.graph-node text {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  pointer-events: none;
}

.graph-node .node-meta {
  fill: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.graph-node.active rect,
.graph-node.selected rect {
  stroke: var(--alert);
  stroke-width: 3;
}

.graph-node.dim {
  opacity: 0.25;
}

.node-band {
  height: 8px;
}

.layer-content {
  fill: var(--content);
}

.layer-runtime {
  fill: var(--runtime);
}

.layer-ops {
  fill: var(--ops);
}

.layer-interface {
  fill: var(--interface);
}

.sticky {
  position: sticky;
  top: 16px;
}

.module-detail {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 10px;
  min-height: 190px;
  padding: 12px;
}

.module-detail h3 {
  font-size: 18px;
  line-height: 1.2;
  margin: 0 0 6px;
}

.module-detail p {
  color: #35423d;
  line-height: 1.55;
  margin: 8px 0;
}

.module-detail dl {
  display: grid;
  gap: 6px;
  grid-template-columns: 84px minmax(0, 1fr);
  margin: 10px 0 0;
}

.module-detail dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.module-detail dd {
  margin: 0;
  min-width: 0;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  padding: 4px 7px;
}

#agentMemo {
  background: #151d1a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #eff8f3;
  display: block;
  line-height: 1.45;
  min-height: 280px;
  outline: none;
  padding: 12px;
  resize: vertical;
  width: 100%;
}

.button-row {
  margin-top: 10px;
}

.button-row button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  flex: 1;
  font-size: 12px;
  font-weight: 800;
  min-height: 36px;
}

.plan-box {
  margin-top: 12px;
}

.plan-box pre {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #35423d;
  line-height: 1.5;
  margin: 0;
  overflow: auto;
  padding: 10px;
  white-space: pre-wrap;
}

.empty {
  align-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: flex;
  font-weight: 700;
  justify-content: center;
  min-height: 118px;
  padding: 18px;
  text-align: center;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .inspector {
    grid-column: 1 / -1;
  }

  .sticky {
    position: static;
  }
}

@media (max-width: 820px) {
  .app {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
    display: grid;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  #moduleGraph {
    height: 720px;
  }
}
