:root {
  --graph-bg: #171d20;
  --graph-panel: #20272a;
  --graph-line: #3d484b;
  --graph-label: #e8eeec;
  --graph-muted: #9aa7a3;
  --graph-green: #43d889;
  --graph-blue: #60a5fa;
  --graph-amber: #f4b860;
  --graph-coral: #f07878;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 4px;
  background: var(--ink);
  color: #fff;
  font-weight: 750;
  text-decoration: none;
  transition: top 160ms ease;
}
.skip-link:focus { top: 10px; }

.view-tabs {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.view-tab {
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}
.view-tab:hover { color: var(--ink); }
.view-tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--green);
  box-shadow: 0 1px 4px rgba(24, 33, 31, 0.1);
}
.view-tab:focus-visible,
.graph-button:focus-visible,
.graph-filter:focus-visible,
.related-record:focus-visible,
.entity-chip:focus-visible {
  outline: 3px solid rgba(67, 216, 137, 0.4);
  outline-offset: 2px;
}

.graph-view {
  min-height: 0;
  padding: 18px;
  overflow: auto;
  background: #edf1f0;
}
.workspace[hidden] { display: none !important; }
.graph-view[hidden] { display: none !important; }
.graph-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: calc(100vh - 94px);
  min-height: 640px;
  max-width: 1540px;
  margin: 0 auto;
  border: 1px solid #303a3d;
  border-radius: 8px;
  overflow: hidden;
  background: var(--graph-bg);
  box-shadow: 0 16px 38px rgba(18, 25, 27, 0.18);
}
.graph-head {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 70px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--graph-line);
  background: var(--graph-panel);
  color: var(--graph-label);
}
.graph-title-wrap { min-width: 0; }
.graph-eyebrow {
  color: var(--graph-green);
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}
.graph-title { margin: 4px 0 0; font-size: 18px; line-height: 1.25; }
.graph-description { margin: 5px 0 0; color: var(--graph-muted); font-size: 12px; line-height: 1.45; }
.graph-tools { display: flex; align-items: center; justify-content: flex-end; gap: 7px; flex-wrap: wrap; }
.graph-search {
  width: min(260px, 34vw);
  height: 36px;
  padding: 0 11px;
  border: 1px solid #465256;
  border-radius: 4px;
  outline: none;
  background: #161c1f;
  color: var(--graph-label);
}
.graph-search::placeholder { color: #7e8c88; }
.graph-search:focus { border-color: var(--graph-green); box-shadow: 0 0 0 3px rgba(67, 216, 137, 0.14); }
.graph-button {
  min-width: 36px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid #465256;
  border-radius: 4px;
  background: #262f32;
  color: var(--graph-label);
  font-weight: 800;
  transition: border-color 160ms ease, background-color 160ms ease;
}
.graph-button:hover { border-color: var(--graph-green); background: #2c373a; }

.graph-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  min-height: 0;
}
.graph-stage {
  position: relative;
  min-width: 0;
  min-height: 640px;
  overflow: hidden;
  background:
    linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px),
    var(--graph-bg);
  background-size: 32px 32px;
}
.graph-canvas { display: block; width: 100%; height: 100%; min-height: 640px; outline: none; }
.graph-canvas:focus-visible { box-shadow: inset 0 0 0 3px rgba(67, 216, 137, 0.45); }
.graph-empty {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  color: var(--graph-muted);
  text-align: center;
}
.graph-empty.visible { display: grid; }

