:root {
  --bg: #fbfdff;
  --panel: #ffffff;
  --muted: #6b7280;
  --accent: #0ea5a4;
  --surface: #f7f9fb;
  --border-color: #ffffff;
  --border-width: 8px;
  --border-radius: 0px;
}
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  margin: 0;
  font-family: Inter, system-ui, Roboto;
  background: var(--bg);
  color: #0f172a;
}
.app {
  display: flex;
  height: 100vh;
  padding: 18px;
  gap: 14px;
}

/* sidebar */
.sidewrap {
  display: flex;
  gap: 12px;
}
.side {
  width: 64px;
  transition: width 0.22s ease;
  border-radius: 12px;
  display: flex;
  flex-direction: row;
}
.side.expanded {
  width: 300px;
}
.rail {
  width: 64px;
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  padding: 8px;
}
.icon-btn {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  border: 1px solid transparent;
  transition: all 0.18s;
}
.icon-btn:hover {
  box-shadow: 0 6px 20px rgba(2, 6, 23, 0.04);
}
.icon-btn.active {
  background: linear-gradient(180deg, var(--surface), #fff);
  color: var(--accent);
  box-shadow: 0 10px 30px rgba(14, 165, 164, 0.08);
}
.panel {
  width: 0;
  overflow: hidden;
  transition: width 0.22s ease;
}

/* --- FIX: Desktop Panel Expansion --- */
/* This ensures the panel has width when the sidebar is expanded on Desktop */
.side.expanded .panel {
  width: 236px; /* 300px Total - 64px Rail = 236px */
}

.panel-inner {
  background: var(--panel);
  height: calc(100vh - 36px);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 8px 30px rgba(2, 6, 23, 0.04);
  border: 1px solid #eef2f7;
  overflow: auto;
}
.muted {
  color: var(--muted);
  font-size: 13px;
}

/* main */
.main {
  display: flex;
  flex: 1;
  gap: 12px;
}
.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
/* Hide mobile-only elements on desktop by default */
.mobile-only {
  display: none;
}
.btn {
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #0f172a;
  font-weight: 600;
  cursor: pointer;
}
.btn.primary {
  background: var(--accent);
  color: white;
}

/* stage */
.stage-outer {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stage-card {
  width: 960px;
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.stage-top {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.size-indicator {
  font-size: 13px;
  color: var(--muted);
}
.stage {
  width: 800px;
  height: 40vw;
  background: var(--surface);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border: 1px solid #eef2f7;
}
.canvas-frame-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.canvas-frame {
  position: relative;
  background: white;
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  /* keep transform-origin center so visual scaling is centered */
  transform-origin: center center;
  box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.5); /* Deep shadow */
}
.canvas-surface {
  position: relative;
  background: var(--surface);
  border-radius: var(--border-radius);
  overflow: hidden;
  width: 100%;
  height: 100%;
  background-color: white;
  border: var(--border-width) solid var(--border-color);
}

/* slots */
.grid-slot {
  position: absolute;
  overflow: hidden;
  background: #ffffff;
  border: var(--border-width) solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  border: radius 0px !important ;
}
.grid-slot.selected {
  outline: 2px solid rgba(14, 165, 164, 0.18);
}
.frame {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #f3f6f8;
}
.frame img {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(1);
  will-change: transform;
  user-select: none;
  touch-action: none;
  pointer-events: none;
}
.badge {
  position: absolute;
  left: 10px;
  top: 10px;
  background: #fff;
  border-radius: 8px;
  padding: 6px 8px;
  border: 1px solid #eef2f7;
  font-size: 12px;
  color: var(--muted);
}

/* hit-zones and separators */
.hit-zone {
  position: absolute;
  pointer-events: auto;
  background: transparent;
  z-index: 800;
}
.sep-visual {
  position: absolute;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
}
.sep-visual .line {
  background: transparent;
  border: 2px dotted rgba(15, 23, 42, 0.22);
}
.sep-visual.h .line {
  width: 100%;
  height: 0;
}
.sep-visual.v .line {
  width: 0;
  height: 100%;
  border-left: 2px dotted rgba(15, 23, 42, 0.22);
}
.sep-visual .handle {
  position: absolute;
  background: var(--accent);
  color: white;
  font-size: 11px;
  padding: 6px 8px;
  border-radius: 6px;
  transform: translate(-50%, -140%);
  display: none;
}
.sep-visual.dragging .handle {
  display: block;
}

/* canvas corner handles */
.resize-handle {
  position: absolute;
  width: 18px;
  height: 18px;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.resize-handle::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 4px;
  background: #fff;
  border: 1px solid #e6ecec;
  box-shadow: 0 6px 18px rgba(2, 6, 23, 0.06);
  opacity: 0.95;
}
.handle-n {
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  cursor: n-resize;
}
.handle-s {
  bottom: -9px;
  left: 50%;
  transform: translateX(-50%);
  cursor: s-resize;
}
.handle-w {
  left: -9px;
  top: 50%;
  transform: translateY(-50%);
  cursor: w-resize;
}
.handle-e {
  right: -9px;
  top: 50%;
  transform: translateY(-50%);
  cursor: e-resize;
}
.handle-nw {
  left: -9px;
  top: -9px;
  cursor: nw-resize;
}
.handle-ne {
  right: -9px;
  top: -9px;
  cursor: ne-resize;
}
.handle-sw {
  left: -9px;
  bottom: -9px;
  cursor: sw-resize;
}
.handle-se {
  right: -9px;
  bottom: -9px;
  cursor: se-resize;
}

/* right panel */

label {
  font-size: 13px;
  color: var(--muted);
}

/* floating context menu */
.slot-menu {
  position: absolute;
  min-width: 160px;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.16);
  border: 1px solid #e5e7eb;
  padding: 6px;
  z-index: 2000;
  display: none;
}
.slot-menu button {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #111827;
}
.slot-menu button span.icon {
  font-size: 14px;
}
.slot-menu button:hover {
  background: #f3f4f6;
}
.slot-menu button.danger {
  color: #b91c1c;
}
.slot-menu button.danger:hover {
  background: #fef2f2;
}

/* Canvas size presets UI */
.canvas-presets {
  margin-top: 10px;
}
.canvas-presets .presets-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 8px;
  align-items: start;
}
.preset-tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.preset-preview {
  width: 56px;
  height: 46px;
  border-radius: 6px;
  border: 2px solid #e6e6e6;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}
.preset-tile .label {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}
.preset-tile.active .preset-preview {
  background: #f59e3b;
  border-color: #f59e3b;
  color: white;
  box-shadow: 0 8px 22px rgba(245, 158, 59, 0.12);
}
.preset-custom {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}
.preset-custom input {
  width: 100%;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #e6e6e6;
}

/* Modern icon styles */
.material-icons {
  font-family: "Material Icons";
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
}
.icon-btn .material-icons {
  font-size: 22px;
}

/* --- REMOVED LEGACY 1100px RULE THAT HID SIDEBAR --- */
/* (This ensures sidebar stays visible on tablets/small laptops) */

/* Remove orange fill from PREVIEW — tile only */
.preset-tile {
  cursor: pointer;
  border-radius: 14px;
  transition: 0.2s;
  text-align: center;
  padding: 0; /* IMPORTANT FIX */
}

/* Only outer tile gets orange */
.preset-tile.active {
  background: #f97316;
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.35);
  padding-top: 8px;
  padding-bottom: 8px;
}

/* Preview box ALWAYS stays white */
.preset-preview {
  width: 70px;
  height: 70px;
  background: #ffffff;
  border: 2px solid #d0d5dd;
  border-radius: 12px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Inner aspect box */
.preset-inner {
  border: 2px solid #ffffff;
  border-radius: 6px;
  width: 60%;
  height: 60%;
}

/* Correct aspect previews */
.preset-inner.portrait {
  width: 40%;
  height: 70%;
}
.preset-inner.landscape {
  width: 70%;
  height: 40%;
}

/* Label clean */
.preset-label {
  font-size: 11px;
  color: #475569;
  margin-top: 6px;
  line-height: 1.3;
}
.preset-label span {
  font-size: 10px;
  color: #94a3b8;
}

/* new code    */
/* ---------- Canvas Size Presets — Material Expansion Panel (FIXED) ---------- */

.presets-panel {
  width: 100%;
  margin-top: 12px;
  background: transparent;
}

/* Panel Header */
.presets-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 6px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.18s;
}
.presets-header:hover {
  background: rgba(0, 0, 0, 0.04);
}

.presets-title {
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
}
.presets-sub {
  font-size: 12px;
  color: #94a3b8;
}

.presets-chevron {
  transition: transform 0.22s ease;
  color: #6b7280;
}

/* Panel Body — no internal scroll */
.presets-body {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.25s ease, opacity 0.25s ease;
}

.presets-panel.open .presets-body {
  max-height: 2000px; /* large enough */
  opacity: 1;
  padding-top: 10px;
}

/* Grid in normal flow — FIXED */
.presets-grid-material {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  width: 100%;
}

/* Tile */
.preset-material {
  cursor: pointer;
  border-radius: 10px;
  padding: 6px;
  background: transparent;
  transition: transform 0.08s;
}
.preset-material:hover {
  transform: translateY(-3px);
}

/* Preview thumb */
.preset-thumb {
  width: 70px;
  height: 70px;
  border-radius: 10px;
  background: white;
  border: 2px solid #d1d5db;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Inner preview */
.preset-inner {
  border: 2px solid #d1d5db;
  border-radius: 6px;
  width: 55%;
  height: 55%;
}
.preset-inner.portrait {
  width: 40%;
  height: 70%;
}
.preset-inner.landscape {
  width: 70%;
  height: 40%;
}
.preset-inner.square {
  width: 55%;
  height: 55%;
}

/* FB Badge */
.preset-platform {
  position: absolute;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  border: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  right: 6px;
  bottom: 6px;
  font-size: 10px;
  color: #1877f2;
}

/* Selected state */
.preset-material.selected .preset-thumb {
  background: linear-gradient(180deg, #bdc3c7, #2c3e50);
  border-color: #000000;
}

/* Meta text */
.preset-meta {
  text-align: center;
  font-size: 12px;
  color: #475569;
}
.preset-meta .ratio {
  color: #94a3b8;
  font-size: 11px;
  margin-top: 4px;
}

/* Custom size row — FIXED */
.presets-custom-row {
  margin-top: 16px;
  width: 100%;
  display: flex;
  flex-direction: column; /* Stack vertically */
  gap: 10px;
}

.presets-custom-row input {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  font-size: 13px;
  box-sizing: border-box;
}
.grid-slot.selected {
  outline: 2px solid rgba(14, 165, 164, 0.35);
  outline-offset: -2px;
  box-shadow: inset 0 0 0 1px rgba(14, 165, 164, 0.25);
}



.btn-apply {
  width: 100%;
  background: #2563eb;
  color: white;
  border: none;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}
.btn-apply:hover {
  background: #1e40af;
}
/* platform icon circle */
.platform-icon {
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  border: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

.platform-icon.ig {
  color: #d62976; /* Instagram pink */
}

.platform-icon.fb {
  color: #1877f2; /* Facebook blue */
}

/* Image manager thumbnails */
.img-thumb {
  flex: 0 0 100px; /* Fixed big size */
  width: 100px;
  height: 100px;
  border-radius: 8px; /* Softer corners */
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: #000;
  position: relative;
  overflow: hidden;
}

/* --- FIX: Desktop Image Manager Grid --- */
/* (Ensures images layout in a grid on desktop instead of stacking) */
#imageManagerGrid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  align-content: start;
  padding-bottom: 20px;
}

.upload-btn {
  flex: 0 0 80px !important;
  background: #8b5cf6; /* Use a nice Violet/Blue like reference */
  background: linear-gradient(135deg, #a855f7, #6366f1); /* Optional gradient */
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}
.upload-btn .material-icons {
  font-size: 42px; /* Big icon */
  color: white;
}
/* Active state for button touch */
.upload-btn:active {
  transform: scale(0.95);
  opacity: 0.9;
}

.img-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

/* Remove button */
.img-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.65);
  color: white;
  font-size: 14px;
  line-height: 18px;
  cursor: pointer;
  display: none;
}

.img-thumb:hover .img-remove {
  display: flex;
  justify-content: center;
  align-items: center;
  line-height: normal;
}
.grid-slot.drop-hover {
  outline: 2px dashed #0ea5a4;
  outline-offset: -4px;
}
/* -------- Template Filter -------- */
.template-filter {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-btn {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  color: #475569;
}

.filter-btn.active {
  background: #0065f2;
  color: #fff;
  border-color: #0065f2;
}

/* -------- Template Grid -------- */
.template-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.template-card {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 8px;
  cursor: pointer;
  transition: 0.15s;
  background: #fff;
}

.template-card:hover {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

/* Preview */
.template-preview {
  width: 100%;
  height: 90px;
  border-radius: 8px;
  background: #f8fafc;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.preview-row {
  display: flex;
  width: 100%;
}

.preview-cell {
  flex: 1;
  border: 1px solid #e5e7eb;
}

/* Label */
.template-label {
  font-size: 12px;
  text-align: center;
  margin-top: 6px;
  color: #475569;
}
.template-filter {
  width: 100%;
  overflow: hidden;
}

/* ONLY filter numbers scroll */
.template-filter-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  padding-bottom: 6px;
  -webkit-overflow-scrolling: touch;
}

.template-filter-scroll::-webkit-scrollbar {
  display: none;
}
.template-filter-scroll {
  scrollbar-width: none;
}

.filter-btn {
  flex: 0 0 auto;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  font-size: 14px;
  cursor: pointer;
}

.filter-btn.active {
  background: #0065f2;
  color: #ffffff;
  border-color: #0065f2;
}
/* Parent filter bar */
.template-filter {
  width: 100%;
  overflow: hidden;
}

/* FORCE scroll container width */
.template-filter-scroll {
  display: flex;
  gap: 10px;

  width: 100%;
  max-width: 100%;

  overflow-x: auto;
  overflow-y: hidden;

  white-space: nowrap;
  box-sizing: border-box;

  -webkit-overflow-scrolling: touch;
}

/* Hide scrollbar */
.template-filter-scroll::-webkit-scrollbar {
  display: none;
}
.template-filter-scroll {
  scrollbar-width: none;
}

/* Buttons MUST NOT shrink */
.filter-btn {
  flex: 0 0 auto; /* 🚨 CRITICAL */
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  font-size: 14px;
  cursor: pointer;
}

.filter-btn.active {
  background: #0065f2;
  color: #ffffff;
  border-color: #0065f2;
}
.template-filter-scroll {
  cursor: grab;
}

.template-filter-scroll.dragging {
  cursor: grabbing;
}
/* --- Drag & Swap Styles --- */

/* The floating image being dragged */
.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.85;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  border: 3px solid #0ea5a4; /* Your accent color */
  border-radius: 8px;
  transform: translate(-50%, -50%); /* Center on mouse */
  object-fit: cover;
}

/* The slot being hovered over during swap */
.grid-slot.swap-target {
  outline: 4px solid #f59e3b !important; /* Orange highlight */
  background: rgba(245, 158, 59, 0.15);
  transition: all 0.2s;
}

/* Dim the original slot while its image is being dragged */
.grid-slot.is-dragging-source img {
  opacity: 0.3;
  filter: grayscale(100%);
}
/* =========================================
   MOBILE & TABLET RESPONSIVENESS
========================================= */

/* Prevent scrolling while dragging on canvas items */
.grid-slot,
.canvas-surface,
.resize-handle {
  touch-action: none;
}

/* =================================================================
   MOBILE APP MODE (collage flow Style - Push Up Layout)
   1. Canvas sits at Top (flex: 1)
   2. Panel & Nav sit at Bottom (auto height)
   3. Panel PUSHES canvas up when opening
================================================================= */
/* =================================================================
   MOBILE APP MODE (collage flow Style - Final Polish)
   1. Canvas PUSHES up (doesn't get covered)
   2. Image Manager is HORIZONTAL SCROLL (not vertical grid)
   3. Dark Theme for Panel
================================================================= */
@media (max-width: 1307px) {
  /* --- GLOBAL APP LAYOUT --- */
  html,
  body {
    height: 100%;
    margin: 0;
    overflow: hidden;
    background-color: #2c3e50;
  }

  .app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    padding: 0;
    gap: 0;
    background: #2c3e50;
  }

  /* --- 1. WORKSPACE (Top Area) --- */
  .main {
    order: 1;
    flex: 1;
    min-height: 0; /* Allows shrinking when panel opens */
    width: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
    transition: all 0.3s ease;
  }

  .workspace {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  .stage-outer {
    flex: 1;
    background: #2c3e50;
    width: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 10px 20px 10px; /* Add bottom padding so canvas isn't flush */
  }

  /* Hide Desktop elements */
  .topbar div:first-child,
  .stage-top,
  .right {
    display: none !important;
  }

  /* Minimal Top Bar */
  .topbar {
    height: 50px;
    background: #2c3e50;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: flex-end;
    padding: 0 12px;
    flex-shrink: 0;
  }
  .topbar .btn {
    color: white;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 11px;
    padding: 6px 10px;
  }
  .stage-card,
  .stage {
    background: transparent !important;
    border: none;
    padding: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* --- 2. BOTTOM NAVIGATION & PANEL --- */
  .sidewrap {
    order: 2;
    width: 100%;
    height: auto;
    z-index: 1000;
    background: #1e293b; /* Dark background */
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
    position: relative !important;
  }

  .side {
    width: 100% !important;
    display: flex !important;
    flex-direction: column-reverse; /* Panel opens ABOVE nav */
  }

  /* --- 3. THE RAIL (Icons) --- */
  .rail {
    height: 60px;
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: space-evenly;
    background: #0f172a; /* Darker bottom bar */
    padding: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
  }

  .icon-btn {
    flex: 1;
    height: 100%;
    width: auto;
    border-radius: 0;
    background: transparent;
    color: #94a3b8;
    flex-direction: column;
    gap: 4px;
  }
  .icon-btn.active {
    background: #1e293b;
    color: #38bdf8;
    border-top: 2px solid #38bdf8;
  }
  .icon-btn::after {
    content: attr(title);
    font-size: 9px;
    text-align: center;
  }

  /* --- 4. THE PANEL (Drawer Content) --- */
  .panel {
    position: relative;
    width: 100%;
    height: 0;
    overflow: hidden;
    background: #1e293b; /* Dark Panel Background */
    transition: height 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  }

  /* Fixed height for the strip - enough for button + scrollbar */
  .side.expanded .panel {
    height: 216px; /* Compact height, won't cover canvas */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  /* --- REPLACE THIS SECTION IN YOUR MOBILE CSS --- */

  .panel-inner {
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: center; /* Centers content vertically inside panel */
    height: 100%;
    background: #1e293b;
  }

  /* Ensure the content inside fills the width */
  .panel-inner > div {
    width: 100%;
    padding: 12px; /* Keep some internal padding for looks */
    box-sizing: border-box;
  }

  /* Force the Upload Button to be full width */
  .panel-inner .btn {
    width: 100% !important;
    display: block;
    margin-bottom: 10px;
  }

  /* --- 5. HORIZONTAL SCROLL FIX (The Magic Part) --- */

  /* Target the Grid created by JS and force it to Flex Row */
  #imageManagerGrid {
    display: flex !important;
    flex-direction: row;
    gap: 12px !important;
    overflow-x: auto;
    overflow-y: hidden;
    width: 100%;
    height: 100%;
    align-items: center; /* Vertically center the thumbs */
    padding: 0 16px; /* Horizontal breathing room */

    /* Hide scrollbar for cleaner look */
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  #imageManagerGrid::-webkit-scrollbar {
    display: none;
  }
  /* Ensure the wrapper centers the canvas perfectly */
  .canvas-frame-wrap {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center; /* Centers vertically */
    justify-content: center; /* Centers horizontally */
    overflow: hidden;
    /* Add padding so canvas never touches the edges */
    padding: 20px;
  }

  /* Ensure the canvas frame has a shadow to pop out like collage flow */
  .canvas-frame {
    box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.5); /* Deep shadow */
    transition: width 0.2s ease-out, height 0.2s ease-out; /* Smooth resize animation */
  }

  /* Thumbnails: Fixed square size */
  .img-thumb {
    flex: 0 0 120px; /* Don't shrink */
    width: 100px;
    height: 100px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: #000;
  }

  /* Styling the JS-generated "Upload" button */
  .panel-inner .btn {
    background: #334155 !important; /* Dark Grey Button */
    color: #fff !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    margin-bottom: 10px !important;
    font-size: 12px !important;
    padding: 6px !important;
    flex-shrink: 0;
    width: 100% !important; /* Force full width button */
    display: block;
  }

  /* Text Colors */
  .muted {
    color: #cbd5e1 !important;
  }
  label {
    color: #cbd5e1 !important;
  }

  /* --- FIX: Header Alignment (Mobile & Desktop) --- */
  .tertiary-header {
    display: grid;
    grid-template-columns: 40px 1fr 40px; /* Exact space for left/right buttons */
    align-items: center; /* Vertical Center */
    width: 100%;
    height: 48px; /* Fixed height for consistency */
    padding: 0 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-sizing: border-box;
  }

  /* 1. Back Button (Left) */
  .tertiary-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
  }

  /* 2. Title (Center) */
  .tertiary-title {
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0; /* Remove old margins */
  }

  /* 3. Pencil Button (Right) */
  .header-action-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    position: static; /* Remove absolute positioning */
    transform: none; /* Remove transform */
    margin: 0;
  }
}
/* =========================================
   CUSTOMIZE SUB-MENU SYSTEM (Mobile & Desktop)
   ========================================= */

