.editor-container {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: row-reverse;
}

.editor-container__controls .preview-controls {
  background-color: var(--color-bg-off-white);
}

.editor-container__controls {
  width: 35%;
  display: flex;
  flex-direction: column;
  padding: 15px;
  gap: 18px;
  overflow: hidden;
}

.editor-container__preview {
  width: 65%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.preview-image {
  flex: 1;
  border: 2px dashed #ccc;
  position: relative;
  overflow: hidden;
  background-color: #fafafa;
  cursor: pointer;
  transition: all 0.2s ease;
  margin: 10px 10px 0 10px;
}

.preview-image:hover {
  border-color: #666;
  background-color: #f5f5f5;
}

.preview-image.dragover {
  border-color: #333;
  background-color: #e8e8e8;
}

.preview-image:focus {
  outline: 2px solid #333;
  outline-offset: -2px;
}

.preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  pointer-events: none;
}

.filter-intensity-wrapper label {
  font-size: 13px;
  color: #333;
  font-weight: 500;
  display: block;
  margin-bottom: 5px;
}

.filter-intensity-wrapper input {
  width: 100%;
}

.carousel-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.carousel-nav__title {
  font-size: 13px;
  font-weight: 600;
  color: #333;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
  min-width: 60px;
  text-align: center;
}

.carousel-arrow {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: var(--border-glossy);
  border-radius: 50%;
  background: linear-gradient(
    to bottom,
    var(--btn-gradient-top) 0%,
    var(--btn-gradient-bottom) 100%
  );
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #333;
  transition: var(--transition-fast);
  user-select: none;
}

.carousel-arrow:hover {
  background: linear-gradient(
    to bottom,
    var(--btn-hover-gradient-top) 0%,
    var(--btn-hover-gradient-bottom) 100%
  );
  box-shadow: var(--shadow-button-hover);
}

.carousel-arrow:active {
  transform: translateY(1px);
  box-shadow: var(--shadow-button-active);
}

.carousel-arrow:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.filter-carousel {
  display: flex;
  gap: var(--gap-md);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.filter-carousel::-webkit-scrollbar {
  display: none;
}

.filter-option {
  scroll-snap-align: start;
}

.filter-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-sm);
  padding: var(--padding-sm);
  cursor: pointer;
  transition: var(--transition-smooth);
  width: var(--carousel-option-width);
  flex-shrink: 0;
  position: relative;
  background: transparent;
  border: none;
  border-radius: var(--border-radius-card);
}

.filter-option:hover {
  transform: translateY(-2px);
}

.filter-option--selected {
  background: var(--overlay-blue-radial);
}

.filter-option__preview {
  width: 100px;
  height: var(--filter-preview-height);
  border-radius: var(--border-radius-card);
  background-size: cover;
  background-position: center;
  box-shadow: var(--shadow-elevation-sm);
  transition: var(--transition-smooth);
}

.filter-option:hover .filter-option__preview {
  box-shadow: var(--shadow-elevation-md);
}

.filter-option__label {
  display: flex;
  align-items: start;
  justify-content: center;
  text-align: center;
  word-wrap: break-word;
  overflow-wrap: break-word;
  width: 100%;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 500;
  color: #333;
}

.filter-option--selected .filter-option__label {
  color: #007aff;
  font-weight: 600;
}

.filter-chip {
  background: linear-gradient(
    to bottom,
    var(--btn-gradient-top) 0%,
    var(--btn-gradient-bottom) 100%
  );
  border: var(--border-glossy);
  border-radius: var(--border-radius-btn);
  padding: 8px 14px;
  cursor: pointer;
  text-align: center;
  transition: var(--transition-fast);
  font-size: 12px;
  font-weight: 600;
  user-select: none;
  box-shadow: var(--shadow-button-outer);
  position: relative;
  color: #333;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  height: 42px;
}

.filter-chip::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: var(--glossy-overlay);
  border-radius: var(--border-radius-btn) var(--border-radius-btn) 0 0;
  pointer-events: none;
}

