:root {
  --surface: #123039;
  --surface-muted: #183d47;
  --surface-raised: #102a32;
  --border: #2b5661;
  --text: #ddf0f1;
  --text-muted: #91adb2;
  --accent: #59b7bf;
  --accent-contrast: #10292f;
  --focus-ring: #82d6dc;
  --danger: #ffd1c4;
  --danger-soft: #472722;
  --danger-border: #91544a;
  --success: #90e0be;
  --bg: #0f2329;
  --grid-dot: #244750;
  --panel: color-mix(in srgb, var(--surface-raised) 98%, transparent);
  --toolbar-bg: rgba(16, 42, 50, 0.84);
  --panel-border: var(--border);
  --muted: var(--text-muted);
  --edge: #5f949b;
  --edge-selected: var(--focus-ring);
  --surface-soft: var(--surface-muted);
  --danger-text: var(--danger);
  --draft-stroke: #8bb8bd;
  --endpoint-stroke: #8bb8bd;
  --endpoint-fill: #112d35;
  --overlay-shadow: 0 12px 30px rgba(0, 0, 0, 0.42);
  --node-shadow: 0 10px 26px rgba(0, 0, 0, 0.4);
  --scrollbar-size: 12px;
  --scrollbar-radius: var(--radius-pill);
  --scrollbar-track: color-mix(in srgb, var(--surface-soft) 76%, transparent);
  --scrollbar-track-border: color-mix(
    in srgb,
    var(--panel-border) 56%,
    transparent
  );
  --scrollbar-thumb: color-mix(in srgb, var(--text) 28%, var(--accent) 72%);
  --scrollbar-thumb-hover: color-mix(
    in srgb,
    var(--text) 18%,
    var(--accent) 82%
  );
  --scrollbar-thumb-active: color-mix(
    in srgb,
    var(--text) 12%,
    var(--accent) 88%
  );
  --scrollbar-corner: transparent;
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 999px;
  --graph-anchor-radius: 999px;
  --graph-resize-radius: 3px;
}

[data-ui-radius="sharp"] {
  --radius-xs: 0px;
  --radius-sm: 0px;
  --radius-md: 0px;
  --radius-lg: 0px;
  --radius-xl: 0px;
  --radius-pill: 0px;
}

[data-ui-radius="soft"] {
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 10px;
  --radius-pill: 12px;
}

[data-ui-radius="rounded"] {
  --radius-xs: 10px;
  --radius-sm: 14px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-pill: 999px;
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

*::-webkit-scrollbar {
  width: var(--scrollbar-size);
  height: var(--scrollbar-size);
}

*::-webkit-scrollbar-track {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--scrollbar-track) 78%, var(--surface) 22%),
    color-mix(in srgb, var(--scrollbar-track) 96%, transparent)
  );
  border: 1px solid var(--scrollbar-track-border);
  border-radius: var(--scrollbar-radius);
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--scrollbar-thumb) 92%, white 8%),
    color-mix(in srgb, var(--scrollbar-thumb) 86%, black 14%)
  );
  border: 2px solid color-mix(in srgb, var(--surface) 78%, transparent);
  border-radius: var(--scrollbar-radius);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, white 20%, transparent),
    0 1px 4px color-mix(in srgb, black 18%, transparent);
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--scrollbar-thumb-hover) 94%, white 6%),
    color-mix(in srgb, var(--scrollbar-thumb-hover) 88%, black 12%)
  );
}

*::-webkit-scrollbar-thumb:active {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--scrollbar-thumb-active) 96%, white 4%),
    color-mix(in srgb, var(--scrollbar-thumb-active) 90%, black 10%)
  );
}

*::-webkit-scrollbar-corner {
  background: var(--scrollbar-corner);
}

body {
  margin: 0;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

input:is([type="radio"], [type="checkbox"], [type="range"]) {
  accent-color: var(--accent);
}

.panel {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 16px;
  background: rgba(252, 253, 255, 0.95);
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.panel h2 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.actions {
  display: grid;
  gap: 8px;
}

button {
  border: 1px solid var(--panel-border);
  background: var(--surface);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
}

button:hover {
  border-color: var(--accent);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.workspace {
  overflow: hidden;
  position: relative;
  width: 100vw;
  height: 100vh;
}

.canvas {
  --bg-step: 24px;
  --bg-major-step: 120px;
  --bg-minor-offset-x: 0px;
  --bg-minor-offset-y: 0px;
  --bg-major-offset-x: 0px;
  --bg-major-offset-y: 0px;
  --bg-dot-radius: 1px;
  --bg-dot-origin: 1px;
  --bg-grid-minor-alpha: 0.45;
  --bg-grid-major-alpha: 0.72;
  --bg-dot-alpha: 0.52;
  --graph-anchor-size: 10px;
  --graph-control-border-width: 1.5px;
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-image: radial-gradient(
    circle at var(--bg-dot-origin) var(--bg-dot-origin),
    color-mix(
        in srgb,
        var(--grid-dot) calc(var(--bg-dot-alpha) * 100%),
        transparent
      )
      var(--bg-dot-radius),
    transparent calc(var(--bg-dot-radius) + 0.1px)
  );
  background-size: var(--bg-step) var(--bg-step);
  background-position: var(--bg-minor-offset-x) var(--bg-minor-offset-y);
  cursor: grab;
}

.canvas-drop-zone {
  position: absolute;
  inset: 22px;
  z-index: 9;
  display: grid;
  place-items: center;
  border: 2px dashed color-mix(in srgb, var(--accent) 56%, transparent);
  border-radius: var(--radius-lg);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--surface) 74%, transparent),
    color-mix(in srgb, var(--surface-soft) 84%, transparent)
  );
  box-shadow: inset 0 0 0 1px
    color-mix(in srgb, var(--panel-border) 55%, transparent);
  pointer-events: none;
}

.canvas-drop-zone[hidden] {
  display: none;
}

.canvas-drop-zone__copy {
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 18px 24px;
  color: var(--text);
  text-align: center;
}

