*{box-sizing:border-box}

/* CSS Custom Properties for responsive design */
:root {
  --mobile-nav-height: 56px;
  --mobile-sheet-max-height: 75vh;
  --sai-top: env(safe-area-inset-top);
  --sai-right: env(safe-area-inset-right);
  --sai-bottom: env(safe-area-inset-bottom);
  --sai-left: env(safe-area-inset-left);
}

html,body{height:100%;margin:0;padding:0;overflow:hidden}
body{margin:0;-webkit-font-smoothing:antialiased;font-family:'Poppins',system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;-webkit-text-size-adjust:100%;-moz-text-size-adjust:100%;text-size-adjust:100%}

/* Light-only: ensure consistent light backgrounds */
body { background: #ffffff; color: #0f172a; }

.swatches{display:flex;gap:10px}
.swatch{
  width:32px;height:32px;border-radius:999px;border:2px solid #e2e8f0;
  background:var(--swatch);
  cursor:pointer;
  transition: all .2s cubic-bezier(0.4, 0, 0.2, 1);
  position:relative;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  min-height: 44px; /* Better touch target */
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.swatch:focus,
.swatch:focus-visible{
  outline:2px solid #3b82f6;
  outline-offset:2px;
}
.swatch:hover{ 
  transform: scale(1.1); 
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  border-color: #cbd5e1;
}
.swatch.selected{ 
  outline:3px solid #3b82f6; 
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
  transform: scale(1.05);
}

/* micro-interactions and touch improvements */
.btn{ 
  transition: all .15s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 44px; /* WCAG AA touch target size */
  position: relative;
  overflow: hidden;
}
.btn:active{ transform: scale(.98) }
.btn:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}
.btn-plain{
  padding: 8px 12px;
  font-size: 12px;
  line-height: 1;
  border-radius: 10px;
  border:1px solid #e2e8f0;
  background:#ffffff;
  color:#0f172a;
  box-shadow:0 1px 2px rgba(16,24,40,0.06);
}
.btn-plain:hover{ border-color:#cbd5e1; background:#f8fafc }
.btn-plain:disabled{ 
  opacity: 0.5; 
  cursor: not-allowed; 
  background: #f1f5f9; 
  color: #94a3b8; 
}
.btn-plain:disabled:hover{ 
  border-color: #e2e8f0; 
  background: #f1f5f9; 
  transform: none; 
}
.btn-xs{ height:30px; padding:4px 10px; font-size:12px }
.input-compact{ 
  height:36px; 
  padding:8px 12px; 
  font-size:13px;
  border-radius: 0.5rem;
  border: 1px solid #e5e7eb;
  background-color: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

.input-compact:focus {
  border-color: #3b82f6;
  box-shadow: 
    0 0 0 2px rgba(59, 130, 246, 0.1),
    0 2px 4px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.input-compact:hover {
  border-color: #3b82f6;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}
.rgb-pill{ padding:6px 10px; border:1px solid #e2e8f0; background:#f1f5f9; color:#334155; border-radius:8px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size:12px }

/* Enhanced field label for line-by-line layout */
.field-label{
  font-size:12px;
  color:#64748b; /* slate-500 */
  margin-bottom:8px;
  text-transform:uppercase;
  letter-spacing:.05em;
  font-weight:600;
  display: block;
  position: relative;
}

.field-label::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 20px;
  height: 2px;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6);
  border-radius: 1px;
}
.rgb-readout{margin-top:8px;color:#6c757d;font-variant-numeric:tabular-nums}

#canvas-container{position:relative; background:#0b0e14}
#canvas-container canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

#loadingOverlay{
  gap:12px;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none; /* hidden by default; JS toggles to flex while loading */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.6);
}
.loader{width:min(420px,70vw);height:8px;background:#0e121a;border:1px solid #dee2e6;border-radius:99px;overflow:hidden}
.bar{height:100%;background:linear-gradient(90deg,#4f8cff,#7c4dff);transition:width .2s ease}
.loading-text{color:#dee2e6}

/* iro.js host fallback (tailwind handles most visuals) */
#colorPicker{min-height:200px}

/* UV Map styling removed */



/* Enhanced dropdown and input styling for controls in sidebar */
#ui select,
#ui input[type="text"],
#ui input[type="search"],
#ui input[type="number"],
#ui input[type="email"],
#ui input[type="url"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  border: 1px solid #e5e7eb; /* slate-200 */
  background-color: #ffffff;
  color: #0f172a; /* slate-900 */
  border-radius: 0.75rem; /* rounded-xl */
  padding: 12px 40px 12px 16px; /* px-4 py-3, extra right padding for arrow */
  height: 44px; /* h-11 */
  line-height: 1.25rem;
  font-size: 14px;
  font-weight: 500;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.05),
    0 1px 2px rgba(0, 0, 0, 0.1);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  position: relative;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 16px;
}

/* Enhanced select dropdown styling - arrow already defined above */

/* Enhanced dropdown options styling */
#ui select option {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  background-color: #ffffff;
  color: #0f172a;
  border: none;
  outline: none;
}

#ui select option:hover {
  background-color: #f8fafc;
}

#ui select option:checked {
  background-color: #3b82f6;
  color: #ffffff;
}

/* Enhanced input focus states */
#ui select:focus,
#ui input[type="text"]:focus,
#ui input[type="search"]:focus,
#ui input[type="number"]:focus,
#ui input[type="email"]:focus,
#ui input[type="url"]:focus {
  border-color: #3b82f6; /* blue-500 */
  box-shadow: 
    0 0 0 3px rgba(59, 130, 246, 0.1),
    0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
  background-color: #ffffff;
  transform: translateY(-1px);
}

/* Enhanced hover states */
#ui select:hover,
#ui input[type="text"]:hover,
#ui input[type="search"]:hover,
#ui input[type="number"]:hover,
#ui input[type="email"]:hover,
#ui input[type="url"]:hover {
  border-color: #3b82f6; /* blue-500 */
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

/* Enhanced dropdown arrow on hover */
#ui select:hover {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%233b82f6' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
}

