/*! 
 * Anti Gravity - Design Tool
 * 
 * Main Stylesheet
 * 
 * Author: Student Project
 */
/* 1. Base Variables & Reset */
:root {
  /* Color Palette - Light Theme (Default) */
  --primary-blue: #0066ff;
  --primary-blue-hover: #0052cc;
  --primary-blue-light: #e6f0ff;
  --bg-white: #ffffff;
  --bg-light: #f9f9f9;
  --bg-canvas: #f0f2f5;
  --bg-dark: #2c3e50;
  --border-light: #e0e0e0;
  --border-medium: #d0d0d0;
  --border-dark: #b0b0b0;
  --text-primary: #2c3e50;
  --text-secondary: #5f6368;
  --text-light: #95a5a6;
  --danger-red: #e74c3c;
  --danger-red-hover: #c0392b;
  --success-green: #2ecc71;
  --warning-orange: #f39c12;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
  /* Grid Color */
  --grid-line-color: #e0e0e0;
  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  /* Sizing */
  --toolbar-height: 64px;
  --panel-width: 280px;
  --layers-panel-width: 280px;
  --properties-panel-width: 280px;
  /* Transitions */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  /* Glassmorphism */
  --glass-bg: rgba(255, 255, 255, 0.75);
  --glass-border: rgba(255, 255, 255, 0.6);
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
  --backdrop-blur: 20px;
  --panel-bg: rgba(255, 255, 255, 0.65);
  --panel-border: rgba(255, 255, 255, 0.5);
}

[data-theme="dark"] {
  --bg-white: #1e1e1e;
  --bg-light: #2a2a2a;
  --bg-canvas: #121212;
  --text-primary: #ffffff;
  --text-secondary: #a0a0a0;
  --border-light: #333333;
  --border-medium: #444444;
  --glass-bg: rgba(30, 30, 30, 0.75);
  --glass-border: rgba(255, 255, 255, 0.1);
  --panel-bg: rgba(30, 30, 30, 0.65);
  --panel-border: rgba(255, 255, 255, 0.1);
  --grid-line-color: #444444;
}

/* === CSS RESET & BASE === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  background: var(--bg-canvas);
  /* Use neutral canvas background */
  background-image: none;
  /* Remove colorful gradients */
}

/* === UTILITY === */
.mobile-only {
  display: none !important;
}

@media (max-width: 900px) {
  .mobile-only {
    display: flex !important;
  }
}

/* Scrollbar Polish */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-dark);
}

/* 2. Utilities & Animations */
/* === ANIMATIONS === */
@keyframes float {
  0% {
    transform: translateY(0px) rotate(0deg);
  }

  50% {
    transform: translateY(-15px) rotate(2deg);
  }

  100% {
    transform: translateY(0px) rotate(0deg);
  }
}

.floating {
  animation: float 4s ease-in-out infinite;
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes rotate {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

@keyframes fadeInUp {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes loadingProgress {
  0% {
    width: 0%;
  }

  100% {
    width: 100%;
  }
}

@keyframes particleFloat {

  0%,
  100% {
    transform: translate(0, 0) scale(1);
    opacity: 0.6;
  }

  25% {
    transform: translate(20px, -30px) scale(1.2);
    opacity: 0.8;
  }

  50% {
    transform: translate(-15px, -60px) scale(0.8);
    opacity: 0.4;
  }

  75% {
    transform: translate(30px, -40px) scale(1.1);
    opacity: 0.7;
  }
}

@keyframes neonPulse {

  0%,
  100% {
    text-shadow: 0 0 10px #00ffa3, 0 0 20px #00ffa3, 0 0 30px #00ffa3, 0 0 40px #00bcd4, 0 0 70px #00bcd4, 0 0 80px #00bcd4, 0 0 100px #00bcd4;
  }

  50% {
    text-shadow: 0 0 5px #00ffa3, 0 0 10px #00ffa3, 0 0 15px #00ffa3, 0 0 20px #00bcd4, 0 0 35px #00bcd4, 0 0 40px #00bcd4, 0 0 50px #00bcd4;
  }
}

@keyframes shapeEntry {
  0% {
    opacity: 0;
    transform: scale(0) rotate(0deg);
  }

  50% {
    opacity: 0.8;
  }

  100% {
    opacity: 0;
    transform: scale(1.5) rotate(180deg);
  }
}

@keyframes logoEntrance {
  0% {
    opacity: 0;
    transform: scale(0.5) rotate(-180deg);
  }

  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

@keyframes logoFloat {

  0%,
  100% {
    transform: translateY(0px);
  }

  50% {
    transform: translateY(-8px);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 3. Components */
/* Toolbar Buttons */
.tool-btn,
.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  height: 42px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
  user-select: none;
  position: relative;
  overflow: visible;
  min-width: 42px;
}

.tool-btn:hover,
.action-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.08);
  color: var(--text-primary);
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.tool-btn:active,
.action-btn:active {
  transform: scale(0.97) translateY(0);
  transition-duration: 0.1s;
}

.tool-btn.active {
  background: linear-gradient(135deg, var(--primary-blue-light) 0%, rgba(0, 102, 255, 0.08) 100%);
  color: var(--primary-blue);
  border-color: rgba(0, 102, 255, 0.15);
  box-shadow: inset 0 1px 3px rgba(0, 102, 255, 0.1), 0 2px 8px rgba(0, 102, 255, 0.15);
  font-weight: 600;
}

/* Hide labels by default */
.tool-btn .label,
.action-btn .label {
  opacity: 0;
  width: 0;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  font-weight: 500;
}

/* Show labels on hover */
.tool-btn:hover .label,
.action-btn:hover .label {
  opacity: 1;
  width: auto;
  margin-left: 4px;
}

/* Expanded state (for double-tap) */
.tool-btn.expanded,
.action-btn.expanded {
  padding: 0 16px;
  background: var(--primary-blue-light);
  border-color: var(--primary-blue);
}

.tool-btn.expanded .label,
.action-btn.expanded .label {
  opacity: 1;
  width: auto;
  margin-left: 4px;
}

/* Tooltip on hover */
.tool-btn::before,
.action-btn::before {
  content: attr(title);
  position: absolute;
  bottom: -38px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: white;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1000;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.25), 0 2px 4px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.1);
  letter-spacing: 0.01em;
}

.tool-btn::after,
.action-btn::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid rgba(0, 0, 0, 0.92);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1000;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.tool-btn:hover::before,
.action-btn:hover::before,
.tool-btn:hover::after,
.action-btn:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Special Buttons */
.action-btn.special {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
  background-size: 200% auto;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 12px rgba(139, 92, 246, 0.35), 0 1px 3px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.action-btn.special::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.action-btn.special:hover {
  background-position: right center;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transform: translateY(-2px) scale(1.03);
}

.action-btn.special:hover::before {
  left: 100%;
}

.action-btn.special.active {
  animation: pulse-special 2s infinite;
  box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.6), 0 4px 20px rgba(139, 92, 246, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.action-btn.danger {
  color: var(--danger-red);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.action-btn.danger:hover {
  background: linear-gradient(135deg, rgba(231, 76, 60, 0.12) 0%, rgba(192, 57, 43, 0.08) 100%);
  border-color: rgba(231, 76, 60, 0.2);
  color: var(--danger-red-hover);
  box-shadow: 0 2px 8px rgba(231, 76, 60, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
}

.icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
  stroke: currentColor;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.tool-btn:hover .icon svg,
.action-btn:hover .icon svg {
  transform: scale(1.08);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.tool-btn.active .icon svg,
.action-btn.active .icon svg {
  transform: scale(1.05);
}

.icon-group {
  display: flex;
  gap: 4px;
  background: var(--bg-light);
  padding: 2px;
  border-radius: 6px;
  border: 1px solid var(--border-medium);
}

.icon-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
}

.icon-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
}

.icon-btn.active {
  background: var(--bg-white);
  color: var(--primary-blue);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  font-weight: bold;
}

/* === ADVANCED PROPERTY CONTROLS === */
.property-section-header {
  margin-top: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-light);
}

.property-section-header h4 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

/* === SCROLLBARS === */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
  background: transparent;
}

::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: content-box;
  transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
  border: 2px solid transparent;
  background-clip: content-box;
}

[data-theme=dark] ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
}

[data-theme=dark] ::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* === SLIDERS === */
.slider-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

/* Styled Range Input */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border-medium);
  border-radius: 2px;
  outline: none;
  margin: 0;
  padding: 0;
  border: none;
  cursor: pointer;
}

