/*
 * ═══════════════════════════════════════════════════════════════════════════
 * PROPRIETARY AND CONFIDENTIAL
 * Copyright © 2024 3D Printer Gear. All Rights Reserved.
 * 
 * This software is the exclusive property of 3D Printer Gear.
 * Unauthorized copying, modification, distribution, or use of this
 * software, in whole or in part, is strictly prohibited.
 * 
 * Violators will be prosecuted to the fullest extent of the law.
 * www.3dprintergear.com.au
 * ═══════════════════════════════════════════════════════════════════════════
 */

/* ========== CSS Variables - Apple-Inspired Design System ========== */
:root {
  --brand: #f08f11;
  --brand-hover: #d67e0e;
  --brand-glow: rgba(240, 143, 17, 0.4);
  
  --bg: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-hover: rgba(255, 255, 255, 0.85);
  --border: rgba(0, 0, 0, 0.06);
  --border-light: rgba(255, 255, 255, 0.2);
  
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-muted: #86868b;
  
  --panel-blur: 20px;
  --panel-radius: 20px;
  --panel-shadow: 0 4px 30px rgba(0, 0, 0, 0.08);
  
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== Reset & Base ========== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

/* ========== Full-Screen 3D Canvas ========== */
#scene {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  background: linear-gradient(180deg, #e8ecf1 0%, #d4dbe5 100%);
  display: block;
}

/* ========== Loading Overlay - Branded ========== */
.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: rgba(245, 245, 247, 0.95);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  z-index: 100;
}

.loading-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: pulse 2.5s ease-in-out infinite;
}

.loading-brand__logo {
  height: 50px;
  width: auto;
  opacity: 0.85;
}

.loading-brand__text {
  font-family: 'Bebas Neue', 'Arial Narrow', sans-serif;
  font-size: 2.2rem;
  letter-spacing: 0.35em;
  color: var(--text);
  opacity: 0.8;
  font-weight: 400;
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.6;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.02);
  }
}

.loading-progress {
  width: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.loading-progress__bar {
  width: 100%;
  height: 4px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.loading-progress__fill {
  height: 100%;
  width: 0%;
  background: var(--brand);
  border-radius: 2px;
  transition: width 0.3s ease-out;
}

.loading-status {
  font-size: 0.85rem;
  color: var(--text-secondary);
  opacity: 0.7;
  text-align: center;
}

/* Keep spinner for backwards compatibility */
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  display: none; /* Hidden by default, use new branded loader */
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========== Error Overlay ========== */
.error-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 245, 247, 0.95);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  z-index: 101;
  animation: fadeIn 0.3s ease-out;
}

.error-modal {
  background: var(--glass);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 40px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
}

.error-modal__icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.error-modal__title {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

.error-modal__message {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 24px;
}

.error-modal__actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.error-modal__btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 0.95rem;
}

/* ========== Upload Progress Overlay ========== */
.upload-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 245, 247, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 100;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.upload-modal {
  width: 90%;
  max-width: 420px;
  padding: 32px;
  background: white;
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  text-align: center;
  animation: scaleIn 0.4s ease-out;
}

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

.upload-modal__icon {
  font-size: 3rem;
  margin-bottom: 16px;
  animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.upload-modal__title {
  font-family: "Manrope", sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 24px 0;
}

.upload-modal__progress-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.upload-modal__progress-bar {
  flex: 1;
  height: 12px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  overflow: hidden;
}

.upload-modal__progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--brand), #ff9f43);
  border-radius: 6px;
  transition: width 0.3s ease-out;
}

.upload-modal__progress-text {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--brand);
  min-width: 45px;
}

.upload-modal__steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
  text-align: left;
}

.upload-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 12px;
  opacity: 0.4;
  transition: all 0.3s ease;
}

.upload-step.active {
  opacity: 1;
  background: rgba(240, 143, 17, 0.1);
  transform: translateX(4px);
}

.upload-step.completed {
  opacity: 0.6;
}

.upload-step__icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.upload-step__text {
  font-size: 0.85rem;
  color: var(--text);
}

.upload-modal__tip {
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: rgba(240, 143, 17, 0.08);
  padding: 12px 16px;
  border-radius: 12px;
  margin: 0;
  line-height: 1.5;
}

.upload-modal__tip strong {
  color: var(--brand);
}

/* ========== Glass Panel Base ========== */
.glass-panel {
  background: var(--surface);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--border-light);
  border-radius: var(--panel-radius);
  box-shadow: var(--panel-shadow);
}

