/**
 * StyleyeS v1.8 — Component Styles
 * UI Components and Interactive Elements
 */

/* ============================================
   BRAND & HEADER
   ============================================ */

.brand {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 1.25rem;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.logo {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  filter: drop-shadow(0 0 20px rgba(220, 47, 90, 0.4));
}

.logo-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.title-group h1 {
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.ver {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.3em 0.7em;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  color: var(--t2);
  letter-spacing: 0.02em;
}

.tag {
  color: var(--t2);
  font-weight: 300;
  font-size: 1.1rem;
}

/* ============================================
   MODE SWITCHER
   ============================================ */

.mode-switch {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 3px;
}

.mode-btn {
  padding: 0.4rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--t2);
  border-radius: 16px;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mode-btn.active {
  background: var(--bg-elevated);
  color: var(--c1);
  box-shadow: var(--shadow-sm);
}

/* ============================================
   IMAGE UPLOAD ZONE
   ============================================ */

.image-upload-zone {
  display: none;
  width: 100%;
  min-height: 120px;
  max-height: 400px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
  position: relative;
  overflow: hidden;
}

.image-upload-zone.active {
  display: flex;
}

.image-upload-zone:hover {
  border-color: var(--c1);
  background: rgba(255, 107, 53, 0.05);
}

/* When image is loaded - dynamic height mode */
.image-upload-zone.has-image {
  border-style: solid;
  border-color: var(--c1);
  min-height: auto;
  height: auto;
  aspect-ratio: var(--img-aspect-ratio, auto);
  max-width: 100%;
}

.zone-text {
  font-size: 0.8rem;
  color: var(--t2);
  pointer-events: none;
  text-align: center;
}

.zone-sub {
  font-size: 0.7rem;
  color: var(--t3);
  margin-top: 4px;
  pointer-events: none;
}

.zone-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  background: var(--bg-card);
  pointer-events: none;
  display: none;
}

/* Full visibility when image is loaded */
.image-upload-zone.has-image .zone-preview {
  display: block;
  position: relative;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 400px;
}

.zone-icon {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--c1);
}

.remove-img {
  position: absolute;
  top: 5px;
  right: 5px;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: var(--z-elevated);
  font-size: 14px;
  transition: background 0.2s ease;
}

.remove-img:hover {
  background: var(--err);
}

/* ============================================
   ASPECT RATIO TOOLBAR
   ============================================ */

.ar-toolbar {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 1.25rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  align-items: center;
}

.ar-toolbar::-webkit-scrollbar {
  display: none;
}

.ar-btn {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.5rem;
  cursor: pointer;
  min-width: 60px;
  transition: all 0.2s ease;
}

.ar-btn:hover {
  background: var(--bg-elevated);
  border-color: rgba(255, 107, 53, 0.3);
}

.ar-btn.active {
  border-color: var(--c1);
  background: rgba(255, 107, 53, 0.1);
}

.ar-btn.active .ar-text {
  color: var(--c1);
  font-weight: 600;
}

.ar-icon-box {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ar-rect {
  border: 2px solid var(--t3);
  border-radius: 2px;
  transition: border-color 0.2s;
}

.ar-btn.active .ar-rect {
  border-color: var(--c1);
}

.ar-text {
  font-size: 0.65rem;
  color: var(--t3);
  font-family: var(--font-mono);
}

/* ============================================
   MODEL DROPDOWN
   ============================================ */

.model-dropdown {
  position: relative;
  z-index: 100;
  width: 100%;
}

.model-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.75rem;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
  width: 100%;
  min-width: 160px;
}

.model-dropdown-trigger:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--c1);
}

.model-icon {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--t1);
  display: flex;
  align-items: center;
}

.model-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.chevron {
  width: 1rem;
  height: 1rem;
  margin-left: auto;
  transition: transform 0.2s ease;
}

.model-dropdown.open .chevron {
  transform: rotate(180deg);
}

