@font-face {
  font-family: 'Geist Sans';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('fonts/Geist.woff2') format('woff2');
}
:root {
  --canvas-bg: rgb(224, 224, 227);
  --canvas-bg-dark: #1c1b22;
  --firefox-menu-bg: #42414d;
  --firefox-menu-border: #777681;
  --firefox-menu-text: #fbfbfe;
  --firefox-menu-hover-bg: #5b5a66;
  --firefox-menu-active-bg: #646370;
  --firefox-menu-separator: #5b5a66;
  --firefox-menu-shadow:
    0 8px 24px rgba(0,0,0,0.32),
    0 0 0 1px rgba(0,0,0,0.10);
  --menu-shell-radius: 8px;
  --menu-shell-padding: 8px;
  --menu-item-height: 32px;
  --menu-item-padding: 0 8px;
  --menu-item-radius: 4px;
  --menu-item-font-size: 13px;
  --menu-item-font-weight: 500;
  --menu-item-letter-spacing: 0;
  --menu-item-line-height: 32px;
  --context-menu-width: 228px;
  --eyedropper-loupe-width: 228px;
  --eyedropper-card-base-z: 99990;
  --window-titlebar-height: 28px;
  --window-titlebar-z: 99991;
  --window-control-width: 48px;
  --window-control-radius: 6px;
  --window-control-icon-size: 18px;
  --window-titlebar-bg: transparent;
  --window-control-bg: transparent;
  --window-control-separator: transparent;
  --window-control-fg: rgba(17, 20, 24, 0.78);
  --window-control-accent: rgba(17, 20, 24, 0.28);
  --window-control-hover-bg: rgba(17, 20, 24, 0.08);
  --window-control-press-bg: rgba(17, 20, 24, 0.14);
  --window-control-close-hover-bg: rgba(232, 17, 35, 0.82);
  --canvas-text: #111418;
  --dialog-overlay-bg: rgba(0,0,0,0.18);
  --selection-handle-bg: #f8fafc;
  --selection-handle-shadow: 0 1px 3px rgba(0,0,0,0.28);
  --menu-active-bg: var(--firefox-menu-active-bg);
}

body[data-theme="dark"] {
  --canvas-bg: var(--canvas-bg-dark);
  --canvas-text: #fbfbfe;
  --window-control-fg: rgba(251, 251, 254, 0.88);
  --window-control-accent: rgba(251, 251, 254, 0.32);
  --window-control-hover-bg: rgba(251, 251, 254, 0.10);
  --window-control-press-bg: rgba(251, 251, 254, 0.16);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

button {
  outline: none;
}
button:focus,
button:focus-visible {
  outline: none;
}
button::-moz-focus-inner {
  border: 0;
}

html {
  overscroll-behavior: none;
  touch-action: none;
}

body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--canvas-bg);
  user-select: none;
  overscroll-behavior: none;
  touch-action: none;
  font-family: 'Geist Sans', system-ui;
}

#canvas {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: clip;
  contain: paint;
  background: var(--canvas-bg);
  overscroll-behavior: none;
  touch-action: none;
}

#canvas.panning    { cursor: grabbing !important; }
#canvas.panning    * { cursor: grabbing !important; }

body.eyedropper-hold-active,
body.eyedropper-hold-active * {
  cursor: none !important;
}

#board-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: block;
  z-index: 0;
  touch-action: none;
}

#file-input {
  display: none;
}

#mac-titlebar {
  display: none;
}

#windows-titlebar {
  display: none;
}

#windows-titlebar-controls {
  display: none;
}

body.is-macos #mac-titlebar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9001;
  pointer-events: auto;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}

body.is-windows #windows-titlebar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--window-titlebar-height);
  display: block;
  z-index: 9001;
  pointer-events: none;
  background: var(--window-titlebar-bg);
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}

#windows-titlebar-drag {
  position: absolute;
  inset: 0 calc(var(--window-control-width) * 3) 0 0;
  height: var(--window-titlebar-height);
  pointer-events: auto;
  cursor: default;
}

