@font-face {
  font-family: "Inter";
  src: url("./fonts/inter-latin-variable.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Noto Sans SC";
  src: url("./fonts/noto-sans-sc-v40-chinese-simplified-regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Noto Sans SC";
  src: url("./fonts/noto-sans-sc-v40-chinese-simplified-600.woff2") format("woff2");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

:root {
  color-scheme: light;
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei UI", sans-serif;
  color: #253142;
  background: #e9edf1;
  --toolbar: #f7f8fa;
  --panel: rgba(250, 251, 252, 0.94);
  --line: #d5dce3;
  --muted: #697586;
  --accent: #176b82;
  --accent-soft: #e7f0f3;
  --shadow: 0 12px 34px rgba(24, 38, 53, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.hidden {
  display: none !important;
}

.graph-app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: 100%;
  background: #eef1f4;
}

.graph-toolbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(210px, auto) minmax(340px, 1fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 58px;
  border-bottom: 1px solid #d5dce3;
  padding: 8px 12px;
  background: var(--toolbar);
  box-shadow: 0 2px 8px rgba(24, 38, 53, 0.05);
}

.graph-brand {
  display: flex;
  min-width: 0;
  gap: 9px;
  align-items: center;
}

.graph-brand-mark {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  border: 2px solid #176b82;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, #fff 0 2px, transparent 3px),
    linear-gradient(135deg, #d9eaee, #79a8b5);
  box-shadow: 10px 5px 0 -7px #176b82, -7px 7px 0 -7px #176b82;
}

.graph-brand h1 {
  margin: 0;
  overflow: hidden;
  color: #1f2937;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.graph-brand p {
  margin: 2px 0 0;
  overflow: hidden;
  color: #8490a0;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.graph-toolbar-center,
.graph-toolbar-actions {
  display: flex;
  min-width: 0;
  gap: 6px;
  align-items: center;
}

.graph-toolbar-center {
  justify-content: center;
}

.graph-toolbar-actions {
  justify-content: flex-end;
}

.graph-cloud-status {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 3px 7px;
  color: #667085;
  background: #e9edf1;
  font-size: 9px;
  white-space: nowrap;
}

.graph-cloud-status::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #98a2b3;
  content: "";
}

.graph-cloud-status[data-state="synced"] {
  color: #25634a;
  background: #e7f3ec;
}

.graph-cloud-status[data-state="synced"]::before {
  background: #3a8b63;
}

.graph-cloud-status[data-state="saving"],
.graph-cloud-status[data-state="loading"] {
  color: #6c5a24;
  background: #f6f0dc;
}

.graph-cloud-status[data-state="saving"]::before,
.graph-cloud-status[data-state="loading"]::before {
  background: #b28a24;
}

.graph-cloud-status[data-state="error"] {
  color: #9b3b43;
  background: #f7e9ea;
}

.graph-cloud-status[data-state="error"]::before {
  background: #ba4b54;
}

.graph-toolbar button,
.project-filter summary {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  border: 1px solid #d5dce3;
  border-radius: 5px;
  padding: 4px 9px;
  color: #536071;
  background: #fff;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

.graph-toolbar button:hover,
.project-filter summary:hover,
.project-filter[open] summary {
  border-color: #aec2ca;
  color: #155e75;
  background: #edf4f6;
}

.project-filter {
  position: relative;
}

.project-filter summary {
  min-width: 112px;
  list-style: none;
}

.project-filter summary::-webkit-details-marker {
  display: none;
}

.project-filter summary::after {
  margin-left: 7px;
  color: #8994a2;
  content: "▾";
}

.project-filter-panel {
  position: absolute;
  top: calc(100% + 7px);
  left: 0;
  display: grid;
  width: 250px;
  max-height: min(430px, calc(100vh - 100px));
  grid-template-rows: auto minmax(0, 1fr);
  gap: 5px;
  border: 1px solid #ced6de;
  border-radius: 7px;
  padding: 6px;
  background: #fff;
  box-shadow: var(--shadow);
}

.project-filter-panel .project-filter-all {
  justify-content: flex-start;
  border-color: transparent;
  background: #f3f6f8;
}

.project-filter-list {
  display: grid;
  gap: 1px;
  overflow: auto;
}

.project-filter-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  min-height: 30px;
  border-radius: 4px;
  padding: 3px 6px;
  color: #435064;
  font-size: 11px;
  cursor: pointer;
}

.project-filter-item:hover {
  background: #f1f5f7;
}

.project-filter-item input {
  margin: 0;
  accent-color: #176b82;
}

.project-filter-item span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-filter-item small {
  color: #98a2b3;
  font-size: 9px;
}

.graph-search {
  display: grid;
  width: min(340px, 34vw);
  grid-template-columns: auto minmax(0, 1fr);
  gap: 5px;
  align-items: center;
  min-height: 30px;
  border: 1px solid #d5dce3;
  border-radius: 5px;
  padding: 3px 8px;
  color: #8994a2;
  background: #fff;
}

.graph-search:focus-within {
  border-color: #91adb8;
  box-shadow: 0 0 0 2px rgba(55, 110, 128, 0.1);
}

.graph-search input {
  min-width: 0;
  border: 0;
  padding: 0;
  color: #344054;
  background: transparent;
  font-size: 11px;
  outline: 0;
}

.compact-toggle {
  display: inline-flex;
  min-height: 30px;
  gap: 5px;
  align-items: center;
  border: 1px solid #d5dce3;
  border-radius: 5px;
  padding: 4px 8px;
  color: #667085;
  background: #fff;
  font-size: 10px;
  white-space: nowrap;
  cursor: pointer;
}

.legend-document .legend-dot {
  border-radius: 2px;
  background: #756da0 !important;
}

.compact-toggle input {
  margin: 0;
  accent-color: #176b82;
}

.graph-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.9), rgba(235, 239, 243, 0.92) 68%),
    #edf0f3;
}

#graphCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#graphCanvas.is-panning {
  cursor: grabbing;
}

#graphCanvas.is-node-hover {
  cursor: pointer;
}

