:root {
  color-scheme: dark;
  --ink-950: #080c17;
  --ink-900: #0b1020;
  --ink-850: #0e1423;
  --ink-800: #121a2b;
  --ink-750: #172136;
  --ink-700: #1c2941;
  --line: rgba(207, 220, 241, 0.13);
  --line-strong: rgba(207, 220, 241, 0.32);
  --paper: #f3f6f7;
  --paper-strong: #ffffff;
  --graphite: #172027;
  --text: #f1f5f9;
  --text-soft: #b4bfd0;
  --text-muted: #8793a7;
  --mist: #a7bee0;
  --mist-strong: #7fa2d4;
  --mint: #72c8b7;
  --sand: #d6bb83;
  --danger: #e47b84;
  --danger-soft: rgba(228, 123, 132, 0.13);
  --focus: #b8d2fa;
  --shadow-lg: 0 24px 70px rgba(2, 6, 23, 0.46);
  --shadow-md: 0 14px 34px rgba(2, 6, 23, 0.3);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --header-h: 76px;
  --roster-w: 248px;
  --inspector-w: 360px;
  --font-ui: "Microsoft YaHei UI", "Noto Sans SC", "PingFang SC", system-ui, sans-serif;
  --font-display: "Songti SC", "Noto Serif CJK SC", "STSong", "SimSun", serif;
  --font-mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

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

body {
  overflow: hidden;
  color: var(--text);
  background: var(--ink-950);
  font-family: var(--font-ui);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button,
summary {
  touch-action: manipulation;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .34;
}

button:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

svg {
  display: block;
}

.hidden {
  display: none !important;
}

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

.skip-link {
  position: fixed;
  z-index: 3000;
  top: 10px;
  left: 12px;
  padding: 10px 14px;
  color: var(--graphite);
  background: var(--paper-strong);
  border-radius: 6px;
  transform: translateY(-140%);
  transition: transform 160ms var(--ease);
}

.skip-link:focus {
  transform: translateY(0);
}

.section-kicker {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .14em;
  line-height: 1.3;
}

.app-header {
  position: relative;
  z-index: 100;
  display: grid;
  grid-template-columns: var(--roster-w) minmax(280px, 1fr) auto;
  align-items: center;
  width: 100%;
  height: var(--header-h);
  background: var(--ink-900);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 22px;
  gap: 12px;
  border-right: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  place-items: center;
  color: var(--ink-950);
  background: var(--mist);
  border-radius: 9px 9px 3px 9px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .12) inset;
}

.brand-mark svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.brand-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.brand-copy strong {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .08em;
  white-space: nowrap;
}

.brand-copy small {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: .13em;
}

.project-heading {
  display: grid;
  min-width: 0;
  padding: 0 28px;
  gap: 4px;
}

.title {
  width: min(640px, 100%);
  min-width: 0;
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  font-family: var(--font-display);
  font-size: clamp(19px, 1.7vw, 25px);
  font-weight: 650;
  letter-spacing: .02em;
  line-height: 1.25;
  text-overflow: ellipsis;
}

.title:hover {
  border-bottom-color: var(--line-strong);
}

.title:focus-visible {
  border-bottom-color: var(--mist);
  outline-offset: 5px;
}

.project-meta {
  display: flex;
  align-items: center;
  min-width: 0;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .02em;
  gap: 14px;
}

.project-meta > span:not(:first-child)::before {
  content: "·";
  margin-right: 14px;
  color: #4d5a70;
}

.save-state {
  display: inline-flex;
  align-items: center;
  color: #9bcfc4;
  gap: 7px;
}

.save-state i {
  width: 6px;
  height: 6px;
  background: var(--mint);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(114, 200, 183, .1);
}

.save-state.session-only {
  color: var(--sand);
}

.save-state.session-only i {
  background: var(--sand);
  box-shadow: 0 0 0 4px rgba(214, 187, 131, .1);
}

.sync-state {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 8px;
}

.icon-button,
.export-button,
.view-controls button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  color: var(--text-soft);
  background: var(--ink-750);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  transition: color 160ms var(--ease), background 160ms var(--ease), border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}

.icon-button:hover,
.view-controls button:hover,
.btn:hover {
  color: var(--text);
  background: var(--ink-700);
  border-color: var(--line-strong);
}

.icon-button svg,
.export-button svg,
.view-controls svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.export-button {
  min-width: 122px;
  padding: 0 17px;
  color: #0d1729;
  background: var(--mist);
  border-color: var(--mist);
  font-weight: 750;
  gap: 8px;
}

