.canvas {
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
  transition: background .35s;
}

.toolbar-item {
  position: absolute;
  z-index: 200;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid rgba(160,152,128,.45);
  background: rgba(245,240,232,.28);
  backdrop-filter: blur(14px) saturate(1.5);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  user-select: none;
  -webkit-user-select: none;
  transition: transform .2s, background .2s;
  font-family: 'Windows', monospace;
  will-change: transform;
  contain: layout style;
}
.toolbar-item:active { cursor: grabbing; }
.toolbar-item:hover  { transform: scale(1.12); background: rgba(245,240,232,.46); }

:root.dark .toolbar-item {
  background: rgba(26,23,20,.28);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border-color: rgba(107,95,74,.4);
}
:root.dark .toolbar-item:hover { background: rgba(26,23,20,.48); }

.site-label {
  position: absolute;
  z-index: 200;
  font-family: 'Windows', monospace;
  font-size: 9px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  background: rgba(245,240,232,.72);
  backdrop-filter: blur(14px) saturate(1.5);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
  border: 1.5px solid rgba(160,152,128,.45);
  border-radius: 20px;
  padding: 0 12px;
  height: 34px;
  display: flex;
  align-items: center;
  transition: background .2s, transform .2s;
  will-change: transform;
  contain: layout style;
}
.site-label:active { cursor: grabbing; }
.site-label:hover  { background: rgba(245,240,232,.88); }

:root.dark .site-label {
  color: var(--ink);
  background: rgba(26,23,20,.72);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border-color: rgba(107,95,74,.4);
}
:root.dark .site-label:hover { background: rgba(26,23,20,.88); }

.tooltip {
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  background: #2c2416;
  color: #f5f0e8;
  font-size: 10px;
  font-family: 'Windows', monospace;
  padding: 5px 9px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
  z-index: 300;
}
.tooltip::after {
  content: '';
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: #2c2416;
}
.tooltip--down {
  bottom: auto;
  top: calc(100% + 7px);
}
.tooltip--down::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: #2c2416;
}
.node:hover         .tooltip { opacity: 1; }
.toolbar-item:hover .tooltip { opacity: 1; }
.site-label:hover   .tooltip { opacity: 1; }

.node {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  /* translate3d instead of translateY → forces GPU compositing path */
  transition: transform var(--transition), opacity var(--transition);
  z-index: 3;
  will-change: transform;
  contain: layout style;
}
.node:active { cursor: grabbing; }
.node:hover  { transform: translate3d(0, -3px, 0) scale(1.06); z-index: 5; }

.node__icon {
  border-radius: var(--radius);
  border: 1.5px solid rgba(160,152,128,.5);
  background: rgba(245,240,232,.28);
  backdrop-filter: blur(14px) saturate(1.5);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  overflow: hidden;
  transition: box-shadow var(--transition), background .35s, border-color .35s;
  flex-shrink: 0;
}
:root.dark .node__icon {
  background: rgba(26,23,20,.30);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border-color: rgba(107,95,74,.45);
}
.node:hover .node__icon {
  box-shadow: 0 8px 28px rgba(0,0,0,.18);
  background: rgba(245,240,232,.44);
}
:root.dark .node:hover .node__icon {
  background: rgba(26,23,20,.46);
}

.node__icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.node__icon span {
  font-size: inherit;
  line-height: 1;
}

.node__label {
  font-family: 'Windows', monospace;
  font-size: inherit;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink);
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  transition: color .35s, background .35s;
  background: rgba(245,240,232,.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 2px 7px 3px;
  border-radius: 20px;
  border: 1px solid rgba(160,152,128,.3);
}
:root.dark .node__label {
  color: var(--ink);
  background: rgba(20,18,14,.70);
  border-color: rgba(107,95,74,.35);
}

.node--big    .node__icon  { width: 96px;  height: 96px;  border-radius: 22px; border-width: 2px; }
.node--big    .node__icon span { font-size: 46px; }
.node--big    .node__label { font-size: 11px; }

.node--medium .node__icon  { width: 64px;  height: 64px;  border-radius: 15px; }
.node--medium .node__icon span { font-size: 30px; }
.node--medium .node__label { font-size: 9.5px; }

.node--small  .node__icon  { width: 42px;  height: 42px;  border-radius: 10px; border-width: 1px; }
.node--small  .node__icon span { font-size: 20px; }
.node--small  .node__label { font-size: 8.5px; }