.filter-chip:hover {
  background: linear-gradient(
    to bottom,
    var(--btn-hover-gradient-top) 0%,
    var(--btn-hover-gradient-bottom) 100%
  );
  box-shadow: var(--shadow-button-hover);
}

.filter-chip:active {
  background: linear-gradient(
    to bottom,
    var(--btn-active-gradient-top) 0%,
    var(--btn-active-gradient-bottom) 100%
  );
  box-shadow: var(--shadow-button-active);
  transform: translateY(1px);
}

.filter-chip--selected {
  background: linear-gradient(
    to bottom,
    var(--btn-primary-gradient-top) 0%,
    var(--btn-primary-gradient-bottom) 100%
  );
  border-color: rgba(0, 122, 255, 0.4);
  box-shadow:
    0 1px 4px rgba(0, 122, 255, 0.4),
    0 1px 0 rgba(255, 255, 255, 0.6) inset;
  color: #ffffff;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.3);
}

.filter-chip--selected::before {
  background: var(--glossy-overlay-strong);
}

.filter-chip--selected:hover {
  background: linear-gradient(
    to bottom,
    var(--btn-primary-hover-top) 0%,
    var(--btn-primary-hover-bottom) 100%
  );
}

.preview-icon {
  color: #666;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview__text--strong {
  margin: 0;
  font-size: 16px;
  font-weight: bold;
  color: #333;
}

.preview__text--muted {
  margin: 0;
  font-size: 14px;
  color: var(--color-text-muted);
}

.preview__hint {
  margin: 0;
  font-size: 12px;
  color: #999;
  font-style: italic;
}

#preview-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview-image:has(#preview-img:not([style*="display: none"]))
  .preview-placeholder {
  display: none;
}

#preview-img.loading {
  opacity: 0.3;
  transition: opacity 0.3s ease;
}

.preview-loading {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
  background-color: rgba(255, 255, 255, 0.8);
  z-index: 10;
}

.preview-loading p {
  margin: 0;
  font-size: 16px;
  color: #333;
  font-weight: 500;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #007aff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.preview-controls {
  display: flex;
  flex-shrink: 0;
  height: 60px;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  width: 100%;
}

.preview-controls button {
  padding: 8px 18px;
  border: var(--border-glossy);
  border-radius: var(--border-radius-btn);
  background: linear-gradient(
    to bottom,
    var(--btn-gradient-top) 0%,
    var(--btn-gradient-bottom) 100%
  );
  box-shadow: var(--shadow-button-outer);
  color: #333;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
  position: relative;
  min-width: 70px;
}

.preview-controls button::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: var(--glossy-overlay);
  border-radius: var(--border-radius-btn) var(--border-radius-btn) 0 0;
  pointer-events: none;
}

.preview-controls button:hover {
  background: linear-gradient(
    to bottom,
    var(--btn-hover-gradient-top) 0%,
    var(--btn-hover-gradient-bottom) 100%
  );
  box-shadow: var(--shadow-button-hover);
}

.preview-controls button:active {
  background: linear-gradient(
    to bottom,
    var(--btn-active-gradient-top) 0%,
    var(--btn-active-gradient-bottom) 100%
  );
  box-shadow: var(--shadow-button-active);
  transform: translateY(1px);
}

.preview-controls button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.preview-options {
  display: none; /* Hidden on desktop, shown only on mobile */
  width: 100%;
  justify-content: space-between;
  align-items: center;
  /* padding: 0px 10px; */
}

.preview-options button {
  width: 100%;
  height: var(--preview-options-height);
  background: linear-gradient(
    to bottom,
    var(--btn-gradient-top) 0%,
    var(--btn-gradient-bottom) 100%
  );
  border: var(--border-glossy);
  border-radius: var(--border-radius-btn) var(--border-radius-btn) 0 0;
  cursor: pointer;
  text-align: center;
  transition: var(--transition-fast);
  font-size: 14px;
  font-weight: 600;
  user-select: none;
  box-shadow: var(--shadow-button-outer);
  position: relative;
  color: #333;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.preview-options button::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: var(--glossy-overlay);
  border-radius: var(--border-radius-btn) var(--border-radius-btn) 0 0;
  pointer-events: none;
}

