:root {
  --sky-1: #eaf7ff;
  --sky-2: #f7fbff;
  --sky-3: #e9ecff;
  --ink: #17212b;
  --muted: #647382;
  --faint: rgba(43, 73, 99, .13);
  --glass: rgba(255, 255, 255, .68);
  --glass-strong: rgba(255, 255, 255, .86);
  --teal: #0d8a83;
  --teal-dark: #066760;
  --sun: #f3a15c;
  --rose: #d55067;
  --violet: #7764d8;
  --blue: #347ec7;
  --line: rgba(36, 50, 64, .72);
  --shadow: 0 24px 70px rgba(57, 83, 111, .20);
  --shadow-tight: 0 12px 30px rgba(57, 83, 111, .16);
  --blur: blur(18px) saturate(138%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

html,
body,
.app-shell {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--sky-2);
}

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

button {
  border: 1px solid rgba(33, 55, 72, .14);
  border-radius: 999px;
  min-height: 38px;
  padding: 0 15px;
  background: rgba(255, 255, 255, .74);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(57, 83, 111, .08);
  transition: transform .14s ease, background .14s ease, border-color .14s ease, box-shadow .14s ease;
}

button:hover {
  background: #fff;
  border-color: rgba(13, 138, 131, .34);
  box-shadow: 0 9px 20px rgba(57, 83, 111, .12);
}

button:active {
  transform: translateY(1px);
}

button.primary {
  border-color: var(--teal);
  background: var(--teal);
  color: white;
}

button.primary:hover {
  background: var(--teal-dark);
}

button.icon {
  width: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(33, 55, 72, .16);
  border-radius: 16px;
  background: rgba(255, 255, 255, .72);
  color: var(--ink);
  outline: none;
  padding: 12px 13px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7);
}

textarea {
  resize: vertical;
  min-height: 118px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(13, 138, 131, .72);
  box-shadow: 0 0 0 4px rgba(13, 138, 131, .11);
}

.sky-canvas {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 24% 12%, rgba(255, 255, 255, .95), transparent 18%),
    radial-gradient(circle at 78% 20%, rgba(191, 222, 255, .62), transparent 24%),
    radial-gradient(circle at 50% 82%, rgba(255, 231, 213, .58), transparent 25%),
    linear-gradient(145deg, var(--sky-1), var(--sky-2) 45%, var(--sky-3));
  cursor: grab;
  user-select: none;
}

.sky-canvas.dragging {
  cursor: grabbing;
}

.sky-canvas::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(36, 65, 88, .032) 1px, transparent 1px),
    linear-gradient(90deg, rgba(36, 65, 88, .028) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(circle at 50% 44%, black 0 48%, transparent 86%);
  pointer-events: none;
}

.aurora {
  position: absolute;
  inset: -18%;
  background:
    radial-gradient(ellipse at 30% 38%, rgba(91, 207, 198, .22), transparent 34%),
    radial-gradient(ellipse at 68% 42%, rgba(119, 100, 216, .16), transparent 32%),
    radial-gradient(ellipse at 48% 64%, rgba(243, 161, 92, .13), transparent 30%);
  filter: blur(30px);
  opacity: .9;
  pointer-events: none;
}

.glass {
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, .74);
  box-shadow: var(--shadow-tight);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.topbar {
  position: absolute;
  top: 22px;
  left: 50%;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 26px;
  width: min(980px, calc(100% - 44px));
  min-height: 62px;
  padding: 10px 12px 10px 16px;
  border-radius: 999px;
  transform: translateX(-50%);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 178px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, #152433, #274259);
  color: #fff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 9px 22px rgba(23, 33, 43, .22);
}