.node--sky      .node__icon { background: rgba(232,244,252,.28); border-color: rgba(45,122,172,.45); }
.node--lavender .node__icon { background: rgba(242,238,250,.28); border-color: rgba(112,64,176,.45); }
.node--green    .node__icon { background: rgba(220,245,220,.28); border-color: rgba(60,140,60,.45); }
:root.dark .node--sky      .node__icon { background: rgba(16,32,46,.30);  border-color: rgba(90,171,220,.4); }
:root.dark .node--lavender .node__icon { background: rgba(30,20,48,.30);  border-color: rgba(160,112,224,.4); }
:root.dark .node--green    .node__icon { background: rgba(20,40,20,.30);  border-color: rgba(80,180,80,.4); }
.node--sky:hover      .node__icon { background: rgba(232,244,252,.46); }
.node--lavender:hover .node__icon { background: rgba(242,238,250,.46); }
.node--green:hover    .node__icon { background: rgba(220,245,220,.46); }
:root.dark .node--sky:hover      .node__icon { background: rgba(16,32,46,.48); }
:root.dark .node--lavender:hover .node__icon { background: rgba(30,20,48,.48); }
:root.dark .node--green:hover    .node__icon { background: rgba(20,40,20,.48); }
.node--yellow    .node__icon { background: rgba(244,245,220,.28); border-color: rgba(139,140,60,.45); }
:root.dark .node--yellow .node__icon { background: rgba(40,40,20,.3);  border-color: rgba(180,180,80,.4); }
.node--yellow:hover    .node__icon { background: rgba(245,245,220,.46); }
:root.dark .node--yellow:hover .node__icon { background: rgba(40,40,20,.48); }

.node--disabled {
  cursor: not-allowed;
  opacity: .45;
  pointer-events: all;
}
.node--disabled:hover { transform: none; }
.node--disabled .node__icon { box-shadow: none !important; }

.page-backdrop {
  position: fixed; inset: 0;
  background: var(--backdrop);
  z-index: 99; opacity: 0; pointer-events: none;
  transition: opacity .4s ease;
  backdrop-filter: blur(4px);
  will-change: opacity;
}
.page-backdrop--visible { opacity: 1; pointer-events: all; }

.page-close {
  position: fixed; top: 18px; right: 22px; z-index: 201;
  background: rgba(245,240,232,.92); border: 1px solid var(--seedling-border);
  border-radius: 50%; width: 38px; height: 38px;
  cursor: pointer; font-size: 17px;
  display: none; align-items: center; justify-content: center;
  transition: all .2s; backdrop-filter: blur(8px); font-family: sans-serif;
  will-change: transform;
}
.page-close--visible { display: flex; }
.page-close:hover { transform: scale(1.1); }

.page-overlay { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.page-inner   {
  position: absolute; overflow: hidden;
  box-shadow: 0 25px 70px rgba(0,0,0,.3);
  will-change: transform, opacity, left, top, width, height;
  contain: layout;
}
.page-frame   { width: 100%; height: 100%; border: none; display: block; }

#bgFileInput { display: none; }

[data-perf="mid"] .toolbar-item,
[data-perf="mid"] .site-label {
  backdrop-filter: blur(7px) saturate(1.5);
  -webkit-backdrop-filter: blur(7px) saturate(1.5);
}
[data-perf="mid"] .node__icon {
  backdrop-filter: blur(7px) saturate(1.5);
  -webkit-backdrop-filter: blur(7px) saturate(1.5);
}
[data-perf="mid"] .node__label {
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
[data-perf="mid"] .page-backdrop {
  backdrop-filter: blur(2px);
}
[data-perf="mid"] .page-close {
  backdrop-filter: blur(4px);
}

[data-perf="low"] .toolbar-item,
[data-perf="low"] .site-label,
[data-perf="low"] .node__icon,
[data-perf="low"] .node__label,
[data-perf="low"] .page-backdrop,
[data-perf="low"] .page-close {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

[data-perf="low"] .toolbar-item {
  background: rgba(245,240,232,.90);
}
[data-perf="low"] .node__icon {
  background: rgba(245,240,232,.92);
}
[data-perf="low"] .node__label {
  background: rgba(245,240,232,.95);
}
[data-perf="low"] .page-close {
  background: rgba(245,240,232,.98);
}
[data-perf="low"] .site-label {
  background: rgba(245,240,232,.92);
}

:root.dark [data-perf="low"] .toolbar-item  { background: rgba(26,23,20,.92); }
:root.dark [data-perf="low"] .node__icon    { background: rgba(26,23,20,.92); }
:root.dark [data-perf="low"] .node__label   { background: rgba(20,18,14,.95); }
:root.dark [data-perf="low"] .page-close    { background: rgba(26,23,20,.98); }
:root.dark [data-perf="low"] .site-label    { background: rgba(26,23,20,.92); }

[data-perf="low"] .node:hover {
  transform: none;
  z-index: 5;
}
[data-perf="low"] .node:hover .node__icon {
  box-shadow: none;
}
[data-perf="low"] .toolbar-item:hover {
  transform: none;
}

[data-perf="low"] .page-backdrop {
  background: rgba(44,36,22,.70);
}
:root.dark [data-perf="low"] .page-backdrop {
  background: rgba(0,0,0,.80);
}

[data-perf="low"] .node,
[data-perf="low"] .toolbar-item,
[data-perf="low"] .site-label,
[data-perf="low"] .page-close,
[data-perf="mid"] .node__label {
  will-change: auto;
}