:root {
  font-family: "Inter", sans-serif;
  font-feature-settings: "liga" 1, "calt" 1;
  color: #222;
  background-color: #f8f8f8;
  font-size: 14px;
  /* radius scale */
  --radius-xs: 0.25rem;
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 0.875rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.25rem;
  --radius-3xl: 1.75rem;
  --radius-item: var(--radius-lg);
  --radius-full: 50%;
  --radius-item-container: var(--radius-2xl);
  --radius-button: var(--radius-xl);
  --button-size: 2.5rem;
  /* tint-purple */
  --tint-purple-6: #f0eefb;
  --tint-purple-5: #dad2fe;
  --tint-purple-4: #c7b9fd;
  --tint-purple-3: #9268f7;
  --tint-purple-2: #7151bf;
  --tint-purple-1: #4b2f88;
  --tint-purple-0: #27174a;
  /* tint-blue */
  --tint-blue-6: #e8f1fe;
  --tint-blue-5: #c2dbff;
  --tint-blue-4: #a3c5ff;
  --tint-blue-3: #2985ff;
  --tint-blue-2: #2a68be;
  --tint-blue-1: #134383;
  --tint-blue-0: #082247;
  /* tint-lightBlue */
  --tint-lightBlue-6: #e1f4f7;
  --tint-lightBlue-5: #91e6f5;
  --tint-lightBlue-4: #4bd7f7;
  --tint-lightBlue-3: #0097d3;
  --tint-lightBlue-2: #17739f;
  --tint-lightBlue-1: #134b67;
  --tint-lightBlue-0: #062738;
  /* tint-cyan */
  --tint-cyan-6: #dff6f1;
  --tint-cyan-5: #7bf1d6;
  --tint-cyan-4: #57e3c2;
  --tint-cyan-3: #00a17d;
  --tint-cyan-2: #007d61;
  --tint-cyan-1: #0a513f;
  --tint-cyan-0: #032b20;
  /* tint-green */
  --tint-green-6: #e6f5e9;
  --tint-green-5: #96eeb1;
  --tint-green-4: #6ae091;
  --tint-green-3: #07a455;
  --tint-green-2: #007839;
  --tint-green-1: #005227;
  --tint-green-0: #002d13;
  /* tint-lime */
  --tint-lime-6: #ecf4df;
  --tint-lime-5: #c5e590;
  --tint-lime-4: #aad754;
  --tint-lime-3: #6e9b00;
  --tint-lime-2: #587700;
  --tint-lime-1: #384e00;
  --tint-lime-0: #1c2900;
  /* tint-yellow */
  --tint-yellow-6: #feeecf;
  --tint-yellow-5: #f7d48f;
  --tint-yellow-4: #f5be3f;
  --tint-yellow-3: #b08300;
  --tint-yellow-2: #886401;
  --tint-yellow-1: #594000;
  --tint-yellow-0: #2f2100;
  /* tint-orange */
  --tint-orange-6: #fdede4;
  --tint-orange-5: #f8caae;
  --tint-orange-4: #faa771;
  --tint-orange-3: #ce6c1b;
  --tint-orange-2: #a15210;
  --tint-orange-1: #69360e;
  --tint-orange-0: #391b05;
  /* tint-red */
  --tint-red-6: #f7eeec;
  --tint-red-5: #ffcbc0;
  --tint-red-4: #ff9c89;
  --tint-red-3: #e74d34;
  --tint-red-2: #ba331e;
  --tint-red-1: #7a2113;
  --tint-red-0: #41120a;
  /* tint-magenta */
  --tint-magenta-6: #f7ecf9;
  --tint-magenta-5: #f1c9f9;
  --tint-magenta-4: #e9a9f5;
  --tint-magenta-3: #bf53d5;
  --tint-magenta-2: #963da8;
  --tint-magenta-1: #671f75;
  --tint-magenta-0: #370f3f;
}

@supports (font-variation-settings: normal) {
  :root {
    font-family: InterVariable, sans-serif;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: row;
  background: #f4f4f5;
  color: #222;
  font-family: inherit;
}

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

#app-shell {
  flex: 1;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
  width: 100%;
  position: relative;
}