#windows-titlebar-controls {
  position: fixed;
  top: 0;
  right: 0;
  align-items: stretch;
  width: calc(var(--window-control-width) * 3);
  height: var(--window-titlebar-height);
  z-index: var(--window-titlebar-z);
  margin-left: auto;
  flex: 0 0 auto;
  pointer-events: auto;
}

body.is-windows #windows-titlebar-controls {
  display: flex;
}

.window-control {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--window-control-width);
  height: var(--window-titlebar-height);
  min-width: var(--window-control-width);
  padding: 0;
  color: var(--window-control-fg);
  background: var(--window-control-bg);
  border: 0;
  border-left: 0;
  border-radius: 0 0 var(--window-control-radius) var(--window-control-radius);
  box-shadow: none;
  cursor: default;
  appearance: none;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.window-control::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid transparent;
  border-top-width: 1px;
  border-bottom-left-radius: var(--window-control-radius);
  border-bottom-right-radius: var(--window-control-radius);
  pointer-events: none;
}

.window-control:hover {
  background: var(--window-control-hover-bg);
}

.window-control:hover::after {
  border-color: var(--window-control-accent);
}

.window-control:active {
  background: var(--window-control-press-bg);
}

.window-control-close:hover,
body[data-theme="dark"] .window-control-close:hover {
  background: var(--window-control-close-hover-bg);
}

.window-control-close:hover::after,
body[data-theme="dark"] .window-control-close:hover::after {
  border-color: rgba(255, 255, 255, 0.22);
}

.window-control-close:active,
body[data-theme="dark"] .window-control-close:active {
  color: #ffffff;
  background: #c50f1f;
}

.window-control-icon {
  position: relative;
  display: block;
  width: var(--window-control-icon-size);
  height: var(--window-control-icon-size);
  pointer-events: none;
}

.window-control-minimize .window-control-icon::before {
  content: "";
  position: absolute;
  left: 5px;
  right: 5px;
  top: 8px;
  height: 3px;
  border-radius: 2px;
  background: currentColor;
}

.window-control-maximize .window-control-icon::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 3px solid currentColor;
  border-radius: 1px;
}

.window-control-close .window-control-icon::before,
.window-control-close .window-control-icon::after {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  width: var(--window-control-icon-size);
  height: 3px;
  border-radius: 2px;
  background: currentColor;
  transform-origin: center;
}

.window-control-close .window-control-icon::before {
  transform: rotate(45deg);
}

.window-control-close .window-control-icon::after {
  transform: rotate(-45deg);
}

/* ── Selection overlay ── */
#sel-overlay {
  position: absolute;
  top: 0; left: 0;
  display: none;
  box-sizing: border-box;
  border: 0;
  box-shadow: inset 0 0 0 1px rgba(10, 132, 255, 0.9);
  pointer-events: none;
  z-index: 99998;
}
#sel-overlay.visible { display: block; }
#sel-overlay.multi {
  border: 1px dashed rgba(10, 132, 255, 0.9);
  box-shadow: none;
}
#sel-overlay.editing .s-handle { display: none; }
#sel-overlay .s-handle[data-dir="w"],
#sel-overlay .s-handle[data-dir="e"] { display: none; }
#sel-overlay.text-resize .s-handle[data-dir="nw"],
#sel-overlay.text-resize .s-handle[data-dir="ne"],
#sel-overlay.text-resize .s-handle[data-dir="sw"],
#sel-overlay.text-resize .s-handle[data-dir="se"] { display: none; }
#sel-overlay.text-resize .s-handle[data-dir="w"],
#sel-overlay.text-resize .s-handle[data-dir="e"] { display: block; }
.s-handle {
  position: absolute;
  width: 7px;
  height: 7px;
  background: var(--selection-handle-bg);
  border-radius: 1px;
  box-shadow: var(--selection-handle-shadow);
  pointer-events: all;
}
.s-handle[data-dir="nw"] { top: -4px;    left: -4px;   cursor: nw-resize; }
.s-handle[data-dir="ne"] { top: -4px;    right: -4px;  cursor: ne-resize; }
.s-handle[data-dir="sw"] { bottom: -4px; left: -4px;   cursor: sw-resize; }
.s-handle[data-dir="se"] { bottom: -4px; right: -4px;  cursor: se-resize; }
.s-handle[data-dir="w"]  { top: 50%; left: -4px; transform: translateY(-50%); cursor: ew-resize; }
.s-handle[data-dir="e"]  { top: 50%; right: -4px; transform: translateY(-50%); cursor: ew-resize; }

