:root {
  color-scheme: light;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background: #f3f5f8;
  color: #162033;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f3f5f8;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

label {
  display: grid;
  gap: 6px;
  color: #536174;
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid #d6dce6;
  border-radius: 6px;
  padding: 8px 10px;
  color: #172033;
  background: #fff;
  outline: none;
}

.fixed-value {
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid #d6dce6;
  border-radius: 6px;
  padding: 8px 10px;
  color: #172033;
  background: #f8fafc;
  text-overflow: ellipsis;
  white-space: nowrap;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #2673e8;
  box-shadow: 0 0 0 3px rgba(38, 115, 232, 0.13);
}

.is-hidden {
  display: none !important;
}

.brand {
  color: #2673e8;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.danger-text {
  color: #b42318;
  background: #fff1f0;
  border: 1px solid #ffccc7;
}

.danger-text {
  margin: 0;
  padding: 10px 12px;
  border-radius: 6px;
  line-height: 1.55;
}

.hint {
  margin: 0;
  color: #6b7686;
  font-size: 12px;
  line-height: 1.5;
}

.primary,
.ghost,
.file-button,
.danger-button {
  min-height: 36px;
  border-radius: 6px;
  padding: 8px 12px;
  font-weight: 700;
}

.primary {
  color: #fff;
  background: #2673e8;
}

.ghost,
.file-button {
  border: 1px solid #d5dce7;
  color: #243247;
  background: #fff;
}

.danger-button {
  border: 1px solid #f0a8a3;
  color: #b42318;
  background: #fff;
}

.danger-button:hover:not(:disabled) {
  border-color: #d92d20;
  background: #fff1f0;
}

.full {
  width: 100%;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 16px;
  border-right: 1px solid #dce2eb;
  background: #fff;
  font-size: 12px;
}

.sidebar-warning {
  width: 100%;
  overflow: hidden;
  border: 1px solid #ffccc7;
  border-radius: 6px;
  padding: 8px 0;
  color: #b42318;
  background: #fff1f0;
  margin-bottom: 12px;
}

.sidebar-warning__track {
  width: max-content;
  display: flex;
  white-space: nowrap;
  animation: sidebar-warning-scroll 18s linear infinite;
  will-change: transform;
}

.sidebar-warning__track span {
  flex: none;
  padding-right: 36px;
  font-size: inherit;
  font-weight: 700;
}

.sidebar-warning:hover .sidebar-warning__track {
  animation-play-state: paused;
}

@keyframes sidebar-warning-scroll {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(-50%);
  }
}

.sidebar__title {
  padding-left: 9px;
  border-left: 3px solid #2673e8;
  color: #111827;
  font-size: inherit;
  font-weight: 800;
}

.sidebar-section {
  display: grid;
  gap: 8px;
  margin: 0 -16px;
  padding: 16px;
  border-top: 1px solid #dce2eb;
}

.sidebar-section + .sidebar-section {
  border-top: 6px solid #eef2f7;
}

.sidebar-section:last-child {
  border-bottom: 1px solid #dce2eb;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  display: grid;
  gap: 8px;
}

.about-link {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d5dce7;
  border-radius: 6px;
  color: #344054;
  font-size: inherit;
  font-weight: 700;
  text-decoration: none;
  background: #fff;
}

.about-link:hover,
.about-link:focus-visible {
  border-color: #2673e8;
  color: #175fc8;
  outline: none;
}

.tree-list {
  display: grid;
  gap: 6px;
  overflow: auto;
}

.tree-list {
  max-height: 260px;
}

.tree-item {
  width: 100%;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  border: 1px solid #e1e6ef;
  border-radius: 6px;
  text-align: left;
  background: #fff;
}

.tree-item.is-active {
  border-color: #2673e8;
  background: #edf4ff;
}

.tree-item strong {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  color: #1c2535;
  font-size: inherit;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-item span {
  flex: none;
  color: #6a7585;
  font-size: inherit;
  white-space: nowrap;
}

.sync-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1800;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.48);
  backdrop-filter: blur(3px);
}

.sync-dialog {
  width: min(760px, calc(100vw - 40px));
  max-height: min(780px, calc(100vh - 40px));
  display: grid;
  gap: 16px;
  overflow: auto;
  padding: 22px;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  color: #1f2937;
  background: #fff;
  box-shadow: 0 24px 72px rgba(15, 23, 42, 0.3);
  font-size: 14px;
  line-height: 1.5;
}

