/* Base reset + typography */
* {
  box-sizing: border-box;
}
html,
body,
#redwood-app {
  height: 100%;
}
body {
  margin: 0;
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Helvetica,
    Arial,
    'Apple Color Emoji',
    'Segoe UI Emoji';
  color: #0f172a; /* slate-900 */
  background: #f8fafc; /* slate-50 */
}

/* Layout helpers */
.app-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, #f8fafc 0%, #eff6ff 50%, #eef2ff 100%);
  position: relative;
}
.full-screen-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.container {
  margin: 0 auto;
  padding: 2rem 1rem;
}
.navbar .container {
  padding: 0;
}

/* Flexbox utilities */
.row {
  display: flex;
  width: 100%;
  flex-direction: row;
}
.row-center {
  align-items: center;
}
.row-between {
  justify-content: space-between;
}
.row-around {
  justify-content: space-around;
}
.row-end {
  justify-content: flex-end;
}
.row-start {
  justify-content: flex-start;
}
.col {
  display: flex;
  flex-direction: column;
}
.col-center {
  align-items: center;
}
.col-between {
  justify-content: space-between;
}
.center {
  display: flex;
  align-items: center;
  justify-content: center;
}
.flex-wrap {
  flex-wrap: wrap;
}
.flex-nowrap {
  flex-wrap: nowrap;
}
.flex-1 {
  flex: 1;
}
.gap-1 {
  gap: 0.25rem;
}
.gap-2 {
  gap: 0.5rem;
}
.gap-3 {
  gap: 0.75rem;
}
.gap-4 {
  gap: 1rem;
}
.gap-5 {
  gap: 1.25rem;
}
.gap-6 {
  gap: 1.5rem;
}

/* Spacing utilities */
.m-0 {
  margin: 0;
}
.m-1 {
  margin: 0.25rem;
}
.m-2 {
  margin: 0.5rem;
}
.m-3 {
  margin: 0.75rem;
}
.m-4 {
  margin: 1rem;
}
.mt-0 {
  margin-top: 0;
}
.mt-1 {
  margin-top: 0.25rem;
}
.mt-2 {
  margin-top: 0.5rem;
}
.mt-3 {
  margin-top: 0.75rem;
}
.mt-4 {
  margin-top: 1rem;
}
.mb-0 {
  margin-bottom: 0;
}
.mb-1 {
  margin-bottom: 0.25rem;
}
.mb-2 {
  margin-bottom: 0.5rem;
}
.mb-3 {
  margin-bottom: 0.75rem;
}
.mb-4 {
  margin-bottom: 1rem;
}
.p-0 {
  padding: 0;
}
.p-1 {
  padding: 0.25rem;
}
.p-2 {
  padding: 0.5rem;
}
.p-3 {
  padding: 0.75rem;
}
.p-4 {
  padding: 1rem;
}

/* Card, glass, shadows */
.glass-effect {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.6);
}
.card {
  border-radius: 1rem;
  padding: 2rem;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(226, 232, 240, 0.6);
}
.card-warning {
  background: rgba(254, 242, 242, 0.8);
  border-color: #fecaca; /* red-200 */
}
.shadow-glow {
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.25);
}
.shadow-glow-hover:hover {
  box-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.35);
}

/* Decorative background circles */
.bg-circle {
  position: absolute;
  width: 24rem; /* 384px */
  height: 24rem;
  border-radius: 9999px;
  filter: blur(48px);
  z-index: -1;
  opacity: 0.6;
}
.bg-circle.top-right {
  top: 0;
  right: 0;
}
.bg-circle.bottom-left {
  bottom: 0;
  left: 0;
}
.bg-circle.cool {
  background: linear-gradient(
    135deg,
    rgba(199, 210, 254, 0.6),
    rgba(221, 214, 254, 0.6)
  );
}
.bg-circle.warm {
  background: linear-gradient(
    135deg,
    rgba(254, 226, 226, 0.6),
    rgba(254, 240, 138, 0.6)
  );
}

/* Gradients */
.gradient-bg {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.gradient-bg-success {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}
.gradient-bg-warning {
  background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.title-gradient-indigo {
  background: linear-gradient(90deg, #4f46e5, #7c3aed);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.title-gradient-red {
  background: linear-gradient(90deg, #dc2626, #ec4899);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Typography */
h1,
.heading-1 {
  font-size: 1.2rem;
  line-height: 1.25;
  font-weight: 800;
  margin: 0;
}
h2,
.heading-2 {
  font-size: 1.25rem;
  line-height: 1.4;
  font-weight: 700;
  margin: 0 0 0.5rem 0;
}
h3,
.heading-3 {
  font-size: 1.125rem;
  line-height: 1.4;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
}
.lead {
  font-size: 1.125rem;
  line-height: 1.5;
  color: #475569;
  margin: 0 0 1rem 0;
}
.text-muted {
  color: #64748b;
}
.text-danger {
  color: #b91c1c;
}
.text-sm {
  font-size: 0.875rem;
  line-height: 1.4;
}
.text-xs {
  font-size: 0.75rem;
  line-height: 1.4;
}
.text-center {
  text-align: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: 0.75rem;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.4;
  color: #fff;
  transition: all 0.2s ease;
  text-decoration: none;
}
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.btn:active:not(:disabled) {
  transform: translateY(0);
}
.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.btn-success {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}
.btn-gray {
  background: #475569;
}
.btn-gray:hover:not(:disabled) {
  background: #334155;
}
.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
}
.badge-blue {
  background: #dbeafe;
  color: #1d4ed8;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}
.label {
  display: inline;
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.5rem;
  margin-right: 0.5rem;
  line-height: 1.4;
}
.input {
  display: inline-block;
  padding: 0.5rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  background: #fff;
  font-size: 1rem;
  line-height: 1.5;
  outline: none;
  transition: all 0.2s ease;
}
.input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.input.monospace {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    'Liberation Mono', 'Courier New', monospace;
}

/* Focus ring helper for non-input elements */
.focus-ring:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
  border-radius: 0.75rem;
}

/* Card, glass, shadows */
.glass-effect {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.6);
}
.card {
  border-radius: 1rem;
  padding: 2rem;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(226, 232, 240, 0.6);
  display: flex;
  flex-direction: column;
}
.card-warning {
  background: rgba(254, 242, 242, 0.8);
  border-color: #fecaca;
}
.shadow-glow {
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.25);
}
.shadow-glow-hover:hover {
  box-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.35);
}

/* Icons */
.icon {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}
.icon-sm {
  width: 1rem;
  height: 1rem;
}
.icon-xs {
  width: 0.8rem;
  height: 0.8rem;
}
.icon-lg {
  width: 1.5rem;
  height: 1.5rem;
}
.icon-xl {
  width: 2rem;
  height: 2rem;
}

/* Animated helpers */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.animate-spin {
  animation: spin 1s linear infinite;
}
@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}
.animate-float {
  animation: float 6s ease-in-out infinite;
}
@keyframes pulseGlow {
  0% {
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.35);
  }
  100% {
    box-shadow: 0 0 30px rgba(102, 126, 234, 0.6);
  }
}
.animate-pulse-glow {
  animation: pulseGlow 2s ease-in-out infinite alternate;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}