#graphCanvas.is-node-dragging {
  cursor: move;
}

.graph-loading,
.graph-empty,
.graph-auth {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 7px;
  color: #536071;
  text-align: center;
  background: rgba(239, 242, 245, 0.86);
  backdrop-filter: blur(3px);
}

.graph-loading strong,
.graph-empty strong {
  font-size: 13px;
}

.graph-loading small,
.graph-empty span {
  max-width: 420px;
  color: #8a95a4;
  font-size: 11px;
  line-height: 1.5;
}

.loading-ring {
  width: 24px;
  height: 24px;
  border: 2px solid #d1dbe0;
  border-top-color: #176b82;
  border-radius: 50%;
  animation: graph-spin 800ms linear infinite;
}

@keyframes graph-spin {
  to { transform: rotate(360deg); }
}

.graph-stats,
.zoom-controls,
.graph-legend,
.graph-notice {
  position: absolute;
  z-index: 8;
  border: 1px solid rgba(207, 216, 224, 0.92);
  border-radius: 6px;
  color: #6c7889;
  background: rgba(250, 251, 252, 0.88);
  box-shadow: 0 5px 16px rgba(32, 44, 57, 0.08);
  backdrop-filter: blur(8px);
}

.graph-stats {
  bottom: 10px;
  left: 10px;
  display: flex;
  gap: 12px;
  padding: 6px 9px;
  font-size: 10px;
  pointer-events: none;
}

.graph-stats strong {
  color: #344054;
  font-variant-numeric: tabular-nums;
}

.zoom-controls {
  right: 10px;
  bottom: 10px;
  display: grid;
  overflow: hidden;
}

.zoom-controls button {
  width: 30px;
  height: 29px;
  border: 0;
  border-bottom: 1px solid #d7dee5;
  color: #536071;
  background: transparent;
  font-size: 17px;
  cursor: pointer;
}

.zoom-controls button:last-child {
  border-bottom: 0;
}