.preview-options button:hover {
  background: linear-gradient(
    to bottom,
    var(--btn-hover-gradient-top) 0%,
    var(--btn-hover-gradient-bottom) 100%
  );
  box-shadow: var(--shadow-button-hover);
}

.preview-options button:active {
  background: linear-gradient(
    to bottom,
    var(--btn-active-gradient-top) 0%,
    var(--btn-active-gradient-bottom) 100%
  );
  box-shadow: var(--shadow-button-active);
  transform: translateY(1px);
}

.preview-options button.active {
  background: linear-gradient(
    to bottom,
    var(--btn-primary-gradient-top) 0%,
    var(--btn-primary-gradient-bottom) 100%
  );
  border-color: rgba(0, 122, 255, 0.4);
  box-shadow:
    0 1px 4px rgba(0, 122, 255, 0.4),
    0 1px 0 rgba(255, 255, 255, 0.6) inset;
  color: #ffffff;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.3);
}

.preview-options button.active::before {
  background: var(--glossy-overlay-strong);
}

.preview-options button.active:hover {
  background: linear-gradient(
    to bottom,
    var(--btn-primary-hover-top) 0%,
    var(--btn-primary-hover-bottom) 100%
  );
}

/* Icon buttons (delete, save, reset) - now img elements */
img.icon-btn {
  width: 42px;
  height: 42px;
  object-fit: contain;
  cursor: pointer;
  transition: var(--transition-smooth);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
  border-radius: var(--border-radius-card);
  padding: 4px;
}