.brand strong {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  line-height: 1.05;
  letter-spacing: 0;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.world {
  position: absolute;
  top: 0;
  left: 0;
  width: 2600px;
  height: 1700px;
  transform-origin: 0 0;
  will-change: transform;
}

.links,
.ghost-layer,
.nodes {
  position: absolute;
  inset: 0;
  width: 2600px;
  height: 1700px;
}

.links {
  overflow: visible;
}

.nodes {
  z-index: 2;
}

.ghost-layer {
  z-index: 1;
  pointer-events: none;
}

.person {
  position: absolute;
  width: 126px;
  min-height: 112px;
  transform: translate(-50%, -50%);
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 8px;
  padding: 13px 12px 12px;
  border: 1px solid rgba(255, 255, 255, .76);
  border-radius: 28px;
  background: rgba(255, 255, 255, .48);
  box-shadow: 0 22px 50px rgba(57, 83, 111, .12);
  backdrop-filter: blur(14px) saturate(135%);
  -webkit-backdrop-filter: blur(14px) saturate(135%);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
}

.person:hover {
  transform: translate(-50%, -50%) translateY(-4px);
  background: rgba(255, 255, 255, .72);
  border-color: rgba(13, 138, 131, .28);
  box-shadow: 0 30px 70px rgba(57, 83, 111, .18);
}

.person.selected {
  background: rgba(238, 255, 253, .82);
  border-color: rgba(13, 138, 131, .72);
  box-shadow: 0 30px 80px rgba(13, 138, 131, .19);
}

.person.preview-target {
  border-color: rgba(243, 161, 92, .76);
  box-shadow: 0 30px 80px rgba(243, 161, 92, .18);
}

.symbol {
  position: relative;
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border: 3px solid #17212b;
  background: rgba(255, 255, 255, .88);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), 0 10px 24px rgba(57, 83, 111, .12);
}

.symbol.female {
  border-radius: 50%;
}

.symbol.male {
  border-radius: 9px;
}

.symbol.other {
  width: 45px;
  height: 45px;
  border-radius: 8px;
  transform: rotate(45deg);
}

.symbol.other .symbol-inner {
  transform: rotate(-45deg);
}

.symbol.deceased::before,
.symbol.deceased::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 62px;
  height: 3px;
  border-radius: 99px;
  background: var(--rose);
  transform-origin: center;
}

.symbol.deceased::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.symbol.deceased::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.note-dot {
  position: absolute;
  top: -7px;
  right: -8px;
  width: 18px;
  height: 18px;
  display: none;
  border: 3px solid rgba(255, 255, 255, .95);
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 5px 12px rgba(57, 83, 111, .18);
}

.person.has-note .note-dot {
  display: block;
}

.person-name {
  max-width: 100%;
  color: var(--ink);
  font-weight: 760;
  font-size: 14px;
  line-height: 1.12;
  text-align: center;
  overflow-wrap: anywhere;
}

.person-meta {
  min-height: 14px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
}

.line-family,
.line-child {
  fill: none;
  stroke: var(--line);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line-family {
  stroke-width: 3.2;
}

.line-child {
  stroke-width: 2.4;
}

.line-emotion {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
  opacity: .92;
}

.line-close {
  stroke: var(--teal);
}

.line-fused {
  stroke: var(--teal);
  stroke-width: 7;
  opacity: .54;
}

.line-conflict {
  stroke: var(--rose);
}

.line-distant {
  stroke: var(--blue);
  stroke-dasharray: 9 8;
}

.line-cutoff {
  stroke: #1e2c39;
  stroke-dasharray: 2 10;
}

.relation-label {
  font-size: 12px;
  fill: rgba(23, 33, 43, .62);
  paint-order: stroke;
  stroke: rgba(244, 250, 255, .92);
  stroke-width: 7px;
  stroke-linejoin: round;
}

.ghost-path {
  position: absolute;
  height: 3px;
  transform-origin: left center;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(13, 138, 131, .65), transparent);
  box-shadow: 0 0 22px rgba(13, 138, 131, .28);
}

.ghost-chip {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .72);
  border: 1px solid rgba(255, 255, 255, .8);
  box-shadow: var(--shadow-tight);
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.radial-menu {
  position: absolute;
  z-index: 9;
  width: 250px;
  height: 250px;
  display: none;
  pointer-events: none;
}

.radial-menu.show {
  display: block;
}

.radial-action {
  position: absolute;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .82);
  border-radius: 50%;
  background: rgba(255, 255, 255, .72);
  box-shadow: 0 18px 38px rgba(57, 83, 111, .18);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  pointer-events: auto;
  color: var(--ink);
  font-weight: 800;
}

.radial-action span {
  display: grid;
  gap: 1px;
  justify-items: center;
  font-size: 17px;
}