#canvas-wrapper {
  min-height: 100vh;
  height: 100%;
}

#flow-header {
  position: absolute;
  top: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem;
  z-index: 25;
  background: #ffffff;
  border: 1px solid #eee;
  border-radius: var(--radius-item-container);
  box-shadow: 0 0px 20px #0000001a;
  width: calc(100% - 2rem);
  max-width: 45rem;
}

#flow-back {
  flex-shrink: 0;
}

#flow-history-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

#flow-title-input {
  height: var(--button-size);
  flex: 1;
  width: 100%;
  padding: 0 0.33rem 0.5px 0.33rem;
  border-radius: var(--radius-item);
  border: 1px solid transparent;
  color: #222;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease,
    background-color 0.12s ease;
}

#flow-title-input:focus {
  background: #fff;
  border-color: #bbb;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.12);
}

#flow-title-input::placeholder {
  color: #999;
}

.flow-back-button,
.flow-history-button,
.flow-action-button {
  position: relative;
  width: var(--button-size);
  height: var(--button-size);
  border-radius: var(--radius-item);
  border: 1px solid #dddddd;
  background: #ffffff;
  color: #222;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 500;
  transition: transform 0.12s ease, box-shadow 0.12s ease,
    border-color 0.12s ease, background-color 0.12s ease;
  text-wrap: nowrap;
}

.flow-back-button .ti,
.flow-history-button .ti {
  font-size: 1.25rem;
  line-height: 1;
}

.flow-save-status {
  height: var(--button-size);
  width: var(--button-size);
  background: #eee;
  border-radius: var(--radius-item);
  border: none;
  cursor: default;
}

.flow-save-status .ti {
  font-size: 1.2rem;
}

.flow-save-status:hover {
  background: #eef7ed;
  transform: none;
}

.flow-save-status:focus-visible {
  outline: none;
  border-color: #dfe7dc;
  box-shadow: none;
}

.flow-back-button:hover,
.flow-history-button:hover {
  background: #eee;
}

.flow-back-button:focus-visible,
.flow-history-button:focus-visible {
  outline: none;
  border-color: var(--tint-blue-4);
  box-shadow: 0 0 0 3px rgba(41, 133, 255, 0.18);
}

.flow-action-button {
  width: auto;
  padding: 0 1rem;
  border-radius: var(--radius-item);
  font-size: 0.9rem;
}

.flow-action-button:hover {
  background: #eee;
}

.flow-action-button:focus-visible {
  outline: none;
  border-color: var(--tint-blue-4);
  box-shadow: 0 0 0 3px rgba(41, 133, 255, 0.18);
}

.flow-test-button {
  color: #222;
  background: #ffffff;
}

.flow-publish-button {
  background: #222;
  color: #fff;
  border: none;
}

.flow-publish-button:hover {
  background: #444;
  color: #fff;
}

.flow-publish-button:focus-visible {
  border-color: #222;
  box-shadow: 0 0 0 3px rgba(34, 34, 34, 0.25);
}

.flow-back-button::after,
.flow-history-button::after,
.flow-action-button::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  top: calc(100% + 1rem);
  transform: translate(-50%, 4px);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-xs);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  white-space: nowrap;
  z-index: 5;
}

.flow-back-button:hover::after,
.flow-history-button:hover::after,
.flow-action-button:hover::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* In the bottom toolbar, show tooltips above the buttons */
#type-toolbar .flow-history-button::after,
#type-toolbar .flow-action-button::after {
  top: auto;
  bottom: calc(100% + 1rem);
  left: 50%;
  transform: translate(-50%, 4px);
}

#type-toolbar .flow-history-button:hover::after,
#type-toolbar .flow-action-button:hover::after {
  transform: translate(-50%, 0);
}

#zoom-display {
  text-align: center;
  font-weight: 600;
  font-size: 0.75rem;
  color: #222;
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--button-size);
  width: var(--button-size);
  background: #eee;
  border-radius: var(--radius-item);
  font-variant-numeric: tabular-nums;
}