.canvas-drop-zone__copy strong {
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.canvas-drop-zone__copy span {
  color: var(--muted);
  font-size: 0.88rem;
}

.selection-marquee {
  position: absolute;
  border: 1px solid color-mix(in srgb, var(--accent) 70%, transparent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-radius: var(--radius-xs);
  pointer-events: none;
  z-index: 6;
}

.canvas[data-background-style="graph-paper"] {
  background-image:
    linear-gradient(
      to right,
      color-mix(
          in srgb,
          var(--grid-dot) calc(var(--bg-grid-minor-alpha) * 100%),
          transparent
        )
        1px,
      transparent 1px
    ),
    linear-gradient(
      to bottom,
      color-mix(
          in srgb,
          var(--grid-dot) calc(var(--bg-grid-minor-alpha) * 100%),
          transparent
        )
        1px,
      transparent 1px
    ),
    linear-gradient(
      to right,
      color-mix(
          in srgb,
          var(--grid-dot) calc(var(--bg-grid-major-alpha) * 100%),
          transparent
        )
        1px,
      transparent 1px
    ),
    linear-gradient(
      to bottom,
      color-mix(
          in srgb,
          var(--grid-dot) calc(var(--bg-grid-major-alpha) * 100%),
          transparent
        )
        1px,
      transparent 1px
    );
  background-size:
    var(--bg-step) var(--bg-step),
    var(--bg-step) var(--bg-step),
    var(--bg-major-step) var(--bg-major-step),
    var(--bg-major-step) var(--bg-major-step);
  background-position:
    var(--bg-minor-offset-x) var(--bg-minor-offset-y),
    var(--bg-minor-offset-x) var(--bg-minor-offset-y),
    var(--bg-major-offset-x) var(--bg-major-offset-y),
    var(--bg-major-offset-x) var(--bg-major-offset-y);
}

.canvas[data-background-style="blank"] {
  background-image: none;
}

.canvas[data-background-style="dots"] {
  background-image: radial-gradient(
    circle at var(--bg-dot-origin) var(--bg-dot-origin),
    color-mix(
        in srgb,
        var(--grid-dot) calc(var(--bg-dot-alpha) * 100%),
        transparent
      )
      var(--bg-dot-radius),
    transparent calc(var(--bg-dot-radius) + 0.1px)
  );
  background-size: var(--bg-step) var(--bg-step);
  background-position: var(--bg-minor-offset-x) var(--bg-minor-offset-y);
}

.edges,
.nodes,
.frames,
.selection-controls {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
}

.frames {
  pointer-events: none;
  z-index: 0;
}

.edges {
  overflow: visible;
  pointer-events: none;
  z-index: 1;
}

.edges--overlay {
  z-index: 4;
}

.selection-controls {
  --viewport-zoom: 1;
  pointer-events: none;
  z-index: 7;
}

.selection-controls__group {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

.selection-controls__group > * {
  pointer-events: auto;
}

.selection-controls__toolbar {
  position: relative;
  z-index: 30;
}

.selection-controls__anchor,
.selection-controls__resize {
  z-index: 12;
}

.edges .edge {
  pointer-events: none;
}

.edges .edge__line {
  fill: none;
  stroke: var(--edge);
  stroke-width: var(--edge-sw, 2);
  stroke-dasharray: var(--edge-da, none);
  pointer-events: none;
  cursor: default;
}

.edges .edge__arrowhead {
  fill: var(--edge);
  pointer-events: none;
}

.edges .edge__hit {
  fill: none;
  stroke: rgba(0, 0, 0, 0.001);
  stroke-width: calc(var(--edge-sw, 2) + 10);
  pointer-events: stroke;
}

.edges .edge__label {
  pointer-events: all;
}

.edges .edge__label-hit {
  fill: transparent;
  pointer-events: all;
}

.edges .edge__label-knockout,
.edges .edge__label-text,
.edge-label-editor__display .edge__label-knockout,
.edge-label-editor__display .edge__label-text {
  font-size: var(--edge-label-font-size, 16px);
  font-weight: 600;
  letter-spacing: 0.01em;
  dominant-baseline: middle;
  pointer-events: none;
  user-select: none;
}

.edges .edge__label-knockout,
.edge-label-editor__display .edge__label-knockout {
  fill: var(--bg);
  stroke: var(--bg);
  stroke-width: var(--edge-label-knockout-main, 5px);
  stroke-linejoin: round;
  stroke-linecap: round;
  paint-order: stroke;
}

.edges .edge__label-text,
.edge-label-editor__display .edge__label-text {
  fill: var(--text);
}

.edges path.is-draft {
  fill: none;
  stroke: var(--draft-stroke);
  stroke-width: 2.4;
  pointer-events: none;
}

.edges .edge__draft-end {
  fill: var(--endpoint-fill);
  stroke: var(--draft-stroke);
  stroke-width: 1.8;
  pointer-events: none;
}

.edges .edge__line:hover,
.edges .edge:hover .edge__line {
  stroke: var(--edge-selected);
  stroke-width: calc(var(--edge-sw, 2) + 1);
}

.edges .edge:hover .edge__arrowhead {
  fill: var(--edge-selected);
}

.edges .edge.is-selected .edge__line {
  stroke: var(--edge-selected);
  stroke-width: calc(var(--edge-sw, 2) + 1);
}

.edges .edge.is-selected .edge__arrowhead {
  fill: var(--edge-selected);
}

.edges .edge.is-selected .edge__label-text,
.edges .edge:hover .edge__label-text {
  fill: var(--text);
}

.edges .edge.is-twang .edge__line {
  animation: edge-twang 240ms cubic-bezier(0.18, 1.35, 0.4, 1);
}

.edges .edge__endpoint {
  fill: var(--endpoint-fill);
  stroke: var(--endpoint-stroke);
  stroke-width: 1.5;
  pointer-events: all;
  transition:
    stroke 120ms ease,
    fill 120ms ease;
}

.edges .edge__endpoint:hover {
  fill: #eff6ff;
  stroke: #2563eb;
}

/* Edge per-colour-key stroke overrides */
.edges .edge[data-edge-color="sage"] .edge__line {
  stroke: var(--palette-sage-swatch);
}
.edges .edge[data-edge-color="sage"] .edge__arrowhead {
  stroke: var(--palette-sage-swatch);
  fill: var(--palette-sage-swatch);
}
.edges .edge[data-edge-color="sky"] .edge__line {
  stroke: var(--palette-sky-swatch);
}
.edges .edge[data-edge-color="sky"] .edge__arrowhead {
  stroke: var(--palette-sky-swatch);
  fill: var(--palette-sky-swatch);
}
.edges .edge[data-edge-color="amber"] .edge__line {
  stroke: var(--palette-amber-swatch);
}
.edges .edge[data-edge-color="amber"] .edge__arrowhead {
  stroke: var(--palette-amber-swatch);
  fill: var(--palette-amber-swatch);
}
.edges .edge[data-edge-color="rose"] .edge__line {
  stroke: var(--palette-rose-swatch);
}
.edges .edge[data-edge-color="rose"] .edge__arrowhead {
  stroke: var(--palette-rose-swatch);
  fill: var(--palette-rose-swatch);
}
.edges .edge[data-edge-color="slate"] .edge__line {
  stroke: var(--palette-slate-swatch);
}
.edges .edge[data-edge-color="slate"] .edge__arrowhead {
  stroke: var(--palette-slate-swatch);
  fill: var(--palette-slate-swatch);
}
.edges .edge[data-edge-color="teal"] .edge__line {
  stroke: var(--palette-teal-swatch);
}
.edges .edge[data-edge-color="teal"] .edge__arrowhead {
  stroke: var(--palette-teal-swatch);
  fill: var(--palette-teal-swatch);
}
.edges .edge[data-edge-color="violet"] .edge__line {
  stroke: var(--palette-violet-swatch);
}
.edges .edge[data-edge-color="violet"] .edge__arrowhead {
  stroke: var(--palette-violet-swatch);
  fill: var(--palette-violet-swatch);
}
.edges .edge[data-edge-color="peach"] .edge__line {
  stroke: var(--palette-peach-swatch);
}
.edges .edge[data-edge-color="peach"] .edge__arrowhead {
  stroke: var(--palette-peach-swatch);
  fill: var(--palette-peach-swatch);
}
.edges .edge[data-edge-color="mint"] .edge__line {
  stroke: var(--palette-mint-swatch);
}
.edges .edge[data-edge-color="mint"] .edge__arrowhead {
  stroke: var(--palette-mint-swatch);
  fill: var(--palette-mint-swatch);
}
.edges .edge[data-edge-color="indigo"] .edge__line {
  stroke: var(--palette-indigo-swatch);
}
.edges .edge[data-edge-color="indigo"] .edge__arrowhead {
  stroke: var(--palette-indigo-swatch);
  fill: var(--palette-indigo-swatch);
}

.edges .edge__delete {
  opacity: 0.9;
  pointer-events: all;
  transition: opacity 120ms ease;
  cursor: default;
}

.edges .edge__delete:hover,
.edges .edge__delete:focus-visible {
  opacity: 1;
}

.edges .edge__delete circle {
  fill: #ffffff;
  stroke: #cbd5e1;
  stroke-width: 1.5;
}

.edges .edge__delete-icon {
  fill: #64748b;
}

.edges .edge__delete:hover circle {
  fill: #fee2e2;
  stroke: #ef4444;
}

.edges .edge__delete:hover .edge__delete-icon {
  fill: #b91c1c;
}

.nodes {
  pointer-events: none;
  z-index: 2;
}

.toolbar {
  position: absolute;
  top: 12px;
  left: 12px;
  transform: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  width: auto;
  z-index: 20;
  padding: 8px 10px;
  background: var(--toolbar-bg);
  border-radius: var(--radius-md);
  backdrop-filter: blur(10px);
}

.workspace[data-toolbar-position="bottom-left"] .toolbar,
.workspace[data-toolbar-position="bottom-right"] .toolbar {
  top: auto;
  bottom: 12px;
}

.workspace[data-toolbar-position="top-right"] .toolbar,
.workspace[data-toolbar-position="bottom-right"] .toolbar {
  left: auto;
  right: 12px;
}

.workspace[data-toolbar-orientation="vertical"] .toolbar {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 10px 8px;
}

.toolbar__group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 2px;
}

.toolbar__group + .toolbar__group {
  border-left: 1px solid
    color-mix(in srgb, var(--panel-border) 78%, transparent);
  padding-left: 10px;
}

.workspace[data-toolbar-orientation="vertical"] .toolbar__group {
  flex-direction: column;
  justify-content: center;
  padding: 0;
}

.workspace[data-toolbar-orientation="vertical"]
  .toolbar__group
  + .toolbar__group {
  border-left: 0;
  border-top: 1px solid color-mix(in srgb, var(--panel-border) 78%, transparent);
  padding-left: 0;
  padding-top: 8px;
}

.toolbar__icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.toolbar__icon-btn {
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  border-radius: var(--radius-sm);
  text-align: center;
}

.toolbar__icon-btn--hinted {
  width: auto;
  height: 34px;
  min-width: 34px;
  padding: 0 8px;
}

.toolbar__icon-btn .bi {
  font-size: 0.96rem;
  line-height: 1;
}

.toolbar__shortcut-hint {
  display: inline-block;
  font-size: 0.64rem;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--muted);
  white-space: nowrap;
}

.toolbar__shortcut-hint[hidden] {
  display: none;
}

.toolbar__icon-btn:hover,
.toolbar__icon-btn:focus-visible,
.node__tool-btn:hover,
.node__tool-btn:focus-visible,
.frame__tool-btn:hover,
.frame__tool-btn:focus-visible,
#about-close-btn:hover,
#about-close-btn:focus-visible,
#documents-close-btn:hover,
#documents-close-btn:focus-visible,
#settings-close-btn:hover,
#settings-close-btn:focus-visible {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 38%, transparent);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

.toolbar__icon-btn--has-swatch {
  position: relative;
}

.toolbar__icon-btn--has-swatch::after {
  content: "";
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 11px;
  height: 11px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--panel) 65%, #000000 35%);
  background: var(--active-node-swatch, transparent);
}

.toolbar__icon-btn[data-node-color-current="sage"],
[data-toolbar-color-current="sage"] {
  --active-node-swatch: var(--palette-sage-swatch);
}

.toolbar__icon-btn[data-node-color-current="sky"],
[data-toolbar-color-current="sky"] {
  --active-node-swatch: var(--palette-sky-swatch);
}

.toolbar__icon-btn[data-node-color-current="amber"],
[data-toolbar-color-current="amber"] {
  --active-node-swatch: var(--palette-amber-swatch);
}

.toolbar__icon-btn[data-node-color-current="rose"],
[data-toolbar-color-current="rose"] {
  --active-node-swatch: var(--palette-rose-swatch);
}

.toolbar__icon-btn[data-node-color-current="slate"],
[data-toolbar-color-current="slate"] {
  --active-node-swatch: var(--palette-slate-swatch);
}

.toolbar__icon-btn[data-node-color-current="teal"],
[data-toolbar-color-current="teal"] {
  --active-node-swatch: var(--palette-teal-swatch);
}

.toolbar__icon-btn[data-node-color-current="violet"],
[data-toolbar-color-current="violet"] {
  --active-node-swatch: var(--palette-violet-swatch);
}

.toolbar__icon-btn[data-node-color-current="peach"],
[data-toolbar-color-current="peach"] {
  --active-node-swatch: var(--palette-peach-swatch);
}

.toolbar__icon-btn[data-node-color-current="mint"],
[data-toolbar-color-current="mint"] {
  --active-node-swatch: var(--palette-mint-swatch);
}

.toolbar__icon-btn[data-node-color-current="indigo"],
[data-toolbar-color-current="indigo"] {
  --active-node-swatch: var(--palette-indigo-swatch);
}

.node-color-picker {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.node-color-picker__swatch {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  border-radius: var(--radius-pill);
  border: 1px solid color-mix(in srgb, var(--panel-border) 90%, transparent);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.32);
  padding: 0;
}

.node-color-picker__swatch:hover,
.node-color-picker__swatch:focus-visible {
  transform: translateY(-1px);
}

.node-color-picker__reset {
  grid-column: 1 / -1;
  text-align: center;
  border-radius: var(--radius-xs);
  padding: 6px 8px;
}

.node-color-picker__swatch[data-toolbar-color-value="sage"] {
  background: var(--palette-sage-swatch);
}

.node-color-picker__swatch[data-toolbar-color-value="sky"] {
  background: var(--palette-sky-swatch);
}

.node-color-picker__swatch[data-toolbar-color-value="amber"] {
  background: var(--palette-amber-swatch);
}

.node-color-picker__swatch[data-toolbar-color-value="rose"] {
  background: var(--palette-rose-swatch);
}

.node-color-picker__swatch[data-toolbar-color-value="slate"] {
  background: var(--palette-slate-swatch);
}

.node-color-picker__swatch[data-toolbar-color-value="teal"] {
  background: var(--palette-teal-swatch);
}

.node-color-picker__swatch[data-toolbar-color-value="violet"] {
  background: var(--palette-violet-swatch);
}

.node-color-picker__swatch[data-toolbar-color-value="peach"] {
  background: var(--palette-peach-swatch);
}

.node-color-picker__swatch[data-toolbar-color-value="mint"] {
  background: var(--palette-mint-swatch);
}

.node-color-picker__swatch[data-toolbar-color-value="indigo"] {
  background: var(--palette-indigo-swatch);
}

.node {
  --node-bg: var(--surface);
  --node-border: var(--panel-border);
  --node-text: var(--text);
  --node-muted: var(--muted);
  --node-editor-bg: var(--surface);
  --node-editor-border: var(--panel-border);
  --node-selected-border: var(--accent);
  position: absolute;
  width: 216px;
  height: 144px;
  border-radius: var(--radius-md);
  border: var(--node-border-width, 1px) var(--node-border-style, solid)
    var(--node-border);
  background: var(--node-bg);
  color: var(--node-text);
  padding: 12px;
  pointer-events: auto;
  user-select: none;
  cursor: default;
}