/* Track progress fill (visual trick using gradient if compatible, else just track) */
/* Ideally we use JS for fill, but simple track is fine for now */
/* Thumb */
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-white);
  border: 2px solid var(--primary-blue);
  cursor: grab;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  margin-top: -5px;
  /* Centers thumb on 4px track */
}

input[type=range]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  background: var(--primary-blue);
  border-color: var(--primary-blue-hover);
}

input[type=range]::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(0.95);
  box-shadow: 0 0 0 4px var(--primary-blue-light);
}

/* Firefox */
input[type=range]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-white);
  border: 2px solid var(--primary-blue);
  cursor: grab;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

input[type=range]::-moz-range-progress {
  background: var(--primary-blue);
  height: 4px;
  border-radius: 2px;
}

/* Dark Mode Overrides for Sliders */
[data-theme=dark] input[type=range] {
  background: rgba(255, 255, 255, 0.1);
}

[data-theme=dark] input[type=range]::-webkit-slider-thumb {
  background: #2c2c2c;
  border-color: var(--primary-blue);
}

[data-theme=dark] input[type=range]::-webkit-slider-thumb:hover {
  background: var(--primary-blue);
}

.slider-wrapper span {
  font-size: 11px;
  color: var(--text-secondary);
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  min-width: 24px;
  text-align: right;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.checkbox-group input[type=checkbox] {
  width: auto;
  cursor: pointer;
}

.checkbox-group label {
  margin-bottom: 0;
  cursor: pointer;
}

.checkbox-row {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
}

.checkbox-row label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.checkbox-row input[type=checkbox] {
  accent-color: var(--primary-blue);
}

.property-row {
  display: flex;
  gap: 8px;
}

.property-group.half {
  flex: 1;
  min-width: 0;
}

/* .icon-group is now defined in _buttons.scss - removed duplicate */
/* === MODAL DIALOG === */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-white);
  width: 90%;
  max-width: 400px;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
  border: 1px solid var(--border-light);
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.2s ease;
}

.modal-close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.5;
}

.modal-footer {
  padding: 20px 24px;
  background: var(--bg-light);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  border-top: 1px solid var(--border-light);
}

.modal-btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.modal-btn.secondary {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-medium);
}

.modal-btn.secondary:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.modal-btn.danger {
  background: var(--danger-red);
  color: white;
  box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
}

.modal-btn.danger:hover {
  background: var(--danger-red-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
}

.modal-btn:active {
  transform: scale(0.96);
}

/* === WELCOME DIALOG === */
.welcome-modal {
  max-width: 700px;
  width: 90%;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.welcome-header {
  text-align: center;
  padding: 40px 32px 32px;
  background: #f5f5f5;
  color: #000000;
  border-bottom: 1px solid var(--border-light);
}

[data-theme="dark"] .welcome-header {
  background: #2a2a2a;
  color: #ffffff;
}

.welcome-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  background: #ffffff;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 900;
  border: 1px solid var(--border-light);
  color: #000000;
}

[data-theme="dark"] .welcome-logo {
  background: #1e1e1e;
  border-color: #444;
  color: #ffffff;
}

.welcome-header h2 {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 8px 0;
  letter-spacing: -0.5px;
}

.welcome-tagline {
  font-size: 15px;
  opacity: 0.9;
  margin: 0;
  font-weight: 500;
}

.welcome-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

.welcome-section {
  margin-bottom: 32px;
}

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

.welcome-section h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 16px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.welcome-section p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 0;
}

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

.feature-list li {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 10px;
  padding-left: 20px;
  position: relative;
}

.feature-list li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: #000000;
  font-weight: 700;
  font-size: 18px;
}

[data-theme="dark"] .feature-list li::before {
  color: #ffffff;
}

.feature-list li strong {
  color: var(--text-primary);
  font-weight: 600;
}

.how-to-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.how-to-item {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.how-to-number {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  background: #000000;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

[data-theme="dark"] .how-to-number {
  background: #ffffff;
  color: #000000;
}

.signature {
  font-family: 'Great Vibes', cursive;
  font-size: 18px;
  color: #444444;
  /* Dark Gray */
  text-align: center;
  margin-top: 16px;
  margin-right: 0;
  opacity: 0.8;
}

[data-theme="dark"] .signature {
  color: #888888;
}

.how-to-text {
  flex: 1;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.how-to-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

.shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.shortcut-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: var(--bg-light);
  border-radius: 8px;
  border: 1px solid var(--border-light);
  transition: all 0.2s ease;
}

.shortcut-item:hover {
  background: var(--bg-canvas);
  border-color: var(--border-medium);
  transform: translateY(-2px);
}

.shortcut-item kbd {
  background: white;
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.shortcut-item span {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  font-weight: 500;
}

.welcome-footer {
  padding: 24px 32px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: center;
  background: var(--bg-light);
}

.btn-primary {
  padding: 12px 32px;
  background: #000000;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
  transform: translateY(-2px);
  background: #333333;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .btn-primary {
  background: #ffffff;
  color: #000000;
}

[data-theme="dark"] .btn-primary:hover {
  background: #e0e0e0;
}

.btn-primary:active {
  transform: translateY(0);
}

/* Dark mode welcome dialog */
[data-theme="dark"] .shortcut-item kbd {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.9);
}

/* Mobile responsive */
@media (max-width: 768px) {
  .welcome-modal {
    max-width: 95%;
    max-height: 90vh;
  }

  .welcome-header {
    padding: 32px 24px 24px;
  }

  .welcome-header h2 {
    font-size: 24px;
  }

  .welcome-content {
    padding: 24px;
  }

  .welcome-section {
    margin-bottom: 24px;
  }

  .shortcuts-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
  }

  .welcome-footer {
    padding: 20px 24px;
  }
}

/* === CONTEXT MENU === */
.context-menu {
  position: fixed;
  z-index: 10000;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 6px 0;
  width: 180px;
  box-shadow: var(--shadow-lg);
  display: none;
  animation: scaleIn 0.15s ease-out;
  transform-origin: top left;
}

.context-menu.visible {
  display: block;
}

.context-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.1s;
}