.radial-action small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.radial-action:hover {
  background: white;
  border-color: rgba(13, 138, 131, .42);
}

.hover-bridge {
  position: absolute;
  z-index: 8;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
}

.hover-bridge.show {
  display: flex;
}

.hover-bridge button {
  min-height: 32px;
  padding: 0 11px;
  font-size: 12px;
  box-shadow: none;
}

.bubble,
.command-palette,
.map-palette {
  position: absolute;
  z-index: 12;
  display: none;
  width: min(370px, calc(100vw - 34px));
  padding: 16px;
  border-radius: 24px;
}

.bubble.show,
.command-palette.show,
.map-palette.show {
  display: block;
}

.bubble h2,
.command-palette h2,
.map-palette h2 {
  margin: 0 0 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  letter-spacing: 0;
}

.bubble p,
.command-palette p,
.map-palette p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.field-grid {
  display: grid;
  gap: 9px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.option-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.option-chip {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 0 12px;
  border-radius: 999px;
  box-shadow: none;
  font-size: 13px;
  font-weight: 760;
  background: rgba(255, 255, 255, .58);
}

.option-chip.active {
  border-color: rgba(13, 138, 131, .74);
  background: rgba(232, 255, 252, .94);
  box-shadow: 0 8px 20px rgba(13, 138, 131, .12);
}

.chip-glyph {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.chip-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(13, 138, 131, .10);
}

.shape-options .option-chip {
  flex: 1 1 106px;
}

.emotion-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.emotion-options .option-chip {
  width: 100%;
}

.emotion-options .option-chip:last-of-type {
  grid-column: 1 / -1;
}

.target-strip {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  padding: 2px 0 4px;
}

.target-strip span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.target-strip button {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  box-shadow: none;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 760;
  background: rgba(232, 255, 252, .72);
}

.map-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.map-actions-grid button {
  min-height: 46px;
  border-radius: 16px;
  box-shadow: none;
  font-weight: 760;
}

.saved-maps {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
  padding-right: 3px;
}

.saved-maps button {
  min-height: 58px;
  display: grid;
  justify-items: start;
  align-content: center;
  gap: 3px;
  border-radius: 16px;
  box-shadow: none;
  text-align: left;
}

.saved-maps strong {
  font-size: 14px;
}

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

.option-chip.tone-teal .chip-dot {
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(13, 138, 131, .11);
}

.option-chip.tone-teal-strong .chip-dot {
  background: var(--teal);
  box-shadow: 0 0 0 6px rgba(13, 138, 131, .14);
}

.option-chip.tone-rose .chip-dot {
  background: var(--rose);
  box-shadow: 0 0 0 4px rgba(213, 80, 103, .12);
}

.option-chip.tone-blue .chip-dot {
  background: var(--blue);
  box-shadow: 0 0 0 4px rgba(52, 126, 199, .12);
}

.option-chip.tone-dark .chip-dot {
  background: var(--ink);
  box-shadow: 0 0 0 4px rgba(23, 33, 43, .10);
}

.option-chip.tone-rose.active {
  border-color: rgba(213, 80, 103, .72);
  background: rgba(255, 238, 241, .94);
}

.option-chip.tone-blue.active {
  border-color: rgba(52, 126, 199, .72);
  background: rgba(235, 246, 255, .96);
}

.option-chip.tone-dark.active {
  border-color: rgba(23, 33, 43, .46);
  background: rgba(238, 242, 245, .96);
}

.bubble-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.mini-tabs {
  display: flex;
  gap: 7px;
  margin: 2px 0 11px;
  flex-wrap: wrap;
}

.mini-tabs button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
  box-shadow: none;
}

.mini-tabs button.active {
  background: var(--ink);
  border-color: var(--ink);
  color: white;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  max-width: min(520px, calc(100vw - 30px));
  padding: 11px 15px;
  border-radius: 999px;
  background: rgba(23, 33, 43, .9);
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity .18s ease, transform .18s ease;
}

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

.hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .topbar {
    top: 12px;
    width: calc(100% - 20px);
    border-radius: 28px;
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .brand {
    width: 100%;
  }

  .tools {
    justify-content: flex-start;
  }

  .person {
    width: 116px;
  }
}