.graph-legend {
  position: absolute;
  left: 14px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  max-width: calc(100% - 28px);
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 4px;
  background: rgba(23,29,32,0.9);
  color: var(--graph-muted);
  font-size: 10px;
  pointer-events: none;
}
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-mark { width: 9px; height: 9px; background: currentColor; }
.legend-mark.broadcast { border-radius: 50%; color: #c5d0cd; }
.legend-mark.series { transform: rotate(45deg); color: var(--graph-blue); }
.legend-mark.person { color: var(--graph-coral); }
.legend-mark.topic { clip-path: polygon(50% 0, 100% 100%, 0 100%); color: var(--graph-green); }
.legend-line { width: 17px; height: 1px; background: var(--graph-line); }

.graph-node { cursor: pointer; }
.graph-node .node-shape {
  stroke: #111719;
  stroke-width: 2px;
  transition: filter 160ms ease, stroke 160ms ease;
}
.graph-node:hover .node-shape,
.graph-node.selected .node-shape { stroke: #fff; filter: drop-shadow(0 0 5px rgba(255,255,255,0.34)); }
.graph-node.dimmed { opacity: 0.15; }
.graph-link { stroke: var(--graph-line); stroke-opacity: 0.68; }
.graph-link.dimmed { stroke-opacity: 0.08; }
.graph-link.highlighted { stroke: var(--graph-amber); stroke-opacity: 0.9; }
.graph-label {
  fill: var(--graph-label);
  font: 500 11px/1.2 Inter, Pretendard, "Noto Sans KR", "Segoe UI", sans-serif;
  paint-order: stroke;
  stroke: var(--graph-bg);
  stroke-width: 4px;
  stroke-linejoin: round;
  pointer-events: none;
}
.graph-label.entity { font-weight: 750; }

.graph-inspector {
  min-height: 0;
  overflow: auto;
  border-left: 1px solid var(--graph-line);
  background: var(--graph-panel);
  color: var(--graph-label);
}
.inspector-section { padding: 16px; border-bottom: 1px solid var(--graph-line); }
.inspector-kicker { color: var(--graph-green); font-size: 10px; font-weight: 850; text-transform: uppercase; }
.inspector-title { margin: 6px 0 0; font-size: 18px; line-height: 1.35; overflow-wrap: anywhere; }
.inspector-meta { margin: 7px 0 0; color: var(--graph-muted); font-size: 11px; line-height: 1.5; }
.entity-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }
.entity-chip {
  min-height: 29px;
  padding: 0 8px;
  border: 1px solid #455155;
  border-radius: 4px;
  background: #242d30;
  color: var(--graph-label);
  font-size: 11px;
}
.entity-chip:hover { border-color: var(--graph-green); }
.inspector-heading { margin: 0 0 11px; font-size: 12px; }
.related-list { display: grid; gap: 6px; }
.related-record {
  width: 100%;
  min-height: 50px;
  padding: 9px 10px;
  border: 1px solid #3a4548;
  border-radius: 4px;
  background: #1b2225;
  color: var(--graph-label);
  text-align: left;
}
.related-record:hover { border-color: var(--graph-green); background: #222c2e; }
.related-date { display: block; color: var(--graph-green); font-size: 10px; font-weight: 800; }
.related-title { display: block; margin-top: 4px; font-size: 11px; line-height: 1.4; }
.open-timeline {
  width: 100%;
  min-height: 38px;
  margin-top: 12px;
  border: 1px solid var(--graph-green);
  border-radius: 4px;
  background: var(--graph-green);
  color: #10231a;
  font-weight: 850;
}
.open-timeline:hover { background: #65e5a1; }

.graph-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.graph-filter {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid #455155;
  border-radius: 4px;
  background: transparent;
  color: var(--graph-muted);
  font-size: 11px;
  font-weight: 750;
}
.graph-filter[aria-pressed="true"] { border-color: currentColor; background: rgba(255,255,255,0.07); color: var(--graph-label); }
.graph-filter[data-type="broadcast"][aria-pressed="true"] { color: #d6dfdc; }
.graph-filter[data-type="series"][aria-pressed="true"] { color: var(--graph-blue); }
.graph-filter[data-type="person"][aria-pressed="true"] { color: var(--graph-coral); }
.graph-filter[data-type="topic"][aria-pressed="true"] { color: var(--graph-green); }

@media (max-width: 980px) {
  .graph-view { padding: 10px; }
  .graph-shell { height: auto; min-height: 0; }
  .graph-head { grid-template-columns: 1fr; }
  .graph-tools { justify-content: flex-start; }
  .graph-search { width: min(100%, 320px); }
  .graph-layout { grid-template-columns: 1fr; }
  .graph-stage { height: 560px; min-height: 560px; }
  .graph-canvas { height: 560px; min-height: 0; }
  .graph-inspector { max-height: none; border-left: 0; border-top: 1px solid var(--graph-line); }
}

@media (max-width: 620px) {
  .app { grid-template-rows: auto minmax(0, 1fr); }
  .topbar { min-height: 58px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
  .view-tabs { order: 3; width: 100%; }
  .view-tab { flex: 1; }
  .graph-view { padding: 0; }
  .graph-shell { border: 0; border-radius: 0; }
  .graph-head { padding: 13px 12px; }
  .graph-tools { display: grid; grid-template-columns: 1fr repeat(3, 38px); width: 100%; }
  .graph-search { width: 100%; }
  .graph-stage { height: 460px; min-height: 460px; }
  .graph-canvas { height: 460px; min-height: 0; }
  .graph-legend { position: static; margin: 0; border-width: 1px 0 0; border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* Unified icon language */
.view-tab,
.top-action,
.graph-button,
.graph-filter,
.open-timeline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.view-tab svg { width: 14px; height: 14px; stroke-width: 2.2; }
.top-action svg { width: 15px; height: 15px; }
.graph-button { width: 36px; padding: 0; }
.graph-button svg { width: 17px; height: 17px; stroke-width: 2; }
.graph-filter svg { width: 13px; height: 13px; }
.open-timeline svg { width: 15px; height: 15px; }
.legend-item svg { width: 12px; height: 12px; }
.legend-item:nth-child(1) svg { color: #c5d0cd; }
.legend-item:nth-child(2) svg { color: var(--graph-blue); }
.legend-item:nth-child(3) svg { color: var(--graph-coral); }
.legend-item:nth-child(4) svg { color: var(--graph-green); }
.legend-item:nth-child(5) svg { color: var(--graph-muted); }
.graph-node .node-halo { stroke-width: 1px; stroke-opacity: 0.2; pointer-events: none; }
.graph-node .node-shape { stroke-width: 1.6px; }
.graph-node:hover .node-halo,
.graph-node.selected .node-halo { stroke-opacity: 0.85; stroke-width: 2px; }
.node-icon-object { overflow: visible; pointer-events: none; }
.node-icon-box { width: 100%; height: 100%; display: grid; place-items: center; }
.node-icon-box svg { width: 62%; height: 62%; stroke-width: 2.2; }