.animate-pulse {
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes ping {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  75%,
  100% {
    transform: scale(2);
    opacity: 0;
  }
}
.animate-ping {
  animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}
.animate-fadeIn {
  animation: fadeIn 0.4s ease-out forwards;
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes scaleFadeIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Components specific */
.navbar {
  position: sticky;
  top: 0;
  z-index: 10;
}
.navbar-inner {
  height: 5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
}
.logo-badge {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.panel-padding {
  padding: 0 1.5rem 1.5rem;
}
.panel-header {
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.product-color-scale {
  position: relative;
  z-index: 2;
  width: 100%;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  max-width: 100%;
  justify-content: center;
  align-items: baseline;
}

/* Brick layout - sorted by default color first, then by SKU count, then out of stock */

.style-tree-page .product-color-scale {
  height: initial;
  max-height: initial;
  overflow: initial;
}

/* Color leaf */
.color-leaf {
  grid-area: 'instock';
  width: 100%;
  max-width: 150px;
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border: 1px solid rgba(203, 213, 225, 0.6);
  border-radius: 0.75rem;
  padding: 0.75rem;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.95),
    rgba(248, 250, 252, 0.9)
  );
  transition: all 0.2s ease;
}
.color-leaf.defaultColor {
  border: 2px solid #fbbf24;
  box-shadow: 0 0 10px rgba(255, 187, 17, 0.8);
}
.color-leaf:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.8);
}
.color-leaf.defaultColor:hover {
  border-width: 3px;
  box-shadow: 0 2px 10px rgba(255, 187, 17, 0.9);
}
.color-leaf .dot {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}
.color-leaf .code {
  font-size: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    'Liberation Mono', 'Courier New', monospace;
  color: #334155;
  background: rgba(255, 255, 255, 0.8);
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  font-weight: 600;
  line-height: 1.4;
}
.color-leaf .name {
  font-size: 0.875rem;
  color: #475569;
  margin-top: 0.25rem;
  line-height: 1.4;
}
.color-leaf .overlay {
  position: absolute;
  inset: 0;
  border-radius: 0.75rem;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0),
    rgba(255, 255, 255, 0.25),
    rgba(255, 255, 255, 0)
  );
  transition: opacity 0.3s ease;
}
.color-leaf:hover .overlay {
  opacity: 1;
}

/* Drag and drop styles */
.color-leaf.dragging {
  opacity: 0.5;
  transform: rotate(5deg);
  z-index: 1000;
}

.color-leaf .drag-handle {
  transition: opacity 0.2s ease;
  opacity: 0;
  touch-action: none;
}

.color-leaf:hover .drag-handle {
  opacity: 1;
}

.drag-preview {
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid #3b82f6;
  border-radius: 0.75rem;
  padding: 0.75rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

/* Drop zone styles */
.color-leaf.drop-over {
  border: 2px dashed #10b981;
  background: rgba(16, 185, 129, 0.1);
  transform: scale(1.05);
  transition: all 0.2s ease;
}

/* Color scale drop zone */
.product-color-scale.scale-drop-over {
  background: rgba(16, 185, 129, 0.05);
  border: 2px dashed #10b981;
  border-radius: 0.75rem;
  padding: 0.5rem;
  transition: all 0.2s ease;
}

/* Style tree layer drop zone - only accepts ColorLeafs */
.styleTreeLayer.style-tree-drop-over {
  background: rgba(16, 185, 129, 0.08);
  border: 3px dashed #10b981;
  border-radius: 1rem;
  padding: 1rem;
  transition: all 0.3s ease;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

/* Invalid drop zone - duplicate 3-digit color code already exists */
.styleTreeLayer.style-tree-drop-invalid {
  background: rgba(239, 68, 68, 0.08);
  border: 3px dashed #ef4444;
  border-radius: 1rem;
  padding: 1rem;
  transition: all 0.3s ease;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}

.style-tree-drop-invalid-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(239, 68, 68, 0.12);
  backdrop-filter: blur(2px);
  box-shadow: outset 0 0 30px rgba(255, 0, 0, 1);
  border-radius: inherit;
  pointer-events: none;
  animation: invalidPulse 1s ease-in-out infinite;
}

.style-tree-drop-invalid-label {
  z-index: 99999;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  background: rgba(239, 68, 68, 0.92);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: 0.5rem;
  box-shadow: 0 0 24px rgba(255, 0, 0, 1);
  white-space: nowrap;
  pointer-events: none;
}

.style-tree-drop-invalid-label svg {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
  stroke: #fff;
}

@keyframes invalidPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Migrated color highlighting */
.color-leaf.migratedColor {
  border: 3px solid #f59e0b;
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.3);
  background: linear-gradient(
    135deg,
    rgba(245, 158, 11, 0.1) 0%,
    rgba(245, 158, 11, 0.05) 100%
  );
  position: relative;
  animation: migratedPulse 2s ease-in-out;
}