/* Better focus states for dropdowns */
#ui select:focus {
  border-color: #3b82f6;
  box-shadow:
    0 0 0 3px rgba(59, 130, 246, 0.1),
    0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%233b82f6' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
}

/* Screen-reader-only utility for hidden native select */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Compact searchable color picker */
#porschePicker { position: relative; }
.pp-trigger {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; width: 100%; height: 36px;
  border: 1px solid #e5e7eb; border-radius: 8px; background: #fff;
  padding: 6px 10px; cursor: pointer; font-size: 12px;
  transition: all 0.2s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.pp-trigger:hover { border-color: #d1d5db; background: #f9fafb; }
.pp-trigger:active { transform: scale(0.98); }
.pp-chip { display: inline-flex; align-items: center; gap: 8px; }
.pp-swatch { width: 16px; height: 16px; border-radius: 999px; border: 1px solid #e5e7eb; flex-shrink: 0; }
.pp-arrow { color: #64748b; font-size: 10px; transition: transform 0.2s ease; }
.pp-trigger:hover .pp-arrow { color: #374151; }
.pp-panel {
  /* Position will be set dynamically via JavaScript */
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  max-height: 400px;
}
.pp-search { padding: 8px; border-bottom: 1px solid #e5e7eb; }
.pp-search input {
  width: 100%; height: 32px; padding: 6px 10px; border: 1px solid #e5e7eb; border-radius: 8px;
  font-size: 13px; outline: none;
}
.pp-search input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); }
.pp-list { max-height: 280px; overflow-y: auto; overflow-x: hidden; }
.pp-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; font-size: 12px;
  transition: background-color 0.15s ease;
  min-height: 44px; /* Better touch target */
  user-select: none;
}
.pp-item:hover { background: #f8fafc; }
.pp-item:active { background: #f1f5f9; }
.pp-code {
  margin-left: auto; color: #94a3b8; font-variant-numeric: tabular-nums;
  font-size: 11px; font-weight: 500;
}

/* Enhanced disabled states */
#ui select:disabled,
#ui input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background-color: #f8fafc; /* slate-50 */
  border-color: #e5e7eb;
  transform: none;
  box-shadow: none;
}

#ui input::placeholder {
  color: #94a3b8; /* slate-400 */
}

#ui select:disabled,
#ui input:disabled {
  opacity: .6;
  cursor: not-allowed;
  background-color: #f8fafc; /* slate-50 */
}

/* Enhanced scrolling for sidebar */
#ui {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 100vh;
}

#ui::-webkit-scrollbar {
  width: 8px;
}