.context-menu-item:hover {
  background: var(--primary-blue);
  color: white;
}

.context-menu-item .shortcut {
  font-size: 11px;
  opacity: 0.6;
}

.context-menu-divider {
  height: 1px;
  background: var(--border-light);
  margin: 4px 0;
}

.context-menu-item.danger {
  color: var(--danger-red);
}

.context-menu-item.danger:hover {
  background: var(--danger-red);
  color: white;
}

/* === LOADING SCREEN === */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: auto;
  height: auto;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 1;
  visibility: visible;
  color: #000000;
}

.loading-screen.fade-out {
  opacity: 0;
  visibility: hidden;
}

.loading-content {
  text-align: center;
  position: relative;
  z-index: 2;
}

/* Animated Logo */
.loading-logo {
  margin-bottom: 48px;
}

.logo-circle {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.05);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 24px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
  animation: logoFloat 3s ease-in-out infinite;
}

.logo-text {
  font-size: 48px;
  font-weight: 900;
  color: #000000;
  letter-spacing: -2px;
}

/* Loading Title */
.loading-title {
  font-size: 32px;
  font-weight: 700;
  color: #000000;
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.loading-subtitle {
  font-size: 15px;
  color: rgba(0, 0, 0, 0.6);
  font-weight: 500;
  margin-bottom: 48px;
  letter-spacing: 0.5px;
}

/* Progress Bar */
.loading-bar-container {
  width: 280px;
  height: 3px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
  margin: 0 auto 20px;
  overflow: hidden;
}

.loading-bar {
  height: 100%;
  background: #000000;
  border-radius: 2px;
  animation: loadingProgress 2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  box-shadow: none;
}

.loading-status {
  font-size: 13px;
  color: rgba(0, 0, 0, 0.5);
  font-weight: 500;
}

@keyframes logoFloat {

  0%,
  100% {
    transform: translateY(0px);
  }

  50% {
    transform: translateY(-10px);
  }
}

@keyframes loadingProgress {
  0% {
    width: 0%;
    opacity: 0;
  }

  10% {
    opacity: 1;
  }

  100% {
    width: 100%;
  }
}

/* Dark mode loading screen */
[data-theme="dark"] .loading-screen {
  background: #1e1e1e;
  color: #ffffff;
}

[data-theme="dark"] .logo-circle {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .logo-text {
  color: #ffffff;
}

[data-theme="dark"] .loading-title {
  color: #ffffff;
}

[data-theme="dark"] .loading-subtitle {
  color: rgba(255, 255, 255, 0.6);
}

[data-theme="dark"] .loading-bar-container {
  background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .loading-bar {
  background: #ffffff;
}

[data-theme="dark"] .loading-status {
  color: rgba(255, 255, 255, 0.5);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .loading-title {
    font-size: 28px;
  }

  .loading-subtitle {
    font-size: 14px;
  }

  .logo-circle {
    width: 80px;
    height: 80px;
  }

  .logo-text {
    font-size: 36px;
  }

  .loading-bar-container {
    width: 220px;
  }
}

/* Entry Animation Overlay */
.entry-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: auto;
  height: auto;
  background: var(--bg-canvas);
  z-index: 9998;
  pointer-events: none;
  transition: opacity 0.8s ease;
}

.entry-overlay.fade-out {
  opacity: 0;
}

.entry-shapes {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.entry-shape {
  position: absolute;
  opacity: 0.6;
  animation: shapeEntry 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.shape-1 {
  width: 200px;
  height: 200px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 30% 70% 70% 30%/30% 30% 70% 70%;
  top: 10%;
  left: 10%;
  animation-delay: 0.1s;
}

.shape-2 {
  width: 150px;
  height: 150px;
  background: linear-gradient(135deg, #f093fb, #f5576c);
  border-radius: 50%;
  top: 60%;
  right: 15%;
  animation-delay: 0.2s;
}

.shape-3 {
  width: 180px;
  height: 180px;
  background: linear-gradient(135deg, #4facfe, #00f2fe);
  border-radius: 20% 80% 80% 20%/80% 20% 80% 20%;
  bottom: 15%;
  left: 20%;
  animation-delay: 0.3s;
}

.shape-4 {
  width: 120px;
  height: 120px;
  background: linear-gradient(135deg, #43e97b, #38f9d7);
  border-radius: 50%;
  top: 30%;
  right: 25%;
  animation-delay: 0.4s;
}

.shape-5 {
  width: 160px;
  height: 160px;
  background: linear-gradient(135deg, #fa709a, #fee140);
  border-radius: 40% 60% 60% 40%/60% 40% 60% 40%;
  bottom: 25%;
  right: 10%;
  animation-delay: 0.5s;
}

/* === EMPTY STATE === */
.empty-state {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 10;
  background: var(--bg-canvas);
  /* Cover grid */
}

.empty-level {
  text-align: center;
  /* Removed animation for watermark look */
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 1;
  /* Full visibility for vibrant logo */
}

.empty-state .logo-circle {
  /* Remove circle styling for signature look */
  margin: 0 auto 16px;
  background: transparent;
  border: none;
  box-shadow: none;
  width: auto;
  height: auto;
}

.empty-state .logo-text {
  /* Ornate Blackletter F */
  font-family: "UnifrakturMagdeburg", cursive;
  font-size: 280px;
  font-weight: 400;
  font-style: normal;
  color: rgba(180, 180, 180, 0.25);
  /* Light grey with low opacity */
  line-height: 0.85;
  position: relative;
  animation: none;
  letter-spacing: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-shadow: -1px -1px 1px rgba(255, 255, 255, 0.5), 1px 1px 2px rgba(0, 0, 0, 0.15);
}

/* Period removed for simple gray F */
.empty-state .logo-text::after {
  content: none;
}

.empty-state p {
  display: none;
}

/* Completely hide grid canvas when empty */
.editor-canvas.empty {
  opacity: 0;
}

/* 4. Layout Modules */
/* === APP CONTAINER === */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  background: var(--bg-white);
  overflow: hidden;
}

/* === MAIN CONTENT LAYOUT === */
/* Desktop Grid Layout */
.main-content {
  display: grid;
  grid-template-columns: var(--layers-panel-width) 1fr var(--properties-panel-width);
  grid-template-rows: 1fr;
  grid-template-areas: "layers canvas properties";
  height: calc(100vh - var(--toolbar-height));
  overflow: hidden;
  position: relative;
}

/* Assign Grid Areas */
.canvas-container {
  grid-area: canvas;
  /* Ensure canvas doesn't overflow grid track */
  min-width: 0;
  min-height: 0;
}

#sidebar-container {
  /* Mobile default: block/flex is handled in media query */
  /* Desktop override below */
  display: none;
  /* Hide by default to prevent FOUC / layout shift if JS/CSS delays */
}

@media (min-width: 901px) {
  #sidebar-container {
    display: contents !important;
    /* Force contents to unwrap panels into grid */
  }
}

/* Pass children to grid */
.layers-panel {
  grid-area: layers;
}

.properties-panel {
  grid-area: properties;
}

/* Smooth panel transitions when not resizing */
.main-content:not(.resizing) {
  transition: grid-template-columns 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Fix for desktop layout where toolbar is floating/fixed */
@media (min-width: 901px) {
  .main-content {
    height: 100vh;
    padding-top: 80px;
  }

  .canvas-container {
    height: 100%;
  }

  /* Prevent toolbar overflow */
  .toolbar {
    max-width: calc(100vw - 40px);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .toolbar::-webkit-scrollbar {
    display: none;
  }

  .toolbar-scroll-container {
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .toolbar-scroll-container::-webkit-scrollbar {
    display: none;
  }
}

/* === PROPERTIES PANEL EMPTY STATE === */
.no-selection {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 32px;
  color: var(--text-secondary);
}

.no-selection-icon {
  font-size: 48px;
  margin-bottom: 16px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

.no-selection p {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.no-selection small {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-light);
  max-width: 200px;
}

/* === TOOLBAR - FLOATING DYNAMIC ISLAND === */
.toolbar {
  display: none;
  /* Hide default toolbar on desktop */
  align-items: center;
  gap: var(--spacing-md);
  padding: 0 clamp(12px, 3vw, 32px);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  height: 64px;
  width: 100%;
  max-width: 100vw;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02), 0 4px 16px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(0, 0, 0, 0.02);
  z-index: 200;
  position: sticky;
  top: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: visible;
}

/* Show traditional toolbar only on mobile */
@media (max-width: 900px) {
  .toolbar {
    display: flex;
  }
}

/* Floating Command Center - Desktop Only */
@media (min-width: 901px) {
  .toolbar {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    width: auto;
    max-width: min(90vw, 900px);
    height: 48px;
    padding: 8px 12px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08), 0 0 0 0.5px rgba(255, 255, 255, 0.5) inset;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    animation: floatIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1000;
  }

  .toolbar:hover {
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.16), 0 4px 12px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(255, 255, 255, 0.6) inset;
    transform: translateX(-50%) translateY(-2px);
  }
}

/* Dark Mode Toolbar */
[data-theme=dark] .toolbar {
  background: rgba(20, 20, 20, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  margin-right: var(--spacing-lg);
  flex-shrink: 0;
}

.app-logo {
  font-weight: 900;
  font-size: 24px;
  background: linear-gradient(135deg, #0066ff 0%, #00d4ff 50%, #0095ff 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -1.2px;
  animation: shine 8s linear infinite;
  filter: drop-shadow(0 2px 8px rgba(0, 102, 255, 0.15));
  user-select: none;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.app-logo:hover {
  transform: scale(1.05);
}

/* Scrollable toolbar for mobile */
.toolbar-scroll-container {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  flex: 1;
  overflow-x: auto;
  overflow-y: visible;
  padding: 4px 0;
  margin: 0 var(--spacing-sm);
  /* Hide scrollbar */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.toolbar-scroll-container::-webkit-scrollbar {
  display: none;
}

.toolbar-section {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  flex-shrink: 0;
  padding: 0 4px;
}

.toolbar-spacer {
  flex: 1;
}

.divider {
  width: 1px;
  height: 24px;
  background: linear-gradient(to bottom, transparent, var(--border-light) 20%, var(--border-light) 80%, transparent);
  margin: 0 var(--spacing-sm);
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 0.2s ease;
}

.divider:hover {
  opacity: 0.8;
}

/* Scroll Indicator */
.scroll-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0.8;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin-left: 8px;
  border-radius: 50%;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  z-index: 10;
}

.scroll-indicator:hover {
  opacity: 1;
  color: var(--primary-blue);
  background: var(--bg-white);
  border-color: var(--primary-blue);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.scroll-indicator:active {
  transform: translateY(0) scale(0.95);
}

.scroll-indicator svg {
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
}

/* Mobile adjustments for scroll indicator */
@media (max-width: 600px) {
  .scroll-indicator {
    width: 28px;
    height: 28px;
    margin-left: 4px;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(4px);
  }

  .scroll-indicator svg {
    width: 16px;
    height: 16px;
  }
}

.scroll-indicator:hover svg {
  animation: bounceHorizontal 1s infinite;
}


@keyframes bounceHorizontal {

  0%,
  100% {
    transform: translateX(0);
  }

  50% {
    transform: translateX(3px);
  }
}

/* Redefine special action button (Gravity) to remove specific color but keep active state */
.action-btn.special {
  /* Removed purple gradient */
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  box-shadow: none;
}

.action-btn.special:hover {
  /* Match standard hover */
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.08);
  color: var(--text-primary);
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.action-btn.special.active {
  /* Dynamic active state: Subtle blue tint + Glow */
  background: rgba(0, 102, 255, 0.08);
  color: var(--primary-blue);
  border-color: rgba(0, 102, 255, 0.3);
  box-shadow: 0 0 12px rgba(0, 102, 255, 0.2), inset 0 0 0 1px rgba(0, 102, 255, 0.1);
  animation: none;
}

.action-btn.special::before,
.action-btn.special:hover::before {
  /* Remove the shine effect elements */
  display: none;
}

/* === PANELS === */
.panel {
  background: var(--panel-bg);
  backdrop-filter: blur(var(--backdrop-blur));
  -webkit-backdrop-filter: blur(var(--backdrop-blur));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
  transition: background 0.3s ease;
}

.layers-panel {
  border-right: 1px solid var(--panel-border);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.02);
}

.properties-panel {
  border-left: 1px solid var(--panel-border);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.02);
}

.panel-header {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.1);
  /* Subtle highlight */
}

.panel-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  opacity: 0.9;
}

.panel-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  opacity: 0.6;
}

.panel-close-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--danger-red);
  opacity: 1;
}

/* === LAYERS PANEL ITEMS === */
.layers-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-sm);
}

.layer-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  position: relative;
}