/* The main container for the customize view */
.customize-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

/* --- ROOT VIEW: 4-Grid Menu --- */
.sub-menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
  height: auto;
  align-items: start; /* Center vertically in panel */
  padding-top: 10px;
}

.sub-menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  height: 80px; /* Fixed height for touch targets */
  cursor: pointer;
  transition: all 0.2s ease;
  color: #64748b;
}

.sub-menu-item:hover {
  background: #fff;
  border-color: #cbd5e1;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  color: #0f172a;
}

.sub-menu-item .material-icons {
  font-size: 24px;
  color: inherit;
}

.sub-menu-label {
  font-size: 11px;
  font-weight: 500;
  text-align: center;
}

/* --- TERTIARY VIEW: Header & Content --- */
.tertiary-view {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  animation: slideInRight 0.25s cubic-bezier(0.2, 1, 0.5, 1);
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Header with Back Button */
.tertiary-header {
  display: flex;
  align-items: center;
  width: 100%;
  padding-bottom: 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
  position: relative;
}

.tertiary-back-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  color: #64748b;
  border-radius: 50%;
  transition: background 0.2s;
}

.tertiary-back-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.tertiary-title {
  flex: 1;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  /* Offset center to account for back button width if needed, 
     but flex usually handles it. We can absolute center if strict. */
  margin-right: 24px; /* Balance the left button */
}