#ui::-webkit-scrollbar-track {
  background: transparent;
  margin: 8px 0;
}

#ui::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #cbd5e1, #94a3b8);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: content-box;
  transition: background 0.2s ease;
}

#ui::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #94a3b8, #64748b);
  background-clip: content-box;
}

#ui::-webkit-scrollbar-corner {
  background: transparent;
}

#ui::-webkit-scrollbar-thumb:hover {
  background-color: #94a3b8;
}

/* Enhanced button hover effects */
button:hover {
  transform: translateY(-1px);
}

/* Section hover effects */
.bg-white:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Enhanced card look for sidebar panels */
.panel-card {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.08); /* subtle slate border */
  border-radius: 16px;
  padding: 20px; /* p-5 */
  box-shadow: 
    0 1px 3px rgba(0, 0, 0, 0.05),
    0 1px 2px rgba(0, 0, 0, 0.1);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.panel-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.panel-card:hover::before {
  opacity: 1;
}

.panel-card:hover {
  box-shadow: 
    0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
  border-color: rgba(59, 130, 246, 0.2);
}
.dark .panel-card {
  background: #0f172a; /* slate-900 */
  border-color: rgba(148, 163, 184, 0.12);
}

/* Sidebar collapsed state */
/* removed collapse mode */

/* Smooth width transition for sidebar and canvas */
#ui {
  width: 30% !important;
  min-width: 320px;
  max-width: 400px;
  transition: width .25s ease, padding .25s ease;
  display: flex;
  flex-direction: column;
}
#canvas-container {
  flex: 1;
  transition: width .25s ease, padding .25s ease;
}
/* removed collapse mode */

/* Enhanced responsive design with better breakpoints */

/* Extra small mobile devices (320px - 479px) */
@media (max-width: 767px) {
  html, body {
    font-size: 14px;
  }

  .mobile-nav {
    left: 6px;
    right: 6px;
    height: 50px;
    border-radius: 12px;
  }
  
  .mobile-nav-btn {
    font-size: 10px;
    gap: 2px;
  }
  
  .mobile-nav-btn svg {
    width: 16px;
    height: 16px;
  }
  
  .mobile-sheet {
    left: 6px;
    right: 6px;
    bottom: calc(64px + env(safe-area-inset-bottom));
    padding: 10px;
    border-radius: 16px;
    max-height: 70vh;
  }
  
  .sheet-actions .btn {
    height: 34px;
    font-size: 11px;
    padding: 6px 10px;
  }
  
  .panel-card {
    padding: 12px;
    border-radius: 12px;
  }
  
  .field-label {
    font-size: 10px;
  }
  
  .btn-xs {
    height: 30px;
    padding: 4px 8px;
    font-size: 10px;
  }
  
  .swatch {
    width: 28px;
    height: 28px;
  }
  
  .input-compact {
    height: 36px;
    padding: 8px 10px;
    font-size: 14px;
  }
  
  #canvas-container {
    height: calc(100vh - 64px) !important;
  }
}

/* Small mobile devices (480px - 639px) */
@media (min-width: 480px) and (max-width: 639px) {
  .mobile-nav {
    left: 8px;
    right: 8px;
    height: 52px;
  }
  
  .mobile-sheet {
    left: 8px;
    right: 8px;
    padding: 12px;
    max-height: 72vh;
  }
  
  .panel-card {
    padding: 14px;
  }
  
  #canvas-container {
    height: calc(100vh - 68px) !important;
  }
}

/* Medium mobile devices (640px - 767px) */
@media (min-width: 640px) and (max-width: 767px) {
  .mobile-nav {
    left: 10px;
    right: 10px;
    height: 54px;
  }
  
  .mobile-sheet {
    left: 10px;
    right: 10px;
    padding: 14px;
    max-height: 74vh;
  }
  
  .panel-card {
    padding: 16px;
  }
  
  #canvas-container {
    height: calc(100vh - 70px) !important;
  }
}

/* Hide mobile navigation on desktop and desktop sidebar on mobile */
@media (min-width: 768px) {
  .mobile-nav {
    display: none !important;
  }
}