.sync-dialog__header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
}

.sync-dialog__header > div {
  display: grid;
  gap: 3px;
}

.sync-dialog__header span {
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
}

.sync-dialog__header h2 {
  margin: 0;
  color: #111827;
  font-size: 22px;
  letter-spacing: 0;
}

.sync-dialog__close {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #dce1e9;
  border-radius: 50%;
  color: #596273;
  background: #f7f8fa;
  font-size: 22px;
  line-height: 1;
}

.sync-dialog__close:hover {
  border-color: #c5ccd7;
  background: #eef1f5;
}

.privacy-notice {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #c6ddff;
  border-radius: 6px;
  color: #24466f;
  background: #f1f7ff;
  font-size: 12px;
  line-height: 1.5;
}

.sync-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.sync-form > button {
  min-height: 40px;
  white-space: nowrap;
}

.sync-history {
  display: grid;
  gap: 16px;
}

.sync-history__list {
  max-height: min(360px, 48vh);
  display: grid;
  gap: 8px;
  overflow: auto;
  padding: 2px;
}

.sync-history__item {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid #dce2eb;
  border-radius: 6px;
  color: #1f2937;
  background: #fafbfc;
  text-align: left;
}

.sync-history__item:hover {
  border-color: #9db9e8;
  background: #f4f8ff;
}

.sync-history__item.is-selected {
  border-color: #2673e8;
  background: #edf4ff;
  box-shadow: 0 0 0 1px #2673e8;
}

.sync-history__time,
.sync-history__hash {
  min-width: 0;
}

.sync-history__time {
  font-weight: 700;
}

.sync-history__hash {
  color: #64748b;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  text-align: right;
}

.sync-history__empty {
  margin: 0;
  padding: 28px 16px;
  border: 1px dashed #cbd3df;
  border-radius: 6px;
  color: #64748b;
  background: #fafbfc;
  text-align: center;
}

.sync-comparison {
  display: grid;
  gap: 16px;
}

.sync-comparison__heading {
  display: grid;
  gap: 4px;
}

.sync-comparison__heading h3,
.sync-comparison__heading p,
.sync-comparison__hint,
.sync-comparison__file-time,
.sync-status {
  margin: 0;
}

.sync-comparison__heading h3 {
  color: #111827;
  font-size: 18px;
  letter-spacing: 0;
}

.sync-comparison__heading p {
  color: #64748b;
  font-size: 13px;
}

.sync-comparison__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
}

.sync-comparison__side {
  min-width: 0;
  padding: 14px;
  border: 1px solid #dfe4eb;
  border-top-width: 3px;
  border-radius: 6px;
  background: #fafbfc;
}

.sync-comparison__side--local {
  border-top-color: #25845f;
}

.sync-comparison__side--remote {
  border-top-color: #2673e8;
}

.sync-comparison__label {
  margin-bottom: 10px;
  overflow: hidden;
  color: #1f2937;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-comparison__side dl,
.sync-comparison__side dl > div {
  margin: 0;
}

.sync-comparison__side dl {
  display: grid;
  gap: 8px;
}

.sync-comparison__side dl > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: baseline;
  padding-bottom: 8px;
  border-bottom: 1px solid #e7eaf0;
}

.sync-comparison__side dl > div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.sync-comparison__side dt {
  color: #6b7280;
  font-size: 12px;
}

.sync-comparison__side dd {
  margin: 0;
  color: #111827;
  font-size: 14px;
  font-weight: 650;
  text-align: right;
}

.sync-comparison__direction {
  display: grid;
  place-items: center;
  color: #2673e8;
  font-size: 28px;
  font-weight: 700;
}

.sync-comparison__file-time {
  margin-top: 10px;
  color: #7b8492;
  font-size: 11px;
}

.sync-comparison__hint {
  padding: 10px 12px;
  border-left: 3px solid #d39b2a;
  color: #624919;
  background: #fff8e8;
  font-size: 13px;
}

.sync-comparison__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.sync-status {
  min-height: 21px;
  color: #596273;
  font-size: 13px;
}

