:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --blue: #1677ff;
  --blue-soft: #eaf3ff;
  --red: #f04438;
  --red-soft: #fff1f0;
  --orange: #fa8c16;
  --orange-soft: #fff7ed;
  --green: #16a34a;
  --green-soft: #f0fdf4;
  --purple: #7c3aed;
  --purple-soft: #f3e8ff;
  --obsidian: #8b5cf6;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-width: 1180px;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.graph-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.graph-topbar {
  flex: 0 0 64px;
  height: 64px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.graph-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.graph-brand-mark {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--blue);
  display: grid;
  place-items: center;
}

.graph-brand-mark svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.graph-brand h1 {
  font-size: 18px;
  line-height: 1.2;
}

.graph-brand p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.graph-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.primary-button,
.ghost-button,
.icon-button {
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 0 13px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary-button {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.icon-button {
  width: 34px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.graph-workspace {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 14px;
}

.graph-workspace.drawer-open {
  grid-template-columns: 280px minmax(0, 1fr) 390px;
}

.graph-filter-panel,
.graph-canvas-panel,
.graph-detail-drawer {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.graph-filter-panel {
  min-height: 0;
  overflow: auto;
}

.panel-title {
  height: 44px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title h2 {
  font-size: 14px;
}

.panel-title span {
  color: var(--muted);
  font-size: 12px;
}

.filter-field {
  display: grid;
  gap: 6px;
  padding: 10px 12px 0;
  color: var(--muted);
  font-size: 12px;
}

input,
select {
  width: 100%;
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.legend-block {
  margin: 14px 12px 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.legend-block h3 {
  margin-bottom: 8px;
  font-size: 13px;
}

.legend-block p {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  color: #394150;
  font-size: 12px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  border: 2px solid var(--line-strong);
  background: #fff;
}

.legend-dot.level1 {
  border-color: #334155;
  background: #334155;
}

.legend-dot.level2 {
  border-color: #64748b;
  background: #64748b;
}

.legend-dot.item.high {
  border-color: #4b5563;
  background: #4b5563;
}

.legend-dot.evidence {
  border-color: var(--green);
  background: var(--green-soft);
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.12);
}

.focus-card {
  margin: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.focus-card span {
  color: var(--muted);
  font-size: 12px;
}

.focus-card strong {
  display: block;
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.35;
}

.focus-card p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

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

.canvas-toolbar {
  flex: 0 0 48px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.canvas-toolbar strong {
  display: block;
  font-size: 14px;
}

.canvas-toolbar span,
.canvas-stats {
  color: var(--muted);
  font-size: 12px;
}

.canvas-stats {
  display: flex;
  gap: 12px;
  white-space: nowrap;
}

.graph-canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #fff;
}

#graphCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

#graphCanvas:active {
  cursor: grabbing;
}

.graph-hint {
  position: absolute;
  left: 12px;
  bottom: 10px;
  z-index: 1;
  padding: 5px 8px;
  border: 1px solid rgba(226, 232, 240, 0.85);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.78);
  color: #94a3b8;
  font-size: 11px;
  pointer-events: none;
}

.graph-hover-card {
  position: absolute;
  z-index: 2;
  width: 230px;
  padding: 9px 10px;
  border: 1px solid #d9d3ff;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
  pointer-events: none;
}

.graph-hover-card strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.graph-hover-card span,
.graph-hover-card em {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.graph-detail-drawer {
  width: 390px;
  max-height: calc(100vh - 88px);
  z-index: 3;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

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

.drawer-head span {
  color: var(--muted);
  font-size: 12px;
}

.drawer-head h2 {
  margin-top: 5px;
  font-size: 16px;
  line-height: 1.4;
}

.drawer-body {
  min-height: 0;
  overflow: auto;
  padding: 12px 14px 14px;
}

.drawer-meta {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 8px 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.drawer-meta span {
  color: var(--muted);
}

.drawer-section {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.drawer-section h3 {
  margin-bottom: 8px;
  font-size: 13px;
}

.drawer-section p,
.drawer-section li,
.drawer-section a {
  color: #394150;
  font-size: 12px;
  line-height: 1.6;
}

.drawer-section ul {
  margin: 0;
  padding-left: 18px;
}

.drawer-section a {
  display: block;
  color: var(--blue);
  overflow-wrap: anywhere;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.tag.high {
  background: var(--red-soft);
  color: var(--red);
}

.tag.medium {
  background: var(--orange-soft);
  color: var(--orange);
}

.tag.low {
  background: var(--green-soft);
  color: var(--green);
}

.tag.evidence {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
}