.layer-item:hover {
  background: var(--primary-blue-light);
  transform: translateX(2px);
  opacity: 0.8;
}

.layer-item.selected {
  background: var(--primary-blue-light);
  color: var(--primary-blue);
  font-weight: 600;
  border-color: rgba(0, 102, 255, 0.1);
  box-shadow: 0 2px 8px rgba(0, 102, 255, 0.15);
}

/* Drag handle */
.layer-drag-handle {
  cursor: grab;
  color: var(--text-secondary);
  opacity: 0.3;
  font-size: 16px;
  line-height: 1;
  padding: 0 4px;
  transition: all 0.2s ease;
  user-select: none;
}

.layer-drag-handle:hover {
  opacity: 0.8;
  color: var(--primary-blue);
}

.layer-drag-handle:active {
  cursor: grabbing;
}

/* Dragging state */
.layer-item.dragging {
  opacity: 0.5;
  background: var(--bg-light);
  transform: scale(0.98);
}

/* Drop indicators */
.layer-item.drop-above {
  border-top: 2px solid var(--primary-blue);
  margin-top: 4px;
}

.layer-item.drop-below {
  border-bottom: 2px solid var(--primary-blue);
  margin-bottom: 4px;
}


.layer-controls {
  padding: var(--spacing-md);
  border-top: 1px solid var(--panel-border);
  display: flex;
  gap: var(--spacing-sm);
  background: var(--bg-light);
  /* Footer differentiate */
}

.control-btn {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  background: var(--bg-white);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.control-btn:hover:not(:disabled) {
  background: var(--primary-blue-light);
  border-color: var(--primary-blue);
  color: var(--primary-blue);
}

.control-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* === PROPERTIES PANEL === */
.properties-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 var(--spacing-md) 80px var(--spacing-md);
  /* Extra space at bottom */
}