.export-button:hover {
  color: #07101e;
  background: #bfd2ee;
  border-color: #bfd2ee;
  box-shadow: 0 8px 24px rgba(127, 162, 212, .18);
}

.project-menu {
  position: relative;
}

.project-menu summary {
  list-style: none;
}

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

.project-menu[open] summary {
  color: var(--text);
  background: var(--ink-700);
  border-color: var(--line-strong);
}

.project-menu-panel {
  position: absolute;
  z-index: 500;
  top: calc(100% + 12px);
  right: 0;
  display: grid;
  width: 250px;
  max-height: min(620px, calc(100dvh - var(--header-h) - 24px));
  padding: 10px;
  overflow-y: auto;
  background: #111a2b;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  gap: 4px;
}

.project-menu-panel::before {
  content: "";
  position: absolute;
  top: -5px;
  right: 16px;
  width: 9px;
  height: 9px;
  background: #111a2b;
  border-top: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
  transform: rotate(45deg);
}

.menu-label {
  padding: 7px 10px 9px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .12em;
}

.project-menu-panel button {
  display: grid;
  width: 100%;
  min-height: 52px;
  padding: 8px 10px;
  text-align: left;
  color: var(--text-soft);
  background: transparent;
  border-radius: 6px;
  gap: 2px;
}

.project-menu-panel button:hover,
.project-menu-panel button:focus-visible {
  color: var(--text);
  background: rgba(167, 190, 224, .09);
}

.project-menu-panel button span {
  font-weight: 650;
}

.project-menu-panel button small {
  color: var(--text-muted);
  font-size: 11px;
}

.project-menu-panel button[hidden] {
  display: none;
}

.workspace {
  position: relative;
  display: grid;
  grid-template-columns: var(--roster-w) minmax(0, 1fr);
  width: 100%;
  height: calc(100dvh - var(--header-h));
  min-height: 0;
  overflow: hidden;
  background: var(--ink-950);
}

.workspace.inspector-open {
  grid-template-columns: var(--roster-w) minmax(0, 1fr) var(--inspector-w);
}

.roster-panel,
.inspector-panel {
  min-width: 0;
  min-height: 0;
  background: var(--ink-850);
}

.roster-panel {
  position: relative;
  z-index: 30;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  padding: 20px 16px 14px;
  border-right: 1px solid var(--line);
}

.panel-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  padding: 0 4px 16px;
}

.panel-heading h1 {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .05em;
}

.count-badge {
  display: grid;
  min-width: 28px;
  height: 28px;
  padding: 0 7px;
  place-items: center;
  color: var(--mist);
  background: rgba(167, 190, 224, .09);
  border: 1px solid rgba(167, 190, 224, .18);
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 46px;
  margin-bottom: 12px;
  color: var(--text-muted);
  background: var(--ink-800);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
}

.search:focus-within {
  color: var(--mist);
  border-color: rgba(167, 190, 224, .55);
  box-shadow: 0 0 0 3px rgba(167, 190, 224, .1);
}

.search svg {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  margin-left: 13px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.search input {
  width: 100%;
  height: 44px;
  min-width: 0;
  padding: 0 8px 0 10px;
  color: var(--text);
  background: transparent;
  border: 0;
}

.search input::placeholder {
  color: var(--text-muted);
}

.search input:focus-visible {
  outline: 0;
}

.search kbd {
  display: grid;
  flex: 0 0 24px;
  height: 24px;
  margin-right: 9px;
  place-items: center;
  color: var(--text-muted);
  background: #0b1120;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
}

.roster-list {
  min-height: 0;
  padding: 2px 2px 12px;
  overflow: auto;
  scrollbar-color: #354158 transparent;
  scrollbar-width: thin;
}

.roster-item {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  min-height: 56px;
  padding: 7px 8px;
  color: var(--text-soft);
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  gap: 10px;
  transition: background 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease);
}

.roster-item + .roster-item {
  margin-top: 3px;
}

.roster-item:hover {
  color: var(--text);
  background: rgba(167, 190, 224, .06);
}

.roster-item.selected {
  color: var(--text);
  background: rgba(167, 190, 224, .1);
  border-color: rgba(167, 190, 224, .22);
}

.roster-item.selected::before {
  content: "";
  position: absolute;
  top: 11px;
  bottom: 11px;
  left: -3px;
  width: 3px;
  background: var(--mist);
  border-radius: 2px;
}