@media (max-width: 767px) {
  #ui {
    display: none !important;
  }
}

/* Tablet layout (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
  #ui {
    width: 35% !important;
    min-width: 280px;
    max-width: 350px;
  }
  
  .panel-card {
    padding: 16px;
  }
  
  .btn-xs {
    height: 28px;
    padding: 3px 8px;
    font-size: 11px;
  }
  
  .field-label {
    font-size: 11px;
  }
  
  #ui select,
  #ui input[type="text"],
  #ui input[type="search"],
  #ui input[type="number"],
  #ui input[type="email"],
  #ui input[type="url"] {
    height: 40px;
    padding: 10px 14px;
    font-size: 13px;
  }
  
  .input-compact {
    height: 32px;
    padding: 6px 10px;
    font-size: 12px;
  }
}

/* Small desktop layout (1024px - 1279px) */
@media (min-width: 1024px) and (max-width: 1279px) {
  #ui {
    width: 32% !important;
    min-width: 300px;
    max-width: 380px;
  }
}

/* Large desktop layout (1280px+) */
@media (min-width: 1280px) {
  #ui {
    width: 28% !important;
    min-width: 320px;
    max-width: 420px;
  }
  
  .panel-card {
    padding: 24px;
  }
}

/* Mobile layout: move controls to a bottom bar and free vertical space for 3D */
@media (max-width: 767px) {
  #app { 
    flex-direction: column; 
    overflow: hidden;
  }
  
  #ui { 
    display: none !important; 
  }
  
  #canvas-container { 
    height: calc(100vh - 72px);
    width: 100%;
    position: relative;
    overflow: hidden;
  }
  
  .mobile-nav {
    position: fixed; 
    bottom: calc(12px + env(safe-area-inset-bottom)); 
    left: 12px; 
    right: 12px; 
    height: 56px;
    background: rgba(255,255,255,.95); 
    border: 1px solid #e5e7eb; 
    display: flex;
    align-items: center; 
    justify-content: space-around; 
    z-index: 200; 
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(16,24,40,0.18); 
    backdrop-filter: saturate(1.2) blur(6px);
    touch-action: manipulation;
    pointer-events: auto;
  }
  
  .mobile-nav-btn { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center;
    gap: 3px; 
    height: 100%; 
    flex: 1; 
    font-size: 11px; 
    color: #0f172a;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 10px;
    margin: 3px;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 44px;
    position: relative;
    overflow: hidden;
  }
  
  .mobile-nav-btn:active,
  .mobile-nav-btn:focus { 
    transform: scale(.95); 
    background: rgba(59, 130, 246, 0.1);
    outline: none;
  }
  
  .mobile-nav-btn:hover {
    background: rgba(59, 130, 246, 0.05);
  }
  
  .mobile-sheet {
    position: fixed; 
    left: 12px; 
    right: 12px; 
    bottom: calc(76px + env(safe-area-inset-bottom)); 
    max-height: 75vh;
    background: #fff; 
    border-radius: 18px;
    border: 1px solid #e5e7eb; 
    box-shadow: 0 -8px 24px rgba(16,24,40,.15);
    overflow: hidden;
    z-index: 190;
    transform: translateY(12px); 
    opacity: 0; 
    pointer-events: none;
    transition: transform .25s cubic-bezier(.2,.8,.2,1), opacity .25s ease;
    /* Better scrolling on mobile */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  
  .mobile-sheet.hidden { 
    display: block; 
    transform: translateY(12px); 
    opacity: 0; 
    pointer-events: none; 
  }
  
  .mobile-sheet.show { 
    transform: translateY(0); 
    opacity: 1; 
    pointer-events: auto; 
  }
  
  /* Mobile sheet content area */
  .mobile-sheet-content {
    padding: 16px;
    max-height: calc(75vh - 120px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }
  
  .mobile-backdrop {
    position: fixed; 
    inset: 0; 
    background: rgba(0,0,0,.28); 
    z-index: 105;
    opacity: 0; 
    pointer-events: none; 
    transition: opacity .25s ease;
  }
  
  .mobile-backdrop.show { 
    opacity: 1; 
    pointer-events: auto; 
  }

  /* Enhanced mobile sheet scrolling */
  .mobile-sheet::-webkit-scrollbar {
    width: 6px;
  }
  
  .mobile-sheet::-webkit-scrollbar-track {
    background: transparent;
  }
  
  .mobile-sheet::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #cbd5e1, #94a3b8);
    border-radius: 3px;
  }

  /* sticky actions inside sheet */
  .sheet-actions { 
    position: sticky; 
    bottom: 0; 
    background: #fff; 
    padding: 12px 0 8px; 
    margin-top: 12px; 
    border-top: 1px solid #e5e7eb; 
    display: flex; 
    gap: 8px; 
    border-bottom-left-radius: 20px; 
    border-bottom-right-radius: 20px;
  }
  
  .sheet-actions .btn { 
    flex: 1; 
    height: 40px; 
    font-size: 13px;
    border-radius: 12px;
  }

  /* sheet header with close and drag handle */
  .sheet-header { 
    position: sticky; 
    top: 0; 
    background: #fff; 
    z-index: 1; 
    padding: 8px 16px 12px; 
    border-bottom: 1px solid #e5e7eb; 
    border-top-left-radius: 20px; 
    border-top-right-radius: 20px; 
  }
  
  .sheet-header-row { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
  }
  
  .sheet-title { 
    font-weight: 600; 
    font-size: 16px; 
    color: #0f172a; 
  }
  
  .sheet-close { 
    width: 40px; 
    height: 40px; 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    border-radius: 12px; 
    border: 1px solid #e5e7eb; 
    background: #fff;
    transition: all 0.2s ease;
    cursor: pointer;
  }
  
  .sheet-close:active { 
    transform: scale(.95); 
    background: #f8fafc;
  }
  
  .sheet-grabber { 
    width: 40px; 
    height: 4px; 
    border-radius: 999px; 
    background: #cbd5e1; 
    margin: 0 auto 8px; 
    touch-action: none;
    opacity: 0.8;
  }
  
  .sheet-switch { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 12px 16px; 
  }
  
  .switch { 
    position: relative; 
    width: 48px; 
    height: 26px; 
    border-radius: 999px; 
    background: #e5e7eb; 
    transition: background .2s; 
  }
  
  .switch.on { 
    background: #22c55e; 
  }
  
  .switch-thumb { 
    position: absolute; 
    top: 2px; 
    left: 2px; 
    width: 22px; 
    height: 22px; 
    border-radius: 999px; 
    background: #fff; 
    box-shadow: 0 1px 2px rgba(0,0,0,.2); 
    transition: transform .2s; 
  }
  
  .switch.on .switch-thumb { 
    transform: translateX(22px); 
  }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
  .mobile-nav {
    left: 8px;
    right: 8px;
    height: 52px;
  }
  
  .mobile-sheet {
    left: 8px;
    right: 8px;
    padding: 12px;
  }
  
  .sheet-actions .btn {
    height: 36px;
    font-size: 12px;
  }
  
  .panel-card {
    padding: 16px;
  }
}

