:root {
  color-scheme: light dark;
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --text: #172033;
  --muted: #667085;
  --line: #d4dbe7;
  --primary: #2563eb;
  --primary-weak: rgba(37, 99, 235, 0.16);
  --danger: #b93815;
  --canvas-bg: #ffffff;
  --grid-major: rgba(71, 84, 103, 0.17);
  --grid-minor: rgba(71, 84, 103, 0.07);
  --shape-bg: #ffffff;
  --shape-border: #344054;
  --connector: #344054;
  --shadow: 0 16px 42px rgba(31, 41, 55, 0.14);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111827;
    --surface: #1f2937;
    --surface-soft: #263244;
    --text: #f3f4f6;
    --muted: #b6c0cf;
    --line: #3a4658;
    --primary: #60a5fa;
    --primary-weak: rgba(96, 165, 250, 0.2);
    --danger: #fb923c;
    --canvas-bg: #ffffff;
    --shape-bg: #ffffff;
    --shape-border: #344054;
    --connector: #344054;
  }
}

* { box-sizing: border-box; }

html,
body {
  height: 100%;
  margin: 0;
}

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

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

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 1160px;
}

.topbar,
.commandbar,
.canvas-header,
.toolbar,
.properties-panel {
  background: var(--surface);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 58px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 148px;
  font-weight: 750;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(79, 140, 255, 0.12);
  color: #ffffff;
  overflow: hidden;
  border: 1px solid rgba(79, 140, 255, 0.22);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.workflow-controls,
.commandbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.workflow-controls {
  justify-content: flex-end;
  flex: 1;
}

.workflow-controls input {
  width: min(320px, 28vw);
}

.workflow-controls select {
  width: min(250px, 22vw);
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
}

input,
select {
  height: 34px;
  padding: 0 9px;
}

textarea {
  min-height: 84px;
  padding: 8px;
  resize: vertical;
}

.workflow-controls button,
.commandbar button,
.tool-button,
.format-buttons button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 7px 10px;
}

.commandbar button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.workflow-controls button:hover,
.commandbar button:hover,
.tool-button:hover,
.format-buttons button:hover {
  border-color: var(--primary);
}

.commandbar {
  height: 44px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.commandbar .divider {
  width: 1px;
  height: 24px;
  margin: 0 3px;
  background: var(--line);
  flex: 0 0 auto;
}

.inline-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.inline-control select {
  width: 126px;
}

.inline-control.checkbox input {
  width: auto;
  height: auto;
}

.main-layout {
  display: flex;
  min-height: 0;
  flex: 1;
}

.toolbar {
  width: 214px;
  padding: 12px;
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.toolbar-section {
  display: grid;
  gap: 7px;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.toolbar-section:last-child {
  border-bottom: 0;
  margin-bottom: 0;
}

.compact-tools {
  grid-template-columns: 1fr 1fr;
}

.compact-tools .tool-button {
  text-align: center;
  padding-inline: 4px;
}

.section-title {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.tool-button {
  width: 100%;
  text-align: left;
}

.tool-select {
  width: 100%;
  min-height: 34px;
}

.tool-button.active,
.format-buttons button.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.tool-button.danger {
  color: var(--danger);
}

.zoom-readout {
  display: grid;
  place-items: center;
  height: 28px;
  color: var(--muted);
  font-size: 13px;
}

.workspace-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  flex: 1;
}

.canvas-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}

.page-tabs {
  display: flex;
  flex: 1 1 280px;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
}

.page-tab {
  min-width: 86px;
  max-width: 170px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 6px 10px;
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-tab.active {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary);
}

.page-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.page-actions button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 6px 8px;
  font-size: 12px;
}

.status-text {
  flex: 0 0 100%;
  color: var(--muted);
  font-size: 13px;
}

.canvas-viewport {
  position: relative;
  min-width: 0;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  background: #dce3ed;
  cursor: default;
}

.canvas-viewport.pan-ready {
  cursor: grab;
}

.canvas-viewport.panning {
  cursor: grabbing;
}

.canvas-plane {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}

.canvas-content {
  position: relative;
  width: 20000px;
  height: 20000px;
  overflow: hidden;
  background-color: var(--canvas-bg);
  background-image:
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid-minor) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px);
  background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
  box-shadow: var(--shadow);
}

.canvas-content.grid-off {
  background-image: none;
}

.matrix-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: auto;
}

/* ── Premium Matrix Frame ── */
.matrix-frame {
  position: absolute;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 16px;
  background: rgba(248, 250, 252, 0.04);
  overflow: visible;
  box-shadow: 0 0 0 1px rgba(148, 163, 184, 0.06);
}

.matrix-stage-header,
.matrix-lane-header,
.matrix-corner,
.matrix-cell {
  position: absolute;
}

/* ── Corner Cell ── */
.matrix-corner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(12px);
  color: #94A3B8;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 14px 0 0 0;
  border-right: 1px solid rgba(148, 163, 184, 0.10);
  border-bottom: 1px solid rgba(148, 163, 184, 0.10);
}

.matrix-corner .corner-icon {
  font-size: 13px;
  opacity: 0.6;
}

/* ── Premium Stage Headers ── */
.matrix-stage-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #0F172A;
  font-size: 13px;
  font-weight: 750;
  text-align: center;
  overflow: hidden;
  padding: 8px 12px;
  text-overflow: ellipsis;
  border-right: 1px solid rgba(148, 163, 184, 0.10);
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  transition: background 200ms ease, box-shadow 200ms ease;
  cursor: pointer;
  user-select: none;
}

.matrix-stage-header .stage-icon {
  font-size: 20px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.08));
}

.matrix-stage-header .stage-name {
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.01em;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matrix-stage-header:hover {
  filter: brightness(0.96);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.06);
}

.matrix-stage-header.is-hovered {
  box-shadow: inset 0 0 0 2px rgba(79, 140, 255, 0.22);
}

/* ── Premium Lane Headers ── */
.matrix-lane-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #0F172A;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  writing-mode: horizontal-tb;
  transform: none;
  overflow: hidden;
  padding: 8px 12px;
  text-overflow: ellipsis;
  border-right: 1px solid rgba(148, 163, 184, 0.10);
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  transition: background 200ms ease, box-shadow 200ms ease;
  cursor: pointer;
  user-select: none;
}

.matrix-lane-header .lane-accent {
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: currentColor;
  opacity: 0.5;
}

.matrix-lane-header .lane-icon {
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}

.matrix-lane-header .lane-name {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.matrix-lane-header .lane-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.06);
  color: inherit;
  opacity: 0.7;
  white-space: nowrap;
  flex-shrink: 0;
}

.matrix-lane-header:hover {
  filter: brightness(0.96);
}

.matrix-lane-header.is-hovered {
  box-shadow: inset 0 0 0 2px rgba(79, 140, 255, 0.22);
}

/* ── Process-First Cells ── */
.matrix-cell {
  background: transparent;
  border-right: 1px solid rgba(148, 163, 184, 0.06);
  border-bottom: 1px solid rgba(148, 163, 184, 0.06);
  transition: background 200ms ease, box-shadow 200ms ease;
}

.matrix-cell:hover {
  background: rgba(79, 140, 255, 0.03);
}

.matrix-cell.is-active-cell {
  box-shadow: inset 0 0 0 2px rgba(79, 140, 255, 0.28);
  background: rgba(79, 140, 255, 0.04);
}

/* ── Drag Target Highlights ── */
.matrix-cell.is-drop-target {
  background: rgba(79, 140, 255, 0.08);
  box-shadow: inset 0 0 0 2px rgba(79, 140, 255, 0.32);
}

.matrix-lane-header.is-drop-lane {
  box-shadow: inset 0 0 0 2px rgba(79, 140, 255, 0.36);
}

.matrix-stage-header.is-drop-stage {
  box-shadow: inset 0 0 0 2px rgba(79, 140, 255, 0.36);
}

/* ── Stage Flow Arrow ── */
.matrix-flow-arrow {
  position: absolute;
  top: 50%;
  right: -7px;
  z-index: 2;
  transform: translateY(-50%);
  color: rgba(148, 163, 184, 0.32);
  font-size: 11px;
  font-weight: 800;
  pointer-events: none;
}