.roster-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--graphite);
  border: 2px solid rgba(255, 255, 255, .25);
  border-radius: 6px 6px 2px 6px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
}

.roster-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.roster-copy strong,
.roster-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.roster-copy strong {
  font-size: 13px;
  font-weight: 650;
}

.roster-copy small {
  color: var(--text-muted);
  font-size: 10px;
}

.roster-code {
  color: #738197;
  font-family: var(--font-mono);
  font-size: 9px;
}

.roster-empty {
  position: absolute;
  z-index: 4;
  top: 145px;
  right: 16px;
  bottom: 48px;
  left: 16px;
  display: grid;
  padding: 24px 8px;
  place-content: center;
  color: var(--text-muted);
  text-align: center;
  background: var(--ink-850);
}

.roster-empty > span {
  display: block;
  margin-bottom: 10px;
  font-family: var(--font-mono);
  font-size: 24px;
}

.roster-empty p {
  margin: 0 0 4px;
  color: var(--text-soft);
}

.roster-empty small {
  font-size: 11px;
}

.roster-foot {
  display: flex;
  justify-content: space-between;
  padding: 13px 4px 0;
  color: #7b899e;
  border-top: 1px solid var(--line);
  font-size: 9px;
  gap: 8px;
}

.roster-foot kbd {
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.canvas-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--ink-800);
  isolation: isolate;
}

#canvas {
  position: absolute;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}

#canvas:focus-visible {
  outline-offset: -5px;
}

.canvas-grid {
  opacity: .45;
}

.view-controls {
  position: absolute;
  z-index: 20;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  padding: 5px;
  background: rgba(12, 18, 31, .93);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  gap: 3px;
}

.view-controls button {
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  color: var(--text-muted);
  background: transparent;
  border-color: transparent;
  border-radius: 6px;
  font-size: 16px;
  gap: 7px;
}

.view-controls button:has(span) {
  min-width: 84px;
}

.view-controls button span {
  font-size: 11px;
  font-weight: 650;
}

.view-controls svg {
  width: 17px;
  height: 17px;
}

.view-separator {
  width: 1px;
  height: 22px;
  margin: 0 3px;
  background: var(--line);
}

.zoom-value {
  min-width: 45px;
  color: var(--text-soft);
  text-align: center;
  font-family: var(--font-mono);
  font-size: 10px;
}

.command-dock {
  position: absolute;
  z-index: 25;
  bottom: 18px;
  left: 50%;
  display: grid;
  grid-template-columns: minmax(170px, 220px) auto;
  align-items: stretch;
  width: min(860px, calc(100% - 150px));
  min-height: 76px;
  color: var(--text);
  background: rgba(10, 16, 29, .96);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(1, 5, 14, .5), 0 1px 0 rgba(255, 255, 255, .04) inset;
  transform: translateX(-50%);
}

.selection-context {
  display: grid;
  align-content: center;
  min-width: 0;
  padding: 12px 15px;
  border-right: 1px solid var(--line);
  gap: 5px;
}

.selection-chips {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 22px;
  overflow: hidden;
  gap: 5px;
}

.selection-chip,
.selection-slot {
  display: inline-flex;
  min-width: 0;
  height: 22px;
  padding: 0 8px;
  align-items: center;
  overflow: hidden;
  color: #0e1727;
  background: var(--mist);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selection-slot {
  color: var(--text-muted);
  background: transparent;
  border: 1px dashed #425069;
  font-weight: 500;
}

.selection-plus {
  color: #627087;
  font-family: var(--font-mono);
  font-size: 10px;
}

.selection-empty {
  color: var(--text-soft);
  font-family: var(--font-display);
  font-size: 13px;
}

.selection-status {
  overflow: hidden;
  color: #738197;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  padding: 8px 10px;
  gap: 4px;
}

.tool {
  position: relative;
  display: grid;
  flex: 0 0 57px;
  width: 57px;
  min-height: 58px;
  padding: 6px 3px 5px;
  place-items: center;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  gap: 2px;
  transition: color 150ms var(--ease), background 150ms var(--ease), border-color 150ms var(--ease);
}

.tool:hover:not(:disabled),
.tool:focus-visible {
  color: var(--text);
  background: rgba(167, 190, 224, .08);
  border-color: rgba(167, 190, 224, .14);
}

.tool i {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  font-style: normal;
}

.tool i svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.75;
}

.tool > span {
  font-size: 10px;
  font-weight: 650;
}