.model-dropdown-panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  right: 0;
  width: 100%;
  min-width: 0;
  max-width: none;
  max-height: 70vh;
  overflow-y: auto;
  background: rgba(30, 30, 35, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1rem;
  backdrop-filter: blur(20px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  padding: 0.5rem;
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  pointer-events: none;
  transition: all 0.2s ease;
}

.model-dropdown.open .model-dropdown-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.model-category-label {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 0.5rem;
}

.model-category-label:first-child {
  margin-top: 0;
}

.model-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.75rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: transform 0.2s var(--ease-spring), box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  margin-bottom: 0.25rem;
  color: inherit;
}

.model-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.model-card:focus-visible {
  outline: 2px solid rgba(255, 107, 53, 0.7);
  outline-offset: 2px;
}

.model-card.selected {
  background: rgba(255, 107, 53, 0.1);
  border-color: var(--c1);
  box-shadow: 0 10px 20px rgba(255, 107, 53, 0.2);
  transform: translateY(-2px);
  animation: modelSelectPulse 0.45s var(--ease-spring);
}

.model-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.model-card-icon {
  width: 1.5rem;
  height: 1.5rem;
  color: var(--t1);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.model-card-name {
  font-weight: 600;
  color: #fff;
  font-size: 0.9375rem;
}

.checkmark {
  margin-left: auto;
  color: var(--c1);
}

.model-card-description {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.6);
  margin: 0 0 0.5rem 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.model-card-capabilities {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.capability-badge {
  padding: 0.25rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 500;
  border-radius: 0.375rem;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
}

.capability-badge.speed {
  background: rgba(100, 200, 255, 0.15);
  color: #64C8FF;
}

.capability-badge.quality {
  background: rgba(255, 200, 100, 0.15);
  color: #FFC864;
}

.capability-badge.feature {
  background: rgba(150, 100, 255, 0.15);
  color: #9664FF;
}

.model-dropdown-panel::-webkit-scrollbar {
  width: 6px;
}

.model-dropdown-panel::-webkit-scrollbar-track {
  background: transparent;
}

.model-dropdown-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.model-dropdown-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ============================================
   ASPECT RATIO SLIDER
   ============================================ */

.aspect-ratio-container {
  display: flex;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.aspect-ratio-slider-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.1rem 1.25rem 1.5rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 1rem;
  max-width: 520px;
  width: min(92vw, 520px);
}

.aspect-ratio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.aspect-ratio-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
}

.aspect-ratio-reset {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  transition: all 0.2s ease;
}

.aspect-ratio-reset:hover {
  color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.05);
}

.aspect-ratio-preview {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  background: rgba(255, 107, 53, 0.08);
  margin-left: auto;
  box-shadow: 0 0 16px rgba(255, 107, 53, 0.25);
}

.aspect-preview-layer {
  position: absolute;
  inset: 0;
  margin: auto;
  border: 2px solid var(--c1);
  border-radius: 6px;
  box-shadow: 0 0 12px rgba(255, 107, 53, 0.45);
  opacity: 0;
  transform: scale(0.96);
  transition: width 0.2s var(--ease-smooth), height 0.2s var(--ease-smooth), opacity 0.2s ease, transform 0.2s var(--ease-smooth);
}

.aspect-preview-layer.is-visible {
  opacity: 1;
  transform: scale(1);
}

.aspect-ratio-categories {
  display: flex;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 0.5rem;
  padding: 0.25rem;
  gap: 0.25rem;
}

.aspect-ratio-categories .category-btn {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.5);
  background: transparent;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.aspect-ratio-categories .category-btn:hover {
  color: rgba(255, 255, 255, 0.8);
}

.aspect-ratio-categories .category-btn.active {
  background: rgba(255, 107, 53, 0.2);
  color: var(--c1);
}

.aspect-ratio-slider-track {
  position: relative;
  height: 24px;
  display: flex;
  align-items: center;
}

.slider-notches {
  position: absolute;
  left: 0;
  right: 0;
  height: 6px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  z-index: 2;
}

.slider-notch {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  transform: translate(-50%, -50%);
  top: 50%;
  transition: transform 0.2s var(--ease-spring), background 0.2s ease, box-shadow 0.2s ease;
}

.slider-notch.active {
  background: var(--c1);
  box-shadow: 0 0 10px rgba(255, 107, 53, 0.6);
  transform: translate(-50%, -50%) scale(1.25);
}