/* Export tab scrollable container */
.export-scrollable {
  max-height: 70vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 8px;
  /* Ensure scrollbar is always visible when content overflows */
  scrollbar-gutter: stable;
}

.export-content {
  padding-bottom: 16px;
  /* Add more content to ensure scrolling is needed */
  min-height: 100px;
}

/* Custom scrollbar for export tab */
.export-scrollable::-webkit-scrollbar {
  width: 8px;
  /* Always show scrollbar track */
  background: rgba(203, 213, 225, 0.3);
}

.export-scrollable::-webkit-scrollbar-track {
  background: rgba(241, 245, 249, 0.8);
  border-radius: 4px;
  border: 1px solid rgba(203, 213, 225, 0.5);
}

.export-scrollable::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #6366f1, #8b5cf6);
  border-radius: 4px;
  border: 1px solid rgba(99, 102, 241, 0.3);
  transition: all 0.2s ease;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.export-scrollable::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #4f46e5, #7c3aed);
  border-color: rgba(79, 70, 229, 0.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.export-scrollable::-webkit-scrollbar-thumb:active {
  background: linear-gradient(180deg, #4338ca, #6d28d9);
  border-color: rgba(67, 56, 202, 0.6);
}

/* Firefox scrollbar */
.export-scrollable {
  scrollbar-width: thin;
  scrollbar-color: #6366f1 rgba(241, 245, 249, 0.8);
}

/* Custom Dropdown Styles */
.custom-dropdown {
  position: relative;
  width: 100%;
}

.custom-dropdown-trigger {
  width: 100%;
  height: 44px;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  background: #ffffff;
  padding: 12px 40px 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: #0f172a;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  -webkit-tap-highlight-color: transparent;
}

.custom-dropdown-trigger:hover {
  border-color: #3b82f6;
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.custom-dropdown-trigger:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1), 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.dropdown-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropdown-arrow {
  color: #6b7280;
  font-size: 12px;
  transition: all 0.2s ease;
  flex-shrink: 0;
  margin-left: 8px;
}

.custom-dropdown-trigger:hover .dropdown-arrow {
  color: #3b82f6;
}

.custom-dropdown-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  z-index: 9999;
  max-height: 300px;
  overflow: hidden;
  display: none;
}

.dropdown-list {
  max-height: 250px;
  overflow-y: auto;
  overflow-x: hidden;
}

.dropdown-item {
  padding: 12px 16px;
  cursor: pointer;
  transition: background-color 0.15s ease;
  min-height: 44px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #f3f4f6;
}

.dropdown-item:last-child {
  border-bottom: none;
}

.dropdown-item:hover {
  background-color: #f9fafb;
}

.dropdown-item.selected {
  background-color: #eff6ff;
  color: #1d4ed8;
  font-weight: 500;
}

/* Mobile improvements for custom dropdowns */
@media (max-width: 767px) {
  .custom-dropdown-trigger {
    min-height: 48px;
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 12px 40px 12px 16px;
    border-radius: 12px;
  }

  .dropdown-item {
    min-height: 48px;
    padding: 14px 16px;
    font-size: 16px;
  }

  .custom-dropdown-panel {
    max-height: 280px;
    border-radius: 12px;
  }

  .dropdown-list {
    max-height: 230px;
  }
  
  /* Porsche picker mobile optimizations */
  .pp-trigger {
    min-height: 48px;
    padding: 12px 16px;
    font-size: 16px;
    border-radius: 12px;
  }

  .pp-item {
    min-height: 48px;
    padding: 12px 14px;
    font-size: 16px;
  }

  .pp-list {
    max-height: 250px;
  }
  
  .pp-panel {
    border-radius: 12px;
  }
}

/* Export tab specific responsive improvements */
@media (max-width: 1023px) {
  /* Make export tab content more compact on smaller screens */
  #export .panel-card {
    padding: 16px;
  }
  
  #export .btn-xs {
    height: 32px;
    padding: 6px 12px;
    font-size: 12px;
  }
  
  #export .grid {
    gap: 6px;
  }
  
  #export .grid-cols-2 {
    grid-template-columns: 1fr 1fr;
  }
  
  /* Adjust scrollable height for mobile */
  .export-scrollable {
    max-height: 60vh;
  }
  
  /* Touch-friendly improvements for export tab */
  #export .btn {
    min-height: 44px;
    touch-action: manipulation;
  }

  #export .btn-xs {
    min-height: 40px;
  }

  /* Export tab dropdown improvements */
  #export select {
    min-height: 44px;
    padding: 12px 40px 12px 16px;
    font-size: 16px; /* Prevents zoom on iOS */
  }

  #export .input-compact {
    min-height: 44px;
    padding: 12px 16px;
    font-size: 16px;
  }

  /* Mobile improvements for all dropdowns and inputs */
  #ui select,
  .mobile-sheet select {
    min-height: 48px;
    padding: 12px 40px 12px 16px;
    font-size: 16px; /* Prevents zoom on iOS */
    border-radius: 12px;
  }
  
  #ui input[type="text"],
  #ui input[type="search"],
  #ui input[type="number"],
  #ui input[type="email"],
  #ui input[type="url"],
  .mobile-sheet input[type="text"],
  .mobile-sheet input[type="search"],
  .mobile-sheet input[type="number"],
  .mobile-sheet input[type="email"],
  .mobile-sheet input[type="url"] {
    min-height: 48px;
    padding: 12px 16px;
    font-size: 16px;
    border-radius: 12px;
  }
  
  .input-compact {
    min-height: 48px;
    padding: 12px 16px;
    font-size: 16px;
    border-radius: 12px;
  }
  
  #export .grid-cols-2 .btn {
    min-height: 44px;
    font-size: 13px;
  }
}