/* ── Drop Guide Overlay ── */
.matrix-drop-guide {
  position: absolute;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(8px);
  color: #E2E8F0;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

/* ── Light Mode Matrix ── */
:root[data-theme="light"] .matrix-frame {
  border-color: rgba(203, 213, 225, 0.22);
  background: rgba(255, 255, 255, 0.02);
}

:root[data-theme="light"] .matrix-corner {
  background: rgba(241, 245, 249, 0.92);
  color: #64748B;
}

:root[data-theme="light"] .matrix-stage-header {
  color: #1E293B;
}

:root[data-theme="light"] .matrix-lane-header {
  color: #1E293B;
}

:root[data-theme="light"] .matrix-cell {
  border-right-color: rgba(203, 213, 225, 0.12);
  border-bottom-color: rgba(203, 213, 225, 0.12);
}

:root[data-theme="light"] .matrix-cell:hover {
  background: rgba(59, 130, 246, 0.03);
}

.connector-layer,
.shape-layer,
.guide-layer {
  position: absolute;
  inset: 0;
}

.connector-layer {
  z-index: 1;
  width: 20000px;
  height: 20000px;
  pointer-events: none;
}

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

.guide-layer {
  z-index: 4;
  pointer-events: none;
}

.connector-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 18;
  pointer-events: stroke;
  cursor: pointer;
}

.connector-path {
  fill: none;
  stroke: var(--connector);
  stroke-width: 2.4;
}

.connector.selected .connector-path {
  stroke: var(--primary);
  stroke-width: 3;
  filter: drop-shadow(0 0 6px rgba(79, 140, 255, 0.42));
}

.connector-preview .connector-path {
  stroke: #0ea5e9;
  stroke-dasharray: 8 7;
  stroke-width: 3;
}

.connector-label-bg {
  fill: #ffffff;
  stroke: #cbd5e1;
  stroke-width: 1;
}

.connector.selected .connector-label-bg {
  fill: #eff6ff;
  stroke: var(--primary);
  stroke-width: 1.4;
}

.connector-label {
  fill: #1f2937;
  font-size: 13px;
  font-weight: 650;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: auto;
  cursor: text;
  user-select: none;
}

.connector.selected .connector-label {
  fill: #12306f;
  font-weight: 800;
}

.waypoint-handle,
.waypoint-add-handle {
  pointer-events: all;
  cursor: move;
}

.waypoint-handle {
  fill: #ffffff;
  stroke: var(--primary);
  stroke-width: 2;
}

.waypoint-add-handle {
  fill: #0ea5e9;
  stroke: #ffffff;
  stroke-width: 2;
  cursor: copy;
}

.shape {
  position: absolute;
  min-width: 32px;
  min-height: 24px;
  color: #1f2937;
  cursor: move;
  pointer-events: auto;
  user-select: none;
  opacity: var(--shape-opacity, 1);
  transform: rotate(var(--shape-rotation, 0deg));
  transform-origin: center;
}

.shape.selected {
  outline: 2px solid var(--primary);
  outline-offset: 4px;
}

.shape.in-group {
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.35);
}

.shape.connect-pending {
  outline: 3px solid #f59e0b;
  outline-offset: 5px;
}

.shape.connection-target,
.shape.auto-connect-target {
  outline: 3px solid #0ea5e9;
  outline-offset: 7px;
}

.shape-body {
  position: absolute;
  inset: 0;
  background: var(--shape-fill, var(--shape-bg));
  border: var(--shape-border-width, 2px) solid var(--shape-stroke, var(--shape-border));
  box-shadow: var(--shape-shadow, 0 7px 18px rgba(15, 23, 42, 0.08));
}

.shape.gradient .shape-body {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0) 54%),
    var(--shape-fill, var(--shape-bg));
}

.shape.locked {
  cursor: not-allowed;
}

.shape.shape-locked {
  cursor: not-allowed;
}

.shape.shape-locked::after {
  content: "Locked";
  position: absolute;
  right: 6px;
  top: 6px;
  z-index: 6;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.72);
  color: #ffffff;
  padding: 2px 5px;
  font-size: 10px;
  font-weight: 750;
}

.shape.shape-locked .shape-body,
.shape.locked .shape-body {
  background:
    repeating-linear-gradient(135deg, rgba(15, 23, 42, 0.045) 0 6px, transparent 6px 12px),
    var(--shape-fill, var(--shape-bg));
}

.shape.shape-locked.selected {
  outline-style: dashed;
}

.shape.contained .shape-body {
  box-shadow:
    inset 0 0 0 1px rgba(14, 165, 233, 0.16),
    var(--shape-shadow, 0 7px 18px rgba(15, 23, 42, 0.08));
}

.shape.process .shape-body,
.shape.container .shape-body,
.shape.subprocess .shape-body,
.shape.textbox .shape-body {
  border-radius: 6px;
}

.shape.textbox .shape-body {
  background: transparent;
  border-style: dashed;
  box-shadow: none;
}

.shape.subprocess .shape-body::before,
.shape.subprocess .shape-body::after {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  width: 2px;
  background: var(--shape-stroke, var(--shape-border));
}

.shape.subprocess .shape-body::before { left: 14px; }
.shape.subprocess .shape-body::after { right: 14px; }

.shape.startend .shape-body {
  border-radius: 999px;
}

.shape.decision .shape-body {
  border: 0;
  background: var(--shape-stroke, var(--shape-border));
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.shape.decision .shape-body::after {
  content: "";
  position: absolute;
  inset: var(--shape-border-width, 2px);
  background: var(--shape-fill, var(--shape-bg));
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.shape.document .shape-body {
  border-radius: 6px 6px 0 0;
  clip-path: polygon(0 0, 100% 0, 100% 82%, 86% 91%, 69% 84%, 50% 92%, 31% 84%, 14% 91%, 0 82%);
}

.shape.document .shape-body::after {
  display: none;
}

.shape.manualInput .shape-body {
  clip-path: polygon(0 22%, 100% 0, 100% 100%, 0 100%);
}

.shape.delay .shape-body {
  border-radius: 0 999px 999px 0;
}

.shape.preparation .shape-body {
  clip-path: polygon(16% 0, 84% 0, 100% 50%, 84% 100%, 16% 100%, 0 50%);
}

.shape.display .shape-body {
  clip-path: polygon(12% 0, 100% 0, 88% 100%, 12% 100%, 0 50%);
}

.shape.offPageConnector .shape-body {
  clip-path: polygon(0 0, 100% 0, 100% 68%, 50% 100%, 0 68%);
}

.shape.dataStore .shape-body {
  border-radius: 999px / 50%;
}

.shape.storedData .shape-body {
  border-radius: 42% / 50%;
}

.shape.dataStore .shape-body::before,
.shape.storedData .shape-body::before {
  content: "";
  position: absolute;
  top: calc(-1 * var(--shape-border-width, 2px));
  bottom: calc(-1 * var(--shape-border-width, 2px));
  left: 18%;
  width: 24%;
  border-left: var(--shape-border-width, 2px) solid var(--shape-stroke, var(--shape-border));
  border-radius: 50%;
  opacity: 0.85;
}

.shape.database .shape-body {
  border-radius: 50% / 15%;
}

.shape.database .shape-body::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--shape-border-width, 2px));
  right: calc(-1 * var(--shape-border-width, 2px));
  top: 10px;
  height: 22px;
  border: var(--shape-border-width, 2px) solid var(--shape-stroke, var(--shape-border));
  border-top: 0;
  border-radius: 0 0 50% 50%;
}

.shape.database .shape-body::after {
  content: "";
  position: absolute;
  left: calc(-1 * var(--shape-border-width, 2px));
  right: calc(-1 * var(--shape-border-width, 2px));
  bottom: 10px;
  height: 22px;
  border: var(--shape-border-width, 2px) solid var(--shape-stroke, var(--shape-border));
  border-bottom: 0;
  border-radius: 50% 50% 0 0;
  opacity: 0.75;
}

.shape.swimlane .shape-body {
  border-radius: 4px;
  background:
    linear-gradient(90deg, rgba(37, 99, 235, 0.12) 0 72px, transparent 72px),
    var(--shape-fill, var(--shape-bg));
}

.shape.actor .shape-body {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.shape.actor .shape-body::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 5%;
  width: 22%;
  height: 22%;
  border: var(--shape-border-width, 2px) solid var(--shape-stroke, var(--shape-border));
  border-radius: 50%;
  transform: translateX(-50%);
}