.primary-tool {
  color: #0d1728;
  background: var(--mist);
  border-color: var(--mist);
}

.primary-tool:hover:not(:disabled),
.primary-tool:focus-visible {
  color: #09111e;
  background: #c2d4ee;
  border-color: #c2d4ee;
}

.command-divider {
  flex: 0 0 1px;
  width: 1px;
  height: 38px;
  margin: 0 4px;
  background: var(--line);
}

.danger-tool {
  color: #b77982;
}

.danger-tool:hover:not(:disabled),
.danger-tool:focus-visible {
  color: #ffadb4;
  background: var(--danger-soft);
  border-color: rgba(228, 123, 132, .2);
}

.color-tool-wrap {
  position: relative;
  flex: 0 0 57px;
}

.color-palette {
  position: absolute;
  z-index: 200;
  right: 18px;
  bottom: 112px;
  display: grid;
  width: 304px;
  max-height: min(620px, calc(100% - 130px));
  padding: 16px;
  overflow: auto;
  color: var(--text);
  background: #121b2c;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  gap: 13px;
}

.color-wheel {
  display: block;
  width: 190px;
  height: 190px;
  margin: 0 auto;
  cursor: crosshair;
  border-radius: 50%;
}

.color-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}

.eyedropper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 12px;
  color: var(--text-soft);
  background: var(--ink-700);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  gap: 7px;
}

.eyedropper svg {
  width: 18px;
  height: 18px;
}

.eyedropper:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

#colorValue {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
}

.color-fallback {
  display: grid;
  grid-template-columns: 1fr 46px;
  align-items: center;
  gap: 8px;
}

.color-fallback input[type="text"] {
  height: 44px;
  padding: 0 11px;
  color: var(--text);
  background: var(--ink-800);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font-family: var(--font-mono);
  text-transform: uppercase;
}

.color-fallback input[type="color"] {
  width: 46px;
  height: 44px;
  padding: 3px;
  background: var(--ink-800);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
}

.palette-title {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .1em;
}

.preset-colors {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
}

.color-swatch {
  position: relative;
  min-width: 44px;
  min-height: 44px;
  border: 3px solid #121b2c;
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .15);
}

.color-swatch:hover,
.color-swatch:focus-visible,
.color-swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--focus);
}

.node {
  cursor: grab;
  outline: none;
}

.node:active {
  cursor: grabbing;
}