/* Mobile sheet for all mobile devices */
@media (max-width: 767px) {
  .mobile-sheet {
    left: 6px;
    right: 6px;
    bottom: calc(64px + env(safe-area-inset-bottom));
    padding: 10px;
    border-radius: 16px;
    max-height: 70vh;
  }

  .sheet-actions .btn {
    height: 34px;
    font-size: 11px;
    padding: 6px 10px;
  }

  .panel-card {
    padding: 12px;
  }

  .field-label {
    font-size: 10px;
  }

  .btn-xs {
    height: 30px;
    padding: 4px 8px;
    font-size: 10px;
  }

  .swatch {
    width: 28px;
    height: 28px;
  }

  .input-compact {
    height: 36px;
    padding: 8px 10px;
    font-size: 14px;
  }
}

/* Landscape mobile orientation */
@media (max-width: 767px) and (orientation: landscape) {
  #canvas-container {
    height: calc(100vh - 60px) !important;
  }

  .mobile-sheet {
    max-height: 65vh;
    bottom: calc(64px + env(safe-area-inset-bottom));
  }
  
  .mobile-nav {
    height: 48px;
  }
  
  .mobile-nav-btn {
    font-size: 10px;
    gap: 1px;
  }
  
  .mobile-nav-btn svg {
    width: 16px;
    height: 16px;
  }
  
  /* Adjust export tab for landscape mobile */
  .export-scrollable {
    max-height: 45vh;
  }
  
  /* Compact sheet content in landscape */
  .mobile-sheet-content {
    max-height: calc(65vh - 100px);
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  #ui select {
    background-size: 12px;
  }
  
  .field-label::after {
    height: 1px;
  }
}