.shape.actor .shape-body::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 30%;
  width: 56%;
  height: 58%;
  border-top: var(--shape-border-width, 2px) solid var(--shape-stroke, var(--shape-border));
  border-left: var(--shape-border-width, 2px) solid transparent;
  border-right: var(--shape-border-width, 2px) solid transparent;
  background:
    linear-gradient(var(--shape-stroke, var(--shape-border)), var(--shape-stroke, var(--shape-border))) center 0 / var(--shape-border-width, 2px) 72% no-repeat,
    linear-gradient(25deg, transparent 48%, var(--shape-stroke, var(--shape-border)) 49% 51%, transparent 52%) center 70% / 70% 44% no-repeat,
    linear-gradient(-25deg, transparent 48%, var(--shape-stroke, var(--shape-border)) 49% 51%, transparent 52%) center 70% / 70% 44% no-repeat;
  transform: translateX(-50%);
}

.shape.cloud .shape-body {
  border-radius: 48% 52% 45% 55% / 60% 42% 58% 40%;
}

.shape.image .shape-body {
  overflow: hidden;
  border-radius: 4px;
}

.shape.image img {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.shape-text {
  position: absolute;
  z-index: 2;
  inset: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--shape-text-color, #1f2937);
  font-family: var(--shape-font-family, Arial, sans-serif);
  font-size: var(--shape-font-size, 14px);
  font-style: var(--shape-font-style, normal);
  font-weight: var(--shape-font-weight, 500);
  text-decoration: var(--shape-text-decoration, none);
  line-height: 1.22;
  text-align: var(--shape-text-align, center);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  outline: none;
}

.shape.decision .shape-text {
  inset: 18% 18%;
}

.shape.swimlane .shape-text {
  left: 82px;
}

.shape.actor .shape-text {
  top: 76%;
  bottom: 0;
}

.shape-text[contenteditable="true"] {
  display: block;
  overflow: auto;
  padding: 6px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--primary);
  border-radius: 4px;
  cursor: text;
  user-select: text;
}

.resize-handle,
.connection-point {
  position: absolute;
  z-index: 5;
  background: #ffffff;
}

.resize-handle {
  width: 10px;
  height: 10px;
  border: 2px solid var(--primary);
  border-radius: 2px;
}

.resize-handle.nw { left: -9px; top: -9px; cursor: nwse-resize; }
.resize-handle.ne { right: -9px; top: -9px; cursor: nesw-resize; }
.resize-handle.se { right: -9px; bottom: -9px; cursor: nwse-resize; }
.resize-handle.sw { left: -9px; bottom: -9px; cursor: nesw-resize; }

.connection-point {
  z-index: 8;
  width: 12px;
  height: 12px;
  border: 2px solid #0ea5e9;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  cursor: crosshair;
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.14);
}

.connection-point.n { left: 50%; top: 0; }
.connection-point.e { left: 100%; top: 50%; }
.connection-point.s { left: 50%; top: 100%; }
.connection-point.w { left: 0; top: 50%; }

.quick-add {
  position: absolute;
  z-index: 12;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid #0ea5e9;
  border-radius: 50%;
  background: #ffffff;
  color: #0369a1;
  font-size: 16px;
  font-weight: 750;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 5px 14px rgba(14, 165, 233, 0.24);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.shape.selected .quick-add {
  opacity: 0.9;
  pointer-events: auto;
}

.shape.selected.quick-add-active .quick-add,
.shape.selected:hover .quick-add,
.quick-add:hover {
  opacity: 1;
  box-shadow: 0 7px 18px rgba(14, 165, 233, 0.32);
}

.quick-add.n { left: 50%; top: -38px; transform: translateX(-50%); }
.quick-add.e { right: -38px; top: 50%; transform: translateY(-50%); }
.quick-add.s { left: 50%; bottom: -38px; transform: translateX(-50%); }
.quick-add.w { left: -38px; top: 50%; transform: translateY(-50%); }

.quick-add::after {
  content: "";
  position: absolute;
  background: #0ea5e9;
}

.quick-add.n::after,
.quick-add.s::after {
  left: 50%;
  width: 1px;
  height: 16px;
  transform: translateX(-50%);
}

.quick-add.n::after { top: 21px; }
.quick-add.s::after { bottom: 21px; }

.quick-add.e::after,
.quick-add.w::after {
  top: 50%;
  width: 16px;
  height: 1px;
  transform: translateY(-50%);
}

.quick-add.e::after { right: 21px; }
.quick-add.w::after { left: 21px; }

.selection-box {
  position: absolute;
  z-index: 10;
  border: 1px solid var(--primary);
  background: var(--primary-weak);
  pointer-events: none;
}

.guide {
  position: absolute;
  background: #f97316;
}

.guide.v {
  width: 1px;
  height: 20000px;
}

.guide.h {
  width: 20000px;
  height: 1px;
}

.minimap {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 12;
  width: 210px;
  height: 150px;
  border: 1px solid rgba(71, 84, 103, 0.35);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.18);
  overflow: hidden;
}

.minimap-content,
.minimap-viewport {
  position: absolute;
  inset: 0;
}

.mini-shape {
  position: absolute;
  border: 1px solid #475467;
  background: #dbeafe;
}

.mini-connector {
  position: absolute;
  height: 1px;
  background: #64748b;
  transform-origin: 0 50%;
}

.minimap-viewport {
  border: 2px solid var(--primary);
  background: rgba(37, 99, 235, 0.08);
}

.properties-panel {
  width: 258px;
  padding: 12px;
  border-left: 1px solid var(--line);
  overflow-y: auto;
}

.panel-title {
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 750;
}

.panel-subtitle {
  margin: 14px 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.layer-controls {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px;
  margin-bottom: 8px;
}

.layer-controls button,
.layer-row button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 6px 8px;
}

.layer-list {
  display: grid;
  gap: 6px;
  max-height: 190px;
  overflow: auto;
}

.layer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  padding: 4px 6px;
}

.layer-row.active {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.08);
}

.layer-name {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.property-grid {
  display: grid;
  gap: 12px;
}

.property-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.property-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.checkbox-row label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.checkbox-row input {
  width: auto;
}

.single-checkbox {
  display: flex !important;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.single-checkbox input {
  width: auto;
}

.validation-list {
  margin: 0;
  padding-left: 20px;
  color: var(--text);
}

.validation-list li {
  margin: 6px 0;
}

.validation-ok {
  color: #047857;
  font-weight: 750;
}

.property-grid input,
.property-grid select,
.property-grid textarea {
  width: 100%;
}

.format-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.42);
}

.dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.32);
  padding: 18px;
}

.dialog h2 {
  margin: 0 0 8px;
  font-size: 18px;
  line-height: 1.25;
}

.dialog p {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.45;
}