.slider-track-bg {
  position: absolute;
  left: 0;
  right: 0;
  height: 6px;
  display: flex;
  border-radius: 3px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
  z-index: 0;
}

.zone {
  flex: 1;
}

.zone.portrait {
  background: linear-gradient(90deg, rgba(100, 150, 255, 0.2), rgba(100, 150, 255, 0.05));
}

.zone.square {
  background: rgba(255, 255, 255, 0.05);
}

.zone.landscape {
  background: linear-gradient(90deg, rgba(255, 150, 100, 0.05), rgba(255, 150, 100, 0.2));
}

.slider-fill {
  position: absolute;
  height: 6px;
  background: var(--c1);
  border-radius: 3px;
  pointer-events: none;
  z-index: 1;
}

.slider-input {
  position: absolute;
  width: 100%;
  height: 24px;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
  -webkit-appearance: none;
  touch-action: pan-x;
}

.slider-thumb {
  position: absolute;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 3;
  transition: transform 0.2s ease, left 0.18s var(--ease-spring);
}

.aspect-ratio-slider-container.is-dragging .slider-thumb {
  transition: transform 0.2s ease;
}

.aspect-ratio-label {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--c1);
  margin-top: 0.25rem;
}

/* ============================================
   UTILITY BAR
   ============================================ */

.utility-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.util-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.util-btn {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--t2);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.util-btn:hover {
  background: var(--bg-elevated);
  color: var(--t1);
  border-color: var(--c1);
}

.util-btn:active {
  transform: scale(0.97);
}

/* ============================================
   PICKER / TABS
   ============================================ */

.picker-container {
  margin-bottom: 1.25rem;
}

.tab-group {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px;
  margin-bottom: 1rem;
  position: relative;
}

.tab-btn {
  flex: 1;
  padding: 0.6rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--t2);
  border-radius: 10px;
  transition: all 0.2s ease;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.tab-btn .btn-icon {
  width: 1.1rem;
  height: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tab-btn .btn-icon svg {
  width: 100%;
  height: 100%;
}

.tab-btn.active {
  color: var(--t1);
  font-weight: 600;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}

/* ============================================
   CATEGORIES
   ============================================ */

.categories {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.categories::-webkit-scrollbar {
  display: none;
}

.cat-btn {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.5rem 0.875rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  color: var(--t2);
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.cat-icon {
  width: 1rem;
  height: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cat-icon svg {
  width: 100%;
  height: 100%;
}

.cat-btn:hover {
  background: var(--bg-elevated);
  color: var(--t1);
}

.cat-btn:active {
  transform: scale(0.97);
}

.cat-btn.active {
  background: var(--gradient);
  border-color: transparent;
  color: white;
}

/* ============================================
   STYLES CONTAINER & CATEGORY CAROUSELS
   ============================================ */

.styles-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-height: 200px;
}

.style-category-section {
  position: relative;
}

.category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding: 0 0.25rem;
}

.category-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--t1);
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.category-title .category-icon {
  width: 1.25rem;
  height: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--c1);
}

.category-title .category-icon svg {
  width: 100%;
  height: 100%;
}

.carousel-nav {
  display: flex;
  gap: 0.5rem;
}

.carousel-arrow {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--t2);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.carousel-arrow:hover {
  background: var(--bg-elevated);
  border-color: var(--c1);
  color: var(--c1);
}

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

.carousel-arrow svg {
  width: 16px;
  height: 16px;
}

/* Hide arrows on touch devices */
@media (hover: none) and (pointer: coarse) {
  .carousel-nav {
    display: none;
  }
}

.carousel-track {
  display: flex;
  gap: 0.875rem;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  padding: 0.5rem 0.25rem;
  margin: 0 -0.25rem;

  /* Hide scrollbar but keep functionality */
  scrollbar-width: none;
  -ms-overflow-style: none;

  /* Performance optimizations */
  will-change: scroll-position;
  touch-action: pan-x;
  overscroll-behavior-x: contain;
}

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

/* Cards within carousel */
.carousel-track .card-item {
  flex: 0 0 auto;
  width: 140px;
  scroll-snap-align: start;
  /* Prevent layout shift during scroll */
  contain: layout style paint;
}