.color-leaf.migratedColor::before {
  content: var(--migration-label, '＊ Migrated');
  position: absolute;
  top: -8px;
  left: 0px;
  background: #f59e0b;
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.4rem;
  border-radius: 0.3rem;
  z-index: 10;
  white-space: nowrap;
}

/* Ghosted child color styling */
.color-leaf.ghostedColor {
  opacity: 0.4;
  border: 2px dashed #9ca3af;
  background: rgba(156, 163, 175, 0.1);
  position: relative;
  filter: grayscale(60%);
  transition: all 0.3s ease;
  cursor: not-allowed;
}

/* Disable drag interactions on ghosted color children, but keep the
   container itself pointer-interactive so :hover fires and the
   unmigrate button can appear and be clicked. */
.color-leaf.ghostedColor .drag-handle,
.color-leaf.ghostedColor .size-leaf {
  pointer-events: none;
}

.color-unmigrate-button {
  position: absolute;
  bottom: 0.5rem;
  left: 0.5rem;
  cursor: pointer;
  color: #dc2626;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  line-height: 1;
  z-index: 11;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transition: all 0.2s ease;
}

.color-leaf:hover .color-unmigrate-button {
  opacity: 1;
}

.color-unmigrate-button:hover {
  background: #dc2626;
  color: white;
  transform: scale(1.1);
}

.color-leaf.ghostedColor::after {
  content: '↑ Moved';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.6rem;
  border-radius: 0.3rem;
  z-index: 10;
  white-space: nowrap;
}

/* Disable hover effects for ghosted colors */
.color-leaf.ghostedColor:hover {
  transform: none;
  box-shadow: none;
  opacity: 0.4;
}

@keyframes migratedPulse {
  0% {
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.3);
  }
  50% {
    box-shadow:
      0 0 25px rgba(245, 158, 11, 0.6),
      0 0 40px rgba(245, 158, 11, 0.3);
  }
  100% {
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.3);
  }
}

/* Unsaved migration highlighting */
.color-leaf.unsavedMigration {
  border: 3px solid #ef4444;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
  background: linear-gradient(
    135deg,
    rgba(239, 68, 68, 0.15) 0%,
    rgba(239, 68, 68, 0.05) 100%
  );
  position: relative;
  animation: unsavedPulse 1.5s ease-in-out infinite;
}

.color-leaf.unsavedMigration::before {
  content: '⚠ Unsaved';
  position: absolute;
  top: -8px;
  right: -5px;
  background: #ef4444;
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.4rem;
  border-radius: 0.3rem;
  z-index: 10;
  white-space: nowrap;
}

@keyframes unsavedPulse {
  0% {
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
  }
  50% {
    box-shadow:
      0 0 25px rgba(239, 68, 68, 0.7),
      0 0 40px rgba(239, 68, 68, 0.4);
  }
  100% {
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
  }
}

/* Size variants for color leaves (for future size data integration) */
.color-leaf-small {
  grid-row-end: span 1;
}

.color-leaf-medium {
  grid-row-end: span 2;
}

.color-leaf-large {
  grid-row-end: span 3;
}

/* Size Leaf Component */
.size-leaf {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 0.5rem;
  padding: 0.75rem;
  margin: 0.25rem 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.size-leaf:hover {
  box-shadow:
    0 4px 16px rgba(59, 130, 246, 0.3),
    0 2px 8px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px) scale(1.02);
  border-color: rgba(59, 130, 246, 0.4);
  background: rgba(255, 255, 255, 0.95);
  cursor: grab;
  position: relative;
}

.size-leaf:hover::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border: 2px solid rgba(59, 130, 246, 0.4);
  border-radius: 0.625rem;
  animation: pulse-border 2s infinite ease-in-out;
  pointer-events: none;
}

@keyframes pulse-border {
  0%,
  100% {
    opacity: 0.4;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.02);
  }
}