.flow-history-button,
.flow-action-button {
  pointer-events: auto;
}

#type-toolbar {
  position: absolute;
  left: 50%;
  bottom: 0.5rem;
  transform: translateX(-50%);
  outline: 1px solid #eee;
  background: #ffffff;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.375rem;
  padding: 0.6rem;
  z-index: 20;
  border-radius: var(--radius-item-container);
  box-shadow: 0 0px 20px #0000001a;
}

.toolbar-button {
  position: relative;
  width: var(--button-size);
  height: var(--button-size);
  border-radius: var(--radius-item);
  border: none;
  background: #f4f4f5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s;
  touch-action: none;
}

.toolbar-button::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.5rem);
  transform: translate(-50%, 0.75rem);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-xs);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  white-space: nowrap;
}

.toolbar-button:hover::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toolbar-button .ti {
  font-size: 1.25rem;
  line-height: 1;
}

.toolbar-button:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}

.toolbar-button.dragging {
  opacity: 0.7;
}

.divider {
  width: 4px;
  height: 4px;
  border-radius: var(--radius-full);
  background: #ddd;
  margin: 0 0.25rem;
  flex-shrink: 0;
}

#canvas-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#canvas {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background-color: #f9f9f9;
  background-image: linear-gradient(
      var(--grid-color, #b8b8b8) 1px,
      transparent 1px
    ),
    linear-gradient(90deg, var(--grid-color, #b8b8b8) 1px, transparent 1px);
  background-size: var(--grid-size, 32px) var(--grid-size, 32px);
  background-position: var(--grid-offset-x, 0px) var(--grid-offset-y, 0px);
}

#card-sidebar {
  position: absolute;
  bottom: 5rem;
  right: -320px;
  width: 320px;
  height: calc(100vh - 10rem);
  z-index: 10;
  background-color: #fff;
  transition: right 0.4s ease;
  border-radius: var(--radius-item-container);
  outline: 1px solid #eee;
  background: #ffffff;
  box-shadow: 0 0px 20px #0000001a;
  padding: 0.5rem;
}

#card-sidebar.visible {
  right: 0.5rem;
  transition: right 0.4s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding-bottom: 0.25rem;
}

.sidebar-type-icon {
  position: relative;
  width: var(--button-size);
  height: var(--button-size);
  border-radius: var(--radius-item);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f4f4f5;
  color: #222;
  flex-shrink: 0;
}

.sidebar-type-icon .ti {
  font-size: 1.25rem;
  line-height: 1;
}

#sidebar-title-input {
  height: var(--button-size);
  flex: 1;
  width: 100%;
  padding: 0 0.33rem;
  border-radius: var(--radius-item);
  border: 1px solid transparent;
  color: #222;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease,
    background-color 0.12s ease;
}

#sidebar-title-input:focus {
  background: #fff;
  border-color: #bbb;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.12);
}

#sidebar-title-input::placeholder {
  color: #999;
}

#sidebar-more,
#sidebar-close {
  flex-shrink: 0;
  padding: 0;
  margin-left: 0.1rem;
}

.sidebar-body {
  flex: 1;
  font-size: 0.875rem;
  color: #444;
}

.trigger-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.trigger-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem;
  min-height: 0;
  background-color: #f5f5f5;
  border: 1px solid #eee;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease,
    box-shadow 0.2s ease;
}

.trigger-item:hover {
  background-color: var(--tint-green-6);
  border-color: var(--tint-green-5);
}

.trigger-item.selected {
  background-color: var(--tint-green-5);
  border-color: var(--tint-green-4);
}

.trigger-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #222;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.trigger-desc {
  font-size: 0.875rem;
  font-weight: 500;
  margin: 0;
  color: #222;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card.selected {
  outline: 2px var(--card-pastel) solid;
  box-shadow: 0 14px 32px #00000030;
}

#canvas-content {
  position: absolute;
  inset: 0;
  transform-origin: top left;
  z-index: 1;
}