.tertiary-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --- COLOR PALETTE GRID (Canvas & Border) --- */
.color-scroll-row {
  display: grid; /* Use Grid layout for Desktop */
  grid-template-columns: repeat(4, 1fr); /* 4 Columns fit nicely */
  gap: 10px;
  width: 100%;
  padding: 4px 2px;
  align-items: start;
  /* Remove scroll properties for desktop */
  overflow-x: visible;
  overflow-y: visible;
}
.color-scroll-row::-webkit-scrollbar {
  display: none;
}

/* Updated Swatch for Scroll Mode */
.color-swatch {
  width: 100%;
  height: auto;
  aspect-ratio: 1; /* Forces perfect square */
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.1);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}

.color-swatch:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  z-index: 2;
}

.color-swatch.active {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #2563eb; /* Blue active ring */
  transform: translateY(-2px);
}
.color-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr); /* 6 cols like reference */
  gap: 10px;
  padding: 4px;
}

.color-swatch {
  aspect-ratio: 1;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.1);
  position: relative;
  transition: transform 0.1s;
}
.color-swatch:hover {
  transform: scale(1.1);
  z-index: 2;
}
.color-swatch.active {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #2563eb; /* Blue focus ring */
}
.color-swatch.transparent-opt {
  background-image: linear-gradient(45deg, #ccc 25%, transparent 25%),
    linear-gradient(-45deg, #ccc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ccc 75%),
    linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
  background-color: white;
}

/* --- BORDER SPECIFIC --- */
.border-type-row {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 12px;
}
.round-btn-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.round-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}
.round-btn:hover {
  transform: scale(1.05);
}
.round-btn.white {
  background: #ffffff;
}
.round-btn.black {
  background: #000000;
  color: white;
}

/* --- FIX: Visual Previews Inner Shapes --- */
.preset-inner-h {
  border: 2px solid #cbd5e1;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1); /* Give them a slight fill */
}

/* Ensure the aspect ratio boxes are visible against the dark tiles */
.preset-inner-h.portrait {
  width: 40%;
  height: 70%;
  background: #64748b;
}
.preset-inner-h.landscape {
  width: 70%;
  height: 40%;
  background: #64748b;
}
.preset-inner-h.square {
  width: 55%;
  height: 55%;
  background: #64748b;
}
.color-scroll-row {
  display: grid;
  /* Use 4 columns to fit the narrow desktop panel */
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 100%;
  padding: 10px 4px;
  /* Remove horizontal scroll, allow vertical flow */
  overflow-x: visible;
  overflow-y: visible;
}

.color-swatch {
  width: 100%; /* Fill the grid cell */
  height: auto;
  aspect-ratio: 1; /* Force perfect square */
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.1);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}

