:root {
  --background: hsl(220, 13%, 9%);
  --foreground: hsl(220, 9%, 46%);
  --card: hsl(220, 13%, 12%);
  --card-foreground: hsl(220, 9%, 95%);
  --popover: hsl(220, 13%, 12%);
  --popover-foreground: hsl(220, 9%, 95%);
  --primary: hsl(210, 100%, 50%);
  --primary-foreground: hsl(0, 0%, 100%);
  --secondary: hsl(220, 13%, 18%);
  --secondary-foreground: hsl(220, 9%, 90%);
  --muted: hsl(220, 13%, 15%);
  --muted-foreground: hsl(220, 9%, 60%);
  --accent: hsl(210, 100%, 45%);
  --accent-foreground: hsl(0, 0%, 100%);
  --destructive: hsl(0, 84%, 60%);
  --destructive-foreground: hsl(0, 0%, 100%);
  --border: hsl(220, 13%, 18%);
  --input: hsl(220, 13%, 18%);
  --ring: hsl(210, 100%, 50%);
  --radius: 8px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: Georgia, serif;
  --font-mono: Menlo, monospace;
}

.dark {
  --background: hsl(220, 13%, 9%);
  --foreground: hsl(220, 9%, 46%);
  --card: hsl(220, 13%, 12%);
  --card-foreground: hsl(220, 9%, 95%);
  --popover: hsl(220, 13%, 12%);
  --popover-foreground: hsl(220, 9%, 95%);
  --primary: hsl(210, 100%, 50%);
  --primary-foreground: hsl(0, 0%, 100%);
  --secondary: hsl(220, 13%, 18%);
  --secondary-foreground: hsl(220, 9%, 90%);
  --muted: hsl(220, 13%, 15%);
  --muted-foreground: hsl(220, 9%, 60%);
  --accent: hsl(210, 100%, 45%);
  --accent-foreground: hsl(0, 0%, 100%);
  --destructive: hsl(0, 84%, 60%);
  --destructive-foreground: hsl(0, 0%, 100%);
  --border: hsl(220, 13%, 18%);
  --input: hsl(220, 13%, 18%);
  --ring: hsl(210, 100%, 50%);
}

* {
  border-color: var(--border);
}

body {
  /* font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased; */
  background-color: var(--background);
  color: var(--foreground);
  overflow-x: hidden;
}

/* Editor-specific styles */
.editor-navbar {
  background-color: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
}

.editor-main {
  height: calc(100vh - 70px);
  background-color: var(--background);
}

.canvas-area {
  background-color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  height: calc(100% - 80px);
}

.canvas-container {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: 
    linear-gradient(45deg, hsl(220, 13%, 20%) 25%, transparent 25%), 
    linear-gradient(-45deg, hsl(220, 13%, 20%) 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, hsl(220, 13%, 20%) 75%), 
    linear-gradient(-45deg, transparent 75%, hsl(220, 13%, 20%) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  overflow: hidden;
  position: relative;
}

#imageContainer {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#mainImage {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.image-placeholder {
  width: 100%;
  max-width: 400px;
  height: 300px;
  background-color: var(--card);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  cursor: pointer;
}

.image-placeholder:hover,
.image-placeholder.dragover {
  border-color: var(--primary);
  background-color: var(--secondary);
}

/* Zoom controls */
.zoom-controls {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  gap: 5px;
  z-index: 100;
}