/* Ripple effect */
.ripple-container { position: relative; overflow: hidden; }
.ripple {
  position: absolute; border-radius: 999px; transform: scale(0);
  background: rgba(15, 23, 42, 0.18); opacity: 0.8;
  animation: ripple-anim 600ms linear;
  pointer-events: none;
}
@keyframes ripple-anim {
  to { transform: scale(4); opacity: 0; }
}

/* Option selection UI */
.option {
  border: 1px solid #e5e7eb; /* slate-200 */
  background: #fff;
  border-radius: 10px;
}
.option:has(input[type="radio"]:checked) {
  border-color: #6366f1;
  box-shadow: 0 0 0 4px rgba(79,70,229,0.12);
  background: #fafaff;
}
.option:hover { border-color: #d1d5db; background: #ffffff; }

/* Tabs */
.sidebar-tabs{
  display:flex;
  gap:8px;
  background:transparent;
}
.tab-btn{
  flex:1;
  padding:8px 10px;
  font-size:12px;
  border-radius:10px;
  border:1px solid #e2e8f0;
  background:#fff;
}
.tab-btn.active{
  border-color:#6366f1;
  background:#eef2ff;
}
.tab-panels{flex:1;display:flex;flex-direction:column;min-height:0}
.tab-panel{display:none}
.tab-panel.active{display:block}

/* Nested View Tabs */
.view-tabs{
  display:flex;
  gap:4px;
  background:transparent;
  margin-bottom:12px;
  flex-wrap: wrap;
}
.view-tab-btn{
  flex:1;
  padding:6px 8px;
  font-size:11px;
  border-radius:8px;
  border:1px solid #e2e8f0;
  background:#fff;
  color:#64748b;
  transition: all .15s cubic-bezier(0.4, 0, 0.2, 1);
}
.view-tab-btn:hover{
  border-color:#cbd5e1;
  background:#f8fafc;
  color:#475569;
}
.view-tab-btn.active{
  border-color:#6366f1;
  background:#eef2ff;
  color:#4338ca;
  font-weight:600;
}
.view-tab-panel{display:none}
.view-tab-panel.active{display:block}

/* Compact inputs */
#ui select, #ui input[type="text"], #ui button { height:36px }

/* Toast UI */
#copyToast{ position:fixed; right:20px; bottom:20px; z-index:9999; }
@media (max-width: 768px) {
  #copyToast{ top:12px; right:12px; bottom:auto; }
}
.toast-card{
  display:flex; align-items:center; gap:10px;
  background:#ffffff; color:#0f172a;
  border:1px solid rgba(15,23,42,0.08);
  box-shadow: 0 8px 24px rgba(16,24,40,0.12);
  padding:10px 12px; border-radius:12px; min-width:200px;
  position:relative; overflow:hidden;
}
.toast-text{ font-size:13px; font-weight:600 }
.toast-progress{
  position:absolute; left:0; bottom:0; height:3px; width:100%;
  background: linear-gradient(90deg,#10b981,#3b82f6);
  animation: toastProgress 1.4s linear forwards;
}
@keyframes toastProgress{ from{transform:translateX(0)} to{transform:translateX(-100%)} }

/* Accordion Styles */
.accordion-item {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
  background: #ffffff;
}

.accordion-header {
  background: #f9fafb;
  padding: 8px 12px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  border-bottom: none;
}

.accordion-header:hover {
  background: #f3f4f6;
}

/* Show border only when content is expanded */
.accordion-content.expanded {
  border-top: 1px solid #e5e7eb;
}

.accordion-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
  color: #374151;
}

.accordion-title .expand-icon {
  font-size: 10px;
  color: #6b7280;
  transition: transform 0.2s ease;
  width: 12px;
  text-align: center;
}

.accordion-title .group-name {
  flex: 1;
}

.accordion-title .mesh-count {
  font-size: 11px;
  color: #9ca3af;
  font-weight: 500;
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background: #ffffff;
}

.accordion-content.expanded {
  max-height: 300px;
  overflow-y: auto;
}

/* Counter Section */
.counter-section {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 -4px 20px rgba(16, 24, 40, 0.08);
  backdrop-filter: blur(8px);
  z-index: 50;
  padding: 16px 20px;
  transition: all 0.3s ease;
}

.counter-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
}