.dialog input {
  width: 100%;
  margin: 4px 0 16px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.dialog-actions button {
  min-width: 82px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 8px 12px;
}

.dialog-actions .confirm {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.dialog-actions .danger-confirm {
  border-color: var(--danger);
  background: var(--danger);
  color: #ffffff;
}

body.exporting .shape.selected,
body.exporting .shape.connect-pending {
  outline: none;
}

body.exporting .resize-handle,
body.exporting .connection-point,
body.exporting .quick-add,
body.exporting .guide,
body.exporting .selection-box {
  display: none;
}

/* 2026 enterprise redesign layer */
:root {
  color-scheme: dark;
  --bg: #0B1220;
  --body-bg:
    radial-gradient(circle at 14% 0%, rgba(79, 140, 255, 0.12), transparent 32%),
    linear-gradient(180deg, #0B1220 0%, #0A1020 100%);
  --surface: #111827;
  --surface-soft: #1F2937;
  --surface-glass: rgba(17, 24, 39, 0.78);
  --text: #E5E7EB;
  --muted: #94A3B8;
  --line: #334155;
  --primary: #4F8CFF;
  --primary-hover: #6BA2FF;
  --primary-weak: rgba(79, 140, 255, 0.18);
  --success: #22C55E;
  --warning: #F59E0B;
  --danger: #EF4444;
  --canvas-bg: #0F172A;
  --grid-major: rgba(148, 163, 184, 0.12);
  --grid-minor: rgba(148, 163, 184, 0.06);
  --shape-bg: #ffffff;
  --shape-border: #334155;
  --connector: #CBD5E1;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  --soft-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
  --radius-panel: 14px;
  --radius-dialog: 16px;
  --transition: 200ms ease;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #F5F7FB;
  --body-bg:
    radial-gradient(circle at 12% 0%, rgba(79, 140, 255, 0.12), transparent 34%),
    linear-gradient(180deg, #F8FAFC 0%, #EEF2F7 100%);
  --surface: #FFFFFF;
  --surface-soft: #F1F5F9;
  --surface-glass: rgba(255, 255, 255, 0.82);
  --text: #111827;
  --muted: #64748B;
  --line: #CBD5E1;
  --primary: #346DFF;
  --primary-hover: #4F8CFF;
  --primary-weak: rgba(52, 109, 255, 0.14);
  --success: #16A34A;
  --warning: #D97706;
  --danger: #DC2626;
  --canvas-bg: #F8FAFC;
  --grid-major: rgba(71, 85, 105, 0.13);
  --grid-minor: rgba(71, 85, 105, 0.06);
  --shape-bg: #FFFFFF;
  --shape-border: #475569;
  --connector: #334155;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.12);
  --soft-shadow: 0 10px 28px rgba(15, 23, 42, 0.1);
}

body {
  background: var(--body-bg);
  color: var(--text);
  font-family: "Inter", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea,
summary {
  transition: transform var(--transition), border-color var(--transition), background var(--transition), color var(--transition), box-shadow var(--transition), opacity var(--transition);
}

button,
summary {
  -webkit-tap-highlight-color: transparent;
}

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

button:active {
  transform: translateY(1px) scale(0.99);
}

.app-shell {
  min-width: 1180px;
  background: transparent;
}

.topbar {
  position: relative;
  z-index: 1100;
  height: 64px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.72);
  background: rgba(11, 18, 32, 0.88);
  backdrop-filter: blur(18px);
}

.brand {
  min-width: 250px;
}

.brand span:last-child {
  display: grid;
  gap: 1px;
}

.brand strong {
  font-size: 15px;
  letter-spacing: 0;
}

.brand small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: rgba(79, 140, 255, 0.10);
  box-shadow: 0 10px 28px rgba(79, 140, 255, 0.16);
}

.workflow-controls {
  gap: 10px;
}

input,
select,
textarea {
  border: 1px solid rgba(51, 65, 85, 0.95);
  border-radius: 12px;
  background: rgba(31, 41, 55, 0.84);
  color: var(--text);
}

input::placeholder,
textarea::placeholder {
  color: #64748B;
}

input:hover,
select:hover,
textarea:hover {
  border-color: rgba(107, 162, 255, 0.65);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 140, 255, 0.12);
}

input[readonly] {
  color: #CBD5E1;
  background: rgba(15, 23, 42, 0.7);
}

.workflow-controls input {
  width: min(340px, 32vw);
  height: 38px;
  font-weight: 650;
}

.workflow-controls select {
  width: min(250px, 22vw);
  height: 38px;
}

.autosave-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  border: 1px solid rgba(34, 197, 94, 0.24);
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.09);
  color: #BBF7D0;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.autosave-indicator::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

.top-icon-button,
.panel-toggle,
.page-actions button,
.ribbon-popover button,
.ribbon-popover label,
.quick-action-bar button,
.quick-action-bar label,
.canvas-hud button,
.command-results button,
.dialog-heading button {
  border: 1px solid rgba(51, 65, 85, 0.95);
  border-radius: 12px;
  background: rgba(31, 41, 55, 0.74);
  color: var(--text);
}

.top-icon-button {
  min-height: 36px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 800;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 86px;
  justify-content: center;
}

.theme-toggle-icon {
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FDE68A 0 50%, #60A5FA 50% 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28), 0 0 18px rgba(79, 140, 255, 0.22);
}

.theme-toggle-icon::after {
  content: "";
  position: absolute;
  right: 2px;
  top: 2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--surface);
}

.top-icon-button:hover,
.panel-toggle:hover,
.page-actions button:hover,
.ribbon-popover button:hover,
.quick-action-bar button:hover,
.canvas-hud button:hover,
.command-results button:hover,
.dialog-heading button:hover {
  border-color: rgba(107, 162, 255, 0.88);
  background: rgba(79, 140, 255, 0.14);
  box-shadow: 0 0 0 4px rgba(79, 140, 255, 0.08);
  transform: translateY(-1px);
}

:root[data-theme="light"] .topbar {
  border-bottom-color: rgba(203, 213, 225, 0.82);
  background: rgba(255, 255, 255, 0.86);
}

:root[data-theme="light"] .commandbar {
  border-bottom-color: rgba(203, 213, 225, 0.78);
  background: rgba(248, 250, 252, 0.78);
}

:root[data-theme="light"] input,
:root[data-theme="light"] select,
:root[data-theme="light"] textarea {
  border-color: rgba(148, 163, 184, 0.78);
  background: rgba(255, 255, 255, 0.88);
}

:root[data-theme="light"] input[readonly] {
  color: #475569;
  background: rgba(241, 245, 249, 0.88);
}

:root[data-theme="light"] .autosave-indicator {
  color: #166534;
  background: rgba(34, 197, 94, 0.12);
}

:root[data-theme="light"] .top-icon-button,
:root[data-theme="light"] .panel-toggle,
:root[data-theme="light"] .page-actions button,
:root[data-theme="light"] .ribbon-popover button,
:root[data-theme="light"] .ribbon-popover label,
:root[data-theme="light"] .quick-action-bar button,
:root[data-theme="light"] .quick-action-bar label,
:root[data-theme="light"] .canvas-hud button,
:root[data-theme="light"] .command-results button,
:root[data-theme="light"] .dialog-heading button {
  border-color: rgba(148, 163, 184, 0.72);
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
}

.commandbar {
  position: relative;
  z-index: 1050;
  height: 48px;
  gap: 6px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.72);
  background: rgba(11, 18, 32, 0.72);
  backdrop-filter: blur(18px);
  overflow: visible;
}

.ribbon-menu {
  position: relative;
}

.ribbon-menu summary {
  display: grid;
  place-items: center;
  min-height: 34px;
  border-radius: 12px;
  color: #CBD5E1;
  cursor: pointer;
  list-style: none;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 760;
}

.ribbon-menu summary::-webkit-details-marker {
  display: none;
}

.ribbon-menu[open] summary,
.ribbon-menu summary:hover {
  background: rgba(79, 140, 255, 0.12);
  color: #F8FAFC;
}

.ribbon-popover {
  position: absolute;
  top: 42px;
  left: 0;
  z-index: 1200;
  display: grid;
  gap: 6px;
  width: 232px;
  border: 1px solid rgba(51, 65, 85, 0.92);
  border-radius: var(--radius-panel);
  background: rgba(17, 24, 39, 0.98);
  box-shadow: var(--shadow);
  padding: 8px;
}

:root[data-theme="light"] .ribbon-menu summary {
  color: #475569;
}

:root[data-theme="light"] .ribbon-menu[open] summary,
:root[data-theme="light"] .ribbon-menu summary:hover {
  color: #0F172A;
}

:root[data-theme="light"] .ribbon-popover {
  border-color: rgba(148, 163, 184, 0.72);
  background: rgba(255, 255, 255, 0.98);
}

.ribbon-popover button,
.ribbon-popover label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 34px;
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 650;
  text-align: left;
}

.ribbon-popover select {
  width: 100%;
}

.ribbon-popover hr {
  width: 100%;
  height: 1px;
  border: 0;
  background: rgba(51, 65, 85, 0.72);
  margin: 4px 0;
}

.main-layout {
  position: relative;
  z-index: 1;
  gap: 10px;
  padding: 10px;
}

.toolbar,
.properties-panel {
  border: 1px solid rgba(51, 65, 85, 0.78);
  border-radius: var(--radius-panel);
  background: rgba(17, 24, 39, 0.92);
  box-shadow: var(--soft-shadow);
  resize: horizontal;
  transition: width var(--transition), opacity var(--transition), padding var(--transition), border-color var(--transition);
}

:root[data-theme="light"] .toolbar,
:root[data-theme="light"] .properties-panel,
:root[data-theme="light"] .workspace-panel {
  border-color: rgba(203, 213, 225, 0.9);
  background: rgba(255, 255, 255, 0.84);
}

.toolbar {
  width: 268px;
  min-width: 220px;
  max-width: 380px;
  padding: 14px;
}

.properties-panel {
  width: 324px;
  min-width: 280px;
  max-width: 460px;
  padding: 14px;
}