img.icon-btn:hover {
  transform: translateY(-2px);
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

img.icon-btn:active {
  background: radial-gradient(
    ellipse at center,
    rgba(0, 122, 255, 0.5) 0%,
    rgba(0, 122, 255, 0.2) 50%,
    transparent 70%
  );
  filter: drop-shadow(0 0 15px rgba(0, 122, 255, 0.7))
    drop-shadow(0 0 30px rgba(0, 122, 255, 0.4))
    drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.deletion-controls,
.navigation-controls,
.save-reset-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

#nav-counter {
  font-size: 13px;
  font-weight: 600;
  color: #666;
  min-width: 50px;
  text-align: center;
}

#nav-prev,
#nav-next {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  min-width: 30px;
  padding: 0;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-controls {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  flex-direction: column;
  max-height: 230px;
  overflow: hidden;
}

.adjustment-controls {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 15px;
  overflow-y: auto;
}

.adjustment-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.adjustment-group label {
  font-size: 13px;
  color: #333;
  font-weight: 500;
}

.slider-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-value {
  font-size: 11px;
  font-weight: 600;
  color: #666;
  min-width: 32px;
  text-align: right;
}

.adjustment-group input[type="range"] {
  flex: 1;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-track {
  width: 100%;
  height: 10px;
  background: linear-gradient(to bottom, #888888 0%, #aaaaaa 50%, #cccccc 100%);
  border-radius: 5px;
  border: 1px solid rgba(0, 0, 0, 0.4);
  box-shadow:
    inset 0 1px 4px rgba(0, 0, 0, 0.5),
    0 1px 0 rgba(255, 255, 255, 0.9);
}

input[type="range"]::-moz-range-track {
  width: 100%;
  height: 10px;
  background: linear-gradient(to bottom, #888888 0%, #aaaaaa 50%, #cccccc 100%);
  border-radius: 5px;
  border: 1px solid rgba(0, 0, 0, 0.4);
  box-shadow:
    inset 0 1px 4px rgba(0, 0, 0, 0.5),
    0 1px 0 rgba(255, 255, 255, 0.9);
}

input[type="range"]::-webkit-slider-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(to bottom, #ffffff 0%, #e0e0e0 100%);
  border: 1px solid rgba(0, 0, 0, 0.3);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(to bottom, #ffffff 0%, #e0e0e0 100%);
  border: 1px solid rgba(0, 0, 0, 0.3);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  cursor: pointer;
  transition: all 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  background: linear-gradient(to bottom, #ffffff 0%, #ececec 100%);
  box-shadow:
    0 1px 4px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 1);
}

input[type="range"]::-moz-range-thumb:hover {
  background: linear-gradient(to bottom, #ffffff 0%, #ececec 100%);
  box-shadow:
    0 1px 4px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 1);
}

input[type="range"]::-webkit-slider-thumb:active {
  background: linear-gradient(to bottom, #d8d8d8 0%, #f4f4f4 100%);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

input[type="range"]::-moz-range-thumb:active {
  background: linear-gradient(to bottom, #d8d8d8 0%, #f4f4f4 100%);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.filter-intensity-wrapper input[type="range"] {
  background: transparent;
  cursor: pointer;
}

.filter-intensity-wrapper input[type="range"]::-webkit-slider-track {
  width: 100%;
  height: 10px;
  background: linear-gradient(to bottom, #888888 0%, #aaaaaa 50%, #cccccc 100%);
  border-radius: 5px;
  border: 1px solid rgba(0, 0, 0, 0.4);
  box-shadow:
    inset 0 1px 4px rgba(0, 0, 0, 0.5),
    0 1px 0 rgba(255, 255, 255, 0.9);
}

.filter-intensity-wrapper input[type="range"]::-moz-range-track {
  width: 100%;
  height: 10px;
  background: linear-gradient(to bottom, #888888 0%, #aaaaaa 50%, #cccccc 100%);
  border-radius: 5px;
  border: 1px solid rgba(0, 0, 0, 0.4);
  box-shadow:
    inset 0 1px 4px rgba(0, 0, 0, 0.5),
    0 1px 0 rgba(255, 255, 255, 0.9);
}

.camera-carousel {
  display: flex;
  flex-direction: row;
  gap: 15px;
  flex: 1;
  overflow-x: auto;
  align-items: center;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.camera-carousel::-webkit-scrollbar {
  display: none;
}

.camera-option {
  scroll-snap-align: start;
}

.camera-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-sm);
  padding: var(--padding-sm);
  cursor: pointer;
  transition: var(--transition-smooth);
  width: var(--carousel-option-width);
  flex-shrink: 0;
  position: relative;
  background: transparent;
  border: none;
  border-radius: var(--border-radius-card);
}

.camera-option img {
  height: 100px;
  width: 100px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.2));
  transition: var(--transition-smooth);
}

.camera-option:hover {
  transform: translateY(-2px);
}

.camera-option:hover img {
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.25));
}

.camera-option--selected {
  background: var(--overlay-blue-radial);
}

.camera-option span {
  display: flex;
  align-items: start;
  justify-content: center;
  text-align: center;
  word-wrap: break-word;
  overflow-wrap: break-word;
  width: 100%;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 500;
  color: #333;
}

.camera-option--selected span {
  color: #007aff;
  font-weight: 600;
}

.filter-controls {
  flex: 0 0 auto;
  gap: var(--gap-sm);
  display: flex;
  flex-direction: column;
  max-height: 230px;
  overflow: hidden;
}

/* =========================================
   PHONE CONTROLS (similar to camera)
   ========================================= */
.phone-controls {
  flex: 0 0 auto;
  display: flex;
  gap: var(--gap-sm);
  flex-direction: column;
  max-height: 230px;
  overflow: hidden;
}

.phone-carousel {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.phone-carousel::-webkit-scrollbar {
  display: none;
}

.phone-option {
  scroll-snap-align: start;
}

.phone-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-sm);
  padding: var(--padding-sm);
  cursor: pointer;
  transition: var(--transition-smooth);
  width: var(--carousel-option-width);
  flex-shrink: 0;
  position: relative;
  background: transparent;
  border: none;
  border-radius: var(--border-radius-card);
}

.phone-option img {
  height: 100px;
  width: 100px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.2));
  transition: var(--transition-smooth);
}

.phone-option:hover {
  transform: translateY(-2px);
}

.phone-option:hover img {
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.25));
}