.counter-number {
  font-size: 32px;
  font-weight: 700;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  min-width: 120px;
  display: inline-block;
}

.counter-text {
  font-size: 14px;
  color: #64748b;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.025em;
}

/* Counter animation */
@keyframes counterGlow {
  0%, 100% {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  }
  50% {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), 0 0 15px rgba(59, 130, 246, 0.3);
  }
}

.counter-number.animated {
  animation: counterGlow 2s ease-in-out;
}

/* Mobile responsiveness for counter */
@media (max-width: 767px) {
  .counter-section {
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.95);
  }

  .counter-number {
    font-size: 28px;
    min-width: 100px;
  }

  .counter-text {
    font-size: 13px;
  }

  /* Adjust mobile nav to account for counter */
  .mobile-nav {
    bottom: calc(20px + 76px + env(safe-area-inset-bottom));
  }

  .mobile-sheet {
    bottom: calc(96px + 76px + env(safe-area-inset-bottom));
  }
}

@media (min-width: 768px) {
  .counter-section {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
  }
}

/* Mesh Tree Styles */
.mesh-tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  font-size: 12px;
  color: #374151;
  margin: 2px 4px;
}

.mesh-tree-item:hover {
  background-color: #f3f4f6;
}

.mesh-tree-item.has-children {
  font-weight: 600;
  color: #1f2937;
}

.mesh-tree-item .mesh-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mesh-tree-item .eye-icon {
  width: 16px;
  height: 16px;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  cursor: pointer;
}

.mesh-tree-item .eye-icon:hover {
  opacity: 1;
}

.mesh-tree-item .eye-icon.hidden {
  opacity: 0.7;
}

.mesh-tree-item .expand-icon {
  width: 12px;
  height: 12px;
  transition: transform 0.2s ease;
}

.mesh-tree-item .expand-icon.expanded {
  transform: rotate(90deg);
}

.mesh-tree-children {
  margin-left: 16px;
  border-left: 1px solid #e5e7eb;
  padding-left: 8px;
}

.mesh-tree-children.collapsed {
  display: none;
}

.mesh-tree-group {
  margin-bottom: 4px;
}

.mesh-tree-group-header {
  font-weight: 600;
  color: #6b7280;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  padding: 2px 8px;
  background: #f9fafb;
  border-radius: 4px;
}