.color-swatch:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  z-index: 2;
}

.color-swatch.active {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #2563eb;
  transform: translateY(-2px);
}

/* Desktop: Pencil is just a normal tile (not sticky) */
.sticky-picker-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #475569;
}
.preset-scroll-container {
  /* Force Grid on Desktop to override JS inline flex */
  display: grid !important; 
  grid-template-columns: repeat(3, 1fr); /* 3 Columns fit the panel nicely */
  gap: 12px;
  width: 100%;
  padding: 10px 4px;
  overflow: visible; /* No scroll needed on desktop */
}
.preset-card-h {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.15s ease;
  width: 100%; /* Fill grid cell */
}
.preset-card-h:hover {
  transform: translateY(-2px);
}
.preset-preview-h {
  width: 56px;
  height: 56px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.preset-inner-h {
  border: 2px solid #94a3b8;
  border-radius: 2px;
}
.preset-inner-h.square { width: 32px; height: 32px; }
.preset-inner-h.portrait { width: 24px; height: 36px; }
.preset-inner-h.landscape { width: 36px; height: 24px; }

/* Text Label Styling */
.preset-label-h {
  font-size: 11px;
  text-align: center;
  color: #64748b;
  line-height: 1.2;
}
.preset-label-h span {
  display: block;
  font-size: 9px;
  color: #94a3b8;
  margin-top: 1px;
}

/* Active State Styling */
.preset-card-h.active .preset-preview-h {
  border-color: #3b82f6;
  background: #eff6ff;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}
.preset-card-h.active .preset-inner-h {
  border-color: #3b82f6;
}
.preset-card-h.active .preset-label-h {
  color: #3b82f6;
  font-weight: 600;
}

#desktop-custom-canvas-inputs {
  display: none; /* Hidden by default */
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #e2e8f0;
}

/* Class added via JS to show the inputs */
#desktop-custom-canvas-inputs.active {
  display: grid;
}
#desktop-apply-btn:hover {
  background-color: #1d4ed8;
}
#desktop-apply-btn {
  grid-column: span 2; /* Span across both inputs */
  margin-top: 8px;
  padding: 10px;
  background-color: #2563eb;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.custom-input-field {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
  color: #334155;
}
.custom-input-label {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 6px;
  display: block;
}