.size-leaf-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.size-leaf-migrated-pill {
  align-self: flex-start;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #0f172a;
  background: linear-gradient(
    135deg,
    rgba(59, 130, 246, 0.1),
    rgba(59, 130, 246, 0.18)
  );
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.size-leaf-migrated-pill::before {
  content: '↪';
  font-size: 0.8rem;
  color: #2563eb;
}

.size-leaf-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.size-leaf-sku {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    'Liberation Mono', 'Courier New', monospace;
  font-size: 0.875rem;
  font-weight: 600;
  color: #111827;
  background: rgba(243, 244, 246, 0.8);
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 8rem;
}

.size-leaf-size {
  font-size: 0.875rem;
  font-weight: 800;
  color: #475569;
}
.sizeOutOfStock .size-leaf-size {
  font-weight: 300;
}

.size-leaf-footer {
  display: flex;
  justify-content: flex-end;
}

.size-leaf-inventory {
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 500;
}
.sizeOutOfStock .size-leaf-inventory {
  text-decoration: line-through;
  color: #ef4444;
}

/* Size Leaf Dragging States */
.size-leaf {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.size-leaf-drag-handle {
  cursor: grab;
  color: #9ca3af;
  padding: 0.125rem;
  border-radius: 0.25rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  transition: color 0.15s ease;
  touch-action: none;
}

.size-leaf-drag-handle:hover {
  color: #4b5563;
}

.size-leaf.dragging .size-leaf-drag-handle {
  cursor: grabbing;
}

.size-leaf.drop-over {
  border-color: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.4);
}

.size-leaf.dragging {
  opacity: 0.5;
  z-index: 1000;
  cursor: grabbing !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  transform: rotate(2deg);
}

.size-unmigrate-button {
  position: absolute;
  bottom: 0.125rem;
  left: 0.125rem;
  cursor: pointer;
  color: #dc2626;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(220, 38, 38, 1);
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  line-height: 1;
  z-index: 11;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transition: all 0.2s ease;
}

.size-leaf:hover .size-unmigrate-button {
  opacity: 1;
}

.size-unmigrate-button:hover {
  background: #dc2626;
  color: white;
  transform: scale(1.1);
}

/* Aspect ratio utilities for color leaves */
.aspect-square {
  aspect-ratio: 1 / 1;
}

.aspect-video {
  aspect-ratio: 16 / 9;
}

.aspect-portrait {
  aspect-ratio: 3 / 4;
}

/* Dialog */
dialog {
  border: none;
  border-radius: 1rem;
  padding: 0;
}
dialog::backdrop {
  background: rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(4px);
}

/* CreateStyleTreeForm Components */
.create-style-tree-dialog {
  min-width: 500px;
  max-width: 600px;
}

.add-child-style-dialog {
  min-width: 500px;
  max-width: 600px;
}

/* Error Alert */
.error-alert {
  padding: 0;
}

.error-alert-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.error-alert-icon {
  color: #ef4444;
  max-width: 2rem;
  flex-shrink: 0;
}

.error-alert-text {
  color: #ef4444;
  font-weight: 600;
}

/* Lookup States */
.lookup-loading-state,
.lookup-error-state,
.lookup-success-state {
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
  transition: all 0.5s ease-in-out;
}

.lookup-loading-state {
  transform: translateY(0);
  opacity: 1;
  max-height: 5rem;
  margin-bottom: 1rem;
}

.lookup-error-state {
  transform: translateY(0);
  opacity: 1;
  max-height: 5rem;
  margin-bottom: 1rem;
}

.lookup-success-state {
  transform: translateY(0);
  opacity: 1;
  max-height: 28rem;
  margin-bottom: 1rem;
}

/* Lookup Panels */
.lookup-loading-content,
.lookup-error-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.lookup-success-content {
  display: grid;
  row-gap: 0.5rem;
}

/* Loading State */
.lookup-loading-icon-container {
  position: relative;
  flex-shrink: 0;
}

.lookup-loading-icon {
  color: #3b82f6;
}

.lookup-loading-ping {
  position: absolute;
  inset: 0;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid rgba(147, 197, 253, 0.5);
  border-radius: 9999px;
  animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.lookup-loading-text {
  color: #1d4ed8;
  font-weight: 600;
}

.lookup-loading-dots {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}

.lookup-loading-dot {
  width: 0.5rem;
  height: 0.5rem;
  background: #60a5fa;
  border-radius: 9999px;
  animation: pulse 1.5s ease-in-out infinite;
}

/* Error State */
.lookup-error-icon-container {
  position: relative;
  flex-shrink: 0;
}

.lookup-error-icon {
  color: #ef4444;
}

.lookup-error-ping {
  position: absolute;
  inset: 0;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid rgba(252, 165, 165, 0.5);
  border-radius: 9999px;
  animation: pulse 1.5s ease-in-out infinite;
}

.lookup-error-text {
  color: #ef4444;
  font-weight: 600;
}

/* Success State */
.product-info-grid {
  display: grid;
  row-gap: 0.5rem;
}

.product-info-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 0.5rem;
}

.product-info-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #475569;
}

.product-info-value {
  font-size: 0.875rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    'Liberation Mono', 'Courier New', monospace;
  color: #111827;
  background: rgba(243, 244, 246, 0.8);
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-info-badge {
  font-size: 0.875rem;
  color: #1e40af;
  background: rgba(219, 234, 254, 0.8);
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  font-weight: 600;
}

/* Color Scale Display */
.color-scale-container {
  position: relative;
  min-height: 12rem;
}

.color-scale-item {
  /*
  position: absolute;
  left: 50%;
  top: 50%;
  opacity: 1;
  */
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Styles for out-of-stock colors */
.colorOutOfStock,
.sizeOutOfStock {
  grid-area: 'outofstock';
  opacity: 0.6;
  position: relative;

  filter: grayscale(50%) brightness(0.9);
}

.colorOutOfStock::befor,
.sizeOutOfStock::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 4px,
    rgba(0, 0, 0, 0.1) 4px,
    rgba(0, 0, 0, 0.1) 8px
  );
  pointer-events: none;
  border-radius: inherit;
}

.colorOutOfStock .code {
  text-decoration: line-through;
  color: #64748b;
}

/* Prevent hover effects on out-of-stock items */
.colorOutOfStock:hover .overlay {
  opacity: 0;
}

/* Alternative approach - more subtle */
.colorOutOfStock.subtle {
  opacity: 0.7;
  filter: grayscale(30%);
}

.colorOutOfStock.subtle .code::after {
  content: ' (Out of Stock)';
  font-size: 0.8em;
  color: #ef4444;
  font-weight: normal;
}