@media (min-width: 500px) {
  .carousel-track .card-item {
    width: 160px;
  }
}

@media (min-width: 768px) {
  .carousel-track .card-item {
    width: 180px;
  }
}

/* Scroll fade indicators */
.style-category-section::before,
.style-category-section::after {
  content: '';
  position: absolute;
  top: 40px;
  bottom: 0;
  width: 30px;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.style-category-section::before {
  left: 0;
  background: linear-gradient(90deg, var(--bg), transparent);
}

.style-category-section::after {
  right: 0;
  background: linear-gradient(270deg, var(--bg), transparent);
}

.style-category-section.scroll-left::before {
  opacity: 1;
}

.style-category-section.scroll-right::after {
  opacity: 1;
}

/* Legacy grid styles for controls mode */
.styles-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.875rem;
  min-height: 200px;
  padding-bottom: 1rem;
}

@media (min-width: 500px) {
  .styles-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
  }
}

@media (min-width: 768px) {
  .styles-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 1024px) {
  .styles-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* ============================================
   CARD ITEMS WITH VISUAL PREVIEWS
   ============================================ */

.card-item {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  /* Performance optimizations */
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Visual Preview Layer */
.card-preview {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  overflow: hidden;
  transition: all 0.4s var(--ease-out);
}

.card-preview-pattern {
  position: absolute;
  inset: 0;
  background-size: 8px 8px;
  opacity: 0.6;
  mix-blend-mode: overlay;
  transition: opacity 0.3s ease;
}

.card-preview-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    transparent 0%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 100%
  );
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Hover Preview Expansion */
.card-preview-hover {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 5;
  padding: 0.75rem;
  pointer-events: none;
  /* Only use backdrop-filter on devices that can handle it */
  will-change: opacity, transform;
}

/* Enable backdrop blur only on hover-capable devices with good performance */
@media (hover: hover) and (min-width: 768px) {
  .card-preview-hover {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
}

.preview-sample {
  width: 80%;
  height: 45px;
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.preview-sample-pattern {
  position: absolute;
  inset: 0;
  background-size: 8px 8px;
  opacity: 0.6;
  mix-blend-mode: overlay;
}

.preview-tags {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.8);
  text-align: center;
  line-height: 1.4;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Card Content */
.card-content {
  position: relative;
  margin-top: auto;
  padding: 0.75rem;
  background: var(--bg-card);
  z-index: 2;
  transition: background 0.3s ease;
}

.card-item:hover .card-content {
  background: var(--bg-elevated);
}

.card-item:hover {
  border-color: rgba(255, 107, 53, 0.4);
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.card-item:hover .card-preview {
  height: 54px;
}

.card-item:hover .card-preview-shine {
  opacity: 1;
  animation: shimmerSlide 1.5s ease-in-out infinite;
}

.card-item:hover .card-preview-hover {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

@keyframes shimmerSlide {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.card-item:active {
  transform: translateY(0) scale(0.98);
}

.card-item.selected {
  border-color: var(--c1);
  box-shadow: 0 0 0 2px rgba(255, 107, 53, 0.2);
}

.card-item.selected .card-content {
  background: rgba(255, 107, 53, 0.1);
}

.card-item.selected .card-preview {
  box-shadow: inset 0 0 20px rgba(255, 107, 53, 0.3);
}

.card-name {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--t1);
  margin-bottom: 0.15rem;
  line-height: 1.3;
}

.card-sub {
  font-size: 0.65rem;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.card-fav {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  width: 26px;
  height: 26px;
  color: rgba(255, 255, 255, 0.7);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  z-index: 10;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.card-fav:hover {
  color: var(--c1);
  background: rgba(255, 107, 53, 0.2);
  transform: scale(1.1);
}

.card-fav.active {
  color: var(--c1);
  background: rgba(255, 107, 53, 0.25);
}

/* ============================================
   EFFECT-SPECIFIC ANIMATIONS & TREATMENTS
   ============================================ */

/* Film Noir - Venetian blinds effect */
.card-item[data-effect="noir"] .card-preview::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(255, 255, 255, 0.08) 3px,
    rgba(255, 255, 255, 0.08) 6px
  );
  pointer-events: none;
}

/* Neon/Cyberpunk - Glowing grid effect */
.card-item[data-effect="neon"] .card-preview,
.card-item[data-effect="glow"] .card-preview {
  animation: pulseGlow 3s ease-in-out infinite;
}

.card-item[data-effect="neon"] .card-preview-pattern {
  background:
    linear-gradient(rgba(0, 212, 255, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 212, 255, 0.1) 1px, transparent 1px) !important;
  background-size: 12px 12px !important;
  animation: neon-pulse 3s ease-in-out infinite;
}

@keyframes neon-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

/* Pastel/Wes Anderson - Soft pastel glow */
.card-item[data-effect="pastel"] .card-preview {
  filter: saturate(0.9) brightness(1.05);
}

.card-item[data-effect="pastel"] .card-preview::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg,
    rgba(255, 255, 255, 0.2) 0%,
    transparent 50%,
    rgba(255, 255, 255, 0.1) 100%
  );
  pointer-events: none;
}

/* Golden Hour warmth */
.card-item[data-effect="warm"] .card-preview,
.card-item[data-effect="golden"] .card-preview {
  filter: saturate(1.2) brightness(1.05);
}

.card-item[data-effect="warm"] .card-preview::after,
.card-item[data-effect="golden"] .card-preview::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(255, 183, 77, 0.15) 0%,
    rgba(255, 138, 101, 0.1) 100%
  );
  pointer-events: none;
}

/* Vintage/Analog fade with grain */
.card-item[data-effect="analog"] .card-preview,
.card-item[data-effect="vintage"] .card-preview,
.card-item[data-effect="retro"] .card-preview {
  filter: sepia(0.15) contrast(0.95) saturate(0.9);
}

.card-item[data-effect="analog"]::after,
.card-item[data-effect="vintage"]::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50px;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='grain'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23grain)' opacity='0.15'/%3E%3C/svg%3E");
  pointer-events: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  z-index: 1;
}