#multi-sel-overlay {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
  z-index: 99997;
}
#multi-sel-overlay.visible { display: block; }
.multi-sel-box {
  position: absolute;
  box-sizing: border-box;
  box-shadow: inset 0 0 0 1px rgba(10, 132, 255, 0.9);
  pointer-events: none;
}

/* ── Context menu ── */
#ctx-menu,
#obj-ctx-menu,
#ctx-actions,
#eyedropper-loupe,
.eyedropper-loupe,
#dialog,
#island,
.opening-shield-pill {
  background: var(--firefox-menu-bg);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: 1px solid var(--firefox-menu-border);
  border-radius: var(--menu-shell-radius);
  box-shadow: var(--firefox-menu-shadow);
  color: var(--firefox-menu-text);
  font-family: inherit;
  padding: var(--menu-shell-padding);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

#ctx-menu,
#obj-ctx-menu,
#ctx-actions {
  position: fixed;
  clip-path: none;
  filter: none;
  z-index: 99999;
  display: none;
  isolation: isolate;
  transform: translateZ(0);
  -webkit-mask-image: -webkit-radial-gradient(white, black);
  mask-image: radial-gradient(white, black);
}

#ctx-menu {
  width: var(--context-menu-width);
  max-width: calc(100vw - 24px);
}

#obj-ctx-menu {
  width: 200px;
  max-width: calc(100vw - 24px);
}

#ctx-menu.visible,
#obj-ctx-menu.visible,
#ctx-actions.visible { display: block; }

#ctx-menu *,
#obj-ctx-menu *,
#ctx-actions * {
  user-select: none;
  -webkit-user-select: none;
}

#ctx-actions {
  display: none;
  width: calc(var(--menu-item-height) + (var(--menu-shell-padding) * 2) + 2px);
  max-width: calc(100vw - 24px);
  box-sizing: border-box;
}

#ctx-actions.visible {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.ctx-action-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: var(--menu-item-height);
  width: var(--menu-item-height);
  height: var(--menu-item-height);
  padding: 0;
  font-family: inherit;
  font-size: var(--menu-item-font-size);
  font-weight: var(--menu-item-font-weight);
  line-height: var(--menu-item-line-height);
  color: var(--firefox-menu-text);
  background: transparent;
  border: 0;
  border-radius: var(--menu-item-radius);
  box-shadow: none;
  cursor: default;
  letter-spacing: var(--menu-item-letter-spacing);
  -webkit-font-smoothing: antialiased;
  white-space: nowrap;
  text-align: left;
  isolation: isolate;
  contain: paint;
  overflow: hidden;
  text-decoration: none;
}
.ctx-action-item::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--menu-item-radius);
  background: transparent;
  pointer-events: none;
  z-index: 0;
}
.ctx-action-item.hotspot-hover::before { background: var(--firefox-menu-hover-bg); }
.ctx-action-item.hotspot-active::before,
.ctx-action-item[aria-pressed="true"]::before { background: var(--menu-active-bg); }
.ctx-action-icon {
  min-width: var(--menu-item-height);
  width: var(--menu-item-height);
}
.ctx-action-icon::before {
  left: 0;
  right: 0;
  width: auto;
  transform: none;
}
.ctx-action-icon .material-symbols-outlined,
.ctx-action-icon svg {
  position: relative;
  z-index: 1;
  display: block;
  width: 20px;
  height: 20px;
}
.ctx-action-icon svg {
  fill: currentColor;
}
.ctx-action-icon .material-symbols-outlined {
  font-size: 20px;
  line-height: 20px;
  font-variation-settings:
    'FILL' 0,
    'wght' 400,
    'GRAD' 0,
    'opsz' 24;
  pointer-events: none;
  contain: paint;
  transform: translateZ(0);
}