.node__toolbar {
  position: absolute;
  right: 10px;
  top: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: var(--toolbar-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(calc(-100% - 6px));
  transition:
    opacity 120ms ease,
    transform 120ms ease;
  z-index: 20;
}

.entity-toolbar__control {
  position: relative;
}

.entity-toolbar__selection-count {
  display: inline-flex;
  align-items: center;
  align-self: stretch;
  padding: 0 10px;
  border-radius: var(--radius-xs);
  background: color-mix(in srgb, var(--surface-muted) 92%, transparent);
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.entity-toolbar__popover {
  position: absolute;
  top: calc(100% + 10px);
  bottom: auto;
  left: 0;
  min-width: 180px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 40;
}

.entity-toolbar__popover[hidden] {
  display: none;
}

.entity-toolbar__popover[data-toolbar-popover-side="top"] {
  top: auto;
  bottom: calc(100% + 10px);
}

.entity-toolbar__popover[data-toolbar-popover-side="bottom"] {
  top: calc(100% + 10px);
  bottom: auto;
}

.entity-toolbar__popover-title {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.entity-toolbar__popover--range {
  min-width: 200px;
}

.entity-toolbar__range {
  display: grid;
  gap: 8px;
}

.entity-toolbar__range-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.entity-toolbar__range-value {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
}

.entity-toolbar__range-input {
  width: 100%;
  margin: 0;
}

.entity-toolbar__style-options {
  display: grid;
  gap: 6px;
}

.entity-toolbar__style-btn {
  --style-preview: solid;
  text-transform: capitalize;
  text-align: center;
  border-width: 2px;
  border-style: var(--style-preview);
}

.entity-toolbar__style-btn[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--panel-border));
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

.entity-toolbar__style-btn[data-toolbar-border-style-value="solid"] {
  --style-preview: solid;
}

.entity-toolbar__style-btn[data-toolbar-border-style-value="dashed"] {
  --style-preview: dashed;
}

.entity-toolbar__style-btn[data-toolbar-border-style-value="dotted"] {
  --style-preview: dotted;
}

.entity-toolbar__trigger--has-swatch {
  position: relative;
}

.entity-toolbar__trigger--has-swatch::after {
  content: "";
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 7px;
  height: 7px;
  border-radius: var(--radius-pill);
  border: 1px solid color-mix(in srgb, var(--surface) 88%, transparent);
  background: var(--active-node-swatch, var(--accent));
}

.node.is-single-selected .node__toolbar {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(calc(-100% - 10px));
}

.entity-toolbar__btn,
.node__tool-btn,
.frame__tool-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  box-shadow: none;
  border-radius: var(--radius-xs);
  text-align: center;
  transition:
    border-color 120ms ease,
    background-color 120ms ease,
    box-shadow 120ms ease,
    transform 120ms ease;
}

.entity-toolbar__btn .bi,
.node__tool-btn .bi,
.frame__tool-btn .bi {
  font-size: 0.82rem;
}

.node__tool-btn-copy {
  display: none;
}

.node__tool-btn[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--panel-border));
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  box-shadow: none;
}

.entity-toolbar__btn.node__tool-btn--danger,
.node__tool-btn--danger {
  color: var(--danger-text);
  background: color-mix(in srgb, var(--danger-soft) 85%, transparent);
}

.entity-toolbar__btn.node__tool-btn--danger:hover,
.node__tool-btn--danger:hover {
  border-color: #ef4444;
  background: var(--danger-soft);
}

.node__content {
  height: 100%;
  min-height: 0;
}

.workspace.is-focus-mode .toolbar,
.workspace.is-focus-mode .canvas,
.workspace.is-focus-mode .workspace-meta {
  filter: blur(1.5px) saturate(0.85);
  opacity: 0.28;
}

.focus-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 10px;
}

.focus-overlay[hidden] {
  display: none;
}

.focus-overlay__backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(
      circle at top left,
      color-mix(in srgb, var(--accent) 14%, transparent),
      transparent 36%
    ),
    color-mix(in srgb, var(--surface) 72%, rgba(15, 23, 42, 0.78));
  backdrop-filter: blur(14px);
}

.focus-overlay__content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(1180px, 100%);
  height: 100%;
  min-height: 0;
}

.focus-overlay__panel.node {
  position: relative;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  padding: 28px;
  border-radius: var(--radius-xl);
  border: var(--node-border-width, 1px) var(--node-border-style, solid)
    var(--node-border);
  overflow: hidden;
  box-shadow:
    0 28px 70px rgba(15, 23, 42, 0.28),
    0 0 0 1px color-mix(in srgb, var(--node-border) 85%, transparent);
}

.node__toolbar--focus {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 8px;
  right: auto;
  margin-left: auto;
  margin-bottom: 10px;
  padding: 0;
  width: fit-content;
  max-width: 100%;
  border: 0;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--node-bg) 96%, transparent),
    color-mix(in srgb, var(--node-bg) 72%, transparent)
  );
  box-shadow: none;
  border-radius: 0;
  opacity: 1;
  pointer-events: auto;
  transform: none;
  z-index: 45;
  backdrop-filter: blur(10px);
  overflow: visible;
}

.node__toolbar--focus .node__tool-btn {
  width: 32px;
  min-width: 32px;
  padding: 0;
  grid-auto-flow: row;
  gap: 0;
}

.node__toolbar--focus .node__tool-btn-copy {
  display: none;
}

.node__toolbar--focus .node__tool-btn-label {
  display: none;
}

.node__toolbar--focus .node__tool-btn-shortcut {
  display: none;
}

.node__tool-btn--primary {
  color: #f8fffb;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, #2f855a 88%, white 12%),
    color-mix(in srgb, #236746 92%, black 8%)
  );
  border-color: color-mix(in srgb, #2f855a 72%, transparent);
  box-shadow: none;
}

.node__tool-btn--primary:hover,
.node__tool-btn--primary:focus-visible {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, #2f855a 92%, white 8%),
    color-mix(in srgb, #236746 94%, black 6%)
  );
  border-color: color-mix(in srgb, #2f855a 84%, transparent);
  box-shadow: 0 2px 8px color-mix(in srgb, #2f855a 18%, transparent);
}

.node__content--focus {
  display: block;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.node__content--focus-shell {
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100%;
  min-height: 0;
}

.node__focus-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding-right: 6px;
  overscroll-behavior: contain;
}

.node__editor-field {
  min-width: 0;
}

.node__focus-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.9fr);
  align-items: stretch;
  gap: 24px;
  min-height: 0;
  height: 100%;
}

.node__focus-text-column {
  min-width: 0;
  min-height: 0;
  grid-column: 1;
  grid-row: 1;
}

.node__focus-text-column--edit {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  overflow: hidden;
}

.node__focus-text-column--read {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.node__focus-media-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  grid-column: 2;
  grid-row: 1;
}

.node__editor-input,
.node__editor-textarea,
.node__description {
  line-height: 1.5;
}

.node__focus-text-column--edit .node__editor-input,
.node__focus-text-column--edit .node__editor-textarea {
  font-size: 1.08rem;
  line-height: 1.65;
  padding: 13px 15px;
  border-radius: var(--radius-md);
}

.node__focus-text-column--edit .node__editor-input {
  min-height: 54px;
  flex: 0 0 auto;
  font-size: clamp(1.55rem, 2vw, 2.1rem);
  line-height: 1.2;
  font-weight: 700;
}

.node__editor-textarea--focus {
  min-height: 14rem;
  flex: 1 1 auto;
  height: 100%;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  resize: vertical;
}

.node__title--focus {
  font-size: clamp(1.55rem, 2vw, 2.1rem);
  line-height: 1.2;
  font-weight: 700;
}

.node__description--focus {
  font-size: 1.08rem;
  line-height: 1.65;
}

.node__focus-field {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.node__focus-field--media {
  margin-bottom: 8px;
}

.node__focus-field--description {
  margin-top: 18px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.node__focus-value {
  padding: 4px 0 0;
}

.node__focus-value--title {
  display: flex;
  align-items: center;
}

.node__focus-value--description {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.node__description--empty {
  opacity: 0.72;
}

.node__focus-media {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  min-height: 0;
  align-self: stretch;
  position: relative;
}

.node__focus-media-column--edit .node__focus-media {
  flex: 1 1 auto;
  min-height: 220px;
}

.node__focus-media--empty {
  min-height: 220px;
}

.node__focus-media--empty .node__image-dropzone {
  flex: 1 1 auto;
  min-height: 220px;
  align-content: center;
}

.node__focus-media--canvas {
  margin-bottom: 0;
}

.node__image-pane--focus {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 0;
  height: auto;
  max-height: none;
  aspect-ratio: var(--node-image-aspect-ratio, 16 / 9);
  border-radius: var(--radius-lg);
  box-shadow: inset 0 0 0 1px
    color-mix(in srgb, var(--node-border) 65%, transparent);
  position: relative;
  background-size: contain;
}

.node__image-pane--focus[data-node-image-pick] {
  cursor: pointer;
}

.node__image-pane--focus[data-node-image-pick]:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

.focus-overlay.is-file-drop-active
  .node__image-pane--focus[data-node-image-pick]::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: color-mix(in srgb, var(--surface) 20%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 44%, transparent);
}

.node__image-remove-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--danger) 36%, transparent);
  background: color-mix(in srgb, var(--surface) 88%, rgba(15, 23, 42, 0.4));
  color: var(--danger-text);
  box-shadow: 0 10px 24px
    color-mix(in srgb, rgba(15, 23, 42, 0.22) 100%, transparent);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    border-color 160ms ease,
    background-color 160ms ease;
}

.node__focus-media:hover .node__image-remove-btn,
.node__focus-media:focus-within .node__image-remove-btn {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.node__image-remove-btn:hover,
.node__image-remove-btn:focus-visible {
  border-color: color-mix(in srgb, var(--danger) 64%, transparent);
  background: color-mix(in srgb, var(--surface) 76%, var(--danger-soft));
}

.node__image-dropzone {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 14px 16px;
  border: 1px dashed color-mix(in srgb, var(--accent) 48%, var(--panel-border));
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--node-text);
  text-align: left;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.node__image-dropzone--overlay {
  display: none;
  position: absolute;
  inset: 14px;
  z-index: 2;
  align-content: center;
  justify-items: start;
  background: color-mix(in srgb, var(--surface) 84%, rgba(15, 23, 42, 0.22));
  backdrop-filter: blur(10px);
}

.focus-overlay.is-file-drop-active .node__image-dropzone--overlay {
  display: grid;
}

.node__image-dropzone:hover,
.node__image-dropzone:focus-visible,
.focus-overlay.is-file-drop-active .node__image-dropzone {
  border-color: var(--accent);
  background: color-mix(
    in srgb,
    var(--surface) 90%,
    color-mix(in srgb, var(--accent) 10%, transparent)
  );
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
  transform: translateY(-1px);
}

.node__focus-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: auto;
  padding-top: 4px;
}

.node__focus-done-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 104px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid
    color-mix(in srgb, var(--node-selected-border) 52%, var(--node-border));
  background: color-mix(
    in srgb,
    var(--node-bg) 82%,
    var(--node-selected-border)
  );
  color: var(--node-text);
  text-align: center;
  box-shadow: 0 10px 24px
    color-mix(in srgb, var(--node-selected-border) 16%, transparent);
}

.node__focus-done-btn:hover,
.node__focus-done-btn:focus-visible {
  background: color-mix(
    in srgb,
    var(--node-bg) 68%,
    var(--node-selected-border)
  );
  border-color: var(--node-selected-border);
  box-shadow: 0 12px 28px
    color-mix(in srgb, var(--node-selected-border) 22%, transparent);
}

.node__focus-done-btn .bi {
  font-size: 0.92rem;
}

.node__image-dropzone-title {
  font-size: 0.92rem;
  font-weight: 700;
}

.node__image-dropzone-hint {
  color: var(--node-muted);
  font-size: 0.8rem;
}