/* ========== Header ========== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  z-index: 50;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  transition: var(--transition);
}

.logo-link:hover {
  opacity: 0.8;
}

.logo-img {
  height: 40px;
  width: auto;
  border-radius: 6px;
  /* Soften the logo */
  filter: brightness(1.02);
}

.logo-text {
  font-family: "Inter", "Helvetica Neue", sans-serif;
  font-size: 1.1rem;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.5);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-family: "Inter", sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--brand);
  color: white;
  box-shadow: 0 2px 8px var(--brand-glow);
}

.btn-primary:hover {
  background: var(--brand-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--brand-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: none;
}

.btn-ghost:hover {
  background: rgba(0, 0, 0, 0.05);
}

.btn svg {
  flex-shrink: 0;
}

/* ========== Left Panel - Model Selector ========== */
.panel-left {
  position: fixed;
  left: 24px;
  top: 88px;
  width: 88px;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--border-light);
  border-radius: var(--panel-radius);
  box-shadow: var(--panel-shadow);
  z-index: 30;
}

.panel-label {
  font-family: "Manrope", sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.model-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.model-card {
  width: 64px;
  height: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.03);
  border: 2px solid transparent;
  border-radius: 14px;
  cursor: pointer;
  transition: var(--transition);
  overflow: hidden;
}

.model-card:hover {
  background: rgba(0, 0, 0, 0.06);
  transform: scale(1.05);
}

.model-card.is-active {
  border-color: var(--brand);
  background: rgba(240, 143, 17, 0.08);
  box-shadow: 0 0 20px var(--brand-glow);
}

.model-card__preview {
  width: 40px;
  height: 40px;
  border-radius: 6px;
}

.model-card__label {
  font-size: 0.55rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Upload Card */
.upload-card {
  width: 64px;
  height: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 2px dashed rgba(0, 0, 0, 0.15);
  border-radius: 14px;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-muted);
}

.upload-card:hover,
.upload-card.is-drag {
  border-color: var(--brand);
  background: rgba(240, 143, 17, 0.05);
  color: var(--brand);
}

.upload-icon {
  width: 24px;
  height: 24px;
}

.upload-text {
  font-size: 0.55rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* ========== Right Panel - Colors & Tools ========== */
.panel-right {
  position: fixed;
  right: 24px;
  top: 88px;
  width: 280px;
  max-height: calc(100vh - 112px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--surface);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--border-light);
  border-radius: var(--panel-radius);
  box-shadow: var(--panel-shadow);
  z-index: 30;
}

.panel-right::-webkit-scrollbar {
  width: 6px;
}

.panel-right::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
}

.panel-section {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.panel-section:last-child {
  border-bottom: none;
}

/* ========== Colour Grid ========== */
.colour-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.colour-cell {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 3px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
  background: none;
  position: relative;
}

.colour-cell::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.08);
  pointer-events: none;
}

.colour-cell:hover {
  transform: scale(1.15);
  z-index: 10;
}

.colour-cell.is-active {
  border-color: var(--brand);
  transform: scale(1.15);
  box-shadow: 0 0 12px var(--brand-glow);
}

/* Color name tooltip */
.colour-cell[data-name]::before {
  content: attr(data-name);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  padding: 6px 10px;
  background: rgba(29, 29, 31, 0.95);
  color: white;
  font-size: 0.7rem;
  font-weight: 500;
  white-space: nowrap;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 100;
}