.ctx-action-sep {
  width: 100%;
}

.ctx-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 18px;
  align-items: center;
  width: 100%;
  height: var(--menu-item-height);
  padding: var(--menu-item-padding);
  font-family: inherit;
  font-size: var(--menu-item-font-size);
  font-weight: var(--menu-item-font-weight);
  line-height: var(--menu-item-line-height);
  color: var(--firefox-menu-text);
  background: transparent;
  border: none;
  border-radius: var(--menu-item-radius);
  text-align: left;
  cursor: default;
  letter-spacing: var(--menu-item-letter-spacing);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: none;
  transform: translateY(0);
}
.ctx-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ctx-shortcut {
  color: rgba(251,251,254,0.72);
  font-size: inherit;
  font-weight: 400;
  justify-self: end;
  white-space: nowrap;
}
.ctx-item:hover {
  background: var(--firefox-menu-hover-bg);
  box-shadow: none;
  color: var(--firefox-menu-text);
}
.ctx-item:active {
  background: var(--menu-active-bg);
}
.ctx-item:disabled,
.ctx-item[aria-disabled="true"] {
  opacity: 0.42;
  pointer-events: none;
}
.ctx-sep {
  height: 1px;
  background: var(--firefox-menu-separator);
  margin: 8px 0;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Island ── */
#island {
  position: fixed;
  bottom: 5%;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  z-index: 9000;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}

.opening-shield-pill {
  position: fixed;
  bottom: 5%;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  z-index: 100000;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}

#island,
#island *,
.opening-shield-pill,
.opening-shield-pill * {
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#island.visible,
.opening-shield-pill.visible {
  display: flex;
}

#isl-zoom {
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  min-height: var(--menu-item-height);
  padding: var(--menu-item-padding);
  font-family: inherit;
  font-size: var(--menu-item-font-size);
  font-weight: var(--menu-item-font-weight);
  line-height: 18px;
  color: var(--firefox-menu-text);
  background: transparent;
  border-radius: var(--menu-item-radius);
  letter-spacing: var(--menu-item-letter-spacing);
  -webkit-font-smoothing: antialiased;
  white-space: normal;
  min-width: 44px;
  max-width: min(680px, calc(100vw - 56px));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-sizing: border-box;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  pointer-events: none;
}

.opening-shield-pill-text {
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  min-height: var(--menu-item-height);
  padding: var(--menu-item-padding);
  font-family: inherit;
  font-size: var(--menu-item-font-size);
  font-weight: var(--menu-item-font-weight);
  line-height: 18px;
  color: var(--firefox-menu-text);
  background: transparent;
  border-radius: var(--menu-item-radius);
  letter-spacing: var(--menu-item-letter-spacing);
  -webkit-font-smoothing: antialiased;
  white-space: normal;
  min-width: 44px;
  max-width: min(680px, calc(100vw - 56px));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-sizing: border-box;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  pointer-events: none;
}