#canvas-content::before {
  content: "";
  position: absolute;
  inset: -200%;
  background-color: #f9f9f9;
  background-image: linear-gradient(#f0f0f0 1px, transparent 1px),
    linear-gradient(90deg, #f0f0f0 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: -1;
}

#connections {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

#trash-zone {
  position: fixed;
  bottom: 0;
  left: 0;
  left: auto;
  width: 240px;
  height: 240px;
  border-radius: 0 100% 0 0;
  background: #e74c342e;
  color: var(--tint-red-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 6rem 3rem 1rem 0;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease, border-color 0.2s ease,
    width 0.2s ease, height 0.2s ease, background 0.2s ease;
  z-index: 40;
}

#trash-zone .ti {
  font-size: 4rem;
  margin-bottom: 1rem;
  color: var(--tint-red-3);
}

#trash-zone::before {
  font-size: 1rem;
}

#trash-zone.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

#trash-zone.active {
  background: #e74c3453;
  width: 260px;
  height: 260px;
}

.card.over-trash {
  opacity: 0.5;
  transform: scale(0.96);
}

.connection {
  pointer-events: visibleStroke;
}

.connection-path {
  pointer-events: stroke;
}

.delete-handle {
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.connection:hover .delete-handle {
  opacity: 1;
}

.delete-handle circle {
  fill: #ff3b30;
  stroke: #b21616;
  stroke-width: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
  cursor: pointer;
}

.delete-handle path {
  fill: none;
  stroke: #fff;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.card {
  position: absolute;
  width: 220px;
  min-height: 120px;
  background: #ffffffe5;
  border-radius: var(--radius-item-container);
  outline: 1px solid var(--card-border, #dedede);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.05);
  padding: 0.5rem;
  cursor: grab;
  user-select: none;
  transition: box-shadow 0.2s ease, transform 0.2s ease, outline-color 0.4s ease;
}

.card.dragging {
  cursor: grabbing;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22);
}

.card-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 32px;
  margin-bottom: 1rem;
}

.type-icon {
  position: relative;
  width: var(--button-size);
  height: var(--button-size);
  border-radius: var(--radius-item);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--card-icon-bg);
  transition: background-color 0.4s ease, border-radius 0.3s ease;
  flex-shrink: 0;
  overflow: hidden;
  color: var(--card-pastel);
}

.card.has-inbound {
  outline-color: var(--card-pastel);
}

.card.has-inbound .type-icon {
  background-color: var(--card-pastel);
  color: var(--card-icon);
}

.type-icon .ti {
  font-size: 1.25rem;
  line-height: 1;
}

.card.inbound-pulse {
  transition: outline-color 0.4s ease;
}

.card.inbound-pulse .type-icon {
  transition: background-color 0.4s ease;
}

.card-title-text {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.05em;
  color: #222;
}

.card-context-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0.5rem 0;
  padding: 0 0 1.5rem 0;
}

.card-context-text {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.875rem;
  color: #444;
  margin: 0;
  border-top: 1px solid #eee;
  padding: 0.75rem 0.25rem;
  white-space: nowrap;
}

.card-context-text .ti {
  font-size: 1rem;
  line-height: 1rem;
}

.card-context-text span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-context-empty {
  display: flex;
  opacity: 0.5;
  align-items: center;
  justify-content: center;
}

.card-footer {
  position: absolute;
  bottom: 0;
  right: 0;
  display: flex;
  justify-content: flex-end;
  padding: 0 0.75rem 0.5rem 0;
  align-items: center;
  pointer-events: none;
}

.card-next-label {
  font-size: 0.75rem;
  line-height: 1.25rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #777;
}

.connector {
  pointer-events: auto;
}

.connector-out {
  position: absolute;
  bottom: 8px;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-item);
  display: flex;
  align-items: center;
  justify-content: center;
  right: -8px;
  cursor: crosshair;
}

.connector-out::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: var(--radius-item);
  background: #777;
}

.toolbar-drag-preview {
  position: fixed;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-item);
  border: 1px solid var(--preview-border, #e4e4e7);
  background: var(--preview-bg, #f4f4f5);
  color: var(--preview-accent, #333);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transform: translate(-999px, -999px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  z-index: 50;
}