.app-shell.left-collapsed .toolbar,
.app-shell.right-collapsed .properties-panel {
  width: 48px;
  min-width: 48px;
  max-width: 48px;
  border-width: 1px;
  opacity: 1;
  overflow: hidden;
  padding: 8px;
  resize: none;
}

.app-shell.left-collapsed .toolbar > :not(.panel-chrome),
.app-shell.right-collapsed .properties-panel > :not(.panel-chrome),
.app-shell.left-collapsed .toolbar .panel-chrome > div,
.app-shell.right-collapsed .properties-panel .panel-chrome > div {
  display: none;
}

.app-shell.left-collapsed .toolbar .panel-chrome,
.app-shell.right-collapsed .properties-panel .panel-chrome {
  justify-content: center;
  margin: 0;
}

.app-shell.left-collapsed .toolbar .panel-toggle,
.app-shell.right-collapsed .properties-panel .panel-toggle {
  writing-mode: vertical-rl;
  min-width: 30px;
  min-height: 74px;
  padding: 8px 4px;
}

.panel-chrome {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-chrome h2 {
  margin: 2px 0 0;
  font-size: 20px;
  line-height: 1.1;
}

.eyebrow {
  color: var(--primary-hover);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel-toggle {
  min-height: 30px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.shape-search {
  width: 100%;
  height: 40px;
  margin-bottom: 12px;
  padding-left: 12px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.tool-button,
.format-buttons button,
.layer-controls button {
  border-radius: 12px;
  background: rgba(31, 41, 55, 0.74);
  color: var(--text);
}

.tool-button.active {
  border-color: rgba(79, 140, 255, 0.9);
  background: rgba(79, 140, 255, 0.18);
  color: #DBEAFE;
}

:root[data-theme="light"] .tool-button,
:root[data-theme="light"] .format-buttons button,
:root[data-theme="light"] .layer-controls button,
:root[data-theme="light"] .matrix-actions button,
:root[data-theme="light"] .matrix-row > button {
  border-color: rgba(148, 163, 184, 0.72);
  background: rgba(255, 255, 255, 0.82);
  color: #172033;
}

:root[data-theme="light"] .tool-button.active,
:root[data-theme="light"] .page-tab.active {
  border-color: rgba(52, 109, 255, 0.88);
  background: rgba(52, 109, 255, 0.16);
  color: #12306F;
}

.shape-section,
.property-section {
  border: 1px solid rgba(51, 65, 85, 0.68);
  border-radius: var(--radius-panel);
  background: rgba(15, 23, 42, 0.52);
  margin-bottom: 10px;
  overflow: hidden;
}

:root[data-theme="light"] .shape-section,
:root[data-theme="light"] .property-section,
:root[data-theme="light"] .empty-state {
  border-color: rgba(203, 213, 225, 0.9);
  background: rgba(248, 250, 252, 0.74);
}

:root[data-theme="light"] .shape-section summary,
:root[data-theme="light"] .property-section summary {
  color: #1E293B;
}

.shape-section summary,
.property-section summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 0 12px;
  color: #E2E8F0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  list-style: none;
}

.shape-section summary::-webkit-details-marker,
.property-section summary::-webkit-details-marker {
  display: none;
}

.shape-section summary::after,
.property-section summary::after {
  content: "⌄";
  color: var(--muted);
  transition: transform var(--transition);
}

.shape-section:not([open]) summary::after,
.property-section:not([open]) summary::after {
  transform: rotate(-90deg);
}

.shape-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: calc(100% - 16px);
  min-height: 40px;
  margin: 0 8px 8px;
  border: 1px solid rgba(51, 65, 85, 0.66);
  border-radius: 12px;
  background: rgba(31, 41, 55, 0.58);
  color: #DDE6F3;
  padding: 8px 10px;
  font-weight: 700;
  text-align: left;
}

:root[data-theme="light"] .shape-item {
  border-color: rgba(203, 213, 225, 0.92);
  background: rgba(255, 255, 255, 0.8);
  color: #1E293B;
}

.shape-icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 9px;
  background: rgba(79, 140, 255, 0.14);
  color: #BFDBFE;
  font-weight: 800;
  position: relative;
  flex: 0 0 26px;
}

.shape-icon::before,
.shape-icon::after {
  content: "";
  position: absolute;
  border: 2px solid #8FB6FF;
  background: rgba(219, 234, 254, 0.30);
  box-sizing: border-box;
}

:root[data-theme="light"] .shape-icon::before,
:root[data-theme="light"] .shape-icon::after {
  border-color: #4F8CFF;
  background: rgba(79, 140, 255, 0.14);
}

.process-icon::before {
  inset: 7px 4px;
  border-radius: 3px;
}

.decision-icon::before {
  width: 14px;
  height: 14px;
  left: 6px;
  top: 6px;
  transform: rotate(45deg);
  border-radius: 2px;
}

.startend-icon::before {
  inset: 7px 4px;
  border-radius: 999px;
}

.text-icon::before,
.text-icon::after {
  display: none;
}

.document-icon::before {
  inset: 6px 4px 5px;
  border-radius: 3px 3px 0 0;
  clip-path: polygon(0 0, 100% 0, 100% 78%, 72% 92%, 50% 82%, 27% 92%, 0 78%);
}

.subprocess-icon::before {
  inset: 7px 4px;
  border-radius: 3px;
}

.subprocess-icon::after {
  inset: 9px 8px;
  border-width: 0 2px;
  background: transparent;
}

.manual-input-icon::before {
  inset: 6px 4px;
  clip-path: polygon(0 28%, 100% 0, 100% 100%, 0 100%);
}

.delay-icon::before {
  inset: 5px 4px;
  border-radius: 0 999px 999px 0;
}

.preparation-icon::before {
  inset: 5px 3px;
  clip-path: polygon(18% 0, 82% 0, 100% 50%, 82% 100%, 18% 100%, 0 50%);
}

.display-icon::before {
  inset: 5px 4px;
  clip-path: polygon(14% 0, 100% 0, 86% 100%, 14% 100%, 0 50%);
}

.offpage-icon::before {
  inset: 4px 5px;
  clip-path: polygon(0 0, 100% 0, 100% 66%, 50% 100%, 0 66%);
}

.swimlane-icon::before {
  inset: 5px 3px;
  border-radius: 3px;
  background:
    linear-gradient(90deg, rgba(143, 182, 255, 0.45) 0 33%, transparent 33%),
    rgba(219, 234, 254, 0.24);
}

.swimlane-icon::after {
  inset: 5px 3px;
  border-width: 0 0 0 2px;
  transform: translateX(6px);
  background: transparent;
}

.container-icon::before {
  inset: 5px 3px;
  border-radius: 5px;
  border-style: dashed;
}

.data-store-icon::before {
  inset: 5px 3px;
  border-radius: 999px / 50%;
}

.data-store-icon::after,
.stored-data-icon::after {
  top: 5px;
  bottom: 5px;
  left: 8px;
  width: 7px;
  border-width: 0 0 0 2px;
  border-radius: 50%;
  background: transparent;
}

.database-icon::before {
  inset: 4px 5px;
  border-radius: 50% / 16%;
}

.database-icon::after {
  left: 5px;
  right: 5px;
  top: 7px;
  height: 7px;
  border-top: 0;
  border-radius: 0 0 50% 50%;
  background: transparent;
}

.stored-data-icon::before {
  inset: 5px 3px;
  border-radius: 42% / 50%;
}

.actor-icon::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  left: 9px;
  top: 4px;
  background: transparent;
}

.actor-icon::after {
  width: 16px;
  height: 14px;
  left: 5px;
  top: 12px;
  border-width: 2px 0 0;
  background: transparent;
  box-shadow:
    inset 7px 0 0 -5px #8FB6FF,
    0 8px 0 -6px #8FB6FF;
}

.cloud-icon::before {
  inset: 7px 3px 6px;
  border-radius: 999px;
  clip-path: path("M3 14 C0 12 1 7 6 8 C7 2 15 2 17 8 C22 7 25 12 21 15 Z");
}

.shape-item:hover {
  border-color: rgba(107, 162, 255, 0.78);
  background: rgba(79, 140, 255, 0.12);
  transform: translateY(-1px);
}

.shape-item.is-hidden {
  display: none;
}