.zoom-btn {
  background-color: var(--card);
  border: 1px solid var(--border);
  color: var(--foreground);
  width: 35px;
  height: 35px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.zoom-btn:hover {
  background-color: var(--secondary);
  border-color: var(--primary);
}

/* Tool panel responsiveness */
@media (max-width: 768px) {
  .tool-panel {
    display: none;
  }
  
  .tool-panel.mobile-open {
    display: block;
    position: fixed;
    top: 70px;
    right: 0;
    width: 300px;
    height: calc(100vh - 70px);
    z-index: 1000;
    box-shadow: -3px 0 10px rgba(0,0,0,0.3);
  }
  
  .canvas-area {
    height: calc(100vh - 140px);
  }
}

/* Thumbnail gallery */
.thumbnail-gallery {
  display: flex;
  gap: 10px;
  padding: 10px;
  overflow-x: auto;
}

.thumbnail {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s ease;
}

.thumbnail:hover {
  border-color: var(--primary);
}

.thumbnail.active {
  border-color: var(--accent);
}

.tool-panel {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: 100%;
  overflow-y: auto;
}

.tool-section {
  border-bottom: 1px solid var(--border);
}

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

.btn-pill {
  border-radius: 50px;
  padding: 0.375rem 1rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-primary-custom {
  background-color: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}

.btn-primary-custom:hover {
  background-color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px hsla(210, 100%, 50%, 0.3);
}

.btn-secondary-custom {
  background-color: var(--secondary);
  border-color: var(--border);
  color: var(--secondary-foreground);
}

.btn-secondary-custom:hover {
  background-color: var(--muted);
  border-color: var(--ring);
}

.status-bar {
  background-color: var(--card);
  border-top: 1px solid var(--border);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
}

.slider-container {
  margin-bottom: 1rem;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
  color: var(--card-foreground);
}

.custom-range {
  background-color: var(--muted);
  border-radius: 4px;
  height: 6px;
}

.custom-range::-webkit-slider-thumb {
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  width: 18px;
  height: 18px;
}

.custom-range::-moz-range-thumb {
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  width: 18px;
  height: 18px;
  border: none;
}

.aspect-ratio-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.aspect-btn {
  padding: 0.5rem;
  text-align: center;
  background-color: var(--secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--secondary-foreground);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.75rem;
}

.aspect-btn:hover, .aspect-btn.active {
  background-color: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

.thumbnail-gallery {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.5rem;
}

.thumbnail {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
}

.thumbnail:hover, .thumbnail.active {
  border-color: var(--primary);
}

.export-preset {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background-color: var(--secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.export-preset:hover {
  background-color: var(--muted);
  border-color: var(--primary);
}

.zoom-controls {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.25rem;
  z-index: 10;
}

.zoom-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--card);
  border: 1px solid var(--border);
  color: var(--card-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.zoom-btn:hover {
  background-color: var(--primary);
  color: var(--primary-foreground);
}

.crop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 5;
}

.guidelines {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 2px solid var(--primary);
  border-radius: 4px;
}

.guidelines::before,
.guidelines::after {
  content: '';
  position: absolute;
  background-color: var(--primary);
}

.guidelines::before {
  width: 100%;
  height: 1px;
  top: 33.33%;
  left: 0;
  box-shadow: 0 33.33% 0 var(--primary);
}

.guidelines::after {
  height: 100%;
  width: 1px;
  left: 33.33%;
  top: 0;
  box-shadow: 33.33% 0 0 var(--primary);
}

.upload-zone {
  border-style: dashed !important;
  transition: all 0.3s ease;
}

.upload-zone.dragover {
  border-color: var(--primary) !important;
  background-color: var(--secondary);
}

@media (max-width: 768px) {
  .tool-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    border-radius: 16px 16px 0 0;
  }

  .tool-panel.active {
    transform: translateY(0);
  }

  .canvas-area {
    height: calc(100% - 40px);
  }
}

.form-control, .form-select, .custom-range {
  background-color: var(--input);
  border: 1px solid var(--border);
  color: var(--foreground);
}

.form-control:focus, .form-select:focus {
  background-color: var(--input);
  border-color: var(--ring);
  color: var(--foreground);
  box-shadow: 0 0 0 2px hsla(210, 100%, 50%, 0.2);
}

.text-primary-custom {
  color: var(--primary) !important;
}

.bg-card {
  background-color: var(--card) !important;
}

.border-custom {
  border-color: var(--border) !important;
}

/* Modal overrides */
.modal-content {
  background-color: var(--card);
  border: 1px solid var(--border);
}

.modal-header {
  border-bottom: 1px solid var(--border);
}

.dropdown-menu {
  background-color: var(--card);
  border: 1px solid var(--border);
}

.dropdown-item {
  color: var(--card-foreground);
}

.dropdown-item:hover {
  background-color: var(--secondary);
  color: var(--card-foreground);
}

.close {
  color: var(--card-foreground);
  opacity: 1;
}

.close:hover {
  color: var(--primary);
}








/* Default desktop/tablet style */
#toolPanel {
  position: static;
  width: auto;
  height: inherit;
  opacity: 1;
  transition: none;
  box-shadow: none;
  border-radius: 0;
}

@media (max-width: 991.98px) {
  #toolPanel {
    position: fixed;
    bottom: -100%;
    left: 0;
    width: 100%;
    height: 47%;
    background: #343a40;
    color: #fff;
    padding: 15px;
    opacity: 0;
    transition: bottom 0.4s ease, opacity 0.4s ease;
    z-index: 1050;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.4);

    overflow-y: auto;          /* 🔑 allow scrolling */
    -webkit-overflow-scrolling: touch; /* smooth scroll on iOS */
  }

  #toolPanel.mobile-open {
    bottom: 0;
    opacity: 1;
  }
}

.h91 {
  height: 91%!important
}