.colour-cell[data-name]:hover::before {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.colour-swatch {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

/* ========== Used Colours ========== */
.used-colours {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 32px;
}

.empty-state {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Simple Buy All Button */
.btn-buy-all {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
  padding: 12px 16px;
  font-family: "Inter", sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: white;
  background: var(--brand);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-buy-all:hover {
  background: var(--brand-hover);
  transform: translateY(-1px);
}

.btn-buy-all svg {
  flex-shrink: 0;
}

.used-colour {
  display: flex;
  align-items: center;
  gap: 8px;
}

.used-colour__swatch-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 20px;
  cursor: pointer;
  transition: var(--transition);
}

.used-colour__swatch-wrap:hover {
  background: rgba(0, 0, 0, 0.08);
}

.used-colour .swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--swatch, #ccc);
  border: 1px solid rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.used-colour__info {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text);
}

.used-colour__name {
  display: block;
  line-height: 1.2;
}

.used-colour__buy {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: var(--brand);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.used-colour__buy:hover {
  background: var(--brand-hover);
  transform: scale(1.08);
}

.used-colour__buy svg {
  width: 14px;
  height: 14px;
}

/* ========== Tools Section ========== */
.tools-section {
  gap: 16px;
}

.tool-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tool-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}

.tool-info svg {
  color: var(--text-secondary);
}

/* Toggle Button */
.toggle-btn {
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
}

.toggle-track {
  display: block;
  width: 44px;
  height: 26px;
  background: rgba(0, 0, 0, 0.12);
  border-radius: 13px;
  position: relative;
  transition: var(--transition);
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: var(--transition);
}

.toggle-btn.is-on .toggle-track {
  background: var(--brand);
}

.toggle-btn.is-on .toggle-thumb {
  left: 21px;
}

/* Slider Row */
.slider-row {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.slider-row .tool-info {
  justify-content: space-between;
}

/* Paint Mode Toggle */
.paint-mode-toggle {
  display: flex;
  gap: 4px;
  background: rgba(0, 0, 0, 0.06);
  padding: 3px;
  border-radius: 10px;
}

.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  font-family: "Inter", sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
}

.mode-btn:hover {
  color: var(--text);
}

.mode-btn.is-active {
  background: white;
  color: var(--brand);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.mode-btn svg {
  width: 14px;
  height: 14px;
}

.slider-control {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slider {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
  outline: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--brand);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px var(--brand-glow);
}

.slider-value {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 32px;
  text-align: right;
}

/* Tool hint icon */
.tool-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  cursor: help;
  margin-left: 4px;
  opacity: 0.7;
}

.tool-hint:hover {
  opacity: 1;
  color: var(--brand);
}

/* ========== Header Undo Button ========== */
.btn-undo-header {
  opacity: 0.4;
  pointer-events: none;
  transition: var(--transition);
}

.btn-undo-header.active {
  opacity: 1;
  pointer-events: auto;
}

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

.btn-undo-header:not(:disabled):hover {
  background: rgba(0, 0, 0, 0.08);
}

/* ========== Hover Tooltip ========== */
.hover-tooltip {
  position: fixed;
  padding: 8px 14px;
  background: rgba(29, 29, 31, 0.9);
  backdrop-filter: blur(8px);
  color: white;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 8px;
  pointer-events: none;
  z-index: 60;
  white-space: nowrap;
}

/* ========== Modal ========== */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
}

.modal__dialog {
  position: relative;
  width: 90%;
  max-width: 380px;
  padding: 24px;
  animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal__header h2 {
  font-family: "Manrope", sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}

.modal__close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.05);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
}

.modal__close:hover {
  background: rgba(0, 0, 0, 0.1);
  color: var(--text);
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

/* ========== Paint Ripple Animation ========== */
@keyframes paintRipple {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 0.6;
  }
  100% {
    transform: translate(-50%, -50%) scale(2);
    opacity: 0;
  }
}

.paint-ripple {
  position: fixed;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--ripple-color, #fff);
  pointer-events: none;
  animation: paintRipple 0.5s ease-out forwards;
  z-index: 25;
}

/* ========== Mobile Bottom Bar ========== */
.mobile-bar {
  display: none;
}

/* ========== Mobile Responsive ========== */
@media (max-width: 900px) {
  .header {
    padding: 0 12px;
    height: 56px;
  }
  
  .logo-text {
    display: none;
  }
  
  .logo-img {
    height: 32px;
  }
  
  .header-actions .btn span {
    display: none;
  }
  
  .header-actions .btn {
    padding: 10px;
    border-radius: 10px;
  }
  
  .header-actions {
    gap: 8px;
  }
  
  /* Hide desktop panels */
  .panel-left {
    display: none;
  }
  
  .panel-right {
    display: none;
  }
  
  /* Mobile panels - half screen height */
  .panel-left.mobile-active,
  .panel-right.mobile-active {
    display: flex;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 76px;
    top: auto;
    max-height: 45vh;
    width: auto;
    border-radius: 16px;
    z-index: 40;
    overflow-y: auto;
    padding-top: 48px;
  }
  
  /* Mobile panel close button */
  .mobile-panel-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.08);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-muted);
    z-index: 10;
  }
  
  .mobile-panel-close:hover,
  .mobile-panel-close:active {
    background: rgba(0, 0, 0, 0.15);
    color: var(--text);
  }
  