.node__focus-layout--read
  .node__focus-text-column--read
  .node__focus-value--description {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.node__focus-layout--edit
  .node__focus-text-column--edit
  .node__editor-textarea--focus {
  flex: 1 1 auto;
  overflow: auto;
}

.frame {
  --frame-bg: color-mix(in srgb, var(--surface-soft) 70%, transparent);
  --frame-border: color-mix(in srgb, var(--panel-border) 82%, transparent);
  --frame-text: var(--text);
  --frame-muted: var(--muted);
  --frame-selected-border: var(--accent);
  position: absolute;
  pointer-events: auto;
}

.frame__box {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-sm);
  border: var(--frame-border-width, 1px) var(--frame-border-style, solid)
    var(--frame-border);
  background: var(--frame-bg);
  box-shadow: inset 0 0 0 1px
    color-mix(in srgb, var(--frame-border) 28%, transparent);
}

.frame__meta {
  margin-top: 8px;
  color: var(--frame-text);
  pointer-events: auto;
  position: relative;
  z-index: 1;
}

.frame__title {
  margin: 0;
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.3;
  user-select: none;
}

.frame__description {
  margin: 4px 0 0;
  font-size: 1.5rem;
  line-height: 1.35;
  color: var(--frame-muted);
  overflow-wrap: anywhere;
}

.frame__description > :first-child {
  margin-top: 0;
}

.frame__description > :last-child {
  margin-bottom: 0;
}

.frame__description p,
.frame__description ul,
.frame__description ol {
  margin: 0.3rem 0 0;
}

.frame__description ul,
.frame__description ol {
  padding-left: 1.1rem;
}

.frame__description h1,
.frame__description h2,
.frame__description h3,
.frame__description h4,
.frame__description h5,
.frame__description h6 {
  margin: 0.45rem 0 0;
  font-size: 1em;
  line-height: 1.25;
}

.frame__description a {
  color: inherit;
}

.frame__description code {
  padding: 0.05rem 0.25rem;
  border-radius: var(--radius-xs);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.92em;
}

.frame.is-selected .frame__box {
  border-color: var(--frame-selected-border);
  box-shadow: inset 0 0 0 2px
    color-mix(in srgb, var(--frame-selected-border) 25%, transparent);
}

.frame.is-editing .frame__box {
  border-color: var(--frame-selected-border);
}

.frame.is-editing .frame__meta {
  opacity: 0;
  pointer-events: none;
}

.frame__editor {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  z-index: 2;
}

.frame__editor-input,
.frame__editor-textarea {
  position: relative;
  z-index: 3;
  appearance: none;
  display: block;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  box-shadow: none;
}

.frame__editor-input {
  min-height: 0;
  font-size: 2rem;
  line-height: 1.3;
  font-weight: 600;
}

.frame__editor-textarea {
  margin-top: 4px;
  resize: none;
  min-height: 52px;
  color: var(--frame-muted);
  font-size: 1.5rem;
  line-height: 1.35;
}

.frame__editor-input::placeholder,
.frame__editor-textarea::placeholder {
  color: var(--frame-muted);
}

