:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: rgba(255, 255, 255, 0.92);
  --line: rgba(24, 34, 51, 0.1);
  --line-strong: rgba(24, 34, 51, 0.18);
  --text: #172033;
  --muted: #6f7887;
  --accent: #ff6b35;
  --accent-soft: rgba(255, 107, 53, 0.09);
  --blue: #2563eb;
  --blue-soft: rgba(37, 99, 235, 0.08);
  --shadow: 0 24px 70px rgba(42, 51, 66, 0.14);
}

* { box-sizing: border-box; }

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

body {
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input { font: inherit; }

button { color: inherit; }

.app-shell,
.workspace,
.graph-panel,
.chart-wrap,
#chart {
  width: 100%;
  height: 100%;
}

.app-shell {
  position: relative;
  min-height: 560px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  width: fit-content;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 11px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 7px 18px rgba(255, 107, 53, 0.24);
  font-size: 12px;
  font-weight: 900;
}

.brand strong,
.brand small { display: block; }

.brand strong {
  font-size: 16px;
  letter-spacing: 0.08em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.workspace { position: relative; }

.graph-panel {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 72% 42%, rgba(255, 255, 255, 0.98), rgba(246, 248, 251, 0.96) 52%, #eef2f6 100%);
}

#chart,
#chart > div,
#chart canvas {
  background: transparent !important;
}

.graph-toolbar {
  position: absolute;
  z-index: 6;
  top: 22px;
  right: 22px;
  display: flex;
  align-items: center;
  gap: 22px;
  min-height: 42px;
  padding: 0 9px 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 10px 30px rgba(42, 51, 66, 0.08);
  backdrop-filter: blur(16px);
  font-size: 10px;
}

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

.graph-toolbar > div,
.toolbar-actions,
.legend,
.legend span,
.ghost-button {
  display: flex;
  align-items: center;
}