.workspace-panel {
  border: 1px solid rgba(51, 65, 85, 0.78);
  border-radius: var(--radius-panel);
  background: rgba(17, 24, 39, 0.68);
  box-shadow: var(--soft-shadow);
  overflow: hidden;
}

.canvas-header {
  min-height: 52px;
  padding: 8px 12px;
  background: rgba(17, 24, 39, 0.92);
}

:root[data-theme="light"] .canvas-header {
  background: rgba(255, 255, 255, 0.9);
}

.page-tabs {
  gap: 8px;
}

.page-tab {
  border-radius: 999px;
  background: rgba(31, 41, 55, 0.7);
  color: var(--muted);
}

.page-tab.active {
  border-color: rgba(79, 140, 255, 0.86);
  background: rgba(79, 140, 255, 0.18);
  color: #DBEAFE;
}

:root[data-theme="light"] .page-tab {
  background: rgba(255, 255, 255, 0.76);
  color: #475569;
}

.page-actions button {
  min-height: 32px;
  font-weight: 750;
}

.status-text {
  flex: 0 0 auto;
  margin-left: auto;
}

.canvas-viewport {
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(11, 18, 32, 0.98));
}

:root[data-theme="light"] .canvas-viewport {
  background: linear-gradient(180deg, rgba(241, 245, 249, 0.96), rgba(226, 232, 240, 0.98));
}

.canvas-content {
  background-color: var(--canvas-bg);
  background-image:
    radial-gradient(circle, rgba(148, 163, 184, 0.22) 1px, transparent 1.3px),
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px);
  background-size: 20px 20px, 100px 100px, 100px 100px;
}

.canvas-content.grid-off {
  background-image: none;
}

.shape {
  transition: box-shadow var(--transition), outline-color var(--transition), transform var(--transition), opacity var(--transition);
}

.shape.selected {
  outline: 2px solid var(--primary);
  outline-offset: 5px;
  animation: selection-pop 180ms ease;
}

@keyframes selection-pop {
  from { outline-offset: 1px; }
  to { outline-offset: 5px; }
}

.shape-body {
  box-shadow: var(--shape-shadow, 0 8px 22px rgba(15, 23, 42, 0.14));
}

.connector-path {
  transition: stroke-dashoffset 220ms ease, stroke var(--transition);
}

.minimap {
  right: 16px;
  bottom: 72px;
  width: 220px;
  height: 150px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.68);
  backdrop-filter: blur(18px);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.28);
}

:root[data-theme="light"] .minimap,
:root[data-theme="light"] .canvas-hud,
:root[data-theme="light"] .quick-action-bar {
  border-color: rgba(148, 163, 184, 0.36);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--soft-shadow);
}

.mini-shape {
  border-color: rgba(226, 232, 240, 0.65);
  border-radius: 2px;
  opacity: 0.86;
}

.minimap-viewport {
  border-color: var(--primary-hover);
  background: rgba(79, 140, 255, 0.14);
  box-shadow: 0 0 0 1px rgba(79, 140, 255, 0.28);
}

.canvas-hud {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 13;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.74);
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.24);
  padding: 5px 8px;
}

.canvas-empty-state {
  position: absolute;
  left: 50%;
  top: 44%;
  z-index: 12;
  width: min(430px, calc(100% - 48px));
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 16px;
  background: rgba(17, 24, 39, 0.86);
  backdrop-filter: blur(18px);
  box-shadow: var(--soft-shadow);
  color: var(--text);
  padding: 18px;
  transform: translate(-50%, -50%);
}

.canvas-empty-state[hidden] {
  display: none;
}

.canvas-empty-state h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.canvas-empty-state p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.canvas-empty-state div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.canvas-empty-state button,
.context-menu button {
  min-height: 34px;
  border: 1px solid rgba(148, 163, 184, 0.34);
  border-radius: 12px;
  background: rgba(31, 41, 55, 0.82);
  color: var(--text);
  padding: 0 11px;
  font-size: 12px;
  font-weight: 800;
}

.canvas-empty-state button:hover,
.context-menu button:hover {
  border-color: rgba(107, 162, 255, 0.88);
  background: rgba(79, 140, 255, 0.16);
}

:root[data-theme="light"] .canvas-empty-state {
  border-color: rgba(148, 163, 184, 0.34);
  background: rgba(255, 255, 255, 0.9);
}

:root[data-theme="light"] .canvas-empty-state button,
:root[data-theme="light"] .context-menu button {
  background: rgba(255, 255, 255, 0.84);
  color: #172033;
}

.canvas-hud span,
.canvas-hud button {
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  color: #DDE6F3;
  font-size: 12px;
  font-weight: 800;
}

:root[data-theme="light"] .canvas-hud span,
:root[data-theme="light"] .canvas-hud button {
  color: #1E293B;
}

.zoom-readout {
  display: inline-grid;
  place-items: center;
  height: 30px;
  color: #DDE6F3;
}

.quick-action-bar {
  position: absolute;
  z-index: 22;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.92);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  padding: 6px;
}

.quick-action-bar[hidden] {
  display: none;
}

.quick-action-bar button,
.quick-action-bar label {
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.quick-action-bar .icon-only {
  display: inline-grid;
  place-items: center;
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  line-height: 1;
}

.quick-action-bar .icon-only span {
  display: grid;
  place-items: center;
  line-height: 1;
}

.quick-context {
  max-width: 220px;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 999px;
  background: rgba(79, 140, 255, 0.12);
  color: #BFDBFE;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

:root[data-theme="light"] .quick-context {
  background: rgba(52, 109, 255, 0.12);
  color: #12306F;
}

.quick-action-bar input[type="color"] {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  padding: 0;
}

.quick-color-button {
  border-radius: 999px;
}

.quick-color-preview {
  width: 20px;
  height: 20px;
  border: 1px solid rgba(255, 255, 255, 0.46);
  border-radius: 999px;
  background: var(--quick-color, #ffffff);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.35);
}

.quick-swatch-row {
  position: absolute;
  top: calc(100% + 8px);
  left: 78px;
  z-index: 24;
  display: grid;
  grid-template-columns: repeat(6, 24px);
  gap: 7px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 14px;
  background: rgba(17, 24, 39, 0.96);
  box-shadow: var(--shadow);
  padding: 9px;
}

.quick-swatch-row[hidden] {
  display: none;
}

:root[data-theme="light"] .quick-swatch-row {
  background: rgba(255, 255, 255, 0.96);
}

.swatch-section {
  display: grid;
  gap: 7px;
}

.swatch-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 7px;
}

.swatch-grid.compact {
  grid-template-columns: repeat(8, minmax(0, 1fr));
}

.color-swatch {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  min-width: 24px;
  aspect-ratio: 1;
  border: 1px solid rgba(148, 163, 184, 0.46);
  border-radius: 10px;
  background: var(--swatch-color) !important;
  color: transparent !important;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
  cursor: pointer;
}

.quick-action-bar .quick-swatch-row .color-swatch {
  width: 24px;
  min-width: 24px;
  height: 24px;
  min-height: 24px;
  border-radius: 999px;
  padding: 0;
}

.color-swatch:hover {
  border-color: rgba(107, 162, 255, 0.96);
  box-shadow: 0 0 0 4px rgba(79, 140, 255, 0.12), inset 0 0 0 1px rgba(255, 255, 255, 0.24);
  transform: translateY(-1px);
}

.color-swatch.active {
  border-color: var(--primary-hover);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.24), inset 0 0 0 1px rgba(255, 255, 255, 0.34);
}

.color-swatch.active::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.38);
}

.empty-state {
  border: 1px dashed rgba(148, 163, 184, 0.28);
  border-radius: var(--radius-panel);
  background: rgba(15, 23, 42, 0.46);
  padding: 16px;
  margin-bottom: 12px;
}

.empty-state h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.property-section .property-grid,
.property-section .layer-controls,
.property-section .layer-list {
  padding: 0 10px 10px;
}

.property-section.inspector-hidden {
  display: none;
}

.cross-functional-panel {
  display: grid;
  gap: 10px;
  padding: 0 10px 10px;
}

.matrix-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.matrix-actions button,
.matrix-row button {
  min-height: 32px;
  border: 1px solid rgba(51, 65, 85, 0.95);
  border-radius: 10px;
  background: rgba(31, 41, 55, 0.74);
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
}

.matrix-editor-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.matrix-editor-list {
  display: grid;
  gap: 8px;
}