.frame__toolbar {
  position: absolute;
  right: 8px;
  top: 0;
  display: flex;
  gap: 6px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(calc(-100% - 8px));
  border-radius: var(--radius-sm);
  padding: 4px;
  background: var(--toolbar-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition:
    opacity 120ms ease,
    transform 120ms ease;
  z-index: 20;
}

.selection-controls__frame-meta {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  margin-top: 8px;
  z-index: 25;
}

.frame.is-selected .frame__toolbar {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(calc(-100% - 12px));
}

.frame.is-membership-add-preview .frame__box {
  box-shadow:
    inset 0 0 0 2px color-mix(in srgb, #2f855a 38%, transparent),
    0 0 0 3px color-mix(in srgb, #2f855a 18%, transparent);
}

.frame.is-membership-remove-preview .frame__box {
  box-shadow:
    inset 0 0 0 2px color-mix(in srgb, #b91c1c 38%, transparent),
    0 0 0 3px color-mix(in srgb, #ef4444 18%, transparent);
}

.frame.is-selected.is-membership-add-preview .frame__box,
.frame.is-editing.is-membership-add-preview .frame__box {
  border-color: var(--frame-selected-border);
  box-shadow:
    inset 0 0 0 2px
      color-mix(in srgb, var(--frame-selected-border) 25%, transparent),
    0 0 0 3px color-mix(in srgb, #2f855a 18%, transparent);
}

.frame.is-selected.is-membership-remove-preview .frame__box,
.frame.is-editing.is-membership-remove-preview .frame__box {
  border-color: var(--frame-selected-border);
  box-shadow:
    inset 0 0 0 2px
      color-mix(in srgb, var(--frame-selected-border) 25%, transparent),
    0 0 0 3px color-mix(in srgb, #ef4444 18%, transparent);
}

.workspace-meta {
  position: absolute;
  left: 14px;
  right: auto;
  top: auto;
  bottom: 14px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(10px);
}

.workspace[data-meta-position="top-left"] .workspace-meta {
  top: 14px;
  bottom: auto;
}

.workspace[data-meta-position="top-right"] .workspace-meta,
.workspace[data-meta-position="bottom-right"] .workspace-meta {
  left: auto;
  right: 14px;
}

.workspace[data-meta-position="top-right"] .workspace-meta {
  top: 14px;
  bottom: auto;
}

.workspace-meta__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: color-mix(in srgb, var(--text) 72%, var(--accent));
}

.workspace-meta__icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border-color: transparent;
  border-radius: var(--radius-sm);
  text-align: center;
  background: transparent;
}

.workspace-meta__icon-btn:hover,
.workspace-meta__icon-btn:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.workspace-meta__separator {
  color: var(--muted);
}

.workspace-meta__name {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}

.workspace-meta__coords {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.frame__resize {
  position: absolute;
  width: 13px;
  height: 13px;
  border-radius: var(--graph-resize-radius);
  border: 1.5px solid var(--endpoint-stroke);
  background: var(--endpoint-fill);
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  padding: 0;
}

.selection-controls .frame__resize,
.selection-controls .node__resize {
  width: var(--selection-resize-size);
  height: var(--selection-resize-size);
  border-width: var(--selection-control-border-width);
  opacity: 1;
  pointer-events: auto;
}

.frame.is-selected:not(.is-editing) .frame__resize {
  opacity: 1;
  pointer-events: auto;
}

.frame__resize--top-left {
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  cursor: nwse-resize;
}

.frame__resize--top-right {
  right: 0;
  top: 0;
  transform: translate(50%, -50%);
  cursor: nesw-resize;
}

.frame__resize--bottom-right {
  right: 0;
  bottom: 0;
  transform: translate(50%, 50%);
  cursor: nwse-resize;
}

.frame__resize--bottom-left {
  left: 0;
  bottom: 0;
  transform: translate(-50%, 50%);
  cursor: nesw-resize;
}

.frame__anchor {
  position: absolute;
  width: var(--graph-anchor-size);
  height: var(--graph-anchor-size);
  border-radius: var(--graph-anchor-radius);
  border: var(--graph-control-border-width) solid var(--endpoint-stroke);
  background: var(--endpoint-fill);
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  padding: 0;
}

.selection-controls .frame__anchor,
.selection-controls .node__anchor {
  width: var(--selection-anchor-size);
  height: var(--selection-anchor-size);
  border-width: var(--selection-control-border-width);
  opacity: 1;
  pointer-events: auto;
}

.frame.is-selected .frame__anchor,
.frame:hover .frame__anchor {
  opacity: 1;
  pointer-events: auto;
}

.frame__anchor--top {
  left: 50%;
  top: 0;
  transform: translate(-50%, -50%);
}

.frame__anchor--right {
  right: 0;
  top: 50%;
  transform: translate(50%, -50%);
}

.frame__anchor--bottom {
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 50%);
}

.frame__anchor--left {
  left: 0;
  top: 50%;
  transform: translate(-50%, -50%);
}

.frame__draft {
  position: absolute;
  border-radius: var(--radius-sm);
  border: 1px dashed color-mix(in srgb, var(--accent) 72%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  pointer-events: none;
  z-index: 7;
}

.node.has-fixed-size:not(.is-editing) .node__content {
  overflow: hidden;
}

.node__meta {
  min-width: 0;
}

.node--image .node__content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.node--image:not(.focus-overlay__panel) {
  padding: 0;
  overflow: visible;
}

.node--image:not(.focus-overlay__panel) .node__content,
.node--image:not(.focus-overlay__panel) .node__editor,
.node--image:not(.focus-overlay__panel) .node__editor-layout--canvas-image {
  gap: 0;
}

.node--image:not(.focus-overlay__panel) .node__content {
  overflow: hidden;
  border-radius: calc(var(--radius-md) - 1px);
}

.node--image:not(.focus-overlay__panel) .node__meta,
.node--image:not(.focus-overlay__panel) .node__editor-fields,
.node--image:not(.focus-overlay__panel) .node__editor-fields--canvas-image {
  padding: 12px;
}

.focus-overlay__panel.node--image .node__content--focus {
  min-height: 0;
}

.node--image .node__image-pane {
  width: 100%;
  aspect-ratio: var(--node-image-aspect-ratio, 16 / 9);
  border-radius: var(--radius-xs);
  border: 1px solid var(--panel-border);
  background-color: color-mix(in srgb, var(--surface-soft) 80%, transparent);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.node--image:not(.focus-overlay__panel) .node__image-pane {
  border: 0;
  border-radius: 0;
}

.node.is-selected {
  border-color: var(--node-selected-border);
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--node-selected-border) 24%, transparent),
    var(--node-shadow);
}

.node.is-connect-source {
  border-color: var(--accent);
}

.node.is-connect-target {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.node.is-connect-candidate {
  border-color: #c6d4e7;
}

.node.is-connect-target:hover {
  border-color: var(--accent);
}

.node.is-frame-membership-remove-preview {
  border-color: #ef4444;
  box-shadow: 0 0 0 2px color-mix(in srgb, #ef4444 24%, transparent);
}

.node.is-frame-membership-add-preview {
  border-color: #2f855a;
  box-shadow: 0 0 0 2px color-mix(in srgb, #2f855a 24%, transparent);
}

.node__title {
  margin: 0;
  font-size: 0.95rem;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node__focus-value--title .node__title--focus {
  font-size: clamp(1.55rem, 2vw, 2.1rem);
  line-height: 1.2;
  font-weight: 700;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.node__head {
  display: flex;
  align-items: start;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
}

.node__description {
  margin: 8px 0 0;
  color: var(--node-muted);
  font-size: 0.85rem;
  line-height: 1.4;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.node__description > :first-child {
  margin-top: 0;
}

.node__description > :last-child {
  margin-bottom: 0;
}

.node__description p,
.node__description ul,
.node__description ol {
  margin: 0.35rem 0 0;
}

.node__description ul,
.node__description ol {
  padding-left: 1.15rem;
}

.node__description h1,
.node__description h2,
.node__description h3,
.node__description h4,
.node__description h5,
.node__description h6 {
  margin: 0.45rem 0 0;
  font-size: 1em;
  line-height: 1.25;
}

.node__description a {
  color: inherit;
}

.node__description code {
  padding: 0.08rem 0.28rem;
  border-radius: var(--radius-xs);
  background: color-mix(in srgb, var(--surface-soft) 80%, transparent);
  color: var(--node-text);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.92em;
}

.node.is-editing {
  border-color: var(--node-selected-border);
}

.node__editor {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
}

.node__editor-layout--canvas-image {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
  container-type: inline-size;
}

.node__editor-layout--canvas-image .node__focus-media {
  order: 1;
  flex: 0 0 auto;
  min-height: 0;
}

.node__editor-layout--canvas-image .node__editor-fields--canvas-image {
  order: 2;
  flex: 1 1 auto;
}

.node__editor-fields {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
}

.node__editor-fields--canvas-image {
  gap: 0;
  min-height: 0;
}

.node__editor-field--title {
  flex: 0 0 auto;
}

.node__editor-field--description {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  height: 100%;
  padding-top: 8px;
  min-height: 0;
  overflow: hidden;
}

.node__editor-input,
.node__editor-textarea {
  border: 1px solid var(--node-editor-border);
  border-radius: var(--radius-xs);
  padding: 7px 8px;
  color: var(--node-text);
  width: 100%;
  background: var(--node-editor-bg);
}

.node__editor .node__editor-input,
.node__editor .node__editor-textarea {
  appearance: none;
  display: block;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.node__editor .node__editor-input {
  font-size: 0.95rem;
  line-height: 1.2;
  font-weight: 600;
  min-height: 0;
}

.node__editor .node__editor-textarea {
  color: var(--node-muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

.node__editor .node__editor-input::placeholder,
.node__editor .node__editor-textarea::placeholder {
  color: var(--node-muted);
}

.node__editor-input:focus-visible,
.node__editor-textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.node__editor .node__editor-input:focus-visible,
.node__editor .node__editor-textarea:focus-visible {
  outline: none;
  border-color: transparent;
  box-shadow: none;
}

.node__editor-textarea {
  flex: 1 1 auto;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  resize: none;
  overflow: auto;
}

.node__editor-layout--canvas-image .node__editor-textarea {
  max-height: 100%;
}

.node__editor-layout--canvas-image .node__image-pane {
  width: 100%;
  min-height: 0;
  height: auto;
  background-size: cover;
}

.node__editor-layout--canvas-image .node__focus-media--has-image {
  min-height: 0;
}

.node__editor-layout--canvas-image .node__focus-media--empty,
.node__editor-layout--canvas-image
  .node__focus-media--empty
  .node__image-dropzone {
  min-height: 132px;
}

.node__editor-layout--canvas-image .node__image-dropzone {
  min-height: 132px;
  align-content: center;
}

@container (min-width: 360px) {
  .node__editor-layout--canvas-image {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(132px, 0.9fr);
    align-items: stretch;
    gap: 14px;
  }

  .node__editor-layout--canvas-image .node__editor-fields--canvas-image {
    order: 1;
  }

  .node__editor-layout--canvas-image .node__focus-media {
    order: 2;
    align-self: start;
    height: auto;
  }

  .node__editor-layout--canvas-image .node__focus-media--has-image,
  .node__editor-layout--canvas-image .node__focus-media--empty,
  .node__editor-layout--canvas-image
    .node__focus-media--empty
    .node__image-dropzone {
    min-height: 0;
  }

  .node__editor-layout--canvas-image .node__image-pane {
    min-height: 0;
  }
}

@media (max-width: 700px) {
  .focus-overlay {
    padding: 10px;
  }

  .focus-overlay__content {
    width: 100%;
    height: 100%;
  }

  .focus-overlay__panel.node {
    padding: 16px 16px 18px;
    border-radius: var(--radius-md);
  }

  .node__focus-layout,
  .node__focus-layout--edit,
  .node__focus-layout--read {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .node__meta--focus,
  .node__description--focus {
    width: 100%;
    max-width: 70ch;
  }

  .node__focus-body {
    padding-right: 0;
  }

  .node__focus-layout {
    height: auto;
  }

  .node__content--focus-shell--edit {
    min-height: 0;
    overflow: hidden;
  }

  .node__focus-text-column,
  .node__focus-media-column,
  .node__focus-text-column--edit,
  .node__focus-text-column--read {
    grid-column: 1;
    grid-row: auto;
  }

  .node__focus-media-column,
  .node__focus-text-column {
    width: 100%;
    height: auto;
    min-height: 0;
  }

  .node__focus-text-column--edit,
  .node__focus-text-column--read {
    overflow: visible;
    height: auto;
  }

  .node__content--focus-shell--read .node__focus-body {
    overflow: auto;
  }

  .node__content--focus-shell--edit .node__focus-body {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding-bottom: 0;
  }

  .node__focus-layout--read
    .node__focus-text-column--read
    .node__focus-value--description {
    flex: 0 0 auto;
    overflow: visible;
  }

  .node__focus-layout--edit > .node__focus-media-column {
    order: 1;
  }

  .node__focus-layout--edit > .node__focus-text-column {
    order: 2;
  }

  .node__focus-layout--edit {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
  }

  .node__focus-layout--edit > .node__focus-text-column {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    padding-bottom: 0;
  }

  .node__focus-layout--edit
    > .node__focus-text-column
    .node__focus-field--description {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    padding-bottom: 10px;
    box-sizing: border-box;
  }

  .node__focus-layout > .node__focus-media-column {
    order: 1;
  }

  .node__focus-layout > .node__focus-text-column {
    order: 2;
  }

  .node__toolbar--focus {
    justify-content: stretch;
    margin-bottom: 12px;
  }

  .node__toolbar--focus .node__tool-btn {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
  }

  .node__content--focus-shell--edit .node__image-pane--focus {
    min-height: 180px;
    height: min(32vh, 280px);
    max-height: none;
    background-size: cover;
  }

  .node__content--focus-shell--read .node__image-pane--focus {
    min-height: 0;
    height: auto;
    background-size: contain;
  }

  .node__focus-media-column--edit .node__focus-media,
  .node__focus-media--empty,
  .node__focus-media--empty .node__image-dropzone {
    min-height: 180px;
  }

  .node__editor-textarea--focus {
    min-height: 0;
    max-height: none;
    height: 100%;
    flex: 1 1 auto;
  }
}

.node.is-editing .node__content {
  display: flex;
  overflow: hidden;
}

.node[data-node-color="sage"] {
  --node-bg: #e8f3e8;
  --node-border: #bfd6bf;
  --node-text: #1f3726;
  --node-muted: #49614f;
  --node-editor-bg: #f2faf2;
  --node-editor-border: #abc6ad;
  --node-selected-border: #2f855a;
}

.node[data-node-color="sky"] {
  --node-bg: #eaf4ff;
  --node-border: #bfd7f3;
  --node-text: #163352;
  --node-muted: #3e6286;
  --node-editor-bg: #f2f8ff;
  --node-editor-border: #adc8e8;
  --node-selected-border: #2b6cb0;
}

.node[data-node-color="amber"] {
  --node-bg: #fff4dd;
  --node-border: #f0d7a4;
  --node-text: #4f3206;
  --node-muted: #81582b;
  --node-editor-bg: #fff8ea;
  --node-editor-border: #e8ca90;
  --node-selected-border: #b7791f;
}

.node[data-node-color="rose"] {
  --node-bg: #fdecef;
  --node-border: #edc5cc;
  --node-text: #4f1f2e;
  --node-muted: #7d4557;
  --node-editor-bg: #fff4f6;
  --node-editor-border: #e3b3bd;
  --node-selected-border: #b83280;
}

.node[data-node-color="slate"] {
  --node-bg: #edf2f7;
  --node-border: #c8d1df;
  --node-text: #1f2937;
  --node-muted: #4b5b6d;
  --node-editor-bg: #f5f8fc;
  --node-editor-border: #bac5d8;
  --node-selected-border: #475569;
}

.node[data-node-color="teal"] {
  --node-bg: #e5f6f4;
  --node-border: #b9ded9;
  --node-text: #173a38;
  --node-muted: #466868;
  --node-editor-bg: #eefaf8;
  --node-editor-border: #a9d3cd;
  --node-selected-border: #0f766e;
}

.node[data-node-color="violet"] {
  --node-bg: #f1ecff;
  --node-border: #d5caf7;
  --node-text: #31245f;
  --node-muted: #62538d;
  --node-editor-bg: #f7f4ff;
  --node-editor-border: #c6b6ee;
  --node-selected-border: #6d28d9;
}

.node[data-node-color="peach"] {
  --node-bg: #fff0e8;
  --node-border: #f3cfbf;
  --node-text: #4f2b1d;
  --node-muted: #7c5446;
  --node-editor-bg: #fff6f1;
  --node-editor-border: #e8c0ad;
  --node-selected-border: #c05621;
}

.node[data-node-color="mint"] {
  --node-bg: #e7f8ef;
  --node-border: #bbe3cb;
  --node-text: #153b27;
  --node-muted: #456c57;
  --node-editor-bg: #f0fbf5;
  --node-editor-border: #abd8be;
  --node-selected-border: #2f855a;
}

.node[data-node-color="indigo"] {
  --node-bg: #eceffd;
  --node-border: #c6cef5;
  --node-text: #1f2a5c;
  --node-muted: #4f5f8d;
  --node-editor-bg: #f4f6ff;
  --node-editor-border: #b7c2ef;
  --node-selected-border: #4338ca;
}

.frame[data-frame-color="sage"] {
  --frame-bg: color-mix(in srgb, var(--palette-sage-swatch) 20%, transparent);
  --frame-border: color-mix(
    in srgb,
    var(--palette-sage-swatch) 72%,
    var(--panel-border)
  );
  --frame-selected-border: #2f855a;
}

.frame[data-frame-color="sky"] {
  --frame-bg: color-mix(in srgb, var(--palette-sky-swatch) 20%, transparent);
  --frame-border: color-mix(
    in srgb,
    var(--palette-sky-swatch) 72%,
    var(--panel-border)
  );
  --frame-selected-border: #2b6cb0;
}

.frame[data-frame-color="amber"] {
  --frame-bg: color-mix(in srgb, var(--palette-amber-swatch) 20%, transparent);
  --frame-border: color-mix(
    in srgb,
    var(--palette-amber-swatch) 72%,
    var(--panel-border)
  );
  --frame-selected-border: #b7791f;
}

.frame[data-frame-color="rose"] {
  --frame-bg: color-mix(in srgb, var(--palette-rose-swatch) 20%, transparent);
  --frame-border: color-mix(
    in srgb,
    var(--palette-rose-swatch) 72%,
    var(--panel-border)
  );
  --frame-selected-border: #b83280;
}

.frame[data-frame-color="slate"] {
  --frame-bg: color-mix(in srgb, var(--palette-slate-swatch) 18%, transparent);
  --frame-border: color-mix(
    in srgb,
    var(--palette-slate-swatch) 72%,
    var(--panel-border)
  );
  --frame-selected-border: #475569;
}

.frame[data-frame-color="teal"] {
  --frame-bg: color-mix(in srgb, var(--palette-teal-swatch) 18%, transparent);
  --frame-border: color-mix(
    in srgb,
    var(--palette-teal-swatch) 72%,
    var(--panel-border)
  );
  --frame-selected-border: #0f766e;
}

.frame[data-frame-color="violet"] {
  --frame-bg: color-mix(in srgb, var(--palette-violet-swatch) 18%, transparent);
  --frame-border: color-mix(
    in srgb,
    var(--palette-violet-swatch) 72%,
    var(--panel-border)
  );
  --frame-selected-border: #6d28d9;
}

.frame[data-frame-color="peach"] {
  --frame-bg: color-mix(in srgb, var(--palette-peach-swatch) 18%, transparent);
  --frame-border: color-mix(
    in srgb,
    var(--palette-peach-swatch) 72%,
    var(--panel-border)
  );
  --frame-selected-border: #c05621;
}

.frame[data-frame-color="mint"] {
  --frame-bg: color-mix(in srgb, var(--palette-mint-swatch) 18%, transparent);
  --frame-border: color-mix(
    in srgb,
    var(--palette-mint-swatch) 72%,
    var(--panel-border)
  );
  --frame-selected-border: #2f855a;
}

.frame[data-frame-color="indigo"] {
  --frame-bg: color-mix(in srgb, var(--palette-indigo-swatch) 18%, transparent);
  --frame-border: color-mix(
    in srgb,
    var(--palette-indigo-swatch) 72%,
    var(--panel-border)
  );
  --frame-selected-border: #4338ca;
}

[data-theme="dark"] .node[data-node-color="sage"] {
  --node-bg: #1e3226;
  --node-border: #365844;
  --node-text: #deefe2;
  --node-muted: #abcaaf;
  --node-editor-bg: #24392c;
  --node-editor-border: #456850;
  --node-selected-border: #68d391;
}

[data-theme="dark"] .node[data-node-color="sky"] {
  --node-bg: #1a3047;
  --node-border: #355475;
  --node-text: #e2efff;
  --node-muted: #adc5df;
  --node-editor-bg: #213a53;
  --node-editor-border: #44678d;
  --node-selected-border: #63b3ed;
}

[data-theme="dark"] .node[data-node-color="amber"] {
  --node-bg: #3b2c13;
  --node-border: #6f5428;
  --node-text: #fff2d8;
  --node-muted: #d8be8f;
  --node-editor-bg: #46361a;
  --node-editor-border: #836333;
  --node-selected-border: #f6ad55;
}

[data-theme="dark"] .node[data-node-color="rose"] {
  --node-bg: #442331;
  --node-border: #734056;
  --node-text: #ffe8ef;
  --node-muted: #d5adbd;
  --node-editor-bg: #4f2b3a;
  --node-editor-border: #87506a;
  --node-selected-border: #f687b3;
}

[data-theme="dark"] .node[data-node-color="slate"] {
  --node-bg: #263445;
  --node-border: #3f536a;
  --node-text: #ebf2fb;
  --node-muted: #b9c7d8;
  --node-editor-bg: #2f3f53;
  --node-editor-border: #51667e;
  --node-selected-border: #a0aec0;
}

[data-theme="dark"] .node[data-node-color="teal"] {
  --node-bg: #15383a;
  --node-border: #2d6361;
  --node-text: #def8f5;
  --node-muted: #a9ceca;
  --node-editor-bg: #1c4445;
  --node-editor-border: #3e7775;
  --node-selected-border: #5eead4;
}

[data-theme="dark"] .node[data-node-color="violet"] {
  --node-bg: #31264d;
  --node-border: #5a4a83;
  --node-text: #f1eaff;
  --node-muted: #c8bcde;
  --node-editor-bg: #3b2f5a;
  --node-editor-border: #6d5a99;
  --node-selected-border: #c4b5fd;
}

[data-theme="dark"] .node[data-node-color="peach"] {
  --node-bg: #43281d;
  --node-border: #734536;
  --node-text: #ffece2;
  --node-muted: #d5b5a5;
  --node-editor-bg: #4f3125;
  --node-editor-border: #875644;
  --node-selected-border: #f6ad55;
}

[data-theme="dark"] .node[data-node-color="mint"] {
  --node-bg: #1b3b2a;
  --node-border: #35654a;
  --node-text: #e4f8ed;
  --node-muted: #b2d4c0;
  --node-editor-bg: #234634;
  --node-editor-border: #477a5d;
  --node-selected-border: #86efac;
}

[data-theme="dark"] .node[data-node-color="indigo"] {
  --node-bg: #232b4e;
  --node-border: #414e84;
  --node-text: #e9edff;
  --node-muted: #b8c1e2;
  --node-editor-bg: #2d3760;
  --node-editor-border: #56659d;
  --node-selected-border: #a5b4fc;
}

.node.is-editing .node__anchor {
  opacity: 0;
  pointer-events: none;
}

.node__resize {
  position: absolute;
  width: 14px;
  height: 14px;
  appearance: none;
  padding: 0;
  border-radius: var(--graph-resize-radius);
  border: 1.5px solid var(--endpoint-stroke);
  background: var(--endpoint-fill);
  box-shadow: 0 0 0 1px rgba(159, 178, 204, 0.22);
  opacity: 0;
  pointer-events: none;
  z-index: 3;
  transition:
    opacity 120ms ease,
    border-color 120ms ease,
    box-shadow 120ms ease,
    background-color 120ms ease;
}

.node__resize:hover {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.node.is-single-selected:not(.is-editing) .node__resize {
  opacity: 1;
  pointer-events: auto;
}

.node__resize--top-left {
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  cursor: nwse-resize;
}

.node__resize--top-right {
  right: 0;
  top: 0;
  transform: translate(50%, -50%);
  cursor: nesw-resize;
}

.node__resize--bottom-right {
  right: 0;
  bottom: 0;
  transform: translate(50%, 50%);
  cursor: nwse-resize;
}

.node__resize--bottom-left {
  left: 0;
  bottom: 0;
  transform: translate(-50%, 50%);
  cursor: nesw-resize;
}

.node__anchor {
  position: absolute;
  width: var(--graph-anchor-size);
  height: var(--graph-anchor-size);
  appearance: none;
  padding: 0;
  line-height: 0;
  aspect-ratio: 1 / 1;
  border-radius: var(--graph-anchor-radius);
  border: var(--graph-control-border-width) solid var(--endpoint-stroke);
  background: var(--endpoint-fill);
  box-shadow: 0 0 0 1px rgba(159, 178, 204, 0.22);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 120ms ease,
    transform 120ms ease,
    border-color 120ms ease,
    box-shadow 120ms ease,
    background-color 120ms ease;
  cursor: default;
  z-index: 2;
}

.node__anchor:hover {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.node:hover .node__anchor,
.node.is-connect-source .node__anchor,
.node.is-connect-candidate .node__anchor,
.node.is-connect-target .node__anchor {
  opacity: 1;
  pointer-events: auto;
}

.node__anchor--top {
  left: 50%;
  top: 0;
  transform: translate(-50%, -50%);
}

.node__anchor--right {
  top: 50%;
  right: 0;
  transform: translate(50%, -50%);
}

.node__anchor--bottom {
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 50%);
}

.node__anchor--left {
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%);
}

.selection-controls__toolbar {
  opacity: 1;
  pointer-events: auto;
  transition: none;
}

.selection-controls__toolbar--node {
  top: 0;
  left: 50%;
  right: auto;
  transform-origin: center bottom;
  transform: translate(
      calc(-50% + var(--toolbar-shift-x, 0px)),
      calc(-100% - (10px / var(--viewport-zoom, 1)))
    )
    scale(var(--selection-toolbar-scale, 1));
}

.selection-controls__toolbar--node[data-toolbar-placement="bottom"] {
  top: 100%;
  transform-origin: center top;
  transform: translate(
      calc(-50% + var(--toolbar-shift-x, 0px)),
      calc(10px / var(--viewport-zoom, 1))
    )
    scale(var(--selection-toolbar-scale, 1));
}

.selection-controls__toolbar--frame {
  transform-origin: right bottom;
  transform: translateY(calc(-100% - (12px / var(--viewport-zoom, 1))))
    scale(var(--selection-toolbar-scale, 1));
}

.selection-controls__toolbar--nodes {
  left: 50%;
  right: auto;
  transform-origin: center bottom;
  transform: translate(-50%, calc(-100% - (10px / var(--viewport-zoom, 1))))
    scale(var(--selection-toolbar-scale, 1));
}

/* Edge toolbar */
.selection-controls__group--edge,
.selection-controls__group--edges {
  width: 0;
  height: 0;
  overflow: visible;
}

.edge__toolbar {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: var(--toolbar-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: none;
  white-space: nowrap;
  z-index: 20;
}

.selection-controls__toolbar--edge,
.selection-controls__toolbar--edges {
  left: 0;
  top: 0;
  transform-origin: center bottom;
  transform: translate(
      calc(-50% + var(--toolbar-shift-x, 0px)),
      calc(-100% - (var(--edge-label-toolbar-offset, 22px) / var(--viewport-zoom, 1)))
    )
    scale(var(--selection-toolbar-scale, 1));
}

.selection-controls__toolbar--edge[data-toolbar-placement="bottom"],
.selection-controls__toolbar--edges[data-toolbar-placement="bottom"] {
  top: 0;
  transform-origin: center top;
  transform: translate(
      calc(-50% + var(--toolbar-shift-x, 0px)),
      calc(var(--edge-label-toolbar-offset, 22px) / var(--viewport-zoom, 1))
    )
    scale(var(--selection-toolbar-scale, 1));
}

.edge-label-editor {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  transform-origin: center;
  z-index: 19;
  width: var(--edge-label-width, 120px);
  height: var(--edge-label-height, 26px);
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.edge-label-editor__display {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--edge-label-content-width, 120px);
  height: var(--edge-label-content-height, 26px);
  transform: translate(-50%, -50%);
  overflow: visible;
  pointer-events: none;
}

.edge-label-editor__display .edge__label-knockout,
.edge-label-editor__display .edge__label-text {
  dominant-baseline: middle;
}

.edge-label-editor__display.is-placeholder .edge__label-text {
  fill: var(--text-muted);
}

.edge-label-editor__input {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--edge-label-content-width, 120px);
  height: var(--edge-label-content-height, 26px);
  transform: translate(-50%, -50%);
  box-sizing: border-box;
  padding: 5px 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: transparent;
  font: inherit;
  font-size: var(--edge-label-font-size, 16px);
  font-family: inherit;
  font-weight: 600;
  text-align: center;
  line-height: 18px;
  box-shadow: none;
  outline: none;
  margin: 0;
  resize: none;
  overflow: hidden;
  white-space: pre;
  display: block;
  text-shadow: none;
  -webkit-text-fill-color: transparent;
  -webkit-text-stroke: 0 transparent;
  caret-color: var(--text);
}

.edge-label-editor__input::placeholder {
  color: transparent;
}

.edge-label-editor__input::selection {
  background: color-mix(in srgb, var(--accent) 32%, transparent);
  color: transparent;
  -webkit-text-fill-color: transparent;
  -webkit-text-stroke: 0 transparent;
  text-shadow: none;
}

.edge-label-editor__input:focus,
.edge-label-editor__input:focus-visible {
  outline: none;
  outline-offset: 0;
  border: 0;
  box-shadow: none;
}

.entity-toolbar__edge-type-options {
  gap: 4px;
}

.entity-toolbar__edge-type-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  height: 32px;
  text-align: left;
  border-width: 1px;
  border-style: solid;
  border-color: transparent;
}

.entity-toolbar__edge-type-btn[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--panel-border));
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

.node.has-overlay-controls .node__toolbar,
.node.has-overlay-controls .node__resize,
.node.has-overlay-controls .node__anchor,
.node.has-overlay-controls:hover .node__anchor,
.node.has-overlay-controls.is-single-selected:not(.is-editing) .node__resize,
.node.has-overlay-controls.is-connect-source .node__anchor,
.node.has-overlay-controls.is-connect-candidate .node__anchor,
.node.has-overlay-controls.is-connect-target .node__anchor,
.frame.has-overlay-controls .frame__toolbar,
.frame.has-overlay-controls .frame__resize,
.frame.has-overlay-controls .frame__anchor,
.frame.has-overlay-controls:hover .frame__anchor,
.frame.has-overlay-controls.is-selected:not(.is-editing) .frame__resize,
.frame.has-overlay-controls.is-selected .frame__anchor {
  opacity: 0 !important;
  pointer-events: none !important;
}

.toast {
  position: absolute;
  top: auto;
  left: auto;
  right: 16px;
  bottom: 16px;
  z-index: 40;
  min-height: 1px;
  max-width: min(560px, calc(100vw - 24px));
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(14px) saturate(1.08);
  -webkit-backdrop-filter: blur(14px) saturate(1.08);
  color: var(--text);
  font-size: 0.86rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition:
    opacity 110ms ease,
    transform 110ms ease;
}

.workspace[data-toast-position="top-left"] .toast {
  top: 16px;
  left: 16px;
  right: auto;
  bottom: auto;
}

.workspace[data-toast-position="top-right"] .toast {
  top: 16px;
  bottom: auto;
}

.workspace[data-toast-position="bottom-left"] .toast {
  left: 16px;
  right: auto;
}

.toast--dialog {
  position: sticky;
  right: auto;
  bottom: 0;
  margin: 0 0 12px auto;
  width: fit-content;
  max-width: min(100%, 420px);
  z-index: 1;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast__content {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.toast__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: color-mix(in srgb, var(--text) 72%, var(--accent));
  flex: 0 0 auto;
}

.toast__icon .bi {
  font-size: 0.92rem;
  line-height: 1;
}

.toast__title {
  font-weight: 600;
  letter-spacing: -0.01em;
}

.toast__description {
  color: var(--muted);
}

.canvas.is-file-drop-active {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 28%, transparent);
}

.canvas.is-panning,
.canvas.is-dragging {
  cursor: grabbing;
}

.canvas.is-resizing {
  cursor: default;
}

.workspace.is-dragging .node {
  cursor: grabbing;
}

.workspace.is-resizing .node {
  cursor: default;
}

.canvas.is-connecting {
  cursor: crosshair;
}

.canvas.is-drawing-frame {
  cursor: crosshair;
}

.workspace.is-marquee-selecting .canvas {
  cursor: crosshair;
}

.workspace.is-connecting .node__anchor {
  opacity: 1;
  pointer-events: auto;
}

.workspace.is-connecting .node.is-editing .node__anchor {
  opacity: 0;
  pointer-events: none;
}

.workspace.is-connecting .frame__anchor {
  opacity: 1;
  pointer-events: auto;
}

kbd {
  border: 1px solid color-mix(in srgb, var(--panel-border) 88%, transparent);
  border-radius: var(--radius-xs);
  background: color-mix(in srgb, var(--surface-soft) 84%, var(--surface));
  color: color-mix(in srgb, var(--text) 88%, var(--muted));
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
}

.app-dialog {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  overflow: hidden;
}

.app-dialog::backdrop {
  background: rgba(2, 6, 23, 0.42);
  backdrop-filter: blur(8px);
}

.app-dialog--fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
}

.app-dialog__article {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: clamp(16px, 2vw, 28px);
  background:
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--panel) 97%, transparent),
      color-mix(in srgb, var(--surface) 96%, transparent)
    ),
    radial-gradient(
      circle at top right,
      color-mix(in srgb, var(--accent) 10%, transparent),
      transparent 28%
    );
}

.app-dialog__body {
  min-height: 0;
  display: grid;
  gap: 18px;
  overflow: hidden;
}

.app-dialog__panel {
  min-height: 0;
  overflow: auto;
  padding-right: 6px;
}

.about-dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0;
  margin: 0;
}

.about-dialog__titlebar {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.about-dialog__title-icon {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-xs);
  color: color-mix(in srgb, var(--text) 76%, var(--accent));
}

#about-dialog .about-dialog__title-icon {
  background: transparent;
  border-color: transparent;
}

.rename-dialog .about-dialog__title-icon {
  background: transparent;
  border-color: transparent;
}

.about-dialog__title-icon .bi {
  font-size: 1.5rem;
}

.about-dialog h2,
.about-dialog h3 {
  margin: 0;
}

.about-dialog h2 {
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.about-dialog__lede {
  margin: 0;
  max-width: 56ch;
  color: color-mix(in srgb, var(--text) 88%, var(--muted));
  line-height: 1.6;
}

.about-dialog__panel {
  position: relative;
  z-index: 1;
}

.about-dialog__body {
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.shortcuts-dialog {
  width: 100vw;
}

.shortcuts-dialog__article {
  gap: 16px;
}

.shortcuts-dialog__body {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.shortcuts-dialog__search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--panel-border) 90%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface) 98%, transparent);
}

.shortcuts-dialog__search .bi {
  color: var(--muted);
  font-size: 0.92rem;
}

.shortcuts-dialog__search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
}

.shortcuts-dialog__panel {
  display: grid;
  align-content: start;
  gap: 12px;
}

.shortcuts-dialog__list {
  display: grid;
  gap: 10px;
}

.shortcuts-dialog__item {
  display: grid;
  grid-template-columns: minmax(180px, 220px) 1fr;
  gap: 14px;
  align-items: start;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--panel-border) 90%, transparent);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
}

.shortcuts-dialog__item[hidden] {
  display: none;
}

.shortcuts-dialog__keys {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.shortcuts-dialog__meta {
  display: grid;
  gap: 4px;
}

.shortcuts-dialog__meta h3 {
  font-size: 0.98rem;
  font-weight: 620;
}

.shortcuts-dialog__meta p {
  margin: 0;
  color: color-mix(in srgb, var(--text) 86%, var(--muted));
  line-height: 1.55;
}

.shortcuts-dialog__empty {
  margin: 0;
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px dashed color-mix(in srgb, var(--panel-border) 90%, transparent);
  color: var(--muted);
  text-align: center;
}

.documents-dialog {
  width: min(760px, calc(100vw - 24px));
  max-width: none;
}

.documents-dialog__article {
  display: grid;
  width: auto;
  height: min(720px, calc(100vh - 24px));
  min-height: 0;
  gap: 16px;
}

.documents-dialog__body {
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.documents-dialog__actions {
  display: flex;
  justify-content: flex-end;
}

.documents-dialog__panel {
  display: grid;
  align-content: start;
  gap: 12px;
}

.documents-dialog__list {
  display: grid;
  gap: 10px;
}

.documents-dialog__item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--panel-border) 90%, transparent);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
}

.documents-dialog__item.is-active {
  border-color: color-mix(in srgb, var(--accent) 68%, transparent);
  box-shadow: inset 0 0 0 1px
    color-mix(in srgb, var(--accent) 24%, transparent);
}

.documents-dialog__open {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}

.documents-dialog__open:hover .documents-dialog__title,
.documents-dialog__open:focus-visible .documents-dialog__title {
  color: color-mix(in srgb, var(--text) 76%, var(--accent));
}

.documents-dialog__title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.documents-dialog__title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 620;
}

.documents-dialog__badge {
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: color-mix(in srgb, var(--text) 76%, var(--accent));
  font-size: 0.72rem;
  font-weight: 700;
}

.documents-dialog__meta {
  color: color-mix(in srgb, var(--text) 84%, var(--muted));
  font-size: 0.85rem;
  line-height: 1.45;
}

.documents-dialog__delete {
  min-width: auto;
  padding: 8px 10px;
  text-align: center;
}

.about-dialog__shortcut-list {
  list-style: none;
  margin: 0;
  padding: 18px 20px;
  display: grid;
  gap: 12px;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--panel-border) 90%, transparent);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
}