/* Custom Scrollbar for Properties Panel */
.properties-content::-webkit-scrollbar {
  width: 10px;
}

.properties-content::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.02);
  border-radius: 10px;
  margin: 4px;
}

.properties-content::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--primary-blue) 0%, rgba(0, 102, 255, 0.7) 100%);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
  transition: all 0.3s ease;
}

.properties-content::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--primary-blue-hover) 0%, var(--primary-blue) 100%);
  border: 1px solid transparent;
}

/* Firefox scrollbar */
.properties-content {
  scrollbar-width: thin;
  scrollbar-color: var(--primary-blue) rgba(0, 0, 0, 0.02);
}

/* Property Groups */
.property-group {
  margin-bottom: 16px;
  animation: slideIn 0.3s ease;
}

.property-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  transition: color 0.2s ease;
}

.property-group input,
.property-group select,
.property-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: var(--bg-white);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  transition: all 0.2s ease;
  outline: none;
}

.property-group input:hover,
.property-group select:hover,
.property-group textarea:hover {
  border-color: var(--border-medium);
  background: var(--bg-light);
}

.property-group input:focus,
.property-group select:focus,
.property-group textarea:focus {
  border-color: var(--primary-blue);
  background: var(--bg-white);
  box-shadow: 0 0 0 3px var(--primary-blue-light);
}

.property-group input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.property-group input[type="number"]::-webkit-inner-spin-button,
.property-group input[type="number"]::-webkit-outer-spin-button {
  opacity: 0.5;
  transition: opacity 0.2s ease;
}

.property-group input[type="number"]:hover::-webkit-inner-spin-button,
.property-group input[type="number"]:hover::-webkit-outer-spin-button {
  opacity: 1;
}

/* Color Input Wrapper */
.color-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: var(--bg-white);
  transition: all 0.2s ease;
}

.color-input-wrapper:hover {
  border-color: var(--primary-blue);
  box-shadow: 0 2px 8px rgba(0, 102, 255, 0.1);
}

.color-input-wrapper input[type="color"] {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  background: transparent;
}

.color-input-wrapper input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-input-wrapper input[type="color"]::-webkit-color-swatch {
  border: 2px solid var(--border-light);
  border-radius: 4px;
  transition: border-color 0.2s ease;
}

.color-input-wrapper input[type="color"]:hover::-webkit-color-swatch {
  border-color: var(--primary-blue);
}

.color-value {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  user-select: all;
}

/* Section Headers */
.property-section-header {
  margin-top: 24px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border-light);
  position: relative;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
}

.property-section-header:hover {
  border-bottom-color: var(--primary-blue);
}

.property-section-header h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-primary);
  letter-spacing: 0.8px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.property-section-header h4::before {
  content: '▼';
  font-size: 10px;
  color: var(--text-secondary);
  transition: transform 0.3s ease;
  display: inline-block;
}

.property-section-header.collapsed h4::before {
  transform: rotate(-90deg);
}

/* Collapsible Section Content */
.property-section-content {
  max-height: 2000px;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
  opacity: 1;
}

.property-section-content.collapsed {
  max-height: 0;
  opacity: 0;
}

/* Textarea */
.property-group textarea {
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
  line-height: 1.5;
}

/* Select Dropdown */
.property-group select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%235f6368' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

.property-group select:hover {
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%230066ff' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* Checkbox Styling */
.property-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary-blue);
  border-radius: 4px;
}

/* Toggle Arrows for Panel */
.panel-toggle-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 56px;
  background: var(--glass-bg);
  border: 1px solid var(--panel-border);
  display: none;
  /* Hidden by default, shown on desktop */
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 101;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.05);
  padding: 0;
  outline: none;
}

/* Show on desktop only */
@media (min-width: 901px) {
  .panel-toggle-btn {
    display: flex;
  }
}

.panel-toggle-btn:hover {
  background: var(--primary-blue-light);
  border-color: var(--primary-blue);
  box-shadow: -4px 0 12px rgba(0, 102, 255, 0.15);
}

.panel-toggle-btn:active {
  transform: translateY(-50%) scale(0.95);
}

.panel-toggle-btn svg {
  width: 14px;
  height: 14px;
  stroke: var(--text-secondary);
  transition: all 0.3s ease;
  stroke-width: 2.5;
}

.panel-toggle-btn:hover svg {
  stroke: var(--primary-blue);
  transform: scale(1.15);
}

/* Position toggle buttons */
.layers-panel .panel-toggle-btn {
  right: -28px;
  border-radius: 0 12px 12px 0;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
}

.properties-panel .panel-toggle-btn {
  left: -28px;
  border-radius: 12px 0 0 12px;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.05);
}

/* When panel is collapsed, flip arrow */
.layers-panel.collapsed .panel-toggle-btn svg {
  transform: rotate(180deg);
}

.properties-panel.collapsed .panel-toggle-btn svg {
  transform: rotate(180deg);
}

/* === PANEL RESIZE HANDLES === */
.panel-resize-handle {
  position: absolute;
  top: var(--toolbar-height);
  bottom: 0;
  width: 8px;
  z-index: 100;
  cursor: col-resize;
  user-select: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: none;
  /* Hidden by default, shown on desktop */
}

@media (min-width: 901px) {
  .panel-resize-handle {
    display: block;
  }
}

/* Layers panel resize handle (right edge) */
.panel-resize-handle-layers {
  left: var(--layers-panel-width);
  transform: translateX(-4px);
}

/* Properties panel resize handle (left edge) */
.panel-resize-handle-properties {
  right: var(--properties-panel-width);
  transform: translateX(4px);
}

/* Hover area - extend hitbox */
.panel-resize-handle::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -8px;
  right: -8px;
  background: transparent;
}

/* Visual indicator line */
.resize-handle-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 40px;
  background: transparent;
  border-radius: 2px;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

/* Hover state */
.panel-resize-handle:hover .resize-handle-indicator {
  background: linear-gradient(to bottom, transparent, var(--primary-blue) 20%, var(--primary-blue) 80%, transparent);
  height: 60px;
  box-shadow: 0 0 12px rgba(0, 102, 255, 0.4);
}

/* Active/dragging state */
.panel-resize-handle.active .resize-handle-indicator {
  background: linear-gradient(to bottom, transparent, var(--primary-blue) 10%, var(--primary-blue) 90%, transparent);
  height: 100%;
  width: 3px;
  box-shadow: 0 0 20px rgba(0, 102, 255, 0.6);
}

/* Body state when resizing */
body.panel-resizing {
  cursor: col-resize !important;
  user-select: none !important;
}

body.panel-resizing * {
  cursor: col-resize !important;
  pointer-events: none !important;
}

body.panel-resizing .panel-resize-handle,
body.panel-resizing .panel-resize-handle * {
  pointer-events: auto !important;
}

/* Panel width constraints */
.layers-panel,
.properties-panel {
  min-width: 0;
  max-width: 600px;
}

.layers-panel.closed,
.properties-panel.closed {
  width: 0 !important;
  min-width: 0 !important;
  padding: 0 !important;
  border: none !important;
  overflow: hidden !important;
  opacity: 0;
  pointer-events: none;
}