.file-button {
  position: relative;
  display: grid;
  place-items: center;
  font-size: inherit;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.tree-info-summary {
  min-height: 36px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tree-info-chip {
  max-width: 100%;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border: 1px solid #dce2eb;
  border-radius: 6px;
  color: #243247;
  background: #fff;
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-info-form {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

.tabs,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tabs button {
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 6px;
  color: #475569;
  background: #e8edf5;
  font-weight: 700;
}

.tabs button.is-active {
  color: #fff;
  background: #26364e;
}

.map-layer-switch {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 18;
  display: flex;
  overflow: hidden;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.18);
}

.map-layer-switch button {
  width: 48px;
  height: 40px;
  padding: 0;
  color: #475569;
  background: transparent;
  font-weight: 700;
}

.map-layer-switch button + button {
  border-left: 1px solid #edf0f3;
}

.map-layer-switch button.is-active {
  color: #fff;
  background: #1677ff;
}

.tab-panel {
  min-height: 0;
}

.tree-canvas,
.map-canvas,
.association-canvas {
  width: 100%;
  height: calc(100vh - 190px);
  min-height: 420px;
  border: 1px solid #dce2eb;
  border-radius: 8px;
  background: #fff;
}

.tree-canvas {
  overflow: hidden;
}

.tree-stage {
  position: relative;
  min-width: 0;
}

.tree-action-bar {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 18;
  display: flex;
  gap: 8px;
  align-items: center;
}

.shared-highlight-toggle,
.tree-export-button {
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid #b9c6d8;
  border-radius: 6px;
  color: #334155;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 5px 18px rgba(23, 38, 61, 0.16);
  font-size: 13px;
  font-weight: 800;
}

.shared-highlight-toggle:hover,
.tree-export-button:hover:not(:disabled) {
  border-color: #e24435;
  color: #b42318;
}

.shared-highlight-toggle.is-active {
  border-color: #c7372a;
  color: #fff;
  background: #c7372a;
}

.associated-depth-control {
  position: absolute;
  top: 50%;
  z-index: 18;
  width: 42px;
  height: 258px;
  display: grid;
  grid-template-rows: 56px 136px 20px;
  justify-items: center;
  gap: 8px;
  padding: 10px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  color: #26364e;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 5px 18px rgba(23, 38, 61, 0.16);
  transform: translateY(-50%);
}

.associated-depth-control--trace {
  left: 12px;
}

.associated-depth-control--inherit {
  right: 12px;
}

.associated-depth-control > span {
  width: 16px;
  height: 56px;
  display: block;
  writing-mode: vertical-rl;
  text-orientation: upright;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
}

.associated-depth-control input[type='range'] {
  width: 24px;
  height: 136px;
  margin: 0;
  padding: 0;
  writing-mode: vertical-lr;
  direction: rtl;
  appearance: slider-vertical;
  accent-color: #2673e8;
  cursor: pointer;
}

.associated-depth-control output {
  min-width: 28px;
  padding: 2px 3px;
  border-radius: 4px;
  color: #fff;
  background: #26364e;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.associated-depth-control::after {
  position: absolute;
  top: 50%;
  width: 270px;
  padding: 9px 11px;
  border-radius: 5px;
  color: #fff;
  background: #172033;
  box-shadow: 0 5px 16px rgba(15, 23, 42, 0.24);
  content: attr(data-tooltip);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.55;
  letter-spacing: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%);
  transition: opacity 120ms ease;
}

.associated-depth-control--trace::after {
  left: calc(100% + 9px);
}

.associated-depth-control--inherit::after {
  right: calc(100% + 9px);
}

.associated-depth-control:hover::after,
.associated-depth-control:focus-within::after {
  opacity: 1;
}

.tree-canvas svg {
  display: block;
}

.tree-viewport {
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.tree-viewport.is-panning,
.tree-viewport.is-panning * {
  cursor: grabbing !important;
}

.tree-viewport > svg {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.tree-canvas .editable-family-link {
  cursor: pointer;
  outline: none;
}

.tree-canvas .editable-family-link .link-hitarea {
  pointer-events: stroke;
}

.tree-canvas.is-family-link-highlighting .links_view .link {
  stroke-width: 1px;
  opacity: 0.2;
}

.tree-canvas.is-family-link-highlighting
  .editable-family-link.is-family-link-highlighted
  .link {
  stroke-width: 3px;
  opacity: 1;
}

.association-canvas {
  position: relative;
  overflow: auto;
  background-color: #fff;
  background-image:
    linear-gradient(rgba(77, 106, 146, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(77, 106, 146, 0.08) 1px, transparent 1px);
  background-size: 16px 16px;
}

.association-card {
  position: absolute;
  z-index: 5;
  width: 220px;
  height: 88px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid #d7dee9;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(23, 38, 61, 0.1);
  cursor: move;
  user-select: none;
  touch-action: none;
}

.association-card:hover,
.association-card:focus-within {
  border-color: #2673e8;
  box-shadow: 0 8px 24px rgba(38, 115, 232, 0.16);
}

.association-card--drop-target,
.association-card.jtk-drag-hover {
  border-color: #1263d4;
  background: #eef5ff;
  box-shadow: 0 0 0 3px rgba(38, 115, 232, 0.2), 0 10px 26px rgba(38, 115, 232, 0.2);
}

.association-card__marker {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  color: #fff;
  background: #26364e;
  font-size: 17px;
  font-weight: 800;
}

.association-card__content {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.association-card__content strong,
.association-card__content span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.association-card__content strong {
  color: #172033;
  font-size: 14px;
}

.association-card__content span {
  color: #6b7686;
  font-size: 12px;
}

.association-card__connect-handle {
  position: absolute;
  top: 50%;
  right: -18px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: #2673e8;
  box-shadow: 0 3px 10px rgba(38, 115, 232, 0.32);
  font: 700 21px/1 Arial, sans-serif;
  opacity: 0;
  pointer-events: none;
  cursor: crosshair;
  transform: translateY(-50%) scale(0.88);
  transition: opacity 140ms ease, transform 140ms ease, background-color 140ms ease;
}

.association-card:hover .association-card__connect-handle,
.association-card:focus-within .association-card__connect-handle,
.association-card__connect-handle.jtk-drag {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) scale(1);
}

.association-card.association-card--drop-target .association-card__connect-handle,
.association-card.jtk-drag-hover .association-card__connect-handle {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) scale(0.88);
}

.association-card__connect-handle:hover,
.association-card__connect-handle:focus-visible {
  outline: 2px solid rgba(38, 115, 232, 0.28);
  outline-offset: 2px;
  background: #145dbf;
}

.association-canvas .jtk-connector {
  z-index: 2;
}

.association-canvas .jtk-endpoint {
  z-index: 7;
  pointer-events: none;
}

.association-canvas .jtk-overlay {
  z-index: 8;
}

.association-link-label {
  max-width: 180px;
  overflow: hidden;
  border: 1px solid #bfcee3;
  border-radius: 4px;
  padding: 5px 9px;
  color: #243247;
  background: #fff;
  box-shadow: 0 3px 10px rgba(23, 38, 61, 0.12);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.association-link-label:hover {
  border-color: #2673e8;
  color: #1e61bd;
}

.association-dialog {
  width: min(560px, calc(100vw - 28px));
  display: grid;
  gap: 16px;
  padding: 20px;
  border: 1px solid #dce2eb;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.22);
}

.child-relation-dialog {
  width: min(920px, calc(100vw - 32px));
  max-height: min(86vh, 760px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 16px;
  overflow: hidden;
  padding: 20px;
  border: 1px solid #dce2eb;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.28);
}

.child-relation-dialog__family {
  margin: 5px 0 0;
  color: #667085;
  font-size: 13px;
}

.child-relation-list {
  min-height: 96px;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
}

.child-relation-list__empty {
  margin: 0;
  padding: 28px 12px;
  color: #8a929d;
  background: #f8fafc;
  text-align: center;
}

.child-relation-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 88px 112px 112px 58px;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid #e0e6ef;
  border-radius: 6px;
  background: #fbfcfe;
}

.child-relation-row__identity {
  min-width: 0;
  display: grid;
  align-self: center;
  gap: 4px;
}

.child-relation-row__identity strong,
.child-relation-row__identity span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.child-relation-row__identity strong {
  color: #172033;
  font-size: 15px;
}

.child-relation-row__identity span {
  color: #7a8493;
  font-size: 12px;
}

.child-relation-row__main-line {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #374151;
  font-size: 13px;
}

.child-relation-row__main-line input {
  width: 18px;
  min-height: 18px;
  flex: 0 0 18px;
  margin: 0;
  padding: 0;
}

.child-relation-row__remove {
  min-height: 36px;
  border: 1px solid #fecaca;
  border-radius: 6px;
  color: #dc2626;
  background: #fff;
  font-size: 13px;
  font-weight: 700;
}

.child-relation-row__remove:hover {
  border-color: #dc2626;
  background: #fef2f2;
}

.child-relation-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding-top: 14px;
  border-top: 1px solid #e5eaf2;
}

.association-dialog__trees {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid #dce2eb;
  border-radius: 6px;
  color: #334155;
  background: #f8fafc;
  text-align: center;
}

.association-dialog__trees strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-hint {
  color: #a33a32;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.45;
}

.linked-readonly-node {
  cursor: default;
}

.node-info-popover {
  position: fixed;
  z-index: 30;
  box-sizing: border-box;
  width: min(340px, calc(100vw - 24px));
  max-height: min(72vh, 520px);
  overflow: auto;
  padding: 14px;
  border: 1px solid #d7e1ee;
  border-radius: 8px;
  color: #111827;
  background: #eef4fb;
  box-shadow: 0 16px 42px rgba(15, 23, 42, 0.26);
}

.node-info-popover--floating {
  right: auto;
  bottom: auto;
}

.node-info-popover--sheet {
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  left: 12px;
  width: auto;
}

.node-info-popover__profile {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  padding-right: 28px;
}

.node-info-popover__avatar {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #e5edf7;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

.node-info-popover__avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.node-info-popover__identity {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.node-info-popover__name {
  overflow: hidden;
  font-size: 20px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-info-popover__meta,
.node-info-popover__nickname {
  overflow: hidden;
  color: #667085;
  font-size: 13px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-info-popover__close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  color: #667085;
  background: transparent;
  font-size: 22px;
  line-height: 1;
}

.node-info-popover__close:hover {
  color: #111827;
  background: #dfe8f3;
}

.node-info-popover__fields,
.node-info-popover__note {
  margin: 12px 0 0;
  border-radius: 6px;
  background: #fff;
}

.node-info-popover__fields {
  padding: 4px 12px;
}

.node-info-popover__field {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 8px;
  padding: 7px 0;
  font-size: 13px;
}

.node-info-popover__field span {
  color: #8a929d;
}

.node-info-popover__field strong {
  overflow-wrap: anywhere;
  color: #374151;
  font-weight: 500;
}

.node-info-popover__note {
  max-height: 96px;
  overflow: auto;
  padding: 10px 12px;
  color: #374151;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.node-info-popover__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.node-info-popover__actions button {
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  color: #2563eb;
  background: #fff;
  font-size: 13px;
  font-weight: 700;
}

.node-info-popover__actions button:hover {
  border-color: #2563eb;
  background: #eff6ff;
}

.node-info-popover__actions button.is-danger {
  border-color: #fecaca;
  color: #dc2626;
}

.node-info-popover__actions button.is-danger:hover {
  border-color: #dc2626;
  background: #fef2f2;
}

.virtual-relation-node {
  cursor: pointer;
}

.relation-editor-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  justify-content: flex-end;
  background: rgba(15, 23, 42, 0.32);
}

.relation-editor-drawer {
  width: min(760px, 82vw);
  height: 100%;
  min-width: 360px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #fff;
  box-shadow: -18px 0 44px rgba(15, 23, 42, 0.2);
}

.relation-editor-header {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px 10px 18px;
  border-bottom: 1px solid #dce2eb;
}

.relation-editor-header strong {
  min-width: 0;
  overflow: hidden;
  color: #172033;
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.relation-editor-close {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #475569;
  background: transparent;
  font-size: 25px;
  line-height: 1;
}

.relation-editor-close:hover {
  border-color: #d8dee9;
  background: #f3f6fa;
}

.relation-editor-canvas {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #fff;
}

.relation-editor-canvas svg {
  display: block;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  align-items: end;
  background: rgba(15, 23, 42, 0.42);
}

.person-dialog {
  width: 100%;
  max-height: min(88vh, 760px);
  display: grid;
  gap: 12px;
  overflow: auto;
  padding: 14px;
  border-radius: 8px 8px 0 0;
  background: #fff;
  box-shadow: 0 -14px 36px rgba(15, 23, 42, 0.24);
}

.dialog-header {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.dialog-header h2,
.operation-panel h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 10px;
}

.form-grid__wide {
  grid-column: 1 / -1;
}

#personNoteInput {
  min-height: 76px;
  resize: vertical;
}

.operation-panel {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid #e5eaf2;
}

.map-canvas {
  position: relative;
  overflow: hidden;
  background: #dfe6ef;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.map-canvas.is-dragging {
  cursor: grabbing;
}

.map-content-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.map-search {
  position: absolute;
  top: 14px;
  left: 16px;
  z-index: 20;
  width: min(520px, calc(100% - 132px));
}

.map-search select {
  height: 42px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.18);
}

.map-control-stack {
  position: absolute;
  right: 16px;
  bottom: 18px;
  z-index: 18;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.18);
}

.map-control-stack button {
  width: 42px;
  height: 42px;
  color: #1f2937;
  background: #fff;
  border-bottom: 1px solid #edf0f3;
  font-size: 20px;
  font-weight: 700;
}

.map-control-stack button:last-child {
  border-bottom: 0;
}

.map-control-stack button:hover {
  background: #f3f6fa;
}

.map-status {
  position: absolute;
  bottom: 10px;
  left: 12px;
  z-index: 10;
  padding: 4px 7px;
  border-radius: 4px;
  color: #475569;
  background: rgba(255, 255, 255, 0.84);
  font-size: 11px;
  pointer-events: none;
}

.map-tile {
  position: absolute;
  width: 256px;
  height: 256px;
  pointer-events: none;
  user-select: none;
}

.map-tile--overlay {
  pointer-events: none;
}

.map-marker {
  z-index: 3;
  position: absolute;
  min-width: 28px;
  max-width: 120px;
  min-height: 28px;
  padding: 4px 7px;
  border: 2px solid #fff;
  border-radius: 999px;
  color: #fff;
  background: #2673e8;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.24);
  font-size: 12px;
  transform: translate(-50%, -100%);
  white-space: nowrap;
  pointer-events: auto;
}

.map-marker.is-cluster {
  min-width: 38px;
  width: auto;
  max-width: none;
  height: 38px;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  background: #1677ff;
  font-weight: 700;
  transform: translate(-50%, -50%);
}

.map-marker.is-user:not(.is-name) {
  width: 28px;
  min-width: 28px;
  max-width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  transform: translate(-50%, -50%);
}

.map-marker.is-female {
  background: #d9467a;
}

.map-pending-marker {
  position: absolute;
  z-index: 4;
  width: 28px;
  height: 28px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: #ef4444;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.24);
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

.map-assignment-panel {
  position: absolute;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 24;
  display: grid;
  gap: 10px;
  min-height: 150px;
  padding: 18px 56px 18px 18px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 26px rgba(15, 23, 42, 0.22);
}

.map-assignment-panel > strong {
  color: #111827;
  font-size: 18px;
}

.map-assignment-panel__coordinate {
  color: #64748b;
  font-size: 13px;
}

.map-assignment-panel__actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.map-assignment-panel__actions select {
  flex: 1;
  min-width: 0;
  min-height: 42px;
}

.map-assignment-panel__actions button {
  min-width: 96px;
  min-height: 42px;
}

.map-panel-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  color: #4b5563;
  background: #f3f4f6;
  font-size: 24px;
  line-height: 1;
}

.map-person-detail {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
}

.map-person-detail__scrim {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.32);
  pointer-events: auto;
}

.map-person-detail__panel {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: min(430px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  display: grid;
  gap: 14px;
  overflow: auto;
  padding: 20px;
  border-radius: 8px;
  background: #f5f6f8;
  box-shadow: 0 16px 42px rgba(15, 23, 42, 0.28);
  pointer-events: auto;
}

.map-person-detail__header {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-right: 32px;
}

.map-person-detail__avatar {
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  border: 3px solid #fff;
  border-radius: 50%;
  object-fit: cover;
  background: #e5edf7;
}

.map-person-detail__identity {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.map-person-detail__identity h2 {
  margin: 0;
  overflow: hidden;
  color: #111827;
  font-size: 22px;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-person-detail__identity span {
  color: #64748b;
  font-size: 13px;
}

.map-person-detail__note,
.map-person-detail__fields {
  margin: 0;
  border-radius: 8px;
  background: #fff;
}

.map-person-detail__note {
  padding: 12px;
  color: #374151;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.map-person-detail__fields {
  padding: 4px 12px;
}

.map-person-detail__field {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid #edf0f3;
  font-size: 13px;
}

.map-person-detail__field:last-child {
  border-bottom: 0;
}

.map-person-detail__field span {
  color: #8a929d;
}

.map-person-detail__field strong {
  overflow-wrap: anywhere;
  color: #374151;
  font-weight: 500;
}

.map-person-detail__actions {
  justify-content: flex-end;
}

.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  z-index: 5000;
  width: max-content;
  min-width: 220px;
  max-width: min(560px, calc(100vw - 32px));
  padding: 11px 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.2);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
  overflow-wrap: anywhere;
  pointer-events: none;
  transform: translateX(-50%);
  animation: toast-slide-in 160ms ease-out;
}

.toast--success {
  border-color: #abefc6;
  color: #067647;
  background: #ecfdf3;
}

.toast--warning {
  border-color: #fedf89;
  color: #b54708;
  background: #fffaeb;
}

.toast--error {
  border-color: #fecdca;
  color: #b42318;
  background: #fef3f2;
}

@keyframes toast-slide-in {
  from {
    opacity: 0;
    transform: translate(-50%, -8px);
  }

  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@media (min-width: 861px) {
  .dialog-backdrop {
    align-items: center;
    justify-items: center;
    padding: 20px;
  }

  .person-dialog {
    width: min(720px, calc(100vw - 40px));
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.28);
  }
}

.dialog-backdrop--centered {
  align-items: center;
  justify-items: center;
  padding: 16px;
}

.confirm-dialog {
  width: min(460px, calc(100vw - 32px));
  display: grid;
  gap: 16px;
  padding: 20px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.28);
}

.confirm-dialog h2,
.confirm-dialog p {
  margin: 0;
}

.confirm-dialog h2 {
  font-size: 18px;
  letter-spacing: 0;
}

.confirm-dialog p {
  max-height: min(50vh, 320px);
  overflow: auto;
  color: #475569;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-line;
}

.confirm-dialog__actions {
  justify-content: flex-end;
}

@media (prefers-reduced-motion: reduce) {
  .sidebar-warning__track {
    width: auto;
    display: block;
    padding: 0 8px;
    white-space: normal;
    animation: none;
  }

  .sidebar-warning__track span {
    padding-right: 0;
  }

  .sidebar-warning__track span + span {
    display: none;
  }
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid #dce2eb;
  }

  .tree-list {
    max-height: 160px;
  }

  .associated-depth-control {
    height: 230px;
    grid-template-rows: 52px 108px 20px;
  }

  .associated-depth-control input[type='range'] {
    height: 108px;
  }

  .associated-depth-control > span {
    height: 52px;
  }

  .associated-depth-control::after {
    width: min(230px, calc(100vw - 86px));
  }

  .main {
    padding: 10px;
  }

  .topbar,
  .tree-info-form,
  .sync-form,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .sync-dialog-backdrop {
    padding: 10px;
  }

  .sync-dialog {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    gap: 14px;
    padding: 16px;
  }

  .sync-dialog__header h2 {
    font-size: 20px;
  }

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

  .sync-comparison__direction {
    min-height: 28px;
    transform: rotate(90deg);
  }

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

  .sync-history__item {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .sync-history__hash {
    text-align: left;
  }

  .tree-info-summary {
    align-items: stretch;
  }

  .tree-info-chip {
    width: 100%;
  }

  .tree-canvas,
  .map-canvas,
  .association-canvas {
    height: 62vh;
    min-height: 360px;
  }

  .relation-editor-drawer {
    width: 100%;
    min-width: 0;
  }

  .child-relation-dialog {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    padding: 14px;
  }

  .child-relation-row {
    grid-template-columns: minmax(0, 1fr) minmax(80px, 0.55fr);
    align-items: end;
  }

  .child-relation-row__identity {
    grid-column: 1 / -1;
  }

  .child-relation-row__remove {
    grid-column: 2;
  }

  .child-relation-add {
    grid-template-columns: 1fr;
  }

}