.about-dialog__shortcut-list li {
  display: grid;
  grid-template-columns: max-content 1fr;
  align-items: start;
  gap: 10px 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid
    color-mix(in srgb, var(--panel-border) 72%, transparent);
}

.about-dialog__shortcut-list li:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.about-dialog__shortcut-list span {
  color: color-mix(in srgb, var(--text) 86%, var(--muted));
  line-height: 1.55;
}

.about-dialog__repo {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.about-dialog__repo a {
  color: color-mix(in srgb, var(--text) 70%, var(--accent));
  text-decoration: none;
  border-bottom: 1px solid
    color-mix(in srgb, var(--panel-border) 92%, transparent);
}

.about-dialog__repo a:hover,
.about-dialog__repo a:focus-visible {
  color: var(--text);
  border-bottom-color: color-mix(in srgb, var(--text) 45%, transparent);
}

#about-close-btn,
#shortcuts-close-btn,
#settings-close-btn,
#documents-close-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border-color: transparent;
  background: transparent;
  border-radius: var(--radius-sm);
  text-align: center;
}

.settings-dialog__section {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  margin: 0;
  padding: 14px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
}

.settings-dialog__section--plain {
  border: 0;
  background: transparent;
  padding: 6px 2px 2px;
}

.rename-dialog {
  width: min(460px, calc(100vw - 24px));
  max-width: none;
}