/* === PANEL TRIGGERS === */
.panel-trigger {
  position: absolute;
  top: 100px;
  /* Aligned with top area */
  width: 24px;
  height: 40px;
  background: var(--bg-white);
  border: 1px solid var(--border-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2000;
  color: var(--text-secondary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.panel-trigger:hover {
  background: var(--primary-blue-light);
  color: var(--primary-blue);
}

.panel-trigger.left {
  left: 0;
  border-left: none;
  border-bottom-right-radius: 8px;
  border-top-right-radius: 8px;
}

.panel-trigger.right {
  right: 0;
  border-right: none;
  border-bottom-left-radius: 8px;
  border-top-left-radius: 8px;
}

.panel-trigger.visible {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

/* === CANVAS AREA === */
.canvas-container {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 100%;
  background: var(--bg-canvas);
  z-index: 1;
  cursor: grab;
  /* Fallback */
  cursor: -webkit-grab;
}

.canvas-container:active {
  cursor: grabbing;
  cursor: -webkit-grabbing;
}

.canvas-container {
  /* Grid pattern */
  background-image: linear-gradient(var(--grid-line-color) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line-color) 1px, transparent 1px);
  background-size: 20px 20px;
  /* Shadow vignette for depth */
}

.canvas-container::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.03);
  z-index: 2;
}

.editor-canvas {
  width: 100%;
  height: 100%;
  cursor: default;
  transform-origin: 0 0;
  pointer-events: none;
  /* Let clicks pass to container for panning selection */
}

/* === CANVAS ELEMENTS === */
.canvas-element {
  position: absolute;
  box-sizing: border-box;
  pointer-events: auto;
  /* Re-enable events for elements */
  user-select: none;
  /* Smooth outline transition for hover */
  transition: box-shadow 0.1s ease;
  /* Hover state (Pre-selection) */
}

.canvas-element:hover:not(.selected) {
  /* Thin blue outline indicating selectability */
  box-shadow: 0 0 0 1px var(--primary-blue) !important;
  z-index: 900;
  /* Pop slightly above others */
}

/* Locked State */
.canvas-element.locked {
  cursor: not-allowed;
}

/* Selected State */
.canvas-element.selected {
  /* Primary Selection Border - Figma Style */
  /* Using box-shadow creates a border that doesn't affect layout and sits 'outside' */
  box-shadow: 0 0 0 1px var(--primary-blue), 0 0 0 4px rgba(0, 102, 255, 0.1);
  /* Subtle glow */
  z-index: 1000 !important;
  /* Ensure selected is always on top */
  /* Locked & Selected */
}

.canvas-element.selected.locked {
  box-shadow: 0 0 0 1px var(--danger-red);
  /* Red border for locked */
  /* Hide handles for locked items */
}

.canvas-element.selected.locked .resize-handle {
  display: none !important;
}

/* Resize Handles */
.resize-handle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: white;
  border: 1.5px solid var(--primary-blue);
  border-radius: 1px;
  /* Square with microscopic rounding */
  z-index: 1001;
  /* Above the element border */
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  /* Invisible Hit Area (Larger than visual handle) */
}

.resize-handle::after {
  content: "";
  position: absolute;
  top: -10px;
  left: -10px;
  right: -10px;
  bottom: -10px;
  border-radius: 4px;
  /* Slightly rounded hit area */
}



.resize-handle.top-left {
  top: -5px;
  left: -5px;
  cursor: nwse-resize;
}

.resize-handle.top-right {
  top: -5px;
  right: -5px;
  cursor: nesw-resize;
}

.resize-handle.bottom-left {
  bottom: -5px;
  left: -5px;
  cursor: nesw-resize;
}

.resize-handle.bottom-right {
  bottom: -5px;
  right: -5px;
  cursor: nwse-resize;
}



.resize-handle:hover {
  background: var(--primary-blue);
  transform: scale(1.3);
  border-color: white;
  /* Invert colors on hover */
  box-shadow: 0 2px 4px rgba(0, 102, 255, 0.4);
}

/* Smart Guides */
.smart-guide {
  pointer-events: none;
  z-index: 9999;
  background-color: var(--danger-red);
  box-shadow: 0 0 2px rgba(255, 255, 255, 0.5);
}

/* Layout Grid Overlay */
.layout-grid-overlay {
  pointer-events: none;
  z-index: 999;
  /* Below handles but above content */
  mix-blend-mode: multiply;
}

/* === MOBILE & RESPONSIVE === */
.mobile-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: 290;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.mobile-backdrop.open,
.mobile-backdrop.mobile-open {
  opacity: 1;
  pointer-events: auto;
}

/* Mobile Tabs */
.mobile-tabs {
  display: none;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid var(--panel-border);
  padding: 0 var(--spacing-sm);
  align-items: center;
  gap: var(--spacing-md);
  height: 56px;
}

.mobile-tab-btn {
  background: none;
  border: none;
  padding: 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  position: relative;
  cursor: pointer;
}

.mobile-tab-btn.active {
  color: var(--primary-blue);
}

.mobile-tab-btn.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--primary-blue);
}

.mobile-close-btn {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
}

/* Tablet Responsiveness */
@media (max-width: 1024px) and (min-width: 901px) {
  :root {
    --panel-width: 240px;
    --layers-panel-width: 240px;
    --properties-panel-width: 240px;
  }

  .tool-btn .label {
    display: none;
  }
}

/* Large Tablet / Small Desktop - Optimize panel widths */
@media (min-width: 1025px) and (max-width: 1280px) {
  :root {
    --layers-panel-width: 260px;
    --properties-panel-width: 260px;
  }
}

/* Desktop - Full panel width */
@media (min-width: 1281px) {
  :root {
    --layers-panel-width: 280px;
    --properties-panel-width: 280px;
  }
}

/* Mobile & Small Tablet Responsiveness */
@media (max-width: 900px) {

  /* Hide Desktop Toolbar Items */
  .toolbar-scroll-container {
    display: none !important;
  }

  /* Adjust Toolbar Layout */
  .toolbar {
    justify-content: space-between;
    padding: 0 var(--spacing-md);
    height: 58px;
    gap: var(--spacing-sm);
  }

  .toolbar-left {
    margin-right: 0;
    gap: var(--spacing-md);
  }

  /* Make mobile buttons more touch-friendly */
  .mobile-only.action-btn {
    min-width: 44px;
    height: 44px;
    padding: 0 12px;
  }

  .app-logo {
    font-size: 20px;
  }

  /* Layout Changes */
  .main-content {
    display: flex;
    flex-direction: column;
    grid-template-columns: 1fr;
    grid-template-areas: none;
  }

  .canvas-container {
    flex: 1;
    width: 100%;
    height: 100%;
  }

  /* Sidebar Drawer */
  #sidebar-container {
    display: flex !important;
    flex-direction: column;
    position: fixed;
    top: 12px;
    left: 12px;
    bottom: 12px;
    width: 85%;
    max-width: 300px;
    height: auto;
    border-radius: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--backdrop-blur));
    box-shadow: var(--glass-shadow);
    z-index: 300;
    transform: translateX(-120%);
    transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    border: 1px solid var(--glass-border);
  }

  #sidebar-container.mobile-open {
    transform: translateX(0);
  }

  /* Styling panels inside sidebar */
  .panel {
    border: none;
    background: transparent;
    display: none;
    flex: 1;
    overflow-y: auto;
  }

  .panel.active-tab {
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
  }

  /* Show Mobile Tabs */
  .mobile-tabs {
    display: flex;
    flex-shrink: 0;
    justify-content: space-between;
    padding-right: 8px;
  }

  .mobile-tab-btn {
    padding: 12px 16px;
    flex: 1;
    text-align: center;
  }

  /* Adjust Canvas Background for small screens */
  .editor-canvas {
    background-size: 15px 15px;
  }

  /* Hide Panel Headers (since we used tabs) */
  .panel-header {
    display: none;
  }

  /* === MOBILE TOOLS PANEL === */
  .mobile-tools-list {
    padding: var(--spacing-md);
    padding-bottom: 80px;
  }

  .mobile-tool-section {
    margin-bottom: 20px;
  }

  .mobile-tool-section h4 {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-light);
  }

  .mobile-tool-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .mobile-tool-grid .tool-btn,
  .mobile-tool-grid .action-btn {
    width: 100%;
    height: 44px;
    padding: 0;
    justify-content: center;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.5);
  }

  .mobile-tool-grid .tool-btn:hover,
  .mobile-tool-grid .action-btn:hover {
    background: var(--bg-light);
    border-color: var(--border-medium);
  }

  .mobile-tool-grid .tool-btn.active {
    background: var(--primary-blue-light);
    border-color: var(--primary-blue);
    color: var(--primary-blue);
  }

  .mobile-tool-grid .icon {
    font-size: 20px;
  }

  .mobile-tool-grid .label {
    display: none;
  }
}