.node .card-surface {
  fill: var(--paper);
  stroke: rgba(255, 255, 255, .6);
  stroke-width: 1;
  filter: url(#shadow);
}

.node .card-accent {
  stroke: none;
}

.node .card-avatar {
  stroke: rgba(23, 32, 39, .13);
  stroke-width: 1;
}

.node .card-initial {
  fill: var(--graphite);
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  pointer-events: none;
}

.node .card-name {
  fill: var(--graphite);
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: .02em;
  pointer-events: none;
}

.node .card-meta {
  fill: #5c6872;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 550;
  pointer-events: none;
}

.node .card-code {
  fill: #627078;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: .08em;
  pointer-events: none;
}

.node .selection-ring {
  fill: none;
  stroke: var(--mist);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
  opacity: 0;
  filter: url(#selectedGlow);
  pointer-events: none;
}

.node.selected .selection-ring,
.node:focus-visible .selection-ring {
  opacity: 1;
}

.node:focus-visible .selection-ring {
  stroke-dasharray: 7 4;
}

.node .card-label {
  fill: var(--graphite);
  font-family: var(--font-display);
  font-weight: 800;
}

.edge,
.edge.spouse,
.edge.link,
.edge.coparent {
  fill: none;
  stroke: #8490a3;
  stroke-width: 2.35;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.edge.spouse {
  stroke: var(--sand);
  stroke-width: 2.8;
}

.edge.link {
  stroke: var(--mist-strong);
  stroke-dasharray: 7 6;
}

.edge.coparent {
  stroke-dasharray: 2 5;
}

.edge.link:has(+ .link-hit:hover),
.edge.spouse:has(+ .spouse-hit:hover),
.edge.coparent:has(+ .coparent-hit:hover) {
  stroke-width: 4;
}

.relationship-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 28;
  vector-effect: non-scaling-stroke;
  pointer-events: stroke;
  cursor: pointer;
  outline: none;
}

.relationship-hit:focus-visible {
  stroke: rgba(167, 190, 224, .42);
  stroke-width: 9;
}

.relationship-selection {
  fill: none;
  stroke: rgba(167, 190, 224, .42);
  stroke-width: 9;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.relation-label rect {
  display: none;
}

.relation-label text {
  fill: #d7e0ec;
  stroke: #101625;
  stroke-width: 8px;
  stroke-linejoin: round;
  paint-order: stroke;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 650;
  pointer-events: none;
}

.selection-box {
  fill: rgba(167, 190, 224, .08);
  stroke: var(--mist);
  stroke-width: 1.5;
  stroke-dasharray: 7 5;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.curve-guide {
  fill: none;
  stroke: rgba(167, 190, 224, .55);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
  vector-effect: non-scaling-stroke;
}

.curve-anchor {
  fill: var(--ink-800);
  stroke: var(--mist);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.curve-control {
  fill: transparent;
  stroke: transparent;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  cursor: move;
}

.curve-control:focus-visible {
  stroke: var(--focus);
  stroke-dasharray: 5 4;
}

.curve-control-visual {
  fill: var(--mist);
  stroke: var(--ink-950);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.inspector-panel {
  position: relative;
  z-index: 35;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 50px rgba(2, 6, 23, .16);
  animation: inspector-in 220ms var(--ease) both;
}

@keyframes inspector-in {
  from { opacity: 0; transform: translateX(14px); }
  to { opacity: 1; transform: translateX(0); }
}

.inspector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.inspector-head > div {
  display: grid;
  gap: 5px;
}

.person-code {
  color: var(--mist);
  font-family: var(--font-mono);
  font-size: 11px;
}

.inspector-head .icon-button {
  min-width: 44px;
  min-height: 44px;
}

.empty {
  margin: auto;
  color: var(--text-muted);
}

.profile-form {
  min-height: 0;
  padding: 4px 18px 28px;
  overflow: auto;
  scrollbar-color: #36435a transparent;
  scrollbar-width: thin;
}

.profile-form label,
.modal label {
  display: grid;
  min-width: 0;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 650;
  gap: 7px;
}

.profile-form input,
.profile-form select,
.profile-form textarea,
.modal input,
.modal select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--text);
  background: #101827;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  transition: border-color 150ms var(--ease), background 150ms var(--ease), box-shadow 150ms var(--ease);
}

.profile-form textarea {
  min-height: 76px;
  resize: vertical;
  line-height: 1.6;
}

.profile-form input::placeholder,
.profile-form textarea::placeholder,
.modal input::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

.profile-form input:hover,
.profile-form select:hover,
.profile-form textarea:hover,
.modal input:hover,
.modal select:hover {
  border-color: var(--line-strong);
}

.profile-form input:focus-visible,
.profile-form select:focus-visible,
.profile-form textarea:focus-visible,
.modal input:focus-visible,
.modal select:focus-visible {
  background: #121c2e;
  border-color: rgba(167, 190, 224, .65);
  outline-offset: 1px;
}

.hero-field {
  padding: 22px 0 20px;
}

.hero-field input {
  height: 50px;
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 750;
}

.field-section {
  display: grid;
  margin: 0;
  padding: 18px 0;
  border: 0;
  border-top: 1px solid var(--line);
  gap: 14px;
}

.field-section legend {
  padding: 0;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .1em;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 10px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tag {
  display: inline-flex;
  min-height: 44px;
  padding-left: 10px;
  align-items: center;
  color: #c9d7e9;
  background: rgba(167, 190, 224, .09);
  border: 1px solid rgba(167, 190, 224, .15);
  border-radius: 5px;
  font-size: 10px;
  gap: 3px;
}

.tag button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: var(--text-muted);
  background: transparent;
  border-radius: 4px;
}

.tag button:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.relations {
  display: grid;
  gap: 6px;
}

.relations h3 {
  margin: 5px 0 3px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
}

.rel {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  min-height: 46px;
  padding: 6px 8px;
  color: var(--text-soft);
  text-align: left;
  background: #101827;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  gap: 9px;
}

.rel:hover,
.rel:focus-visible {
  color: var(--text);
  border-color: rgba(167, 190, 224, .35);
}

.rel span {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: var(--graphite);
  background: var(--mist);
  border-radius: 4px;
  font-family: var(--font-display);
  font-weight: 800;
}

.rel em {
  color: var(--text-muted);
  font-size: 9px;
  font-style: normal;
}

.danger {
  width: 100%;
  min-height: 46px;
  margin-top: 16px;
  color: #f0a3aa;
  background: var(--danger-soft);
  border: 1px solid rgba(228, 123, 132, .2);
  border-radius: 6px;
  font-weight: 700;
}

.danger:hover {
  color: #ffd3d6;
  background: rgba(228, 123, 132, .2);
  border-color: rgba(228, 123, 132, .35);
}

.backdrop {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  padding: 24px;
  place-items: center;
  background: rgba(3, 7, 18, .7);
  backdrop-filter: blur(5px);
}

.modal {
  position: relative;
  width: min(500px, calc(100vw - 32px));
  max-height: calc(100dvh - 40px);
  padding: 30px;
  overflow: auto;
  color: var(--text);
  background: #121b2c;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  animation: modal-in 210ms var(--ease) both;
}

.sync-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100dvh - 40px);
  padding: 0;
  overflow: auto;
  color: var(--text);
  background: #121b2c;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}

.sync-dialog[open] {
  animation: modal-in 210ms var(--ease) both;
}

.sync-dialog::backdrop {
  background: rgba(3, 7, 18, .76);
  backdrop-filter: blur(5px);
}

.sync-dialog-body {
  padding: 30px;
}

.sync-dialog h2 {
  margin: 8px 0;
  font-family: var(--font-display);
  font-size: clamp(24px, 4vw, 32px);
  line-height: 1.18;
}

.sync-dialog h2:focus {
  outline: none;
}

.sync-dialog-body > p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.65;
}

.sync-auth-dialog {
  width: min(520px, calc(100vw - 32px));
}

.sync-auth-form {
  display: grid;
}

.sync-auth-field {
  display: grid;
  margin-top: 24px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  gap: 8px;
}

.sync-auth-field input {
  width: 100%;
  min-height: 48px;
  padding: 0 13px;
  color: var(--text);
  background: var(--ink-900);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: .035em;
}

.sync-auth-field input:focus-visible {
  border-color: var(--mist);
  outline: 3px solid rgba(167, 190, 224, .18);
  outline-offset: 1px;
}

.sync-auth-field input[aria-invalid="true"] {
  border-color: #ff9aa3;
}

.sync-auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 11px;
  gap: 14px;
}

.sync-auth-reveal {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  cursor: pointer;
  gap: 7px;
}

.sync-auth-reveal input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--mist);
}