/* Chiaroscuro/Dramatic lighting */
.card-item[data-effect="chiaroscuro"] .card-preview,
.card-item[data-effect="dramatic"] .card-preview {
  position: relative;
}

.card-item[data-effect="chiaroscuro"] .card-preview::after,
.card-item[data-effect="dramatic"] .card-preview::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 70% 30%,
    transparent 0%,
    rgba(0, 0, 0, 0.4) 70%
  );
  pointer-events: none;
}

/* Soft/Bokeh effect with blur orbs */
.card-item[data-effect="bokeh"] .card-preview::before,
.card-item[data-effect="soft"] .card-preview::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 25% 35%, rgba(255,255,255,0.2) 0%, transparent 25%),
    radial-gradient(circle at 75% 65%, rgba(255,255,255,0.15) 0%, transparent 20%),
    radial-gradient(circle at 50% 20%, rgba(255,255,255,0.18) 0%, transparent 22%);
  filter: blur(2px);
  z-index: 1;
}

/* Chrome/Metallic effect */
.card-item[data-effect="chrome"] .card-preview,
.card-item[data-effect="metallic"] .card-preview {
  background-size: 100% 200% !important;
  animation: chromeShine 3s linear infinite;
}

/* Cel-shaded/Anime flat colors */
.card-item[data-effect="cel"] .card-preview,
.card-item[data-effect="flat"] .card-preview {
  filter: contrast(1.1) saturate(1.15);
}

.card-item[data-effect="cel"] .card-preview::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-radius: inherit;
  pointer-events: none;
}

/* Mist/Fog effect */
.card-item[data-effect="mist"] .card-preview::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(255, 255, 255, 0.3) 0%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 100%
  );
  pointer-events: none;
}

/* Dark/Brooding vignette */
.card-item[data-effect="dark"] .card-preview::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center,
    transparent 20%,
    rgba(0, 0, 0, 0.5) 100%
  );
  pointer-events: none;
}

/* Flare effect */
.card-item[data-effect="flare"] .card-preview::before {
  content: '';
  position: absolute;
  top: 10%;
  right: 10%;
  width: 30%;
  height: 30%;
  background: radial-gradient(ellipse at center,
    rgba(255, 200, 100, 0.4) 0%,
    transparent 70%
  );
  filter: blur(3px);
  z-index: 1;
}