/* Styling for the input wrappers (Label + Input) */
.canvas-input-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.canvas-input-group label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
}

/* Styling the actual input fields */
.canvas-input-group input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 14px;
  color: #334155;
  outline: none;
  transition: border-color 0.2s;
}

.canvas-input-group input:focus {
  border-color: #3b82f6;
}

/* Styling the 'Apply' button */
#desktop-apply-canvas-btn {
  grid-column: span 2; /* Make button span across both columns below inputs */
  margin-top: 8px;
  padding: 10px;
  background-color: #2563eb; /* Blue color */
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

#desktop-apply-canvas-btn:hover {
  background-color: #1d4ed8; /* Darker blue on hover */
}


/* --- MOBILE DARK MODE OVERRIDES (Matches previous Mobile Fix) --- */
@media (max-width: 1307px) {
  /* Show Clean button on mobile */
  .mobile-only {
    display: block !important;
    /* Optional: Style it to match your mobile buttons */
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
  }
  .sub-menu-item {
    background: #334155;
    border-color: rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
  }
  .sub-menu-item:hover {
    background: #475569;
    color: #fff;
  }
  .tertiary-header {
    display: grid;
    grid-template-columns: 40px 1fr 40px; /* Exact space for left/right buttons */
    align-items: center; /* Vertical Center */
    width: 100%;
    height: 48px; /* Fixed height for consistency */
    padding: 0 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-sizing: border-box;
  }
  .tertiary-title {
    color: #fff;
    color: #ffffff !important; /* Force white text */
    flex: 1;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
  }
  .tertiary-back-btn {
    color: #cbd5e1 !important;
  }
  .header-pencil-btn {
    background: transparent;
    border: none;
    color: #cbd5e1;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  .header-pencil-btn:hover {
    color: #fff;
  }

  .tertiary-back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
  }

  /* Sliders in dark mode */
  input[type="range"] {
    accent-color: #38bdf8;
  }

  /* Round buttons */
  .round-btn {
    border-color: rgba(255, 255, 255, 0.2);
  }
  .round-btn-label {
    color: #94a3b8;
  }

  /* =========================================
   Horizontal Scroll for Colors (Updated with Sticky Picker)
   ========================================= */

  .color-scroll-row {
    display: flex;
    flex-direction: row;
    gap: 12px;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 2px;
    align-items: center;
    position: relative; /* Context for sticky */

    /* Hide scrollbars */
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .color-scroll-row::-webkit-scrollbar {
    display: none;
  }

  /* Common Swatch Style */
  .color-swatch {
    flex: 0 0 50px !important; /* Fixed size */
    width: 50px !important;
    aspect-ratio: auto;
    height: 50px;
  }

  .color-swatch:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  }
  .color-swatch.active {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #2563eb;
    transform: translateY(-2px);
  }

  /* --- THE STICKY PENCIL BUTTON --- */
  .sticky-picker-btn {
    position: sticky !important; /* Force Stickiness */
    left: 0;
    z-index: 20;
    margin-right: 2px;
    box-shadow: 4px 0 8px -2px rgba(0, 0, 0, 0.1);
  }

  .sticky-picker-btn .material-icons {
    font-size: 20px;
    color: #475569;
  }

  /* Active state for pencil (when custom color is selected) */
  .sticky-picker-btn.active {
    background: #2563eb;
    border-color: #2563eb;
  }
  .sticky-picker-btn.active .material-icons {
    color: white;
  }
  /* --- HORIZONTAL LAYOUTS CAROUSEL (Mobile Only) --- */
  .template-grid {
    display: flex !important; /* Switch from Grid to Flex */
    flex-direction: row; /* Horizontal alignment */
    flex-wrap: nowrap; /* Prevent wrapping to next line */
    gap: 12px;
    overflow-x: auto; /* Enable horizontal scrolling */
    overflow-y: hidden;
    padding: 4px 16px 16px 16px; /* Padding avoids shadow clipping */

    /* Hide Scrollbar */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
  }

  .template-grid::-webkit-scrollbar {
    display: none; /*Chrome/Safari*/
  }

  .template-card {
    flex: 0 0 100px; /* Fixed width: 100px, don't shrink */
    width: 100px;
    margin: 0;
  }

  /* Adjust preview height slightly for compact mobile view */
  .template-preview {
    height: 80px;
  }

  /* Ensure label doesn't break layout */
  .template-label {
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* ... end of media query ... */

  /* --- PRESET SCROLL CONTAINER (Mobile Horizontal) --- */
  /* This was missing in your file! */
  .preset-scroll-container {
    display: flex !important;
    flex-direction: row;
    gap: 16px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 15px 25px 15px;
    width: 100%;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Hide scrollbar Firefox */
  }
  .preset-scroll-container::-webkit-scrollbar {
    display: none;
  }

  /* Horizontal Preset Tile (Restored Preview) */
  .preset-card-h {
    flex: 0 0 85px; /* Fixed width */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
  }

  .preset-preview-h {
    width: 56px; /* Fixed width */
    height: 56px; /* Fixed height */
    display: flex; /* Use Flexbox to center the shape */
    align-items: center; /* Vertical Center */
    justify-content: center; /* Horizontal Center */
    margin: 0 auto 8px auto; /* Center in tile + bottom spacing */
    background: transparent; /* Transparent bg (or #334155 if you want a box) */
  }

  /* The Aspect Ratio Box inside the preview */
  .preset-inner-h {
    border: 2px solid #cbd5e1; /* Light Grey Border */
    border-radius: 4px; /* Slight rounded corners */
    box-sizing: border-box; /* Includes border in width/height */
    background: transparent; /* Keep hollow like reference */
  }
  .preset-inner-h.portrait {
    width: 28px;
    height: 42px;
  }
  .preset-inner-h.landscape {
    width: 44px;
    height: 26px;
  }
  .preset-inner-h.square {
    width: 36px;
    height: 36px;
  }

  /* Selected State */
  .preset-card-h.active .preset-preview-h {
    border-color: #38bdf8; /* Light blue */
    background: #0f172a;
  }
  .preset-card-h.active .preset-label-h {
    color: #3b82f6; /* Blue Text when active */
    font-weight: 600;
  }
  .preset-card-h.active .preset-inner-h {
    border-color: #3b82f6; /* Blue Border */
    background: rgba(59, 130, 246, 0.15); /* Slight Blue Fill */
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2); /* Glow effect */
  }

  .preset-label-h {
    text-align: center;
    font-size: 12px;
    color: #94a3b8;
    line-height: 1.2;
  }
  .preset-label-h span {
    display: block;
    font-size: 9px;
    opacity: 0.8;
  }

  /* --- CUSTOM SIZE BOTTOM SHEET (Mobile Only) --- */
  .custom-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    z-index: 2000;
    display: none;
  }
  .custom-sheet-overlay.active {
    display: block;
  }

  .custom-size-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #1e293b;
    border-radius: 20px 20px 0 0;
    padding: 24px 20px 40px 20px;
    /* Use transform for opening animation, but bottom for keyboard offset */
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), bottom 0.2s ease;
    z-index: 10001; /* Higher than any other UI element */
    box-sizing: border-box;
  }
  .custom-size-sheet.active {
    transform: translateY(0);
  }

  /* Header Text Style */
  .custom-sheet-header {
    color: white;
    font-weight: 600;
    text-align: center;
    margin-bottom: 20px;
  }

  /* Inputs inside Sheet */
  .custom-size-sheet input {
    font-size: 16px !important;
    background: #0f172a;
    border: 1px solid #334155;
    color: white;
    padding: 12px;
    border-radius: 8px;
    width: 100%;
  }
  .custom-size-sheet input::placeholder {
    color: #64748b;
  }
  .sub-menu-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: 100%;
    height: 100%;
    align-items: center; /* Center vertically in panel */
  }

  /* Apply Button */
  .custom-size-sheet .btn-apply {
    background: #3b82f6;
    color: white;
    padding: 14px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    width: 100%;
  }

  /* --- MOBILE SPECIFIC OVERRIDES --- */

  /* Show Pencil on Mobile */
  .header-action-btn {
    display: flex !important; /* Force visibility on mobile */
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #ffffff !important;
    z-index: 10;
  }
  .header-action-btn:hover {
    color: #fff;
  }

  /* HIDE the desktop inline inputs on mobile */
  .desktop-custom-input-wrap {
    display: none !important;
  }

  /* Hide pencil on desktop */
  .header-action-btn {
    display: none;
  }
  .side.expanded .panel {
    width: 100% !important;
  }
  #desktop-custom-canvas-inputs.active {
      display: none !important;
  }
}
/* ... Keep all your existing CSS ... */