/* Spline Connector Base Styles */
.spline-connector {
  fill: none;
  stroke: rgba(255, 0, 179, 0.9);
  stroke-width: 10px;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: all 0.3s ease;
  opacity: 1;
}

.spline-connector:hover {
  stroke: rgba(99, 102, 241, 0.7);
  stroke-width: 10px;
  opacity: 1;
}

/* Specific spline connection styles */
.spline-connection {
  stroke: rgba(99, 102, 241, 0.4);
  stroke-width: 10;
}

.spline-connection:hover {
  stroke-opacity: 1;
}

/* Color connection specific styles */
.color-spline {
  stroke: rgba(139, 69, 19, 0.4);
  stroke-width: 10px;
  stroke-dasharray: 4, 6;
}

.color-spline:hover {
  stroke: rgba(139, 69, 19, 0.7);
  stroke-width: 3;
  stroke-dasharray: 6, 4;
}

/* Animated splines */
.spline-connector.animated {
  stroke-dasharray: 8, 8;
  animation: spline-dash 2s linear infinite;
}

@keyframes spline-dash {
  0% {
    stroke-dashoffset: 16;
  }
  100% {
    stroke-dashoffset: 0;
  }
}
/* Style tree page specific splines */
.style-tree-page .spline-connector {
  stroke: rgba(34, 197, 94, 0.4);
  stroke-width: 5px;
}

.style-tree-page .spline-connector:hover {
  stroke: rgba(34, 197, 94, 0.8);
  stroke-width: 2.5;
}

/* Migration spline connection styles */
.migration-spline:not(.has-gradient) {
  stroke: rgba(34, 197, 94, 0.8);
  stroke-width: 3px;
  stroke-dasharray: 8, 4;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: all 0.3s ease;
  animation: migration-flow 1.5s linear infinite;
}

.migration-spline.has-gradient {
  stroke: rgba(34, 197, 94, 0.8);
  stroke-width: 3px;
  stroke-dasharray: 8, 4;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: all 0.3s ease;
  animation: migration-flow 1.5s linear infinite;
}

.migration-spline:hover:not(.has-gradient) {
  stroke: rgba(34, 197, 94, 1);
  stroke-width: 4px;
  stroke-dasharray: 12, 6;
}

.size-migration-spline:not(.has-gradient) {
  stroke: rgba(59, 130, 246, 0.9);
  stroke-width: 3px;
  stroke-dasharray: 7, 3;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: all 0.25s ease;
}

.size-migration-spline.has-gradient {
  stroke: rgba(59, 130, 246, 0.9);
  stroke-width: 3px;
  stroke-dasharray: 7, 3;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: all 0.25s ease;
}

/* Path hover state - triggered by JavaScript hover handlers */
.spline-connector.path-hovered {
  filter: brightness(1.2) saturate(1.1);
  transition:
    stroke-width 0.2s ease,
    filter 0.2s ease;
  animation: size-migration-flow 1s linear infinite;
  filter: drop-shadow(0 0 4px rgba(14, 165, 233, 0.35));
  cursor: pointer;
}

.size-migration-spline:hover:not(.has-gradient) {
  stroke: rgba(14, 165, 233, 1);
  stroke-width: 3.75px;
  stroke-dasharray: 10, 4;
  filter: drop-shadow(0 0 8px rgba(14, 165, 233, 0.45));
}