/* Horizon/Layers effect */
.card-item[data-effect="horizon"] .card-preview,
.card-item[data-effect="layers"] .card-preview {
  background-size: 100% 100% !important;
}

/* Halftone/Dots effect */
.card-item[data-effect="halftone"] .card-preview-pattern,
.card-item[data-effect="dots"] .card-preview-pattern {
  background: radial-gradient(circle, currentColor 1.5px, transparent 1.5px) !important;
  background-size: 6px 6px !important;
  opacity: 0.3 !important;
}

/* Scan lines effect */
.card-item[data-effect="scan"] .card-preview::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.1) 2px,
    rgba(0, 0, 0, 0.1) 4px
  );
  pointer-events: none;
}

@keyframes chromeShine {
  0% {
    background-position: 0% 0%;
  }
  100% {
    background-position: 0% 200%;
  }
}

@keyframes pulseGlow {
  0%, 100% {
    filter: brightness(1) saturate(1);
  }
  50% {
    filter: brightness(1.2) saturate(1.3);
  }
}

/* Grain effect */
.card-item[data-effect="grain"] .card-preview::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.4'/%3E%3C/svg%3E");
  opacity: 0.5;
  mix-blend-mode: overlay;
}

/* Motion/Dynamic effect */
.card-item[data-effect="motion"] .card-preview {
  animation: motionShift 4s ease-in-out infinite;
}

@keyframes motionShift {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

/* Glitch effect */
.card-item[data-effect="glitch"]:hover .card-preview {
  animation: glitchEffect 0.3s steps(2) infinite;
}

@keyframes glitchEffect {
  0% {
    clip-path: inset(20% 0 40% 0);
    transform: translate(-2px, 0);
  }
  20% {
    clip-path: inset(60% 0 10% 0);
    transform: translate(2px, 0);
  }
  40% {
    clip-path: inset(10% 0 70% 0);
    transform: translate(-1px, 0);
  }
  60% {
    clip-path: inset(50% 0 20% 0);
    transform: translate(1px, 0);
  }
  80% {
    clip-path: inset(30% 0 50% 0);
    transform: translate(0, 0);
  }
  100% {
    clip-path: inset(0 0 0 0);
    transform: translate(0, 0);
  }
}

/* Shimmer/Rainbow effect */
.card-item[data-effect="rainbow"] .card-preview,
.card-item[data-effect="shimmer"] .card-preview {
  background-size: 200% 200%;
  animation: rainbowShift 5s ease infinite;
}

@keyframes rainbowShift {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

/* Pixel effect */
.card-item[data-effect="pixel"] .card-preview {
  image-rendering: pixelated;
}

/* Warp/Surreal effect */
.card-item[data-effect="warp"]:hover .card-preview {
  animation: warpEffect 2s ease-in-out infinite;
}

@keyframes warpEffect {
  0%, 100% {
    border-radius: 12px 12px 0 0;
  }
  25% {
    border-radius: 12px 20px 0 0;
  }
  75% {
    border-radius: 20px 12px 0 0;
  }
}

/* Magic/Sparkle effect */
.card-item[data-effect="magic"]:hover .card-preview::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 30%, rgba(255,255,255,0.8) 0%, transparent 8%),
              radial-gradient(circle at 80% 20%, rgba(255,255,255,0.6) 0%, transparent 6%),
              radial-gradient(circle at 40% 70%, rgba(255,255,255,0.7) 0%, transparent 5%),
              radial-gradient(circle at 70% 60%, rgba(255,255,255,0.5) 0%, transparent 7%);
  animation: sparkle 1.5s ease-in-out infinite;
}

@keyframes sparkle {
  0%, 100% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .card-item,
  .card-preview,
  .card-preview-hover,
  .card-preview-shine,
  .card-fav {
    animation: none !important;
    transition: opacity 0.2s ease, background 0.2s ease !important;
  }

  .card-item:hover {
    transform: none;
  }

  .card-item:hover .card-preview-shine {
    animation: none;
    opacity: 0.5;
  }
}

/* ============================================
   STACK SECTION
   ============================================ */