.live-dot {
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.toolbar-actions { gap: 18px; }
.legend { gap: 13px; }
.legend span { gap: 6px; }

.legend i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.legend-user { background: var(--accent); }
.legend-keyword { background: var(--blue); }
.legend-direct-relation {
  width: 14px !important;
  height: 0 !important;
  border-top: 2px solid #aab6c6;
  border-radius: 0 !important;
}

.relation-chip {
  border-color: rgba(136, 103, 217, 0.22) !important;
  color: #6947bd !important;
  background: rgba(136, 103, 217, 0.08) !important;
}

.relation-tooltip {
  border-color: rgba(136, 103, 217, 0.28) !important;
}

.ghost-button {
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 10px;
}

.ghost-button:hover {
  border-color: rgba(255, 107, 53, 0.35);
  color: var(--accent);
}

.ghost-button svg {
  width: 13px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.relation-explorer {
  position: relative;
}

.relation-explorer > .ghost-button.is-active {
  border-color: rgba(49, 95, 232, 0.28);
  color: var(--blue);
  background: var(--blue-soft);
}

.relation-explore-menu {
  position: absolute;
  z-index: 12;
  top: calc(100% + 10px);
  right: 0;
  width: 330px;
  max-height: min(520px, calc(100vh - 100px));
  padding: 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 18px 48px rgba(42, 51, 66, 0.16);
  backdrop-filter: blur(18px);
}

.relation-explore-menu[hidden] {
  display: none;
}

.relation-explore-head {
  padding: 7px 8px 10px;
}

.relation-explore-head strong,
.relation-explore-head small {
  display: block;
}

.relation-explore-head strong {
  color: var(--text);
  font-size: 13px;
}

.relation-explore-head small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}

.relation-type-list {
  display: grid;
  gap: 4px;
}

.relation-type-option {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 8px;
  border: 1px solid transparent;
  border-radius: 9px;
  text-align: left;
  background: transparent;
  cursor: pointer;
}

.relation-type-option:hover,
.relation-type-option.is-active {
  border-color: var(--line);
  background: #f7f9fc;
}

.relation-type-option.is-active {
  box-shadow: inset 3px 0 0 var(--blue);
}

.relation-type-option > i {
  width: 18px;
  height: 0;
  border-top: 2px dashed var(--relation-color, #aab6c6);
}

.relation-type-option > span,
.relation-type-option strong,
.relation-type-option small {
  display: block;
}

.relation-type-option strong {
  color: var(--text);
  font-size: 11px;
}

.relation-type-option small {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.relation-type-option em {
  color: #929aa7;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
  font-style: normal;
}

.relation-type-none > i {
  border-top-style: solid;
  opacity: 0.55;
}

.chart-wrap,
#chart { position: absolute; inset: 0; }

.chart-wrap::after {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: 0;
  width: 154px;
  height: 42px;
  pointer-events: none;
  background: #f6f8fb;
  content: "";
}

#chart { z-index: 1; }

#chart canvas {
  outline: none;
}

.graph-tooltip-card {
  width: min(340px, 72vw);
  padding: 14px 16px;
  border: 1px solid rgba(24, 34, 51, 0.12);
  border-radius: 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 14px 38px rgba(42, 51, 66, 0.16);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.graph-tooltip-card strong {
  display: block;
  color: var(--text);
  font-size: 15px;
}

.graph-tooltip-card p {
  margin: 7px 0 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.graph-tooltip-card small {
  display: block;
  color: var(--blue);
  font-size: 10px;
  line-height: 1.5;
}

.graph-tooltip-card.keyword-tooltip {
  border-color: rgba(49, 95, 232, 0.22);
}

.graph-tooltip-card.compact-tooltip {
  width: auto;
  padding: 9px 12px;
  color: var(--muted);
  font-size: 11px;
}

.people-panel {
  position: fixed;
  z-index: 8;
  top: 22px;
  bottom: 22px;
  left: 22px;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  width: 360px;
  min-height: 0;
  padding: 0 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  transition: width 200ms ease, height 200ms ease, padding 200ms ease;
}

.panel-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 76px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
}

.panel-brand .brand {
  min-width: 120px;
}

.panel-stats {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-left: auto;
}

.panel-stats span {
  display: flex;
  flex-direction: column;
  color: var(--muted);
  font-size: 8px;
  text-align: center;
}

.panel-stats strong {
  margin-bottom: 2px;
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.panel-toggle {
  display: grid;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  cursor: pointer;
}

.panel-toggle:hover {
  border-color: rgba(255, 107, 53, 0.35);
  color: var(--accent);
}

.panel-toggle svg {
  width: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  transition: transform 200ms ease;
}

.people-panel.is-collapsed {
  bottom: auto;
  width: 42px;
  height: 42px;
  padding: 0;
  overflow: visible;
  border-radius: 12px;
}

.people-panel.is-collapsed .panel-brand {
  min-height: 42px;
  padding: 0;
  border: 0;
}

.people-panel.is-collapsed .brand,
.people-panel.is-collapsed .panel-stats,
.people-panel.is-collapsed .panel-content {
  display: none;
}

.people-panel.is-collapsed .panel-toggle {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.people-panel.is-collapsed .panel-toggle svg {
  transform: rotate(180deg);
}

.search-box {
  display: grid;
  grid-template-columns: 19px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  margin: 14px 0 13px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(248, 249, 251, 0.95);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.search-box:focus-within {
  border-color: rgba(255, 107, 53, 0.5);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-box svg {
  width: 17px;
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-width: 1.6;
}

.search-box input {
  width: 100%;
  height: 44px;
  padding: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 12px;
}

.search-box input::placeholder { color: #9aa1ad; }

.search-box kbd {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--muted);
  background: #fff;
  font-family: inherit;
  font-size: 10px;
}

.active-filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  padding: 9px 10px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 9px;
  color: var(--muted);
  background: var(--blue-soft);
  font-size: 10px;
}

.active-filter[hidden] { display: none; }
.active-filter strong { color: var(--blue); }

.active-filter button {
  padding: 0;
  border: 0;
  color: var(--blue);
  background: transparent;
  cursor: pointer;
}
