.grid {
  position: relative;
  display: grid;
  align-content: start;
  width: max-content;
  min-width: 100%;
  min-height: 100%;
  padding: var(--grid-pad-top) 28px 80px 12px;
}

.traces {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: visible;
}

.trace {
  stroke: rgba(12, 110, 102, 0.45);
  stroke-width: 1.5;
  stroke-linecap: round;
}

.trace.is-drawing {
  stroke: var(--accent);
  animation: trace-draw 320ms var(--spring) forwards;
}

@keyframes trace-draw { to { stroke-dashoffset: 0; } }

.corner, .stage-head, .stage-add {
  position: sticky;
  top: var(--stick-top);
  z-index: 3;
  background: var(--sticky);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  box-shadow: inset 0 -0.5px 0 var(--separator);
}

.corner {
  left: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
  min-height: 88px;
  padding: 28px 16px 12px;
}

.corner-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-headline);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.stage-head {
  min-height: 88px;
  padding: 28px 12px 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  align-content: end;
  gap: 2px 8px;
}

.stage-head.is-awareness .stage-label { color: var(--accent-bright); }

.stage-tools {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 0;
}

.stage-title {
  grid-column: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 2px 0;
  border: 0;
  background: transparent;
  text-align: left;
  font-family: var(--font-display);
  font-size: var(--text-headline);
  font-weight: 650;
  letter-spacing: -0.022em;
  line-height: 1.2;
}

.stage-label { white-space: normal; }

.stage-title .mini-icon { color: var(--label-tertiary); }

.stage-title-input {
  width: 100%;
  border: 0;
  border-radius: 10px;
  min-height: 36px;
  padding: 6px 8px;
  background: var(--field);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.advance-chip {
  grid-column: 1 / -1;
  justify-self: start;
  border: 0;
  background: transparent;
  padding: 0;
  min-height: 22px;
  color: var(--label-tertiary);
  font-size: var(--text-caption);
  font-weight: 650;
}

.advance-chip.is-set { color: var(--accent); }

.stage-kicker, .map-link {
  grid-column: 1 / -1;
  color: var(--label-tertiary);
  font-size: var(--text-caption);
}

.map-link {
  justify-self: start;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--accent);
  text-decoration: none;
  font-weight: 560;
}

.map-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.count-pill {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--accent-deep);
  color: var(--accent-bright);
  font-size: var(--text-caption);
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.stage-add {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 0 10px 14px;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.add-stage {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: var(--surface);
  color: var(--label);
  box-shadow: inset 0 0 0 1px var(--separator), 0 8px 18px rgba(0, 0, 0, 0.06);
  display: grid;
  place-items: center;
}

.add-stage:hover { background: var(--field); }

.add-stage .mini-icon { width: 18px; height: 18px; }

.persona-cell, .y-start, .y-add, .segment-label {
  position: sticky;
  left: 0;
  z-index: 2;
}

.persona-cell {
  background: var(--sticky);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  min-height: 116px;
  display: flex;
  align-items: center;
  padding: 10px 48px 10px 12px;
  overflow: visible;
}

.avatar-float {
  position: absolute;
  right: -34px;
  top: 50%;
  width: 76px;
  height: 92px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  transform: translateY(-50%);
  z-index: 4;
  filter: drop-shadow(0 10px 16px rgba(29, 29, 31, 0.14));
}

.avatar-float .avatar { width: 76px; height: 92px; }

.avatar-float:hover { transform: translateY(-54%); }

.persona-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
}

.persona-copy { min-width: 0; flex: 1; }

.persona-name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: var(--text-headline);
  font-weight: 650;
  letter-spacing: -0.02em;
}

.persona-role { color: var(--label-secondary); font-size: var(--text-footnote); margin-top: 2px; }

.persona-remove { margin-left: auto; }

.persona-empty {
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  color: var(--label-secondary);
  font-size: var(--text-footnote);
}