/* Close buttons are added dynamically on mobile only */
  
  /* Larger touch targets for mobile colour selection */
  .panel-right.mobile-active .colour-cell {
    width: 44px;
    height: 44px;
    touch-action: manipulation;
  }
  
  .panel-right.mobile-active .colour-cell:active {
    transform: scale(1.2);
    box-shadow: 0 0 16px var(--brand-glow);
  }
  
  .panel-left.mobile-active {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: center;
    padding: 16px;
    gap: 12px;
  }
  
  .panel-left.mobile-active .panel-label {
    width: 100%;
    text-align: center;
    margin-bottom: 8px;
  }
  
  .panel-left.mobile-active .model-grid {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
  }
  
  .panel-left.mobile-active .model-card {
    width: 80px;
    height: 80px;
  }
  
  .panel-left.mobile-active .model-card__preview {
    width: 50px;
    height: 50px;
  }
  
  .panel-left.mobile-active .upload-card {
    width: 80px;
    height: 80px;
  }
  
  .panel-right.mobile-active {
    padding: 16px;
  }
  
  .panel-right.mobile-active .panel-section {
    padding: 16px 0;
  }
  
  .panel-right.mobile-active .colour-grid {
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
  }
  
  .panel-right.mobile-active .colour-cell {
    width: 44px;
    height: 44px;
  }
  
  /* Mobile bottom navigation */
  .mobile-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    z-index: 50;
  }
  
  .mobile-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
  }
  
  .mobile-tab.active {
    color: var(--brand);
  }
  
  .mobile-tab svg {
    width: 22px;
    height: 22px;
  }
  
  /* Help popup mobile adjustment */
  .help-popup {
    left: 12px;
    right: 12px;
    bottom: 76px;
    width: auto;
  }
  
  /* Color tooltip - show below on mobile */
  .colour-cell[data-name]::before {
    bottom: auto;
    top: calc(100% + 8px);
  }
  
  /* Upload overlay mobile */
  .upload-modal {
    padding: 24px;
    margin: 16px;
  }
  
  .upload-modal__title {
    font-size: 1.2rem;
  }
  
  .upload-modal__steps {
    gap: 10px;
  }
  
  .upload-step {
    padding: 10px 12px;
  }
  
  /* Mobile Paint Toolbar */
  .mobile-paint-toolbar {
    position: fixed;
    bottom: 76px;
    left: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px;
    z-index: 45;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  }
  
  .mobile-paint-toolbar__row {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  
  .mobile-paint-tool {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
  }
  
  .mobile-paint-tool.active {
    background: var(--brand);
    border-color: var(--brand);
    color: white;
  }
  
  .mobile-paint-tool:active {
    transform: scale(0.95);
  }
  
  /* Color button with preview */
  .mobile-color-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    flex: 1;
  }
  
  .mobile-color-btn:active {
    transform: scale(0.98);
  }
  
  .mobile-color-preview {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 2px solid var(--border);
    background: var(--brand);
    flex-shrink: 0;
  }
  
  .mobile-rotate-btn {
    flex: 0 0 auto;
    padding: 12px 16px;
  }
  
  .mobile-rotate-btn.active {
    background: #10b981;
    border-color: #10b981;
    color: white;
  }
  
  /* Slider rows */
  .mobile-slider-row {
    padding: 8px 4px;
    background: var(--bg-secondary);
    border-radius: 10px;
    border: 1px solid var(--border);
  }
  
  .mobile-slider-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 40px;
    padding-left: 4px;
  }
  
  .mobile-slider {
    flex: 1;
    height: 10px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, var(--border) 0%, var(--brand) 50%, var(--border) 100%);
    border-radius: 5px;
    outline: none;
    border: 2px solid var(--border);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
  }
  
  .mobile-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--brand);
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  }
  
  .mobile-slider::-webkit-slider-runnable-track {
    height: 10px;
    border-radius: 5px;
  }
  
  .mobile-slider::-moz-range-thumb {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--brand);
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  }
  
  /* Floating close button */
  .mobile-floating-close {
    position: fixed;
    top: 70px;
    right: 16px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 55;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }
  
  .mobile-floating-close:active {
    transform: scale(0.9);
    background: rgba(0, 0, 0, 0.9);
  }
  
  /* Mobile Quick Buy FAB */
  .mobile-quick-buy {
    position: fixed;
    bottom: 150px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    background: linear-gradient(135deg, var(--brand) 0%, #e05a00 100%);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(255, 132, 25, 0.4);
    z-index: 44;
    animation: pulse-fab 2s ease-in-out infinite;
  }
  
  .mobile-quick-buy:active {
    transform: scale(0.95);
  }
  
  @keyframes pulse-fab {
    0%, 100% { box-shadow: 0 4px 20px rgba(255, 132, 25, 0.4); }
    50% { box-shadow: 0 4px 30px rgba(255, 132, 25, 0.6); }
  }
  
  /* Paint mode active state on mobile tab */
  .mobile-tab-paint.active {
    color: var(--brand);
    background: rgba(255, 132, 25, 0.1);
    border-radius: 8px;
  }
  
  /* Shop tab styling */
  .mobile-tab-shop {
    color: var(--text-muted);
  }
  
  .mobile-tab-shop.active {
    color: var(--brand);
  }
}

