:root {
  --bg: #0b0f19;
  --panel: #111827;
  --panel2: #1a2236;
  --panel3: #0f172a;
  --ink: #e2e8f0;
  --muted: #94a3b8;
  --faint: #64748b;
  --line: #1e293b;
  --accent: #06b6d4;
  --blue: #3b82f6;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --purple: #8b5cf6;
  --shadow: 0 0 0 1px rgba(59, 130, 246, 0.08), 0 18px 45px rgba(0, 0, 0, 0.26);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  padding: 10px;
  -webkit-font-smoothing: antialiased;
}

html,
body {
  overflow-x: hidden;
}

.topbar {
  max-width: 1440px;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 auto 8px;
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  flex-wrap: wrap;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1.1;
}

.topbar p,
.note,
.empty p,
.meta {
  color: var(--muted);
}

.topbar p {
  margin-top: 6px;
  font-size: 13px;
}

.summary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.summary span,
.status-pill {
  border: 1px solid var(--line);
  background: var(--panel2);
  border-radius: 4px;
  padding: 5px 10px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.workspace {
  max-width: 1440px;
  height: calc(100vh - 96px);
  display: grid;
  grid-template-columns: 280px minmax(420px, 1fr) 340px;
  gap: 8px;
  min-height: 650px;
  margin: 0 auto;
}

.sidebar,
.detail-panel {
  overflow: auto;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sidebar section + section {
  margin-top: 18px;
}

h2 {
  margin-bottom: 10px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.search {
  display: grid;
  gap: 8px;
  margin-bottom: 24px;
  font-size: 14px;
  font-weight: 650;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--panel3);
  font: inherit;
}

input::placeholder {
  color: var(--faint);
}

.filters {
  display: grid;
  gap: 8px;
}

.filter {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  padding: 8px 9px;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.filter.active {
  border-color: var(--blue);
  background: rgba(59, 130, 246, 0.1);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.18);
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex: 0 0 auto;
}

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

.map-area {
  min-width: 0;
  position: relative;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.map-toolbar {
  position: absolute;
  z-index: 2;
  left: 18px;
  right: 18px;
  top: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.map-toolbar button,
.map-toolbar span {
  pointer-events: auto;
}

button {
  border: 1px solid var(--line);
  background: var(--panel2);
  border-radius: 4px;
  padding: 8px 11px;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

button:hover {
  border-color: var(--blue);
  color: var(--ink);
}

#map {
  min-width: 1120px;
  min-height: 820px;
  width: 100%;
  height: 100%;
  background:
    linear-gradient(rgba(148, 163, 184, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.05) 1px, transparent 1px);
  background-size: 36px 36px;
}

.edge {
  fill: none;
  stroke: #78716c;
  stroke-width: 3;
  stroke-linecap: round;
  opacity: 0.42;
}

.track-edge {
  fill: none;
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.5;
}

.connector-edge {
  fill: none;
  stroke: #475569;
  stroke-width: 2;
  stroke-dasharray: 6 8;
  stroke-linecap: round;
  opacity: 0.5;
}

.relation-edge {
  fill: none;
  stroke: var(--ink);
  stroke-width: 4;
  stroke-linecap: round;
  opacity: 0.78;
}

.track-label {
  font-size: 17px;
  font-weight: 780;
  letter-spacing: 0;
  paint-order: stroke;
  stroke: var(--panel);
  stroke-width: 6px;
  stroke-linejoin: round;
}

.node {
  cursor: pointer;
}

.node rect {
  fill: var(--panel3);
  filter: drop-shadow(0 6px 10px rgba(31, 41, 55, 0.12));
  transition: stroke-width 160ms ease, filter 160ms ease, transform 160ms ease;
}

.node:hover rect {
  filter: drop-shadow(0 10px 16px rgba(31, 41, 55, 0.2));
}

.node text {
  fill: var(--ink);
  font-size: 13px;
  font-weight: 720;
  pointer-events: none;
}

.node.is-selected rect {
  stroke: var(--ink);
  stroke-width: 5;
}

.node.is-muted,
.edge.is-muted {
  opacity: 0.1;
}

.empty,
.detail {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.empty h2 {
  margin-bottom: 8px;
}

.hidden {
  display: none;
}

.detail h2 {
  color: var(--ink);
  font-size: 22px;
  text-transform: none;
  margin-bottom: 8px;
}

.detail .category {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 10px 0 16px;
  font-size: 14px;
}

.fields {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.field {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.field strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.field p,
.field a {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.field a {
  color: var(--accent);
  text-decoration: none;
}

.field a:hover {
  text-decoration: underline;
}

@media (max-width: 1050px) {
  body {
    padding: 8px;
  }

  .topbar,
  .workspace {
    max-width: none;
  }

  .workspace {
    height: auto;
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .map-area {
    order: 1;
  }

  .sidebar {
    order: 2;
  }

  .detail-panel {
    order: 3;
  }

  .sidebar,
  .detail-panel {
    border: 1px solid var(--line);
  }

  .map-area {
    height: 72vh;
    min-height: 560px;
  }
}

@media (max-width: 700px) {
  body {
    padding: 6px;
    font-size: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    padding: 12px;
  }

  h1 {
    font-size: 21px;
  }

  .topbar p {
    max-width: 30ch;
    line-height: 1.45;
  }

  .summary {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .summary span,
  .status-pill {
    min-width: 0;
    padding: 6px 8px;
    font-size: 12px;
    text-align: center;
  }

  .workspace {
    gap: 6px;
  }

  .map-area {
    height: 64vh;
    min-height: 470px;
    max-height: 620px;
  }

  .detail-panel {
    order: 2;
  }

  .sidebar {
    order: 3;
  }

  .sidebar,
  .detail-panel {
    padding: 12px;
  }

  .map-toolbar {
    left: 10px;
    right: 10px;
    top: 10px;
    gap: 8px;
  }

  .map-toolbar button,
  .map-toolbar span {
    padding: 7px 9px;
    font-size: 12px;
  }

  #map {
    min-width: 1280px;
    min-height: 760px;
  }

  .track-label {
    font-size: 16px;
  }

  .node rect {
    filter: none;
  }

  .node text {
    font-size: 13px;
  }

  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .filter {
    justify-content: flex-start;
    min-height: 40px;
    padding: 8px;
    font-size: 13px;
  }

  .status-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .search {
    margin-bottom: 18px;
  }

  input {
    min-height: 42px;
    font-size: 16px;
  }

  .empty,
  .detail {
    padding: 13px;
  }

  .detail h2 {
    font-size: 20px;
  }
}

@media (max-width: 420px) {
  .summary,
  .filters,
  .status-list {
    grid-template-columns: 1fr;
  }

  .map-area {
    height: 60vh;
    min-height: 430px;
  }

  #map {
    min-width: 1220px;
    min-height: 720px;
  }
}