/* Fix: Hide tools panel on desktop (default) */
@media (min-width: 769px) {
  #tools-panel {
    display: none !important;
  }
}

/* Fix: Show tools panel on mobile when active */
@media (max-width: 768px) {
  #tools-panel.active-tab {
    display: flex !important;
  }
}

/* 5. Themes */
/* Dark Theme Overrides */
[data-theme=dark] {
  --primary-blue: #3b82f6;
  --primary-blue-hover: #60a5fa;
  --primary-blue-light: rgba(59, 130, 246, 0.15);
  --bg-white: #1e1e1e;
  --bg-light: #252526;
  --bg-canvas: #121212;
  --bg-dark: #000000;
  --border-light: #333333;
  --border-medium: #454545;
  --border-dark: #5a5a5a;
  --text-primary: #ecf0f1;
  --text-secondary: #a0a0a0;
  --text-light: #6e6e6e;
  --danger-red: #ef5350;
  --danger-red-hover: #e57373;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --grid-line-color: #2a2a2a;
  --glass-bg: rgba(30, 30, 30, 0.85);
  /* Slightly more opaque for readability */
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
  --panel-bg: rgba(30, 30, 30, 0.85);
  --panel-border: rgba(255, 255, 255, 0.06);
}

/* Fix Body Gradient for Dark Mode */
[data-theme=dark] body {
  background-image: radial-gradient(circle at 0% 0%, rgba(59, 130, 246, 0.1) 0%, transparent 40%), radial-gradient(circle at 100% 100%, rgba(59, 130, 246, 0.05) 0%, transparent 40%);
}

[data-theme=dark] .tool-btn:hover,
[data-theme=dark] .action-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
}

[data-theme=dark] .tool-btn.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25) 0%, rgba(59, 130, 246, 0.15) 100%);
  color: #60a5fa;
  border-color: rgba(96, 165, 250, 0.25);
  box-shadow: inset 0 1px 3px rgba(59, 130, 246, 0.2), 0 2px 8px rgba(59, 130, 246, 0.25);
}

[data-theme=dark] .tool-btn::before,
[data-theme=dark] .action-btn::before {
  background: rgba(255, 255, 255, 0.96);
  color: var(--text-primary);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.15);
}

[data-theme=dark] .tool-btn::after,
[data-theme=dark] .action-btn::after {
  border-bottom-color: rgba(255, 255, 255, 0.96);
}

[data-theme=dark] .panel-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ff6b6b;
}

[data-theme=dark] .layer-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

[data-theme=dark] .layer-item.selected {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border-color: rgba(96, 165, 250, 0.3);
}

[data-theme=dark] .panel-resize-handle:hover .resize-handle-indicator {
  background: linear-gradient(to bottom, transparent, #60a5fa 20%, #60a5fa 80%, transparent);
  box-shadow: 0 0 12px rgba(96, 165, 250, 0.4);
}

[data-theme=dark] .panel-resize-handle.active .resize-handle-indicator {
  background: linear-gradient(to bottom, transparent, #60a5fa 10%, #60a5fa 90%, transparent);
  box-shadow: 0 0 20px rgba(96, 165, 250, 0.6);
}

[data-theme=dark] .property-group input,
[data-theme=dark] .property-group select,
[data-theme=dark] .property-group textarea {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

[data-theme=dark] .property-group input:hover,
[data-theme=dark] .property-group select:hover,
[data-theme=dark] .property-group textarea:hover {
  background: rgba(255, 255, 255, 0.08);
}

[data-theme=dark] .property-group input:focus,
[data-theme=dark] .property-group select:focus,
[data-theme=dark] .property-group textarea:focus {
  background: rgba(0, 0, 0, 0.3);
}

[data-theme=dark] .icon-group {
  background: rgba(0, 0, 0, 0.2);
  border-color: var(--border-light);
}

[data-theme=dark] .icon-btn.active {
  background: var(--bg-light);
  color: var(--primary-blue);
}

[data-theme=dark] .toolbar {
  background: rgba(20, 20, 20, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.04);
}

[data-theme=dark] .empty-state .logo-text {
  color: rgba(100, 100, 100, 0.3);
  text-shadow: -1px -1px 1px rgba(255, 255, 255, 0.05), 1px 1px 2px rgba(0, 0, 0, 0.4);
}

[data-theme=dark] .empty-state .logo-circle {
  background: transparent;
  border: none;
  box-shadow: none;
}

[data-theme=dark] .loader {
  border-top-color: #00ffa3;
  box-shadow: 0 0 0 3px rgba(0, 255, 163, 0.1);
  filter: drop-shadow(0 0 8px rgba(0, 255, 163, 0.4));
}

[data-theme=dark] .loader::after {
  border-top-color: rgba(0, 255, 163, 0.3);
}

[data-theme=dark] .modal {
  background: var(--bg-light);
  border: 1px solid var(--border-dark);
}

[data-theme=dark] .modal-header {
  border-bottom-color: var(--border-dark);
}

[data-theme=dark] .modal-footer {
  background: rgba(0, 0, 0, 0.2);
  border-top-color: var(--border-dark);
}

[data-theme=dark] .modal-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.05);
}

[data-theme=dark] .entry-overlay {
  background: var(--bg-canvas);
}

[data-theme=dark] .loading-screen {
  background: #000000;
}

/* === DARK MODE - PROPERTIES PANEL === */
[data-theme=dark] .properties-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}

[data-theme=dark] .properties-content::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #60a5fa 0%, rgba(96, 165, 250, 0.7) 100%);
}

[data-theme=dark] .properties-content::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #3b82f6 0%, #60a5fa 100%);
}

[data-theme=dark] .properties-content {
  scrollbar-color: #60a5fa rgba(255, 255, 255, 0.02);
}