.matrix-row {
  display: grid;
  grid-template-columns: 64px minmax(96px, 1fr) 32px 32px 32px;
  gap: 6px;
  align-items: center;
  border: 1px solid rgba(51, 65, 85, 0.68);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.48);
  padding: 7px;
}

.matrix-row input[type="text"] {
  grid-column: 1 / -1;
  min-width: 0;
  height: 34px;
}

.matrix-row input[type="number"] {
  padding: 0 6px;
}

.matrix-row input[type="color"] {
  width: 32px;
  height: 32px;
  padding: 2px;
}

.matrix-swatch-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}

.matrix-swatch-row .color-swatch {
  background: var(--swatch-color) !important;
  color: transparent !important;
  width: 20px;
  min-width: 20px;
  height: 20px;
  min-height: 20px;
  border-radius: 7px;
  padding: 0;
}

.matrix-swatch-row .color-swatch:nth-child(n+5) {
  display: none;
}

:root[data-theme="light"] .matrix-row {
  border-color: rgba(203, 213, 225, 0.92);
  background: rgba(255, 255, 255, 0.72);
}

.property-grid input[type="color"][data-hidden-picker] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.property-grid {
  gap: 10px;
}

.property-grid label {
  color: var(--muted);
  font-size: 11px;
  text-transform: none;
}

.format-buttons {
  grid-template-columns: repeat(3, 1fr);
}

.dialog-overlay,
.overlay-shell {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: start center;
  background: rgba(2, 6, 23, 0.58);
  backdrop-filter: blur(12px);
  padding-top: 12vh;
}

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

.dialog,
.command-palette,
.shortcuts-dialog {
  width: min(620px, calc(100vw - 40px));
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: var(--radius-dialog);
  background: rgba(17, 24, 39, 0.96);
  box-shadow: var(--shadow);
  padding: 16px;
}

:root[data-theme="light"] .dialog,
:root[data-theme="light"] .command-palette,
:root[data-theme="light"] .shortcuts-dialog {
  border-color: rgba(148, 163, 184, 0.34);
  background: rgba(255, 255, 255, 0.97);
}

:root[data-theme="light"] .dialog h2,
:root[data-theme="light"] .dialog-heading h2 {
  color: #0F172A;
}

:root[data-theme="light"] .dialog p {
  color: #475569;
}

.dialog h2,
.dialog-heading h2 {
  color: #F8FAFC;
}

.dialog p {
  color: #CBD5E1;
  white-space: pre-wrap;
}

.dialog-actions button,
.dialog-heading button {
  border-radius: 12px;
}

.command-palette {
  padding: 10px;
}

.command-palette input {
  width: 100%;
  height: 48px;
  border-radius: 14px;
  padding: 0 14px;
  font-size: 15px;
}

.command-results {
  display: grid;
  gap: 6px;
  max-height: 360px;
  overflow: auto;
  padding-top: 10px;
}

.command-results button {
  display: flex;
  justify-content: space-between;
  min-height: 42px;
  padding: 0 12px;
  text-align: left;
}

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.shortcut-grid {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

kbd {
  min-width: 34px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  background: rgba(31, 41, 55, 0.86);
  color: #E2E8F0;
  padding: 5px 8px;
  text-align: center;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
}

.toast-host {
  position: fixed;
  right: 18px;
  top: 126px;
  z-index: 95;
  display: grid;
  gap: 8px;
  width: 320px;
  pointer-events: none;
}

.toast {
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 14px;
  background: rgba(17, 24, 39, 0.94);
  color: #E2E8F0;
  box-shadow: var(--soft-shadow);
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 700;
  animation: toast-in 220ms ease;
}

.context-menu {
  position: fixed;
  z-index: 1300;
  display: grid;
  gap: 6px;
  width: 184px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 14px;
  background: rgba(17, 24, 39, 0.96);
  box-shadow: var(--shadow);
  padding: 8px;
}

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

.context-menu button {
  justify-content: flex-start;
  width: 100%;
  text-align: left;
}

.context-menu hr {
  width: 100%;
  height: 1px;
  border: 0;
  background: rgba(148, 163, 184, 0.24);
  margin: 2px 0;
}

:root[data-theme="light"] .context-menu {
  background: rgba(255, 255, 255, 0.98);
}

:root[data-theme="light"] .toast,
:root[data-theme="light"] .statusbar {
  border-color: rgba(203, 213, 225, 0.92);
  background: rgba(255, 255, 255, 0.9);
  color: #475569;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.statusbar {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 28px;
  border-top: 1px solid rgba(51, 65, 85, 0.72);
  background: rgba(11, 18, 32, 0.88);
  color: var(--muted);
  padding: 0 14px;
  font-size: 12px;
  font-weight: 650;
}

.statusbar span {
  min-width: 0;
}

#statusTextMirror {
  max-width: 44%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#selectionSummary {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1280px) {
  .properties-panel {
    width: 300px;
  }

  .toolbar {
    width: 244px;
  }
}

/* ══════════════════════════════════════════════════════════════
   KaizenFlow Unified Design System
   ══════════════════════════════════════════════════════════════ */

/* ── Design Tokens (Dark) ── */
:root {
  --bg: #020617;
  --body-bg: #020617;
  --canvas-bg: #0F172A;
  --grid-major: rgba(148, 163, 184, 0.05);
  --grid-minor: rgba(148, 163, 184, 0.022);
  --connector: #94A3B8;
  --connector-hover: #CBD5E1;
  --connector-selected: var(--primary);
  --shape-card-radius: 14px;
  --shape-card-shadow: 0 12px 32px rgba(0, 0, 0, 0.32), 0 2px 8px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.10);
  --shape-hover-shadow: 0 18px 48px rgba(0, 0, 0, 0.38), 0 4px 12px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  --shape-selected-shadow: 0 22px 52px rgba(2, 6, 23, 0.42), 0 0 0 1px rgba(255, 255, 255, 0.10) inset;

  /* Stage tints */
  --stage-tint-1: rgba(59, 130, 246, 0.035);
  --stage-tint-2: rgba(139, 92, 246, 0.035);
  --stage-tint-3: rgba(34, 197, 94, 0.035);
  --stage-tint-4: rgba(245, 158, 11, 0.035);
  --stage-tint-5: rgba(236, 72, 153, 0.035);
  --stage-tint-6: rgba(14, 165, 233, 0.035);
}

/* ── Design Tokens (Light) ── */
:root[data-theme="light"] {
  --bg: #F8FAFC;
  --body-bg: #F8FAFC;
  --canvas-bg: #FFFFFF;
  --grid-major: rgba(100, 116, 139, 0.045);
  --grid-minor: rgba(100, 116, 139, 0.018);
  --connector: #64748B;
  --connector-hover: #475569;
  --shape-card-shadow: 0 8px 24px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.40);
  --shape-hover-shadow: 0 14px 36px rgba(15, 23, 42, 0.12), 0 4px 10px rgba(15, 23, 42, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.48);
  --shape-selected-shadow: 0 18px 42px rgba(15, 23, 42, 0.14), 0 0 0 1px rgba(59, 130, 246, 0.12) inset;

  --stage-tint-1: rgba(59, 130, 246, 0.028);
  --stage-tint-2: rgba(139, 92, 246, 0.028);
  --stage-tint-3: rgba(34, 197, 94, 0.028);
  --stage-tint-4: rgba(245, 158, 11, 0.028);
  --stage-tint-5: rgba(236, 72, 153, 0.028);
  --stage-tint-6: rgba(14, 165, 233, 0.028);
}

/* ── Canvas Background (Process-First) ── */
.canvas-viewport {
  background:
    radial-gradient(circle at 18% 10%, rgba(79, 140, 255, 0.06), transparent 28%),
    radial-gradient(circle at 82% 88%, rgba(139, 92, 246, 0.04), transparent 24%),
    var(--bg);
}

:root[data-theme="light"] .canvas-viewport {
  background:
    radial-gradient(circle at 18% 10%, rgba(79, 140, 255, 0.05), transparent 28%),
    radial-gradient(circle at 82% 88%, rgba(139, 92, 246, 0.03), transparent 24%),
    #F8FAFC;
}