.phone-option--selected {
  background: var(--overlay-blue-radial);
}

.phone-option span {
  display: flex;
  align-items: start;
  justify-content: center;
  text-align: center;
  word-wrap: break-word;
  overflow-wrap: break-word;
  width: 100%;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 500;
  color: #333;
}

.phone-option--selected span {
  color: #007aff;
  font-weight: 600;
}

/* =========================================
   MOBILE RESPONSIVENESS
   ========================================= */
@media (max-width: 1200px) {
  /* Prevent scrolling and lock to viewport */
  body {
    overflow: hidden;
    height: 100vh;
  }

  .editor-container {
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
  }

  .editor-container__preview {
    position: relative; /* Positioning context for overlaid controls */
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  /* Reorder preview section: controls above image */
  .preview-controls {
    order: 1;
    height: var(--preview-controls-height);
    flex-shrink: 0;
  }

  .preview-image {
    order: 2;
    flex: 1;
    min-height: 0; /* Critical: allows flexbox to shrink below content size */
    margin: 0; /* Remove margins to maximize space */
    overflow: hidden;
  }

  .preview-options {
    display: flex; /* Show on mobile */
    order: 3;
    height: var(--preview-options-height);
    flex-shrink: 0;
  }

  /* Constrain actual image to fit within available space */
  .preview-image img,
  #preview-img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Scale to fit, preserve aspect ratio */
    object-position: center; /* Center the image */
  }

  .editor-container__controls {
    width: 100%;
    padding: 0px;
    gap: 20px;
    overflow: visible;
  }

  /* Make carousels scroll horizontally on mobile */
  .camera-carousel,
  .phone-carousel,
  .filter-carousel {
    max-height: none;
    overflow-x: auto;
  }

  /* Position control sections to overlay the preview image on mobile */
  .camera-controls,
  .phone-controls,
  .filter-controls {
    display: none;
    position: absolute;
    bottom: var(
      --preview-options-height
    ); /* Height of preview-options buttons */
    left: 0;
    right: 0;
    width: 100%;
    max-height: 250px; /* Limit height to avoid covering entire image */
    overflow-y: auto;
    background: var(--overlay-white-semi); /* Semi-transparent white overlay */
    backdrop-filter: blur(10px); /* Modern glass effect */
    box-shadow: var(--shadow-overlay); /* Subtle elevation shadow */
    z-index: 10; /* Above image content */
    padding: var(--padding-md);
    border-radius: var(--border-radius-card) var(--border-radius-card) 0 0; /* Rounded top corners */
  }

  /* Stack preview controls better on mobile */
  .preview-controls {
    flex-wrap: wrap;
    justify-content: center;
    padding: 0 10px;
    gap: 10px;
  }

  .navigation-controls,
  .save-reset-controls,
  .deletion-controls {
    justify-content: center;
  }

  /* Larger touch targets on mobile */
  .carousel-arrow,
  #nav-prev,
  #nav-next {
    width: 36px;
    height: 36px;
    min-width: 36px;
    font-size: 16px;
  }

  .preview-controls button {
    padding: 10px 20px;
    font-size: 14px;
  }

  /* Hide adjustment controls on mobile */
  .adjustment-controls {
    display: none;
  }

  /* Hide carousel navigation arrows on mobile (users can swipe) */
  .carousel-nav {
    display: none;
  }

  .slider-wrapper {
    gap: 12px;
  }

  .slider-value {
    font-size: 12px;
    min-width: 40px;
  }
}