[data-theme=dark] .property-group input,
[data-theme=dark] .property-group select,
[data-theme=dark] .property-group textarea {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

[data-theme=dark] .property-group input:hover,
[data-theme=dark] .property-group select:hover,
[data-theme=dark] .property-group textarea:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

[data-theme=dark] .property-group input:focus,
[data-theme=dark] .property-group select:focus,
[data-theme=dark] .property-group textarea:focus {
  background: rgba(0, 0, 0, 0.3);
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

[data-theme=dark] .color-input-wrapper {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme=dark] .color-input-wrapper:hover {
  border-color: #60a5fa;
  box-shadow: 0 2px 8px rgba(96, 165, 250, 0.2);
}

[data-theme=dark] .color-input-wrapper input[type="color"]::-webkit-color-swatch {
  border-color: rgba(255, 255, 255, 0.2);
}

[data-theme=dark] .color-input-wrapper input[type="color"]:hover::-webkit-color-swatch {
  border-color: #60a5fa;
}

[data-theme=dark] .color-value {
  color: rgba(255, 255, 255, 0.7);
}

[data-theme=dark] .property-section-header {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

[data-theme=dark] .property-section-header:hover {
  border-bottom-color: #60a5fa;
}

[data-theme=dark] .property-section-header h4 {
  color: var(--text-primary);
}

[data-theme=dark] .property-section-header h4::before {
  color: rgba(255, 255, 255, 0.5);
}

[data-theme=dark] .property-group select {
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%23a0a0a0' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
}

[data-theme=dark] .property-group select:hover {
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%2360a5fa' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
}

[data-theme=dark] .panel-toggle-btn {
  background: rgba(30, 30, 30, 0.95);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: -2px 0 12px rgba(0, 0, 0, 0.5);
}

[data-theme=dark] .panel-toggle-btn:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: #60a5fa;
  box-shadow: -4px 0 16px rgba(96, 165, 250, 0.4);
}

[data-theme=dark] .panel-toggle-btn svg {
  stroke: rgba(255, 255, 255, 0.7);
}

[data-theme=dark] .panel-toggle-btn:hover svg {
  stroke: #60a5fa;
}

[data-theme=dark] .control-btn {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

[data-theme=dark] .control-btn:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.2);
  border-color: #60a5fa;
  color: #60a5fa;
}

[data-theme=dark] .layer-controls {
  background: rgba(0, 0, 0, 0.2);
}

/*# sourceMappingURL=styles.css.map */
/* === HELP MODAL === */
.help-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.help-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.help-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.help-modal-content {
  position: relative;
  background: var(--bg-white);
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1px solid var(--border-light);
}

.help-modal.active .help-modal-content {
  transform: translateY(0) scale(1);
}

.help-modal-header {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f5f5f5;
  color: #000000;
  border-radius: 16px 16px 0 0;
}

[data-theme="dark"] .help-modal-header {
  background: #2a2a2a;
  color: #ffffff;
}

.help-modal-header h2 {
  font-size: 24px;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  letter-spacing: -0.5px;
}

.help-modal-header svg {
  flex-shrink: 0;
}

.help-close-btn {
  background: transparent;
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.help-close-btn:hover {
  background: var(--bg-canvas);
  transform: scale(1.05);
}

.help-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

.help-sections {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.help-section h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 24px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.help-category {
  margin-bottom: 24px;
}

.help-category:last-child {
  margin-bottom: 0;
}

.help-category h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 12px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.8;
}

.help-shortcuts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.help-shortcut {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-light);
  border-radius: 8px;
  border: 1px solid var(--border-light);
  transition: all 0.2s ease;
}

.help-shortcut:hover {
  background: var(--bg-canvas);
  border-color: var(--border-medium);
  transform: translateX(4px);
}

.help-keys {
  display: flex;
  align-items: center;
  gap: 4px;
}

.help-keys kbd {
  background: white;
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05),
    inset 0 -2px 0 rgba(0, 0, 0, 0.1);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-width: 28px;
  text-align: center;
}

.help-description {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.help-features {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.help-feature {
  padding: 20px;
  background: var(--bg-light);
  border-radius: 12px;
  border: 1px solid var(--border-light);
  transition: all 0.2s ease;
}

.help-feature:hover {
  background: var(--bg-canvas);
  border-color: var(--border-medium);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.help-feature h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 8px 0;
}

.help-feature p {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 0;
}

.help-modal-footer {
  padding: 16px 32px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-light);
  text-align: center;
  border-radius: 0 0 16px 16px;
}

.help-modal-footer p {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.help-modal-footer kbd {
  background: white;
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Dark Mode Help Modal */
[data-theme="dark"] .help-shortcut {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .help-shortcut:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .help-keys kbd {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2),
    inset 0 -2px 0 rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .help-feature {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .help-feature:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .help-modal-footer kbd {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.9);
}

/* Mobile Responsive Help Modal */
@media (max-width: 768px) {
  .help-modal-content {
    width: 95%;
    max-height: 90vh;
  }

  .help-modal-header {
    padding: 20px 24px;
  }

  .help-modal-header h2 {
    font-size: 20px;
  }

  .help-modal-body {
    padding: 24px;
  }

  .help-sections {
    gap: 32px;
  }

  .help-section h3 {
    font-size: 18px;
    margin-bottom: 20px;
  }

  .help-features {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .help-shortcut {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .help-keys {
    flex-wrap: wrap;
  }
}

/* Update color input wrapper to handle the text input */
.color-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.color-value-input {
  background: #333;
  border: 1px solid #444;
  color: #fff;
  border-radius: 4px;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 12px;
  width: 80px;
}

.color-value-input:focus {
  border-color: var(--primary-color);
  outline: none;
}

/* Text Element Cursor Hint */
.canvas-element[data-type="text"]:hover {
  cursor: text;
  outline: 1px solid rgba(0, 102, 255, 0.3);
}

/* Canvas Navigation Controls */
.canvas-controls {
  position: absolute;
  bottom: 24px;
  right: 24px;
  display: flex;
  gap: 8px;
  background: var(--glass-bg, rgba(30, 30, 30, 0.85));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--border-light, rgba(255, 255, 255, 0.1));
  box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
  z-index: 100;
}

.canvas-control-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-secondary, #aaa);
  cursor: pointer;
  transition: all 0.2s ease;
}

.canvas-control-btn:hover {
  background: var(--bg-hover, rgba(255, 255, 255, 0.1));
  color: var(--text-primary, #fff);
  transform: translateY(-1px);
}

.canvas-control-btn:active {
  transform: translateY(0);
}

.canvas-control-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* === TEXT EDITING MODE === */
.canvas-element.editing {
  outline: 2px solid var(--primary-blue);
  background-color: rgba(255, 255, 255, 0.9) !important;
  /* Slightly transparent */
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  z-index: 1000 !important;
  cursor: text !important;
  min-width: 20px;
  min-height: 20px;
  user-select: text !important;
  /* CRITICAL: Allow text selection and editing */
  -webkit-user-select: text !important;
}

.canvas-element.editing::before {
  content: "✎ Editing";
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary-blue);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  pointer-events: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  white-space: nowrap;
}


.text-edit-controls {
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  background: #2c3e50;
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  pointer-events: auto;
  /* clickable */
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  animation: fadeIn 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 1001;
}

.text-edit-controls button {
  background: var(--primary-blue);
  border: none;
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
}

.text-edit-controls button:hover {
  background: var(--primary-blue-hover);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}