.stack-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin-bottom: 1.25rem;
}

.stack-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.stack-count {
  font-size: 0.75rem;
  color: var(--t3);
}

.stack-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 40px;
}

.stack-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.8rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--t1);
  animation: fadeIn 0.3s ease;
}

.stack-row.type-style {
  border-left: 3px solid var(--c2);
}

.stack-row.type-control {
  border-left: 3px solid var(--c1);
}

.row-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.row-icon {
  width: 1.25rem;
  height: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.row-icon svg {
  width: 100%;
  height: 100%;
}

.type-control .row-icon {
  color: var(--c1);
}

.type-style .row-icon {
  color: var(--c2);
}

.row-name {
  font-weight: 500;
}

.row-remove {
  color: var(--t3);
  font-size: 1.1rem;
  padding: 0.2rem;
  line-height: 1;
  transition: color 0.2s;
}

.row-remove:hover {
  color: var(--err);
}

.stack-empty {
  color: var(--t3);
  font-size: 0.85rem;
  font-style: italic;
  text-align: center;
  padding: 1rem;
}

.stack-controls-area {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ============================================
   WEIGHT CONTROL
   ============================================ */

.weight-control {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.weight-control label {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--t2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  min-width: 80px;
  margin-bottom: 0;
}

.weight-value {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--c1);
  min-width: 2ch;
  text-align: right;
}

/* ============================================
   OUTPUT SECTION
   ============================================ */

.output-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin-bottom: 1.25rem;
}

.output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.prompt-output {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  padding: 0.875rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--t1);
  min-height: 80px;
  white-space: pre-wrap;
  word-break: break-word;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  transition: all 0.2s var(--ease-out);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--gradient);
  color: white;
  box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
  box-shadow: var(--shadow-glow-hover);
}

.btn-primary.copied {
  background: var(--success);
  box-shadow: none;
}

.btn-secondary {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--t1);
}

.btn-secondary:hover {
  border-color: var(--c1);
}

/* ============================================
   TOAST
   ============================================ */

.toast {
  position: fixed;
  bottom: max(1.5rem, calc(var(--safe-bottom) + 1.5rem));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 0.75rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--success);
  border-radius: 10px;
  color: var(--success);
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s var(--ease-spring);
  z-index: var(--z-toast);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================
   MODAL
   ============================================ */

.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: flex-end;
  justify-content: center;
}

@media (min-width: 600px) {
  .modal {
    align-items: center;
    padding: 1rem;
  }
}

.modal.show {
  display: flex;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 1.25rem;
  padding-bottom: calc(1.25rem + var(--safe-bottom));
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  animation: slideUp 0.3s var(--ease-out);
}

@media (min-width: 600px) {
  .modal-box {
    border-radius: var(--radius-xl);
    max-width: 500px;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.modal-close {
  color: var(--t3);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 1.25rem;
  transition: all 0.2s;
}

.modal-close:hover {
  color: var(--t1);
  background: var(--bg-elevated);
}

/* ============================================
   HISTORY
   ============================================ */

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-empty {
  color: var(--t3);
  text-align: center;
}

.history-item {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.875rem;
}

.history-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.history-time {
  font-size: 0.7rem;
  color: var(--t3);
}

.history-model {
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  background: rgba(255, 107, 53, 0.15);
  border-radius: 4px;
  color: var(--c1);
  font-weight: 500;
}

.history-prompt {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--t2);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.history-actions button {
  font-size: 0.7rem;
  padding: 0.3rem 0.6rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--t2);
  transition: all 0.2s;
}

.history-actions button:hover {
  color: var(--t1);
  border-color: var(--c1);
}

/* ============================================
   UI ICONS
   ============================================ */

.btn-icon {
  width: 1rem;
  height: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-icon svg {
  width: 100%;
  height: 100%;
}

.header-icon {
  width: 1.25rem;
  height: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  margin-right: 0.35rem;
  color: var(--c1);
}

.header-icon svg {
  width: 100%;
  height: 100%;
}

/* Zone icon styling */
.zone-icon .btn-icon,
.zone-icon span[data-ui-icon] {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.zone-icon span[data-ui-icon] svg {
  width: 100%;
  height: 100%;
}