.canvas-content {
  background-color: var(--canvas-bg);
  background-image:
    radial-gradient(circle, var(--grid-minor) 0.8px, transparent 1px),
    linear-gradient(var(--grid-major) 0.5px, transparent 0.5px),
    linear-gradient(90deg, var(--grid-major) 0.5px, transparent 0.5px);
  background-size: 20px 20px, 120px 120px, 120px 120px;
}

/* ── Shape Unified Styling ── */
.shape {
  transition: filter 200ms ease, outline-color 200ms ease, outline-offset 200ms ease, opacity 200ms ease;
}

.shape .shape-body {
  transition: transform 200ms ease, box-shadow 200ms ease, border-color 200ms ease, filter 200ms ease;
}

.shape:hover .shape-body {
  transform: translateY(-1.5px);
  box-shadow: var(--shape-hover-shadow);
  filter: saturate(1.03) brightness(1.02);
}

.shape.selected {
  outline: 2px solid rgba(79, 140, 255, 0.88);
  outline-offset: 6px;
  filter: drop-shadow(0 0 14px rgba(79, 140, 255, 0.22));
}

.shape.selected .shape-body {
  box-shadow: var(--shape-selected-shadow);
}

/* ── Shape Card Presentation ── */
.shape.process .shape-body,
.shape.decision .shape-body,
.shape.document .shape-body,
.shape.subprocess .shape-body,
.shape.startend .shape-body {
  border-radius: var(--shape-card-radius);
  border: 1px solid color-mix(in srgb, var(--shape-stroke, #CBD5E1) 60%, #ffffff 40%);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.01) 50%, rgba(2, 6, 23, 0.08)),
    var(--shape-fill, #123B63);
  box-shadow: var(--shape-card-shadow);
  clip-path: none;
}

.shape.decision .shape-body::after,
.shape.document .shape-body::after {
  display: none;
}

.shape.startend .shape-body {
  border-radius: 16px;
}

.shape.subprocess .shape-body::before,
.shape.subprocess .shape-body::after {
  top: 16px;
  bottom: 16px;
  width: 1px;
  background: rgba(255, 255, 255, 0.28);
}

.shape.subprocess .shape-body::before { left: 18px; }
.shape.subprocess .shape-body::after { right: 18px; }

/* ── Shape Type Indicators ── */
.shape.process::before,
.shape.decision::before,
.shape.document::before,
.shape.subprocess::before,
.shape.startend::before {
  content: "";
  position: absolute;
  left: 14px;
  bottom: 12px;
  z-index: 3;
  width: 24px;
  height: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
  pointer-events: none;
}

.shape.decision::after {
  content: "";
  position: absolute;
  left: 16px;
  top: 12px;
  z-index: 3;
  width: 10px;
  height: 10px;
  border-radius: 2.5px;
  background: rgba(255, 255, 255, 0.28);
  transform: rotate(45deg);
  pointer-events: none;
}

.shape.shape-locked::after {
  content: "Locked";
  left: auto;
  right: 6px;
  top: 6px;
  width: auto;
  height: auto;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.72);
  color: #ffffff;
  padding: 2px 5px;
  font-size: 10px;
  font-weight: 750;
  transform: none;
}

/* ── Shape Text ── */
.shape-text {
  inset: 12px 16px;
  color: var(--shape-text-color, #FFFFFF);
  font-family: var(--shape-font-family, "Inter", Arial, sans-serif);
  font-weight: var(--shape-font-weight, 600);
  line-height: 1.22;
  letter-spacing: -0.01em;
}

.shape.decision .shape-text {
  inset: 16px 22px;
}

.shape.textbox .shape-text,
.shape.actor .shape-text,
.shape.image .shape-text {
  color: var(--shape-text-color, var(--text));
}

/* ── Connector Unified Styling ── */
.connector-path {
  stroke: var(--connector);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--connector);
  filter: drop-shadow(0 4px 8px rgba(2, 6, 23, 0.10));
  transition: stroke 180ms ease, stroke-width 180ms ease, filter 180ms ease;
}

.connector:hover .connector-path {
  stroke: var(--connector-hover);
  stroke-width: 2.8;
  filter: drop-shadow(0 6px 14px rgba(2, 6, 23, 0.18));
}

.connector.selected .connector-path {
  stroke: var(--connector-selected);
  stroke-width: 3;
  filter: drop-shadow(0 0 12px rgba(79, 140, 255, 0.36));
}

.connector-preview .connector-path {
  stroke: #38BDF8;
  stroke-dasharray: 8 7;
  stroke-width: 2.6;
  animation: connector-draw 600ms linear infinite;
}

@keyframes connector-draw {
  to { stroke-dashoffset: -30; }
}

.connector-label-bg {
  fill: color-mix(in srgb, var(--canvas-bg) 94%, #ffffff 6%);
  stroke: color-mix(in srgb, var(--connector) 50%, transparent);
  stroke-width: 0.8;
  rx: 8px;
}

.connector-label {
  fill: color-mix(in srgb, var(--connector) 80%, var(--text));
  font-family: "Inter", Arial, sans-serif;
  font-size: 12px;
  font-weight: 700;
}

/* ── Minimap Lane/Stage/Connector ── */
.mini-lane {
  position: absolute;
  left: 0;
  right: 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  pointer-events: none;
}

.mini-stage {
  position: absolute;
  top: 0;
  bottom: 0;
  border-right: 1px solid rgba(148, 163, 184, 0.18);
  pointer-events: none;
}

.mini-matrix {
  position: absolute;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 2px;
  pointer-events: none;
}

.mini-connector {
  position: absolute;
  height: 1px;
  background: rgba(148, 163, 184, 0.28);
  transform-origin: left center;
  pointer-events: none;
}

/* ── Presentation Mode ── */
.app-shell.presentation-mode .toolbar,
.app-shell.presentation-mode .properties-panel,
.app-shell.presentation-mode .ribbon,
.app-shell.presentation-mode .statusbar,
.app-shell.presentation-mode .page-tab-bar,
.app-shell.presentation-mode .minimap-container,
.app-shell.presentation-mode .hud-strip,
.app-shell.presentation-mode .quick-action-bar,
.app-shell.presentation-mode .canvas-empty-state,
.app-shell.presentation-mode #leftPanelToggle,
.app-shell.presentation-mode #rightPanelToggle {
  display: none !important;
}

.app-shell.presentation-mode .canvas-viewport {
  grid-column: 1 / -1;
  grid-row: 1 / -1;
}

.app-shell.presentation-mode .canvas-content {
  background-image: none;
}

.app-shell.presentation-mode .matrix-cell {
  border-color: rgba(148, 163, 184, 0.03);
}

.app-shell.presentation-mode .shape::before,
.app-shell.presentation-mode .shape.decision::after {
  display: none;
}

.app-shell.presentation-mode .shape .shape-body {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* ── Container / Swimlane Shape Polish ── */
.shape.container .shape-body,
.shape.swimlane .shape-body {
  border-radius: 12px;
  border: 1.5px dashed color-mix(in srgb, var(--shape-stroke, #94A3B8) 50%, transparent);
  background: color-mix(in srgb, var(--shape-fill, #1E293B) 8%, transparent);
  box-shadow: none;
}

.shape.container:hover .shape-body,
.shape.swimlane:hover .shape-body {
  border-color: color-mix(in srgb, var(--shape-stroke, #94A3B8) 70%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--shape-stroke, #94A3B8) 12%, transparent);
  transform: none;
}

/* ── Light Mode Shape Polish ── */
:root[data-theme="light"] .shape.process .shape-body,
:root[data-theme="light"] .shape.decision .shape-body,
:root[data-theme="light"] .shape.document .shape-body,
:root[data-theme="light"] .shape.subprocess .shape-body,
:root[data-theme="light"] .shape.startend .shape-body {
  border-color: color-mix(in srgb, var(--shape-stroke, #CBD5E1) 40%, rgba(0,0,0,0.08));
}

:root[data-theme="light"] .shape.process::before,
:root[data-theme="light"] .shape.decision::before,
:root[data-theme="light"] .shape.document::before,
:root[data-theme="light"] .shape.subprocess::before,
:root[data-theme="light"] .shape.startend::before {
  background: rgba(0, 0, 0, 0.10);
}

:root[data-theme="light"] .shape.decision::after {
  background: rgba(0, 0, 0, 0.10);
}

:root[data-theme="light"] .shape.subprocess .shape-body::before,
:root[data-theme="light"] .shape.subprocess .shape-body::after {
  background: rgba(0, 0, 0, 0.10);
}