/* --- NEW: Privacy Banner Styles --- */
/* --- PRIVACY BANNER STYLES --- */
/* --- PRIVACY BANNER STYLES (Fixed for All Devices) --- */
.privacy-banner {
  position: fixed;
  /* On Desktop: Stick to bottom left */
  bottom: 20px;
  left: 20px;
  width: auto;
  max-width: 400px;
  background: #1e293b;
  color: #fff;
  padding: 16px 20px;
  z-index: 99999; /* Ensure it's above everything */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.1);
  
  /* Animation */
  transform: translateY(150%);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
}

.privacy-banner.visible {
  transform: translateY(0);
  opacity: 1;
}

.privacy-content {
  font-size: 13px;
  line-height: 1.4;
  color: #cbd5e1;
}

.privacy-content strong {
  display: block;
  color: #fff;
  margin-bottom: 2px;
  font-size: 14px;
}


.btn-primary-small {
  background: #3b82f6;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-primary-small:hover {
  background: #2563eb;
}

/* --- MOBILE SPECIFIC FIX (All Phones) --- */
@media (max-width: 900px) {
  .privacy-banner {
    /* Position it ABOVE the bottom rail (60px) + Extra space (20px) + Safe Area */
    /* This ensures it clears the UI on iPhone X, Pixel, Samsung, etc. */
    bottom: calc(60px + 20px + env(safe-area-inset-bottom));
    
    left: 12px;
    right: 12px;
    width: auto; /* Allow it to stretch */
    max-width: none;
    
    /* Make it look distinct from the app UI */
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(8px);
  }
}
/* --- Mobile Size Indicator Style --- */
.size-pill {
  font-size: 11px;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.05);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-right: auto; /* This pushes the buttons to the far right */
  font-family: monospace; /* Makes numbers look tabular and neat */
  white-space: nowrap;
}
/* --- RESUME SESSION MODAL --- */
.resume-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.85); /* Dark backdrop */
  backdrop-filter: blur(8px);
  z-index: 100000; /* Highest z-index */
  display: flex; /* Hidden by default via JS */
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.resume-modal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.resume-modal-card {
  width: 90%;
  max-width: 440px;
  background: #1e293b; /* Dark Slate */
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.resume-modal-overlay.visible .resume-modal-card {
  transform: translateY(0);
}

/* Mini Preview Grid */
.resume-preview-container {
  width: 160px;
  height: 160px;
  background: #0f172a;
  border-radius: 12px;
  margin-bottom: 20px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.resume-mini-grid {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 4px;
  border-radius: 8px;
  overflow: hidden;
}

.resume-mini-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #334155;
}

/* Typography */
.resume-text h3 {
  color: #fff;
  margin: 0 0 8px 0;
  font-size: 18px;
  font-weight: 600;
}

.resume-text p {
  color: #94a3b8;
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 20px 0;
}

/* Options */
.resume-options {
  width: 100%;
  display: flex;
  justify-content: flex-start;
  margin-bottom: 24px;
}

.resume-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.resume-checkbox span {
  font-size: 13px;
  color: #cbd5e1;
}

.resume-checkbox input {
  accent-color: #6366f1;
  width: 16px;
  height: 16px;
}

/* Buttons */
.resume-actions {
  display: flex;
  gap: 12px;
  width: 100%;
}

.resume-btn {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.resume-btn.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.resume-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.resume-btn.primary {
  background: #6366f1; /* Indigo */
  color: #fff;
}
.resume-btn.primary:hover {
  background: #4f46e5;
}