@keyframes size-migration-flow {
  0% {
    stroke-dashoffset: 10;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

@keyframes migration-flow {
  0% {
    stroke-dashoffset: 12;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

/* Enhanced color leaf positioning for connections */
.style-tree-page .color-leaf {
  position: relative;
  transition: transform 0.2s ease;
}

.style-tree-page .color-leaf:hover {
  transform: translateY(-2px);
  z-index: 10;
}

.default-pill {
  position: absolute;
  top: -10px;
  left: -10px;
  font-size: 0.65rem;
  font-weight: 600;
  background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
  color: white;
  padding: 0.125rem 0.375rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.swapped-pill {
  position: absolute;
  top: -10px;
  left: -10px;
  font-size: 0.65rem;
  font-weight: 600;
  background: repeating-linear-gradient(
    45deg,
    #3b82f6 0px,
    #3b82f6 6px,
    #10b981 6px,
    #10b981 12px
  );
  color: white;
  padding: 0.125rem 0.375rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Database Status Indicator */
.dbStatus {
  display: flex;
  align-items: center;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid;
  animation: fadeIn 0.2s ease-in;
}

.dbStatus.saving {
  background-color: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
}

.dbStatus.saved {
  background-color: #d1fae5;
  border-color: #10b981;
  color: #065f46;
}

.dbStatus.error {
  background-color: #fee2e2;
  border-color: #ef4444;
  color: #991b1b;
  box-shadow: inset 0 0 5px rgba(239, 68, 68, 0.5);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  border-radius: 0.5rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid #e2e8f0;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e293b;
}

.modal-close-button {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #64748b;
  cursor: pointer;
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.25rem;
}

.modal-close-button:hover {
  background: #f1f5f9;
  color: #475569;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #374151;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  font-size: 0.875rem;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group input.error,
.form-group select.error {
  border-color: #dc2626;
}

.required {
  color: #dc2626;
}

.error-message {
  color: #dc2626;
  font-size: 0.75rem;
  margin-top: 0.25rem;
  display: block;
}

.loading-indicator {
  color: #64748b;
  font-style: italic;
  padding: 0.75rem;
  text-align: center;
}

.existing-colors-info {
  margin-top: 1.5rem;
  padding: 1rem;
  background: #f8fafc;
  border-radius: 0.375rem;
  border: 1px solid #e2e8f0;
}

.existing-colors-info h4 {
  margin: 0 0 0.75rem 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
}

.color-codes-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.color-code-chip {
  background: #3b82f6;
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  font-family: monospace;
}

.no-colors {
  color: #64748b;
  font-style: italic;
  font-size: 0.875rem;
}

/* Tree list page clickable cards */
.tree-list-card {
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease,
    border-color 0.2s ease;
  cursor: pointer;
}

.tree-list-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(59, 130, 246, 0.3);
  background-color: rgba(59, 130, 246, 0.05);
  border-color: #3b82f6;
}

.tree-list-card:focus {
  outline: none;
  box-shadow:
    0 0 0 3px rgba(59, 130, 246, 0.4),
    0 12px 24px rgba(59, 130, 246, 0.3);
  background-color: rgba(59, 130, 246, 0.05);
  border-color: #3b82f6;
}

/* Style tree page save animation */
.style-tree-page.save-animation {
  animation: saveSuccess 1.5s ease-in-out;
}

@keyframes saveSuccess {
  0% {
    box-shadow: inset 0 0 0 0 rgba(34, 197, 94, 0);
  }
  20% {
    box-shadow: inset 0 0 30px 10px rgba(34, 197, 94, 0.4);
  }
  40% {
    box-shadow: inset 0 0 40px 15px rgba(34, 197, 94, 0.5);
  }
  60% {
    box-shadow: inset 0 0 40px 15px rgba(34, 197, 94, 0.4);
  }
  100% {
    box-shadow: inset 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

/* Visual refresh overrides */
:root {
  --app-ink: #0f172a;
  --app-muted: #52607a;
  --app-soft: #6b7a90;
  --app-border: rgba(148, 163, 184, 0.18);
  --app-border-strong: rgba(71, 85, 105, 0.22);
  --app-panel: rgba(255, 255, 255, 0.84);
  --app-panel-strong: rgba(255, 255, 255, 0.96);
  --app-shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
  --brand-start: #1d4ed8;
  --brand-end: #0ea5e9;
}

body {
  font-family: 'Avenir Next', 'Segoe UI', 'Helvetica Neue', ui-sans-serif,
    system-ui, sans-serif;
  background: radial-gradient(
      circle at top left,
      rgba(59, 130, 246, 0.08),
      transparent 26%
    ),
    radial-gradient(
      circle at top right,
      rgba(14, 165, 233, 0.08),
      transparent 22%
    ),
    #f5f7fb;
  color: var(--app-ink);
}

.app-bg {
  background: radial-gradient(
      circle at top left,
      rgba(59, 130, 246, 0.1),
      transparent 30%
    ),
    radial-gradient(circle at 85% 0%, rgba(56, 189, 248, 0.1), transparent 24%),
    linear-gradient(180deg, #f8fbff 0%, #f3f6fb 100%);
}

.container {
  width: min(1180px, calc(100% - 2rem));
  padding: 2rem 0 4rem;
}

.navbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(248, 250, 252, 0.74);
  border-bottom: 1px solid rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(18px);
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
}

.navbar-shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 4.75rem;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.brand-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 750;
  line-height: 1.2;
  color: var(--app-ink);
}

.gradient-bg {
  background: linear-gradient(
    135deg,
    var(--brand-start) 0%,
    var(--brand-end) 100%
  );
}

.logo-badge {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.95rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.panel {
  background: rgba(255,255,255, .2);
  border: 1px solid var(--app-border);
  border-radius: 1.75rem;
  box-shadow: var(--app-shadow);
}

.panel-padding {
  padding: 1.25rem 1.5rem 1.5rem;
}

.page-shell {
  display: grid;
  gap: 1.5rem;
}

.page-hero {
  padding: clamp(1.25rem, 2vw, 2rem);
}

.page-hero-copy {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.page-title {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 1.02;
  font-weight: 800;
}

.page-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.section-shell {
  display: grid;
  gap: 1.25rem;
  padding: 1.5rem;
}

.section-header {
  display: grid;
  gap: 0.35rem;
}

.section-header-spaced {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 1rem;
}

.section-title {
  margin: 0;
  font-size: 1.4rem;
  line-height: 1.2;
  font-weight: 750;
  color: var(--app-ink);
}

.section-description {
  margin: 0;
  color: var(--app-muted);
  line-height: 1.6;
}

.section-body {
  display: grid;
  gap: 1rem;
}

.info-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.42rem 0.72rem;
  border-radius: 999px;
  font-size: 0.83rem;
  font-weight: 700;
}

.info-pill {
  background: rgba(241, 245, 249, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: #334155;
}

.section-empty-state {
  display: grid;
  gap: 0.75rem;
  justify-items: center;
  padding: 2.5rem 1rem;
  text-align: center;
  border-radius: 1.25rem;
  background: rgba(248, 250, 252, 0.74);
  border: 1px dashed rgba(148, 163, 184, 0.35);
}

.section-empty-state-error {
  justify-items: start;
  text-align: left;
}

.state-shell {
  min-height: min(70vh, 34rem);
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1rem;
  padding: 2.5rem 1.5rem;
  text-align: center;
}

.state-orb {
  width: 4rem;
  height: 4rem;
  display: grid;
  place-items: center;
  border-radius: 1.2rem;
  background: linear-gradient(
    135deg,
    rgba(37, 99, 235, 0.12),
    rgba(14, 165, 233, 0.16)
  );
  color: #1d4ed8;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.state-orb-danger {
  background: linear-gradient(
    135deg,
    rgba(239, 68, 68, 0.14),
    rgba(251, 113, 133, 0.18)
  );
  color: #b91c1c;
}

.state-orb-muted {
  background: linear-gradient(
    135deg,
    rgba(148, 163, 184, 0.18),
    rgba(226, 232, 240, 0.45)
  );
  color: #475569;
}

.inline-message {
  padding: 0.85rem 1rem;
  border-radius: 1rem;
  font-size: 0.92rem;
  border: 1px solid transparent;
}

.inline-message-danger {
  color: #b91c1c;
  background: rgba(254, 226, 226, 0.75);
  border-color: rgba(239, 68, 68, 0.18);
}

.btn {
  border-radius: 999px;
  padding: 0.8rem 1.15rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: none;
}

.btn-sm {
  padding: 0.55rem 0.9rem;
  font-size: 0.82rem;
}

.btn-primary {
  background: linear-gradient(
    135deg,
    var(--brand-start) 0%,
    var(--brand-end) 100%
  );
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.92);
  color: var(--app-ink);
  border: 1px solid var(--app-border-strong);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.btn-secondary:hover:not(:disabled) {
  background: #fff;
  color: var(--app-ink);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626 0%, #f97316 100%);
}

.btn:focus-visible,
.focus-ring:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.monospace {
  font-family: 'SFMono-Regular', 'Menlo', 'Monaco', 'Consolas',
    'Liberation Mono', 'Courier New', monospace;
}

.tree-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.tree-summary-card {
  position: relative;
  display: grid;
  gap: 1rem;
  min-height: 18rem;
  padding: 1.1rem;
}

.tree-card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  z-index: 2;
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.tree-card-body {
  display: grid;
  grid-template-columns: minmax(0, 30%) minmax(0, 70%);
  gap: 0.9rem;
  align-items: start;
  min-height: 100%;
  padding: 0.95rem;
  border-radius: 1.2rem;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.92),
    rgba(248, 250, 252, 0.9)
  );
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 10px 24px rgba(15, 23, 42, 0.05);
}

.tree-card-thumbnail {
  overflow: hidden;
  aspect-ratio: 9/16;
  width: 100%;
}

.tree-card-thumbnail-image {
  display: block;
  width: 100%;
  height: 100%;
  -o-object-fit: contain;
     object-fit: contain;
}

.tree-card-content {
  display: flex;
  gap: 0.75rem;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  min-width: 0;
}

.tree-card-children {
  width: 100%;
}

.tree-card-title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.25;
  font-weight: 500;
  word-break: break-word;
}

.tree-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.tree-chip {
  padding: 0.38rem 0.62rem;
  border-radius: 999px;
  background: rgba(241, 245, 249, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.22);
  color: #1e293b;
  font-size: 0.78rem;
}

.tree-chip-muted {
  background: rgba(219, 234, 254, 0.8);
  color: #1d4ed8;
}

.tree-card-empty {
  margin: 0;
  color: var(--app-muted);
  line-height: 1.55;
}

.tree-card-delete-button {
  cursor: pointer;
  color: #dc2626;
  background: rgba(255, 255, 255, 0.94);
  border: none;
  border-radius: 999px;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: scale(0.92);
  transition: all 0.2s ease;
}

.tree-list-card:hover .tree-card-delete-button,
.tree-list-card:focus-visible .tree-card-delete-button,
.tree-list-card:focus-within .tree-card-delete-button {
  opacity: 1;
  transform: scale(1);
}

.tree-card-delete-button:hover,
.tree-card-delete-button:focus-visible {
  background: #dc2626;
  color: #fff;
  transform: scale(1.08);
  outline: none;
}

.tree-list-card {
  cursor: pointer;
  transition:
    transform 0.24s ease,
    box-shadow 0.24s ease,
    border-color 0.24s ease,
    background 0.24s ease;
}

.tree-list-card:hover,
.tree-list-card:focus-visible {
  transform: translateY(-4px);
  border-color: rgba(37, 99, 235, 0.28);
  box-shadow: 0 22px 48px rgba(37, 99, 235, 0.16);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.98),
    rgba(239, 246, 255, 0.92)
  );
}

.detail-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.5rem;
  align-items: start;
  padding: clamp(1.25rem, 2.1vw, 2rem);
}

.detail-hero-copy {
  display: grid;
  gap: 1rem;
}

.detail-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.detail-code-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.48rem 0.78rem;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
}

.detail-hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
  align-items: flex-start;
}

.style-tree-layout {
  display: grid;
  gap: 1.25rem;
}

/* Root tree panel: groups header + parent layer into one card */
.root-tree-panel {
  display: grid;
  gap: 0;
  overflow: hidden;
}

.root-tree-panel > .detail-hero {
  background: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(226, 232, 240, 0.7);
}

.root-tree-panel > .styleTreeLayer {
  background: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 1.35rem 1.5rem;
}

/* Back link: small, muted breadcrumb-style button */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.1rem;
  border: none;
  background: none;
  color: var(--app-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s ease;
}

.back-link:hover {
  color: var(--app-ink);
  text-decoration: underline;
}

.styleTreeLayer {
  position: relative;
  display: grid;
  gap: 1.25rem;
  padding: 1.35rem;
  border-radius: 1.5rem;
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

.style-layer-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: start;
}

.style-layer-copy {
  display: grid;
  gap: 0.6rem;
}

.style-layer-actions {
  display: grid;
  gap: 0.75rem;
  justify-items: end;
}

.style-subsection {
  display: grid;
  gap: 0.85rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(226, 232, 240, 0.8);
}

.subsection-head {
  display: flex;
  flex-wrap: wrap;
  align-items: start;
  justify-content: space-between;
  gap: 0.75rem;
}

.colors-section-body {
  position: relative;
}

.product-color-scale {
  justify-content: space-around;
  gap: 0.7rem;
  padding: 0.15rem 0 0.1rem;
}

.color-leaf {
  max-width: 172px;
  border-radius: 1rem;
  padding: 0.9rem;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
}

.color-leaf:hover,
.style-tree-page .color-leaf:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 30px rgba(15, 23, 42, 0.2);
}