#eyedropper-loupe,
.eyedropper-loupe {
  position: fixed;
  top: 0;
  left: 0;
  display: none;
  width: var(--eyedropper-loupe-width);
  max-width: calc(100vw - 24px);
  z-index: var(--eyedropper-card-base-z);
  pointer-events: auto;
  font-size: var(--menu-item-font-size);
  font-weight: var(--menu-item-font-weight);
  letter-spacing: var(--menu-item-letter-spacing);
  -webkit-font-smoothing: antialiased;
}
#eyedropper-loupe.visible,
.eyedropper-loupe.visible { display: block; }
#eyedropper-loupe.pinned,
#eyedropper-loupe.dragging,
.eyedropper-loupe.pinned,
.eyedropper-loupe.dragging { cursor: pointer; }
#eyedropper-loupe.pinned *,
#eyedropper-loupe.dragging *,
.eyedropper-loupe.pinned *,
.eyedropper-loupe.dragging * { cursor: pointer; }
#eyedropper-top,
.eyedropper-top {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  height: auto;
  margin: calc(var(--menu-shell-padding) * -1) calc(var(--menu-shell-padding) * -1) 0;
}
#eyedropper-preview,
.eyedropper-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 0;
  border: 0;
  outline: 0;
  box-shadow: none;
  overflow: hidden;
  background: var(--canvas-bg);
}
#eyedropper-canvas,
.eyedropper-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}
#eyedropper-values,
.eyedropper-values {
  --eyedropper-readout-height: calc((var(--menu-item-height) * 2) + (var(--menu-shell-padding) * 2));
  position: relative;
  width: calc(100% + (var(--menu-shell-padding) * 2));
  display: grid;
  grid-template-columns: max-content minmax(var(--eyedropper-readout-height), 1fr);
  grid-template-rows: var(--menu-shell-padding) repeat(2, var(--menu-item-height)) var(--menu-shell-padding);
  column-gap: 0;
  row-gap: 0;
  margin: 0 calc(var(--menu-shell-padding) * -1) calc(var(--menu-shell-padding) * -1);
  padding: 0;
  background: var(--firefox-menu-bg);
  box-shadow: none;
}
#eyedropper-values::before,
.eyedropper-values::before {
  content: "RGB: 255 255 255";
  grid-column: 1;
  grid-row: 2;
  padding: 0 16px;
  font: inherit;
  line-height: var(--menu-item-line-height);
  white-space: nowrap;
  visibility: hidden;
}
.eyedropper-value-row {
  grid-column: 1;
  width: auto;
  display: flex;
  align-items: center;
  padding: 0 16px;
}
.eyedropper-hex-row {
  grid-row: 2;
}
.eyedropper-value-row:not(.eyedropper-hex-row) {
  grid-row: 3;
}
.eyedropper-value-row:hover,
.eyedropper-value-row:active {
  background: transparent;
}
.eyedropper-value-text {
  min-width: 0;
  white-space: nowrap;
}
#eyedropper-swatch,
.eyedropper-swatch {
  display: block;
  grid-column: 2;
  grid-row: 1 / -1;
  width: auto;
  height: auto;
  border-radius: 0;
  border: 0;
  outline: 0;
  box-shadow: none;
  background: transparent;
}
.material-symbols-outlined {
  font-variation-settings:
    'FILL' 0,
    'wght' 400,
    'GRAD' 0,
    'opsz' 24;
}



#opening-shield {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99998;
  cursor: default;
}
#opening-shield.active { display: block; }
#opening-shield.opening-freeze {
  overflow: hidden;
  background: var(--canvas-bg);
}
#opening-shield.opening-freeze *,
#opening-shield.opening-freeze *::before,
#opening-shield.opening-freeze *::after {
  animation: none !important;
  transition: none !important;
}
.opening-freeze-canvas {
  position: absolute;
  display: block;
}
.opening-freeze-card {
  pointer-events: none !important;
}

#rubber-band {
  display: none;
  position: fixed;
  border: 1px solid rgba(10, 132, 255, 0.9);
  background: transparent;
  pointer-events: none;
  z-index: 8000;
}

/* ── Unsaved changes dialog ── */
#dialog-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--dialog-overlay-bg);
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  z-index: 9999999;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
}
#dialog-overlay.show { display: flex; }
#dialog-overlay * {
  user-select: none;
  -webkit-user-select: none;
}

#dialog {
  position: relative;
  width: 250px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

#dialog-body {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
}

#dialog-title {
  pointer-events: none;
}

#dialog-btns {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0;
}

#dlg-right {
  display: flex;
  gap: 4px;
}

#dialog-btns .dialog-action {
  width: auto;
  display: inline-flex;
  justify-content: center;
  text-align: center;
}

#dlg-discard {
  background: rgba(255, 69, 58, 0.18);
  color: #FF453A;
}
#dlg-discard:hover {
  background: rgba(255, 69, 58, 0.26);
}
#dlg-discard:active {
  background: rgba(255, 69, 58, 0.34);
}