.sync-auth-form > .sync-auth-error {
  min-height: 20px;
  margin-top: 4px;
}

.sync-version-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 22px;
  gap: 12px;
}

.sync-version-card {
  display: grid;
  min-width: 0;
  padding: 17px;
  background: var(--ink-900);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  gap: 7px;
}

.sync-version-card > span {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.sync-version-card strong,
.sync-version-card small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-version-card strong {
  font-size: 16px;
}

.sync-version-card small {
  color: var(--text-muted);
  font-size: 11px;
}

.sync-dialog-body > .sync-safety-note {
  margin-top: 14px;
  padding: 12px 14px;
  font-size: 12px;
  background: rgba(114, 200, 183, .08);
  border: 1px solid rgba(114, 200, 183, .2);
  border-radius: 8px;
}

.sync-dialog-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  gap: 9px;
}

.sync-dialog-actions .btn {
  min-height: 44px;
}

.sync-later {
  display: block;
  min-height: 44px;
  margin: 10px 0 0 auto;
  padding: 0 8px;
  color: var(--text-muted);
  background: transparent;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.sync-later:hover,
.sync-later:focus-visible {
  color: var(--text);
}

@media (max-width: 680px) {
  .sync-dialog-body {
    padding: 22px 18px;
  }

  .sync-version-grid {
    grid-template-columns: 1fr;
  }

  .sync-auth-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .sync-dialog-actions {
    display: grid;
  }

  .sync-dialog-actions .btn {
    width: 100%;
  }
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal .close {
  position: absolute;
  top: 12px;
  right: 12px;
  min-width: 44px;
  min-height: 44px;
  background: transparent;
}

.modal h2 {
  margin: 8px 0 8px;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 750;
}

.modal > p {
  margin: 0 0 23px;
  color: var(--text-muted);
  line-height: 1.6;
}

.modal label + label,
.modal label + .gender,
.modal .gender + label,
#existingWrap + #newPersonFields {
  margin-top: 15px;
}

.gender {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 4px;
  background: var(--ink-900);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  gap: 4px;
}

.gender button {
  min-height: 44px;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
}

.gender button:hover {
  color: var(--text);
}

.gender .on {
  color: #0e1727;
  background: var(--mist);
  border-color: var(--mist);
  font-weight: 750;
}

.field-error {
  display: block;
  min-height: 16px;
  margin-top: 5px;
  color: #ff9aa3;
  font-size: 11px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  gap: 9px;
}

.btn {
  min-width: 96px;
  padding: 0 18px;
  font-weight: 700;
}

.btn.primary {
  color: #0c1524;
  background: var(--mist);
  border-color: var(--mist);
}

.btn.primary:hover {
  color: #07101c;
  background: #c2d4ee;
  border-color: #c2d4ee;
}

.toast {
  position: fixed;
  z-index: 2000;
  top: calc(var(--header-h) + 18px);
  left: 50%;
  max-width: min(420px, calc(100vw - 32px));
  padding: 11px 15px;
  color: var(--text);
  text-align: center;
  background: #172238;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -10px);
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1180px) {
  :root {
    --roster-w: 218px;
  }

  .brand {
    padding-inline: 16px;
  }

  .project-heading {
    padding-inline: 20px;
  }

  .workspace.inspector-open {
    grid-template-columns: var(--roster-w) minmax(0, 1fr);
  }

  .inspector-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    bottom: 12px;
    width: min(var(--inspector-w), calc(100% - 24px));
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
  }

  .command-dock {
    width: min(800px, calc(100% - 40px));
  }

  .tool {
    flex-basis: 52px;
    width: 52px;
  }

  .color-tool-wrap {
    flex-basis: 52px;
  }
}