.rename-dialog__article {
  display: grid;
  width: auto;
  height: auto;
  min-height: 0;
  gap: 16px;
}

.rename-dialog__body {
  overflow: visible;
}

.rename-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.rename-dialog__actions button {
  min-width: 96px;
  text-align: center;
}

.settings-dialog__section--spacious {
  padding-top: 18px;
}

.settings-dialog__article {
  display: grid;
  min-height: 0;
  gap: 14px;
}

.settings-dialog__body {
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  align-items: start;
}

.settings-dialog__body > .toast--dialog {
  grid-column: 1 / -1;
}

.settings-dialog__nav {
  grid-column: 1;
  grid-row: 2;
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 0;
}

.settings-dialog__tab-select-label {
  display: none;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.settings-dialog__tab-select {
  display: none;
  width: 100%;
  border: 1px solid color-mix(in srgb, var(--panel-border) 86%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface) 98%, transparent);
  color: var(--text);
  padding: 10px 12px;
}

.settings-dialog__tabs {
  display: grid;
  gap: 8px;
}

.settings-dialog__tab {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--panel-border) 88%, transparent);
  background: color-mix(in srgb, var(--surface) 98%, transparent);
  color: color-mix(in srgb, var(--text) 88%, var(--muted));
  text-align: left;
  font-size: 0.92rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    box-shadow 160ms ease,
    color 160ms ease;
}

.settings-dialog__tab.is-active {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 42%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent);
}

.settings-dialog__tab:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.settings-dialog__panels {
  grid-column: 2;
  grid-row: 2;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.settings-dialog__panel {
  display: grid;
  align-content: start;
  gap: 12px;
  height: 100%;
  min-height: 0;
  overflow: auto;
  padding: 4px 6px 22px 4px;
}

.settings-dialog__panel[hidden] {
  display: none;
}

.settings-dialog__section legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.settings-dialog__label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.settings-dialog__input {
  width: 100%;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
}

.settings-dialog__section--plain .settings-dialog__input {
  border-color: color-mix(in srgb, var(--panel-border) 82%, transparent);
}

.settings-dialog__input[type="range"] {
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  accent-color: var(--accent);
}

.settings-dialog__option {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}

.settings-dialog__theme-list {
  display: grid;
  gap: 6px;
}

.settings-dialog__theme-list-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px 72px;
  align-items: center;
  gap: 12px;
  padding: 0 12px 2px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.settings-dialog__theme-list-head > :nth-child(2),
.settings-dialog__theme-list-head > :nth-child(3) {
  text-align: center;
}

.settings-dialog__theme-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px 72px;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--panel-border) 82%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
}