.drag-preview {
  border-color: #1d4ed8;
}

.imagined-color-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.imagined-color-chip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.65rem;
  border-radius: 1rem;
  background: rgba(248, 250, 252, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.imagined-color-name {
  color: #0f172a;
  font-weight: 700;
}

.imagined-color-code {
  color: var(--app-soft);
}

.child-styles-list {
  padding: 1.5rem;
}

.child-style-stack {
  display: grid;
  gap: 1rem;
}

.child-style-card {
  position: relative;
  display: grid;
  gap: 0.9rem;
  padding: 1rem;
  border-radius: 1.35rem;
  background: rgba(248, 250, 252, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.child-style-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.child-style-order {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
}

.child-style-index {
  width: 2.2rem;
  height: 2.2rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 800;
}

.child-style-title {
  font-size: 1rem;
  word-break: break-word;
}

.child-style-connector {
  position: absolute;
  top: -1rem;
  left: 2rem;
  width: 2px;
  height: 1rem;
  background: linear-gradient(
    180deg,
    rgba(148, 163, 184, 0.1),
    rgba(37, 99, 235, 0.4)
  );
}

.child-style-card-body {
  display: grid;
  gap: 0.75rem;
}

.dbStatus {
  display: flex;
  align-items: center;
  padding: 0.65rem 1rem;
  border-radius: 999px;
  font-weight: 700;
  border: 1px solid transparent;
  box-shadow: none;
}

.dbStatus.saving {
  background: rgba(245, 158, 11, 0.12);
  color: #92400e;
  border-color: rgba(245, 158, 11, 0.25);
}

.dbStatus.saved {
  background: rgba(22, 163, 74, 0.12);
  color: #166534;
  border-color: rgba(22, 163, 74, 0.25);
}

.dbStatus.error {
  background: rgba(220, 38, 38, 0.12);
  color: #991b1b;
  border-color: rgba(220, 38, 38, 0.25);
}

.create-style-tree-dialog,
.add-child-style-dialog {
  min-width: min(720px, calc(100vw - 2rem));
  max-width: 720px;
  border-radius: 1.4rem;
  overflow: hidden;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.98),
    rgba(248, 250, 252, 0.96)
  );
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.25);
}