@media (min-width: 981px) and (max-width: 1180px) {
  .workspace.inspector-open .view-controls {
    right: calc(var(--inspector-w) + 30px);
  }

  .workspace.inspector-open .view-controls #arrange,
  .workspace.inspector-open .view-controls #fit {
    min-width: 44px;
    padding: 0;
  }

  .workspace.inspector-open .view-controls #arrange span,
  .workspace.inspector-open .view-controls #fit span {
    display: none;
  }

  .workspace.inspector-open .command-dock {
    left: 18px;
    grid-template-columns: minmax(0, 1fr);
    width: calc(100% - var(--inspector-w) - 48px);
    transform: none;
  }

  .workspace.inspector-open .selection-context {
    display: none;
  }

  .workspace.inspector-open .command-tools {
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .workspace.inspector-open .tool {
    flex-basis: 44px;
    width: 44px;
  }

  .workspace.inspector-open .color-tool-wrap {
    flex-basis: 44px;
  }

  .workspace.inspector-open .command-divider {
    display: none;
  }

  .workspace.inspector-open .color-palette {
    right: calc(var(--inspector-w) + 30px);
  }
}

@media (max-width: 980px) {
  .app-header {
    grid-template-columns: 190px minmax(180px, 1fr) auto;
  }

  .brand-copy small,
  .project-meta > span:not(:first-child),
  .export-button span {
    display: none;
  }

  .export-button {
    min-width: 46px;
    width: 46px;
    padding: 0;
  }

  .header-actions {
    padding-inline: 10px;
  }

  .command-dock {
    grid-template-columns: 180px minmax(0, 1fr);
  }

  .inspector-panel {
    position: absolute;
    top: 78px;
    right: 8px;
    bottom: 106px;
    left: 8px;
    width: auto;
    max-height: none;
  }

  .color-palette {
    top: 10px;
    right: 10px;
    bottom: 106px;
    max-height: none;
  }

  .command-tools {
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .command-tools::-webkit-scrollbar {
    display: none;
  }
}

@media (max-width: 820px) {
  :root {
    --header-h: 66px;
  }

  .app-header {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .brand {
    padding: 0 10px;
    border-right: 0;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand-copy {
    display: none;
  }

  .project-heading {
    padding-inline: 8px;
  }

  .title {
    font-size: 17px;
    min-height: 44px;
  }

  .project-meta {
    font-size: 8px;
  }

  .header-actions {
    gap: 4px;
  }

  .workspace,
  .workspace.inspector-open {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 154px minmax(0, 1fr);
  }

  .roster-panel {
    grid-row: 1;
    grid-template-columns: 150px minmax(180px, 1fr);
    grid-template-rows: 52px minmax(0, 1fr);
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .panel-heading {
    grid-column: 1;
    grid-row: 1;
    align-items: center;
    padding: 0 10px 0 2px;
  }

  .panel-heading h1 {
    margin-top: 2px;
    font-size: 17px;
  }

  .search {
    grid-column: 2;
    grid-row: 1;
    margin-bottom: 6px;
  }

  .roster-list {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    padding: 4px 0;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 6px;
  }

  .roster-item {
    flex: 0 0 172px;
    min-height: 58px;
  }

  .roster-item + .roster-item {
    margin-top: 0;
  }

  .roster-foot {
    display: none;
  }

  .roster-empty {
    top: 62px;
    right: 12px;
    bottom: 8px;
    left: 12px;
    grid-auto-flow: column;
    padding: 6px;
    gap: 8px;
  }

  .roster-empty > span,
  .roster-empty small {
    display: none;
  }

  .roster-empty p {
    margin: 0;
  }

  .canvas-wrap {
    grid-row: 2;
  }

  .view-controls {
    top: 10px;
    right: 10px;
  }

  .view-separator {
    display: none;
  }

  .view-controls #arrange,
  .view-controls #fit {
    min-width: 44px;
    padding: 0;
  }

  .view-controls #arrange span,
  .view-controls #fit span {
    display: none;
  }

  .command-dock {
    bottom: max(10px, env(safe-area-inset-bottom));
    grid-template-columns: minmax(0, 1fr);
    width: calc(100% - 20px);
  }

  .selection-context {
    min-height: 55px;
    padding: 8px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .selection-context .section-kicker {
    display: none;
  }

  .selection-status {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
  }

  .command-tools {
    padding: 5px 7px;
  }

  .tool {
    flex-basis: 48px;
    width: 48px;
    min-height: 54px;
  }

  .color-tool-wrap {
    flex-basis: 48px;
  }

  .color-palette {
    position: absolute;
    top: 10px;
    right: 10px;
    bottom: calc(145px + env(safe-area-inset-bottom));
    width: min(304px, calc(100vw - 20px));
    max-height: none;
  }

  .inspector-panel {
    position: absolute;
    top: 226px;
    right: 8px;
    bottom: calc(145px + env(safe-area-inset-bottom));
    left: 8px;
    width: auto;
    max-height: none;
  }

  .search input,
  .profile-form input,
  .profile-form select,
  .profile-form textarea,
  .modal input,
  .modal select,
  .color-fallback input[type="text"] {
    font-size: 16px;
  }

  #canvas {
    touch-action: none;
  }
}

@media (max-width: 460px) {
  .app-header {
    grid-template-columns: 52px minmax(0, 1fr) auto;
  }

  .header-actions {
    padding-left: 2px;
  }

  .project-meta {
    display: none;
  }

  .title {
    font-size: 16px;
  }

  .command-divider {
    display: none;
  }

  .tool {
    flex-basis: 44px;
    width: 44px;
  }

  .color-tool-wrap {
    flex-basis: 44px;
  }

  .inspector-panel {
    top: 214px;
  }

  .workspace,
  .workspace.inspector-open {
    grid-template-rows: 142px minmax(0, 1fr);
  }

  .roster-panel {
    grid-template-columns: 116px minmax(140px, 1fr);
  }

  .panel-heading .section-kicker,
  .count-badge,
  .search kbd {
    display: none;
  }

  .roster-item {
    flex-basis: 158px;
  }

  .modal {
    padding: 26px 20px 20px;
  }

  .modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .btn {
    min-width: 0;
  }
}

@media (max-width: 820px) and (max-height: 520px) {
  .workspace,
  .workspace.inspector-open {
    grid-template-rows: 96px minmax(0, 1fr);
  }

  .roster-panel {
    grid-template-rows: 42px minmax(0, 1fr);
    padding: 6px 10px;
  }

  .panel-heading {
    padding-bottom: 4px;
  }

  .search {
    min-height: 40px;
    margin-bottom: 2px;
  }

  .search input {
    height: 38px;
  }

  .roster-item {
    min-height: 44px;
    padding-block: 4px;
  }

  .roster-empty {
    top: 48px;
    bottom: 4px;
  }

  .view-controls {
    top: 6px;
  }

  .command-dock {
    bottom: max(6px, env(safe-area-inset-bottom));
    grid-template-columns: minmax(0, 1fr);
  }

  .selection-context {
    display: none;
  }

  .command-tools {
    padding-block: 4px;
  }

  .tool {
    min-height: 50px;
  }

  .inspector-panel {
    top: 8px;
    bottom: calc(72px + env(safe-area-inset-bottom));
  }

  .color-palette {
    top: 6px;
    bottom: calc(72px + env(safe-area-inset-bottom));
  }
}

@media (pointer: coarse) {
  .relationship-hit:not(:focus-visible) {
    stroke-width: 44;
  }
}

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