.segment-row { grid-column: 1 / -1; padding: 22px 8px 0; }

.segment-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 8px;
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--label-secondary);
  font-size: var(--text-footnote);
  font-weight: 650;
  letter-spacing: -0.01em;
}

.y-start {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  text-align: left;
  min-height: 0;
  margin: 48px 16px 12px;
  padding: 8px 4px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--label);
  box-shadow: none;
}

.y-start:hover { background: rgba(255, 255, 255, 0.55); }

.y-kicker {
  position: relative;
  color: var(--accent);
  font-size: var(--text-caption);
  font-weight: 650;
}

.y-start strong {
  position: relative;
  font-family: var(--font-display);
  font-size: var(--text-title3);
  font-weight: 650;
  letter-spacing: -0.022em;
  line-height: 1.15;
}

.y-start > span:not(.y-kicker):not(.y-cta) {
  position: relative;
  color: var(--label-secondary);
  font-size: var(--text-footnote);
  line-height: 1.4;
  max-width: 28ch;
}

.y-cta {
  position: relative;
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-bright);
  font-size: var(--text-subhead);
  font-weight: 650;
}

.y-add {
  padding: 8px 12px 12px;
  background: var(--sticky);
}

.cell {
  position: relative;
  z-index: 1;
  min-height: 116px;
  display: grid;
  place-items: center;
}

.cell-blank { pointer-events: none; }

.bubble {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  position: relative;
  padding: 0;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur) var(--ease);
}

.bubble.is-empty {
  background: transparent;
  color: var(--label-tertiary);
  box-shadow: inset 0 0 0 1.25px rgba(60, 60, 67, 0.28);
}

.bubble.is-empty .mini-icon { width: 18px; height: 18px; }

.bubble.is-empty:hover {
  color: var(--label);
  box-shadow: inset 0 0 0 1.5px var(--accent);
  transform: scale(1.04);
}

.bubble.is-filled {
  background: var(--accent-deep);
  color: var(--accent);
  box-shadow: inset 0 0 0 1.5px rgba(12, 110, 102, 0.45);
}

.bubble.is-filled.is-set {
  background: radial-gradient(circle at 32% 28%, #f7fffc 0%, #c6efe8 26%, #6fbfb6 58%, #246e67 100%);
  color: #08312e;
  box-shadow: var(--shadow-node);
}

.bubble.is-filled:hover { transform: scale(1.04); }

.bubble.is-new { animation: bubble-in 320ms var(--spring) 180ms both; }

.bubble.is-fade { animation: fade-in 180ms linear both; }

@keyframes bubble-in {
  0% { transform: scale(0.6); opacity: 0; }
  68% { transform: scale(1.045); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.bubble-mode svg { width: 18px; height: 18px; display: block; }

.bubble-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  display: flex;
  justify-content: center;
  gap: 3px;
}

.bubble-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  display: block;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.28);
}

.icp {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--gold);
  color: var(--gold-ink);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.04em;
}

@media (hover: hover) and (pointer: fine) {
  .stage-tools,
  .stage-title .mini-icon,
  .persona-remove { opacity: 0; }

  .stage-tools { pointer-events: none; }

  .stage-head:hover .stage-tools,
  .stage-head:focus-within .stage-tools,
  .stage-head:hover .stage-title .mini-icon,
  .stage-title:focus-visible .mini-icon,
  .persona-card:hover .persona-remove,
  .persona-remove:focus,
  .persona-remove:focus-visible { opacity: 1; }

  .stage-head:hover .stage-tools,
  .stage-head:focus-within .stage-tools { pointer-events: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .trace.is-drawing { animation: none; stroke-dashoffset: 0; }
  .bubble.is-new { animation: fade-in 180ms linear both; }
  .bubble,
  .y-start,
  .avatar-float { transition: none; }
  .bubble:hover,
  .y-start:hover { transform: none; }
  .avatar-float:hover { transform: translateY(-50%); }
}