.create-style-tree-dialog .panel,
.add-child-style-dialog .panel {
  border: 0;
  box-shadow: none;
  background: transparent;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(8px);
}

@media (max-width: 920px) {
  .detail-hero,
  .style-layer-header,
  .section-header-spaced {
    grid-template-columns: 1fr;
  }

  .detail-hero-actions,
  .style-layer-actions {
    justify-content: flex-start;
    justify-items: start;
  }
}

@media (max-width: 640px) {
  .container {
    width: min(100% - 1rem, 100%);
  }

  .page-title {
    font-size: 2.15rem;
  }

  .tree-grid {
    grid-template-columns: 1fr;
  }

  .tree-summary-card {
    min-height: auto;
  }

  .tree-card-footer,
  .child-style-card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .styleTreeLayer,
  .section-shell,
  .panel-padding {
    padding: 1rem;
  }

  .root-tree-panel > .detail-hero,
  .root-tree-panel > .styleTreeLayer {
    padding: 1rem;
  }

  .color-leaf {
    max-width: 100%;
  }
}
._overlay_1i8gz_1 {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

._dialog_1i8gz_14 {
  max-width: 32rem;
  width: 100%;
  margin: 1rem;
  max-height: 90vh;
  overflow: auto;
}

._header_1i8gz_22 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

._title_1i8gz_29 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #dc2626;
}

._closeButton_1i8gz_35 {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #64748b;
}

._successBox_1i8gz_43 {
  padding: 1.5rem;
  background-color: #f0fdf4;
  border-radius: 0.5rem;
  border: 1px solid #86efac;
  text-align: center;
}

._successIcon_1i8gz_51 {
  font-size: 3rem;
  margin-bottom: 1rem;
}

._successTitle_1i8gz_56 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #15803d;
  margin-bottom: 1rem;
}

._successDetail_1i8gz_63 {
  color: #166534;
  margin-bottom: 0.5rem;
}

._warningBox_1i8gz_68 {
  padding: 1rem;
  background-color: #fef2f2;
  border-radius: 0.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid #fecaca;
}

._warningTitle_1i8gz_76 {
  font-weight: 600;
  color: #991b1b;
  margin-bottom: 0.75rem;
}

._warningText_1i8gz_82 {
  color: #7f1d1d;
  margin-bottom: 1rem;
}

._warningList_1i8gz_87 {
  margin-left: 1.5rem;
  color: #7f1d1d;
}

._inputGroup_1i8gz_92 {
  margin-bottom: 1.5rem;
}

._label_1i8gz_96 {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: #0f172a;
}

._input_1i8gz_92 {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.375rem;
  font-size: 1rem;
}

._errorBox_1i8gz_111 {
  padding: 0.75rem;
  background-color: #fee;
  border: 1px solid #fcc;
  border-radius: 0.375rem;
  color: #c00;
  margin-bottom: 1rem;
}

._buttonGroup_1i8gz_120 {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

._deleteButton_1i8gz_126 {
  background-color: #dc2626;
  color: white;
}
