:root { --card: #0c1118; --ink: #191919; --muted: #383838; --edge: #808080; --edge-2: #35516b; --gap: 10px; --ui-hue: 0deg; --ui-sat: 1; --ui-bright: 1;}
* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body { margin: 0; background: #0b0f16; color: var(--ink); font: 14px system-ui, Arial; font-weight: 400; }

#share-modal,
#lead-modal {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

#layout { display: grid; grid-template-columns: minmax(600px, 1fr) 360px; gap: var(--gap); height: 100vh; padding: 12px; }
@media (max-width: 1100px) { #layout { grid-template-columns: 1fr 340px; } }
@media (max-width: 900px) { #layout { grid-template-columns: 1fr 320px; } }

.canvas-wrap { position: relative; border: 1px solid var(--edge); border-radius: 16px; background: #0b0f16; overflow: hidden; }
#bgImg { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); height: 100%; width: auto; display: block; pointer-events: none; user-select: none; z-index: 0; transition: filter .25s ease; }
#brandingLogo { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: none; display: none; pointer-events: none; user-select: none; z-index: 1; }
#cv-canvas { position: relative; z-index: 2; display: block; width: 100%; height: 100%; touch-action: none; background: transparent; }

#side {
  position: relative;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  filter:
  hue-rotate(var(--ui-hue))
  saturate(var(--ui-sat))
  brightness(var(--ui-bright));
  scrollbar-width: thin;
  scrollbar-color: #324a63 transparent;
}

#topbar { position: absolute; left: 0; right: 0; top: 12px; display: flex; align-items: center; justify-content: space-between; padding: 0 var(--gap); z-index: 2; }
.pill { padding: 5px 9px; border: 1px solid var(--edge-2); border-radius: 999px; background: #132544; color: #cfe0f0; }
.btn { appearance: none; border: 1px solid var(--edge-2); background: #1b2b88; color: #fff; padding: 10px 12px; border-radius: 14px; font-weight: 650; cursor: pointer; transition: .2s; font-size: 14px;}
.btn:hover { transform: translateY(-1px); border-color: #7c94b2; }

.card { position: relative; left: 0; right: 0; margin: 0 var(--gap); border: 1px solid var(--edge); border-radius: 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); overflow: hidden; background: linear-gradient(180deg, #0c121a, #0a1017); transition: top 0.3s ease, height 0.3s ease; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid #1a2a3a; background: linear-gradient(180deg, #294679, #112039); cursor: pointer; user-select: none; }
.card-title { font-weight: 700; font-size: 14px; color: #e9f2fb; }
.collapse-btn { width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--edge-2); background: #0b1220; color: #cfe0f0; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: .2s; }
.collapse-btn:hover { transform: translateY(-1px); border-color: #7c94b2; }
.collapse-icon { width: 12px; height: 12px; display: block; transform: rotate(0deg); transition: .2s; }
.card.collapsed .collapse-icon { transform: rotate(-90deg); }

.card-body {
  padding: 14px 15px 28px;
  background-color: #f3f7fa;
  max-height: 55vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #112039 transparent;
  overscroll-behavior: contain;
}
.card.collapsed .card-body { display: none; }

.card-body::-webkit-scrollbar { width: 6px; }
.card-body::-webkit-scrollbar-track { background: rgba(15, 24, 38, .08); border-radius: 999px; }
.card-body::-webkit-scrollbar-thumb { background: #b0c2d8; border-radius: 999px; }
.card-body::-webkit-scrollbar-thumb:hover { background: #8ea4c1; }

#side::-webkit-scrollbar { width: 8px; }
#side::-webkit-scrollbar-track { background: rgba(4, 8, 15, 0.9); border-radius: 999px; }

/* Car-specific hide override - ensures zero layout height */
.card.car-hidden-override {
  display: none !important;
}

#side::-webkit-scrollbar-thumb { background: #324a63; border-radius: 999px; }
#side::-webkit-scrollbar-thumb:hover { background: #49658a; }

label { font-size: 12px; color: #363636; font-weight: 500; }
input[type="text"], input[type="number"], select { background: #0b1220; border: 1px solid var(--edge-2); color: #f3f7fa; border-radius: 10px; padding: 8px 10px; width: 100%; margin-top: 5px; margin-bottom: 5px; }
input[type="color"] { appearance: none; border: 1px solid var(--edge-2); border-radius: 10px; background: #0b1220; width: 100%; height: 36px; margin-top: 5px; }
input[type="range"] { width: 100%; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.mini { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.checkrow { display: flex; align-items: center; gap: 8px; margin-top: 6px; }

.car-list { margin-top: 6px; }
.car-item { display: flex; gap: 8px; align-items: center; width: 100%; padding: 6px 8px; border-radius: 10px; border: 1px solid rgba(128, 151, 180, 0.35); background: rgba(7, 12, 20, 0.9); cursor: pointer; text-align: left; margin-top: 5px; }
.car-item:hover { border-color: #7c94b2; background: rgba(25, 40, 70, 0.95); }
.car-item.selected { border-color: #e9f2fb; background: linear-gradient(90deg, #152166, #02063c); }
.car-thumb { width: 44px; height: 44px; border-radius: 8px; flex: 0 0 auto; object-fit: cover; padding: 1px; background: #ffffff; }
.color-thumb { border: 3px; padding: 1px; }
.car-label { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; }
.car-make { font-size: 13px; font-weight: 600; color: #e9f2fb; padding-bottom: 2px; }
.car-model { font-size: 12px; color: #e9f2fb }
.empty-text { font-size: 12px; color: var(--muted); padding: 4px 2px; }

.car-slider-nav { margin-top: 4px; display: flex; justify-content: space-between; gap: 8px; }

/* --- MODERN SHOWCASE PREVIEW --- */
.preview-showcase-container {
  width: 100%;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 16px;
  padding: 22px 20px; /* Increased vertical padding for air */
  text-align: center;
  position: relative;
  overflow: hidden;
  margin: 20px 0; /* More space around the container */
}

.showcase-display {
  position: relative;
  width: 100%; /* Slightly larger thumbnail */
  height: 100%;
  margin: 0 auto; /* More space below image */
}

.preview-img-large {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px 12px 0px 0px;
  transition: opacity 0.5s ease;
}

.lock-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ff3e3e;
  color: white;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 2px;
  box-shadow: 0 4px 10px rgba(255,62,62,0.4);
}

.showcase-info .model-name {
  display: block;
  font-size: 18px; /* Increased from 18px */
  font-weight: 700;
  color: #0c1118;
  letter-spacing: 0.6px;
  margin-top: 6px;
}

.showcase-info .make-name {
  display: block;
  font-size: 16px;
  color: #1a73e8;
  text-transform: uppercase;
  letter-spacing: 1px; /* More tracking for a "luxury" look */
  font-weight: 700;
}

/* Carbon Carousel */
.carbon-carousel-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
}

.carbon-carousel {
  flex: 1;
  display: flex;
  overflow-x: auto;
  scroll-behavior: smooth;
  padding: 4px;
  gap: 8px;
}

.carbon-item {
  min-width: 120px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  padding: 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.carbon-item:hover {
  background: #2a2a2a;
  border-color: #3a7bd5;
}

.carbon-item.selected {
  background: #1e3a5f;
  border-color: #3a7bd5;
  box-shadow: 0 0 0 1px #3a7bd5;
}

.carbon-thumb {
  width: 100%;
  height: 60px;
  border-radius: 4px;
  margin-bottom: 4px;
  background: linear-gradient(45deg, #222, #333);
}

.carbon-label {
  font-size: 12px;
  font-weight: bold;
  color: #fff;
}

.carbon-desc {
  font-size: 10px;
  color: #aaa;
  margin-top: 2px;
}

.car-nav-btn { flex: 1; appearance: none; border: 1px solid var(--edge-2); background: #0b1220; color: #cfe0f0; padding: 6px 0; border-radius: 999px; font-size: 13px; font-weight: 700; cursor: pointer; transition: .2s; }
.car-nav-btn:hover { border-color: #7c94b2; background: #1b2950; transform: translateY(-1px); }

#status { position: fixed; left: 12px; bottom: 12px; background: #0a1017; border: 1px solid #324a63; border-radius: 10px; padding: 8px 10px; color: #c9d6e3; font: 12px monospace; max-width: 95vw; }

.subtle { color: #363636; font-size: 14px; margin-top: 8px; margin-bottom: 6px; font-weight: 500; }
.subtle-w { color: #ffffff; font-size: 14px; margin-top: 8px; margin-bottom: 6px; font-weight: 500; }
.wrap-controls { margin-top: 10px; }
.hidden { display: none !important; }

#rimsPanel .subttl, #rimsPanel .miniLabel, #rimsPanel .miniVal { color: #000 !important; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--edge-2); border-radius: 999px; background: #213a6d; color: #cfe0f0; font-weight: 700; }
.chip input { accent-color: #6da3ff; }
.chip.disabled { opacity: .5; pointer-events: none; }

.switch-row { display: flex; align-items: center; justify-content: space-between; border: 1px solid #cbd6e2; background: #fff; border-radius: 12px; padding: 8px 10px; margin-top: 8px; }
.switch-label { font-size: 14px; color: #1b2840; font-weight: 600; }
.toggle { appearance: none; display: inline-block; width: 56px; height: 28px; border-radius: 999px; border: 1px solid #b2c0d1; position: relative; cursor: pointer; transition: .2s; background: #ef3d3d; }
.toggle:after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .25s; }
.toggle:checked { background: #29a744; border-color: #1e7e34; }
.toggle:checked:after { left: 31px; }
.switch-hint { font-size: 11px; color: #5c6a7a; }

#btnFrontFlipH { background: #0b173c; border-color: #070f26; color: #ffffff; }
#btnFrontFlipV { background: #0b173c; border-color: #070f26; color: #ffffff; }
#btnFrontPlateReset { background: #1b1b88; border-color: #151563; color: #ffffff; }
#btnRearFlipH { background: #0b173c; border-color: #070f26; color: #ffffff; }
#btnRearFlipV { background: #0b173c; border-color: #070f26; color: #ffffff; }
#btnRearPlateReset { background: #1b1b88; border-color: #151563; color: #ffffff; }

#btnCopyHead { background: #d34d00; border-color: #923500; color: #ffffff; }
#btnCopyLedRed { background: #d34d00; border-color: #923500; color: #ffffff; }
#btnCopyFog { background: #d34d00; border-color: #923500; color: #ffffff; }
#btnCopyBrake { background: #d34d00; border-color: #923500; color: #ffffff; }

.numInput { background: #0b1220; border: 1px solid var(--edge-2); color: #f3f7fa; border-radius: 6px; padding: 4px; width: 50px; font-size: 12px; text-align: center; font-family: monospace; }
.numInput:focus { border-color: #6da3ff; outline: none; }

/* --- FORCE LAYOUT UNLOCK (Restored Styling) --- */
#side {
  position: relative !important;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

.card {
  position: absolute !important; /* Required for JS layout */
  left: 0;
  right: 0; /* Restores the side gaps */
  width: auto; /* Allow right:0 to control width */
  margin: 0 var(--gap); /* Restores the 10px side margins */
  
  /* Original Aesthetics */
  background: linear-gradient(180deg, #0c121a, #0a1017) !important;
  border: 1px solid var(--edge);
  border-radius: 16px !important;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
  
  transition: top 0.3s ease, height 0.3s ease;
  overflow: hidden;
}

.card-header {
  padding: 10px 12px;
  background: linear-gradient(180deg, #294679, #112039); /* Restored Blue Header */
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #1a2a3a;
}

.card:not(.collapsed) .card-header {
  border-bottom: 1px solid #1a2a3a;
}

.card.collapsed .card-body {
  display: none;
}

/* Sleek Dropdown for Collections */
.dark-select {
  width: 100%;
  background: #0b1220;
  border: 1px solid var(--edge-2);
  color: #f3f7fa;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  margin-bottom: 4px;
}

.dark-select:focus {
  border-color: #6da3ff;
}

/* ==================================================
   ADMIN LOCKED PANEL (CLEAN + FINAL)
   ================================================== */

.card.admin-locked {
  position: relative;
}

/* -------------------------
   Header: replace collapse icon with lock
   ------------------------- */

.card.admin-locked .card-header {
  position: relative;
}

/* Hide normal collapse icon */
.card.admin-locked .card-header .collapse-icon,
.card.admin-locked .card-header .collapse-btn {
  opacity: 0;
}

/* Lock icon in same position */
.card.admin-locked .card-header::after {
  content: "🔒";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  opacity: 0.9;
  pointer-events: none;
  padding-right: 4px;
}

/* -------------------------
   Panel content state
   ------------------------- */

/* Grey content but KEEP scrolling */
.card.admin-locked .card-body {
  opacity: 0.45;
  filter: grayscale(1);
  pointer-events: auto;
}

/* Disable interaction on actual controls only */
.card.admin-locked .card-body button,
.card.admin-locked .card-body input,
.card.admin-locked .card-body select,
.card.admin-locked .card-body textarea,
.card.admin-locked .card-body a,
.card.admin-locked .card-body [role="button"] {
  pointer-events: none !important;
}

/* -------------------------
   Admin locked panel base
   ------------------------- */

.card.admin-locked {
  position: relative; /* REQUIRED for overlay positioning */
}

/* Grey out + disable panel controls */
.card.admin-locked .card-body {
  pointer-events: none;
  opacity: 0.55;
}

/* Allow scrolling of the panel body */
.card.admin-locked .card-body {
  overflow-y: auto;
}

/* -------------------------
   Upgrade overlay (Logic)
   ------------------------- */

/* CTA should never take layout space by default */
  #side section.card .panel-upgrade-cta {
    display: none;
  }

  /* When locked: CTA becomes a true overlay */
  #side section.card.admin-locked .panel-upgrade-cta {
    display: flex;
    position: absolute;
    top: 44px; /* Matches header height */
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0,0,0,0.25);
    backdrop-filter: blur(2px);
  }

/* -------------------------
   Upgrade overlay (true overlay)
   ------------------------- */

.card.admin-locked .panel-upgrade-cta {
  position: absolute;
  top: 48px;              /* below header */
  left: 0;
  right: 0;
  bottom: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  z-index: 50;
  pointer-events: none;   /* allow scrolling */
}

/* Hide upgrade CTA when panel is collapsed */
.card.admin-locked.collapsed .panel-upgrade-cta {
  display: none !important;
}

/* CTA container (clickable) */
.panel-upgrade-cta .cta-inner {
  pointer-events: auto;

  background: radial-gradient(
    circle at top,
    rgba(26, 115, 232, 0.25) -90%,
    rgba(8, 12, 20, 0.94) 70%
  );

  border: 2px solid rgba(255, 255, 255, 0.877);
  border-radius: 16px;
  padding: 15px 24px;
  padding-bottom: 20px;
  max-width: 300px;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  color: #ffffff;

  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

/* Hide upgrade CTA when panel is collapsed */
.card.admin-locked.collapsed .panel-upgrade-cta {
  display: none !important;
}

/* CTA text */
.panel-upgrade-cta .cta-title {
  color: #ffffff;
  font-weight: 800;
  font-size: 16px;
  margin: 0 0 6px;
}

.panel-upgrade-cta .cta-sub {
  color: #cfd8e3;
  font-size: 13px;
  line-height: 1.45;
  margin: 0 0 16px;
}

/* Hide upgrade CTA when panel is collapsed */
.card.admin-locked.collapsed .panel-upgrade-cta {
  display: none !important;
}

/* CTA button */
.panel-upgrade-cta .upgrade-btn {
  appearance: none;
  border: none;
  cursor: pointer;

  padding: 10px 22px;
  border-radius: 999px;

  background: linear-gradient(135deg, #1a73e8, #4da3ff);
  color: #ffffff;

  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-decoration: none;

  box-shadow:
    0 6px 18px rgba(26, 115, 232, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);

  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* Hide upgrade CTA when panel is collapsed */
.card.admin-locked.collapsed .panel-upgrade-cta {
  display: none !important;
}

.panel-upgrade-cta .upgrade-btn:hover {
  transform: translateY(-1px);
  box-shadow:
    0 10px 26px rgba(26, 115, 232, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

/* Hide upgrade CTA when panel is collapsed */
.card.admin-locked.collapsed .panel-upgrade-cta {
  display: none !important;
}

/* --- New Branding Panel Section Headers --- */
.panel-section-title {
  font-size: 11px;
  font-weight: 700;
  color: #000000;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  
  margin-top: 4px;
  margin-bottom: 12px;
  
  padding-left: 10px;
  border-left: 3px solid #4da3ff; /* Matches your primary accent color */
  
  /* Optional: subtle background fade */
  background: linear-gradient(90deg, rgba(77, 163, 255, 0.1) 0%, transparent 100%);
  padding-top: 4px;
  padding-bottom: 4px;
  border-radius: 0 4px 4px 0;
}

section.card.admin-locked {
  position: relative;
  overflow: hidden;
}

section.card.admin-locked .panel-upgrade-cta {
  display: flex !important;
  position: absolute;
  top: var(--card-header-height, 44px);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(3px);
  color: white;
  text-align: center;
}

section.card.admin-locked .card-body {
  opacity: 0.35;
  filter: grayscale(0.8);
  pointer-events: none;
}

/* Hide CTA when not locked */
section.card:not(.admin-locked) .panel-upgrade-cta {
  display: none !important;
}

section.card[style*="display: none"] {
  margin: 0 !important;
  padding: 0 !important;
  height: 0 !important;
  overflow: hidden;
}

/* Smoothly animate panel movement when reflowUI changes the 'top' property */
section.card {
  transition: top 0.4s cubic-bezier(0.25, 1, 0.5, 1), 
              opacity 0.3s ease, 
              transform 0.3s ease;
  will-change: top; /* Optimizes performance for the movement */
}

/* Optional: Slight fade-in when panels appear */
section.card.admin-locked {
  transition: top 0.4s cubic-bezier(0.25, 1, 0.5, 1), filter 0.3s ease;
}

/* Limited mode for subfeatures - subtle lock overlay */
[data-subfeature].limited {
  position: relative;
  filter: grayscale(0.6);
  /* Remove opacity: 0.6 from here */
}

/* Instead, apply opacity only to children that aren't the button */
[data-subfeature].limited > *:not(.limited-upgrade-btn) {
  opacity: 0.2;
  pointer-events: none;
}

[data-subfeature].limited .limited-upgrade-btn {
  pointer-events: auto !important;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #003a81;
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  z-index: 10000 !important;
  border: 1px solid #ffd700;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: background 0.2s ease;
  /* Ensure button itself is NOT affected by opacity */
  opacity: 1 !important;
}

[data-subfeature].limited .limited-upgrade-btn:hover {
  background: #155db5;
}

/* Remove the pseudo-element since we're using a real button */
[data-subfeature].limited::before {
  display: none !important;
}

/* ================================
   LAYOUT SMOOTHING (anti-stutter)
   Put this at the VERY BOTTOM
   ================================ */

/* During batch DOM changes (feature gating), kill transitions so panels don't "fight" */
#side.layout-freeze .card {
  transition: none !important;
}

/* Optional: ensure the intended transition wins (over any earlier duplicates) */
#side .card {
  transition: top 0.25s cubic-bezier(0.25, 1, 0.5, 1), height 0.25s cubic-bezier(0.25, 1, 0.5, 1) !important;
  will-change: top, height;
}

/* ==================================================
   MOBILE UI FOUNDATION
   Main Panel + Single Control Panel Mode
   ================================================== */

:root {
  --mobile-breakpoint: 767px;
  --mobile-panel-h: clamp(320px, 44vh, 460px);
  --mobile-panel-radius: 24px;
  --mobile-panel-pad: 12px;
  --mobile-header-h: 52px;
  --mobile-panel-gap: 10px;
  --mobile-safe-bottom: max(10px, env(safe-area-inset-bottom, 0px));
}

/* ----------------------------------
   MOBILE MODE: overall layout
   ---------------------------------- */
@media (max-width: 767px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  body.ui-mobile {
    overflow: hidden;
  }

  body.ui-mobile #layout {
    display: block !important;
    position: relative;
    width: 100vw;
    height: 100dvh;
    padding: 0 !important;
    gap: 0 !important;
  }

  body.ui-mobile .canvas-wrap {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: calc(var(--mobile-panel-h) - var(--mobile-panel-radius)) !important;
    width: 100% !important;
    height: auto !important;
    border-radius: 0 !important;
    border: none !important;
    overflow: hidden !important;
  }

  body.ui-mobile #cv-canvas {
    width: 100% !important;
    height: 100% !important;
  }

  /* leave room visually for the Main Panel */
  body.ui-mobile .canvas-wrap::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--mobile-panel-h) + 24px);
    pointer-events: none;
    background: linear-gradient(
      to top,
      rgba(5, 8, 14, 0.55) 0%,
      rgba(5, 8, 14, 0.18) 35%,
      rgba(5, 8, 14, 0) 100%
    );
    z-index: 3;
  }

    /* ----------------------------------
     Top bar moves to top of screen
     ---------------------------------- */
    body.ui-mobile #topbar {
    position: fixed !important;
    top: max(10px, env(safe-area-inset-top, 0px)) !important;
    left: 10px !important;
    right: 10px !important;
    width: auto !important;
    z-index: 2000 !important;

    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px !important;
    padding: 0 !important;
    pointer-events: none;
  }

  body.ui-mobile #topbar .pill,
  body.ui-mobile #topbar .btn {
    pointer-events: auto;
  }

  body.ui-mobile #topbar .pill {
    padding: 7px 12px !important;
    font-size: 12px !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background: rgba(19, 37, 68, 0.82) !important;
  }

  body.ui-mobile #topbar #btnReset {
    padding: 9px 12px !important;
    font-size: 12px !important;
    border-radius: 12px !important;
    min-width: 84px;
  }

  /* ----------------------------------
     Main Panel shell
     ---------------------------------- */
    body.ui-mobile #side {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100% !important;
    height: var(--mobile-panel-h) !important;
    margin: 0 !important;
    padding:
      12px
      12px
      calc(var(--mobile-safe-bottom) + 12px)
      12px !important;
    overflow: hidden !important;
    z-index: 1000 !important;

    display: block !important;

    background:
      linear-gradient(180deg, rgba(16, 22, 33, 0.96), rgba(8, 12, 19, 0.98));
    border-top: 1px solid rgba(126, 152, 185, 0.35);
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
    border-radius: var(--mobile-panel-radius) var(--mobile-panel-radius) 0 0 !important;
    box-shadow:
      0 -10px 40px rgba(0, 0, 0, 0.45),
      inset 0 1px 0 rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: transform 0.24s ease, opacity 0.24s ease !important;

    filter:
      hue-rotate(var(--ui-hue))
      saturate(var(--ui-sat))
      brightness(var(--ui-bright));
  }

  body.ui-mobile #side::-webkit-scrollbar {
    display: none;
  }

    body.ui-mobile.ui-mobile-panel-minimized #side {
    transform: translateY(calc(100% + 18px)) !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  body.ui-mobile.ui-mobile-panel-minimized .canvas-wrap {
    bottom: 0 !important;
  }

  body.ui-mobile.ui-mobile-panel-minimized .canvas-wrap::after {
    opacity: 0 !important;
  }

  body.ui-mobile .mobile-panel-reopen {
    position: fixed;
    left: 50%;
    bottom: max(14px, calc(env(safe-area-inset-bottom, 0px) + 14px));
    transform: translateX(-50%);
    z-index: 1900;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid rgba(123, 151, 183, 0.34);
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(16, 22, 33, 0.96), rgba(8, 12, 19, 0.98));
    color: #e9f2fb;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    cursor: pointer;
  }

  body.ui-mobile.ui-mobile-panel-minimized .mobile-panel-reopen {
    display: inline-flex;
  }

  /* ----------------------------------
     Mobile top strip inside Main Panel
     ---------------------------------- */
  body.ui-mobile .mobile-panel-nav {
    position: relative;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    height: var(--mobile-header-h);
    margin-bottom: 10px;
    padding: 0 4px;
    pointer-events: auto;
  }

  body.ui-mobile .mobile-panel-nav-left,
  body.ui-mobile .mobile-panel-nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 64px;
  }

  body.ui-mobile .mobile-panel-nav-right {
    justify-content: flex-end;
  }

  body.ui-mobile .mobile-panel-title-wrap {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-align: center;
  }

  body.ui-mobile .mobile-panel-title {
    color: #f1f6fb;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  body.ui-mobile .mobile-panel-counter {
    color: #97abc2;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
  }

  body.ui-mobile .mobile-panel-arrow {
    appearance: none;
    border: 1px solid rgba(123, 151, 183, 0.34);
    background: linear-gradient(180deg, #2e538b, #0d3a83);
    color: #e9f2fb;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    font-weight: 700;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  }

  body.ui-mobile .mobile-panel-arrow:active {
    transform: scale(0.98);
  }

    /* ----------------------------------
     Cards become single-panel slides
     ---------------------------------- */
  body.ui-mobile #side > section.card {
    position: absolute !important;
    left: 10px !important;
    right: 10px !important;
    top: calc(10px + var(--mobile-header-h) + 10px) !important;
    bottom: calc(var(--mobile-safe-bottom) + 10px) !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;

    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    transform: translateX(18px) !important;
    pointer-events: none !important;
    z-index: 1 !important;

    overflow: hidden !important;
    border-radius: 18px !important;
    background: linear-gradient(180deg, #0d1520, #0a1017) !important;
    border: 1px solid rgba(91, 115, 145, 0.24) !important;
    box-shadow: none !important;
    transition: opacity 0.22s ease, transform 0.22s ease !important;
  }

  body.ui-mobile #side > section.card.mobile-active-panel {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    transform: translateX(0) !important;
    pointer-events: auto !important;
    z-index: 3 !important;
  }

  body.ui-mobile #side > section.card.mobile-exit-left {
    display: none !important;
  }

  body.ui-mobile #side > section.card.mobile-exit-right {
    display: none !important;
  }

  /* ----------------------------------
     Card header becomes static title bar
     ---------------------------------- */
  body.ui-mobile #side > section.card .card-header {
    display: none !important;
  }

    body.ui-mobile #side > section.card.collapsed .card-body {
    display: block !important;
  }

  body.ui-mobile #side > section.card .collapse-btn,
  body.ui-mobile #side > section.card .collapse-icon {
    display: none !important;
  }

      /* ----------------------------------
     Card body fills Main Panel
     Vertical scroll allowed inside panel
     ---------------------------------- */
  body.ui-mobile #side > section.card .card-body {
    display: block !important;
    height: 100% !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 12px !important;
    background: #f3f7fa !important;
    border-radius: 18px !important;
    scrollbar-width: none;
    overscroll-behavior-y: contain;
    overscroll-behavior-x: none;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }

    body.ui-mobile #side .subtle,
  body.ui-mobile #side .subtle-w {
    font-size: 14px !important;
    line-height: 1.3 !important;
    font-weight: 600 !important;
  }

  body.ui-mobile #side > section.card .card-body::-webkit-scrollbar {
    display: none;
  }

    /* ----------------------------------
     Beefier sliders for touch
     ---------------------------------- */
  body.ui-mobile #side input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100% !important;
    height: 34px !important;
    background: transparent !important;
    margin: 6px 0 !important;
  }

  body.ui-mobile #side input[type="range"]::-webkit-slider-runnable-track {
    height: 8px !important;
    border-radius: 999px !important;
    background: linear-gradient(90deg, #18345a, #2c5b96) !important;
  }

  body.ui-mobile #side input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px !important;
    height: 24px !important;
    border-radius: 50% !important;
    background: #ffffff !important;
    border: 2px solid #23497a !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.22) !important;
    margin-top: -8px !important;
    cursor: pointer;
  }

  body.ui-mobile #side input[type="range"]::-moz-range-track {
    height: 8px !important;
    border-radius: 999px !important;
    background: linear-gradient(90deg, #18345a, #2c5b96) !important;
  }

  body.ui-mobile #side input[type="range"]::-moz-range-thumb {
    width: 24px !important;
    height: 24px !important;
    border-radius: 50% !important;
    background: #ffffff !important;
    border: 2px solid #23497a !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.22) !important;
    cursor: pointer;
  }

  /* ----------------------------------
     Horizontal-friendly inner layout helpers
     ---------------------------------- */
  body.ui-mobile #side .row {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  body.ui-mobile #side .row::-webkit-scrollbar {
    display: none;
  }

  body.ui-mobile #side .mini {
    grid-template-columns: 1fr !important;
    min-width: 0 !important;
  }

  body.ui-mobile #side .car-list,
  body.ui-mobile #side .collection-list,
  body.ui-mobile #side .thumb-grid,
  body.ui-mobile #side #gradientPresetCarousel,
  body.ui-mobile #side #graphicsPresetCarousel,
  body.ui-mobile #side .carbon-carousel,
  body.ui-mobile #side #sceneList,
  body.ui-mobile #side #envList,
  body.ui-mobile #side #hdrCarousel {
    width: 100% !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 10px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 2px 0 6px 0 !important;
    margin-top: 6px !important;
    scrollbar-width: none;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }

  body.ui-mobile #side .car-list::-webkit-scrollbar,
  body.ui-mobile #side .collection-list::-webkit-scrollbar,
  body.ui-mobile #side .thumb-grid::-webkit-scrollbar,
  body.ui-mobile #side #gradientPresetCarousel::-webkit-scrollbar,
  body.ui-mobile #side #graphicsPresetCarousel::-webkit-scrollbar {
    display: none;
  }

    body.ui-mobile #side .car-item,
    body.ui-mobile #side .carbon-item {
    flex: 0 0 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-top: 0 !important;
    scroll-snap-align: start;
  }

  /* ----------------------------------
     Locked overlay still works on mobile
     ---------------------------------- */
  body.ui-mobile #side section.card.admin-locked .panel-upgrade-cta {
    top: 0 !important;
    border-radius: 18px;
  }

  /* ----------------------------------
     Optional: hide desktop status clutter if needed
     ---------------------------------- */
    body.ui-mobile #status {
    display: none !important;
  }
}

@media (max-width: 767px) {
  body.ui-mobile #side > section.card {
    position: absolute !important;
  }

  body.ui-mobile #side > section.card:not(.mobile-active-panel) {
    display: none !important;
  }

  body.ui-mobile #side > section.card.mobile-active-panel {
    display: block !important;
  }
}