@media (max-width: 600px) {
  .header-actions .btn-ghost:not(.btn-undo-header) {
    display: none;
  }
  
  /* Keep undo button visible on mobile but icon-only */
  .header-actions .btn-undo-header {
    padding: 8px;
    min-width: 40px;
  }
  
  .panel-right.mobile-active .colour-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

@media (max-width: 400px) {
  .panel-right.mobile-active .colour-grid {
    grid-template-columns: repeat(5, 1fr);
  }
  
  .panel-left.mobile-active .model-card {
    width: 70px;
    height: 70px;
  }
}

/* ========== Body States ========== */
body.modal-open {
  overflow: hidden;
}

/* ========== Copyright Footer ========== */
.copyright-footer {
  position: fixed;
  bottom: 8px;
  right: 24px;
  font-size: 0.65rem;
  color: var(--text-muted);
  opacity: 0.6;
  z-index: 10;
  pointer-events: none;
}

@media (max-width: 900px) {
  .copyright-footer {
    bottom: 72px;
    right: 12px;
    font-size: 0.6rem;
  }
}

/* ========== Scrollbar for Panels ========== */
.panel-right {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.panel-right::-webkit-scrollbar {
  display: none;
}

/* ========== Help Popup ========== */
.help-popup {
  position: fixed;
  left: 24px;
  bottom: 24px;
  width: 300px;
  padding: 20px;
  background: var(--surface);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--border-light);
  border-radius: var(--panel-radius);
  box-shadow: var(--panel-shadow);
  z-index: 35;
  animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.help-popup.hidden {
  display: none;
}

.help-popup__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.05);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-muted);
}

.help-popup__close:hover {
  background: rgba(0, 0, 0, 0.1);
  color: var(--text);
}

.help-popup__title {
  font-family: "Manrope", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 12px 0;
  color: var(--text);
}

.help-popup__steps {
  margin: 0 0 16px 0;
  padding-left: 20px;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.help-popup__steps li {
  margin-bottom: 6px;
}

.help-popup__steps strong {
  color: var(--brand);
  font-weight: 600;
}

/* Tips Carousel */
.tips-carousel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 12px;
}

.tips-carousel__nav {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-muted);
  flex-shrink: 0;
}

.tips-carousel__nav:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.tips-carousel__content {
  flex: 1;
  text-align: center;
  min-height: 50px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.tips-carousel__label {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brand);
  margin-bottom: 4px;
}

.tips-carousel__text {
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text);
  margin: 0;
  transition: opacity 0.3s ease;
}

/* Bundle deal styling when it appears */
.tips-carousel--deal .tips-carousel__content {
  background: linear-gradient(135deg, rgba(240, 143, 17, 0.15) 0%, rgba(240, 143, 17, 0.08) 100%);
  border-radius: 8px;
  padding: 10px;
  margin: -4px 0;
  border: 1px solid rgba(240, 143, 17, 0.3);
  transition: all 0.2s ease;
}

.tips-carousel--deal .tips-carousel__content:hover {
  background: linear-gradient(135deg, rgba(240, 143, 17, 0.2) 0%, rgba(240, 143, 17, 0.12) 100%);
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(240, 143, 17, 0.2);
}

.tips-carousel--deal .tips-carousel__label {
  color: var(--brand);
  font-size: 0.7rem;
}

.tips-carousel--deal .tips-carousel__text {
  font-weight: 500;
}

@media (max-width: 900px) {
  .help-popup {
    left: 16px;
    right: 16px;
    bottom: 80px;
    width: auto;
  }
}