.zoom-controls button:hover {
  color: #155e75;
  background: #eaf2f4;
}

.graph-legend {
  top: 10px;
  left: 10px;
  display: flex;
  max-width: min(70vw, 720px);
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 6px 8px;
  font-size: 9px;
  pointer-events: none;
}

.legend-item {
  display: inline-flex;
  max-width: 145px;
  gap: 4px;
  align-items: center;
}

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

.legend-item span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.graph-notice {
  top: 10px;
  right: 10px;
  max-width: 360px;
  padding: 7px 9px;
  color: #8a5f16;
  background: rgba(255, 247, 226, 0.94);
  font-size: 10px;
  line-height: 1.45;
}

.event-inspector {
  position: absolute;
  z-index: 10;
  top: 10px;
  right: 10px;
  display: grid;
  width: min(320px, calc(100% - 20px));
  gap: 10px;
  border: 1px solid #cfd8e0;
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.event-inspector header {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
}

.event-inspector header > div {
  display: grid;
  gap: 2px;
}

.event-inspector header strong {
  color: #155e75;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.event-inspector header span,
.event-inspector section > span {
  color: #8490a0;
  font-size: 10px;
}

.event-inspector header button {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 4px;
  padding: 0;
  color: #7b8795;
  background: transparent;
  cursor: pointer;
}

.event-inspector header button:hover {
  color: #9c2d36;
  background: #f6e8e9;
}

.event-inspector h2 {
  max-height: 100px;
  overflow: auto;
  margin: 0;
  color: #253142;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.55;
}

.inspector-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.inspector-meta span {
  border-radius: 999px;
  padding: 3px 7px;
  color: #667085;
  background: #edf0f3;
  font-size: 9px;
}

.event-inspector section {
  display: grid;
  gap: 5px;
}

.inspector-links {
  display: grid;
  max-height: 150px;
  gap: 2px;
  overflow: auto;
}

.inspector-link {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 6px;
  border: 0;
  border-radius: 4px;
  padding: 5px 6px;
  color: #4b5869;
  text-align: left;
  background: transparent;
  font-size: 10px;
  cursor: pointer;
}

.inspector-link:hover {
  color: #155e75;
  background: #eaf2f4;
}

.inspector-link strong {
  font-variant-numeric: tabular-nums;
}

.inspector-link span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.open-event-button {
  min-height: 31px;
  border: 1px solid #176b82;
  border-radius: 5px;
  padding: 5px 10px;
  color: #fff;
  background: #176b82;
  font-size: 10px;
  cursor: pointer;
}

.open-event-button:hover {
  background: #105c70;
}

.graph-auth {
  position: fixed;
  background: #eef1f4;
}

.graph-auth > div {
  display: grid;
  width: min(420px, calc(100vw - 32px));
  justify-items: center;
  gap: 9px;
  border: 1px solid #d3dae1;
  border-radius: 10px;
  padding: 28px;
  background: #fff;
  box-shadow: var(--shadow);
}

.graph-auth h1 {
  margin: 0;
  font-size: 17px;
}

.graph-auth p {
  margin: 0;
  color: #778393;
  font-size: 11px;
  line-height: 1.6;
}

.graph-auth button {
  min-height: 32px;
  border: 0;
  border-radius: 5px;
  padding: 5px 12px;
  color: #fff;
  background: #176b82;
  font-size: 11px;
  cursor: pointer;
}

@media (max-width: 900px) {
  .graph-toolbar {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .graph-brand p {
    display: none;
  }

  .graph-toolbar-center {
    justify-content: flex-end;
  }

  .graph-toolbar-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
}

@media (max-width: 620px) {
  .graph-toolbar-center {
    flex-wrap: wrap;
  }

  .graph-search {
    width: min(250px, 50vw);
  }

  .compact-toggle span {
    display: none;
  }

  .graph-cloud-status {
    max-width: 96px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .event-inspector {
    top: auto;
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
  }

  .graph-stats,
  .zoom-controls {
    display: none;
  }
}