.settings-dialog__theme-option.is-disabled {
  opacity: 0.62;
}

.settings-dialog__theme-option-main {
  display: flex;
  align-items: center;
  min-width: 0;
}

.settings-dialog__theme-option-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.settings-dialog__theme-option-title {
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
}

.settings-dialog__theme-option-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.settings-dialog__theme-option-control {
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-dialog__switch-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  margin: 0;
  cursor: pointer;
}

.settings-dialog__section--switch {
  display: block;
  cursor: pointer;
}

.settings-dialog__switch-copy {
  min-width: 0;
  display: grid;
  flex: 1 1 auto;
  gap: 8px;
}

.settings-dialog__switch-label {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text);
}

.settings-dialog__switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  min-width: 46px;
  height: 28px;
}

.settings-dialog__switch-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.settings-dialog__switch-ui {
  position: relative;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-soft) 72%, var(--surface));
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--panel-border) 90%, transparent),
    inset 0 10px 18px rgba(255, 255, 255, 0.05);
  transition:
    background-color 180ms ease,
    box-shadow 180ms ease;
}

.settings-dialog__switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.28),
    0 2px 8px rgba(15, 23, 42, 0.18);
  transition:
    transform 180ms ease,
    background-color 180ms ease;
}

.settings-dialog__switch-input:hover + .settings-dialog__switch-ui {
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--accent) 26%, var(--panel-border)),
    inset 0 10px 18px rgba(255, 255, 255, 0.05);
}

.settings-dialog__switch-input:checked + .settings-dialog__switch-ui {
  background: color-mix(in srgb, var(--accent) 82%, var(--surface) 18%);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--accent) 58%, transparent),
    0 0 0 3px color-mix(in srgb, var(--accent) 8%, transparent);
}

.settings-dialog__switch-input:checked:hover + .settings-dialog__switch-ui {
  background: color-mix(in srgb, var(--accent) 88%, var(--surface) 12%);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--accent) 72%, transparent),
    0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

.settings-dialog__switch-input:checked + .settings-dialog__switch-ui::after {
  transform: translateX(18px);
  background: color-mix(in srgb, var(--surface) 82%, white 18%);
}

.settings-dialog__switch-input:focus-visible + .settings-dialog__switch-ui {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.settings-dialog__switch-input:disabled + .settings-dialog__switch-ui {
  opacity: 0.45;
}

.settings-dialog__hint {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.settings-dialog__section--switch .settings-dialog__hint {
  margin: 0;
}

.settings-dialog__position-picker {
  display: grid;
}

.settings-dialog__position-screen {
  position: relative;
  min-height: 116px;
  border-radius: var(--radius-md);
  border: 1px dashed color-mix(in srgb, var(--panel-border) 86%, transparent);
  background: var(--surface-raised);
}

.settings-dialog__position-btn {
  position: absolute;
  z-index: 1;
  min-width: 82px;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  line-height: 1.2;
  color: var(--text);
  background: color-mix(in srgb, var(--panel) 84%, transparent);
  border: 1px solid color-mix(in srgb, var(--panel-border) 86%, transparent);
  backdrop-filter: blur(10px);
}

.settings-dialog__position-btn.is-active {
  background: color-mix(in srgb, var(--accent) 16%, var(--panel));
  border-color: color-mix(in srgb, var(--accent) 46%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent);
}

.settings-dialog__position-btn.is-unavailable,
.settings-dialog__position-btn:disabled {
  opacity: 0.42;
}

.settings-dialog__position-btn--top-left {
  top: 14px;
  left: 14px;
}

.settings-dialog__position-btn--top-right {
  top: 14px;
  right: 14px;
}

.settings-dialog__position-btn--bottom-left {
  bottom: 14px;
  left: 14px;
}

.settings-dialog__position-btn--bottom-right {
  right: 14px;
  bottom: 14px;
}

.settings-dialog__orientation {
  display: inline-flex;
  margin-top: 10px;
  gap: 8px;
  flex-wrap: wrap;
}

.settings-dialog__orientation-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 98px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--panel-border) 86%, transparent);
  background: color-mix(in srgb, var(--surface) 98%, transparent);
  color: var(--text);
}

.settings-dialog__orientation-btn .bi {
  font-size: 0.86rem;
  color: var(--muted);
}

.settings-dialog__orientation-btn.is-active {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 42%, transparent);
}

.settings-dialog__orientation-btn.is-active .bi {
  color: color-mix(in srgb, var(--text) 70%, var(--accent));
}

:root {
  --palette-sage-swatch: #a7d6ae;
  --palette-sky-swatch: #9ec9f0;
  --palette-amber-swatch: #edbf6a;
  --palette-rose-swatch: #e7a5b8;
  --palette-slate-swatch: #95a9c0;
  --palette-teal-swatch: #7ecac4;
  --palette-violet-swatch: #baa4ea;
  --palette-peach-swatch: #f0b79b;
  --palette-mint-swatch: #98ddb4;
  --palette-indigo-swatch: #9da8ea;
}

[data-theme="dark"] {
  --palette-sage-swatch: #3d7d52;
  --palette-sky-swatch: #3a6f9f;
  --palette-amber-swatch: #9a6a25;
  --palette-rose-swatch: #9d4d67;
  --palette-slate-swatch: #5d7189;
  --palette-teal-swatch: #2e7670;
  --palette-violet-swatch: #66529f;
  --palette-peach-swatch: #8d563f;
  --palette-mint-swatch: #3f7f5b;
  --palette-indigo-swatch: #4a5ca4;
}

@media (max-width: 720px) {
  .toolbar {
    left: 12px;
    right: 12px;
    transform: none;
    justify-content: center;
  }

  .workspace[data-toolbar-position="top-right"] .toolbar,
  .workspace[data-toolbar-position="bottom-left"] .toolbar,
  .workspace[data-toolbar-position="bottom-right"] .toolbar {
    top: auto;
    bottom: 12px;
    left: 12px;
    right: 12px;
    flex-direction: row;
    transform: none;
    align-items: center;
    justify-content: center;
  }

  .toolbar__group {
    flex-wrap: wrap;
    justify-content: center;
  }

  .toolbar__group + .toolbar__group {
    padding-left: 6px;
  }

  .workspace[data-toolbar-orientation="vertical"] .toolbar__group {
    flex-direction: row;
    padding: 0 2px;
  }

  .workspace[data-toolbar-orientation="vertical"]
    .toolbar__group
    + .toolbar__group {
    border-top: 0;
    border-left: 1px solid
      color-mix(in srgb, var(--panel-border) 78%, transparent);
    padding-top: 0;
    padding-left: 6px;
  }

  .workspace[data-toolbar-orientation="vertical"] .toolbar__popover {
    top: auto;
    bottom: calc(100% + 10px);
    left: 0;
    right: auto;
  }

  .toast {
    max-width: calc(100vw - 24px);
  }

  .workspace-meta {
    max-width: calc(100vw - 24px);
    gap: 8px;
    padding: 10px 12px;
  }

  .workspace[data-toast-position="top-left"] .toast,
  .workspace[data-toast-position="top-right"] .toast {
    top: 12px;
  }

  .workspace[data-toast-position="bottom-left"] .toast,
  .workspace[data-toast-position="bottom-right"] .toast {
    bottom: 12px;
  }

  .workspace[data-toast-position="top-left"] .toast,
  .workspace[data-toast-position="bottom-left"] .toast {
    left: 12px;
    right: auto;
  }

  .workspace[data-toast-position="top-right"] .toast,
  .workspace[data-toast-position="bottom-right"] .toast {
    right: 12px;
    left: auto;
  }

  .workspace[data-meta-position="top-left"] .workspace-meta,
  .workspace[data-meta-position="top-right"] .workspace-meta {
    top: 12px;
  }

  .workspace[data-meta-position="bottom-left"] .workspace-meta,
  .workspace[data-meta-position="bottom-right"] .workspace-meta {
    bottom: 12px;
  }

  .workspace[data-meta-position="top-left"] .workspace-meta,
  .workspace[data-meta-position="bottom-left"] .workspace-meta {
    left: 12px;
    right: auto;
  }

  .workspace[data-meta-position="top-right"] .workspace-meta,
  .workspace[data-meta-position="bottom-right"] .workspace-meta {
    right: 12px;
    left: auto;
  }

  .app-dialog__article {
    padding: 14px;
    gap: 14px;
  }

  .settings-dialog__body {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .settings-dialog__nav,
  .settings-dialog__panels {
    grid-column: 1;
    grid-row: auto;
  }

  .settings-dialog__tab-select-label,
  .settings-dialog__tab-select {
    display: block;
  }

  .settings-dialog__tabs {
    display: none;
  }

  .settings-dialog__theme-list-head,
  .settings-dialog__theme-option {
    grid-template-columns: minmax(0, 1fr) 56px 64px;
    gap: 10px;
  }

  .shortcuts-dialog__item,
  .about-dialog__shortcut-list li {
    grid-template-columns: 1fr;
  }

  .shortcuts-dialog__item {
    padding: 14px;
  }
}

@keyframes edge-twang {
  0% {
    stroke-width: 4.5;
  }
  55% {
    stroke-width: 1.6;
  }
  100% {
    stroke-width: 2;
  }
}

/* ── Context menu ──────────────────────────────────────────────────── */

.context-menu__backdrop {
  position: fixed;
  inset: 0;
  z-index: 9998;
}

.context-menu__backdrop[hidden] {
  display: none;
}

.context-menu {
  position: fixed;
  z-index: 9999;
  min-width: 192px;
  max-width: 280px;
  padding: 6px;
  border-radius: var(--radius-md);
  background: var(--toolbar-bg);
  border: 1px solid color-mix(in srgb, var(--panel-border) 72%, transparent);
  backdrop-filter: blur(18px) saturate(1.1);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
  box-shadow:
    0 8px 30px rgba(15, 23, 42, 0.14),
    0 1.5px 4px rgba(15, 23, 42, 0.06);
  animation: context-menu-in 120ms ease-out both;
  pointer-events: auto;
  user-select: none;
}

.context-menu[hidden] {
  display: none;
}

@keyframes context-menu-in {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(-4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.context-menu__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.context-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.835rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  outline: none;
  transition:
    background 80ms ease,
    color 80ms ease;
}

.context-menu__item:hover,
.context-menu__item--focused {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
}

.context-menu__item:active {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.context-menu__item--disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.context-menu__item--disabled:hover,
.context-menu__item--disabled.context-menu__item--focused {
  background: transparent;
  color: var(--text);
}

.context-menu__icon {
  flex-shrink: 0;
  font-size: 1rem;
  width: 18px;
  text-align: center;
  opacity: 0.82;
}

.context-menu__item:hover .context-menu__icon,
.context-menu__item--focused .context-menu__icon {
  opacity: 1;
}

.context-menu__label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.context-menu__shortcut {
  flex-shrink: 0;
  margin-left: auto;
  padding-left: 16px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  opacity: 0.7;
}

.context-menu__separator {
  height: 1px;
  margin: 5px 8px;
  background: color-mix(in srgb, var(--panel-border) 60%, transparent);
}
