/* CSS Design System & Theme Variables */
:root {
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;
  
  /* Color Palette: Sophisticated & Soft Light Mode */
  --bg-app: #f4f6fa;
  --bg-sidebar: rgba(255, 255, 255, 0.85);
  --bg-card: #ffffff;
  --bg-input: #f8fafc;
  
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --color-primary: #6366f1; /* Indigo */
  --color-primary-hover: #4f46e5;
  --color-secondary: #0ea5e9; /* Sky Blue */
  --color-accent: #f43f5e; /* Rose */
  --color-success: #10b981; /* Emerald */
  --color-warning: #f59e0b; /* Amber */
  --color-border: #e2e8f0;
  
  --border-radius-sm: 8px;
  --border-radius-md: 16px;
  --border-radius-lg: 24px;
  --border-radius-round: 50%;
  
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 20px -2px rgba(100, 116, 139, 0.08), 0 4px 6px -4px rgba(100, 116, 139, 0.08);
  --shadow-lg: 0 20px 25px -5px rgba(100, 116, 139, 0.12), 0 8px 10px -6px rgba(100, 116, 139, 0.12);
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme Overrides */
body.dark-theme {
  --bg-app: #0b0f19;
  --bg-sidebar: rgba(15, 23, 42, 0.9);
  --bg-card: #151f32;
  --bg-input: #0d1527;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-light: #475569;
  
  --color-border: #1e293b;
  
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.2), 0 1px 2px -1px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 20px -2px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
}

body.dark-theme kbd {
  background-color: #1e293b;
  border-color: #334155;
  color: #f8fafc;
}

body.dark-theme .btn-secondary {
  background-color: #1e293b;
  border-color: #334155;
  color: #f8fafc;
}

body.dark-theme .btn-secondary:hover {
  background-color: #0d1527;
  border-color: #475569;
}

body.dark-theme .quick-info {
  background-color: rgba(30, 41, 59, 0.4);
}


/* Reset & General Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Text utility classes */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.uppercase { text-transform: uppercase; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.hidden { display: none !important; }

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--border-radius-sm);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-light);
}

/* App Shell Layout */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Sidebar Navigation */
.sidebar {
  width: 280px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--color-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 2.5rem 1.75rem;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  left: 0;
  top: 0;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 3.5rem;
}

.brand-logo {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius-md);
  font-size: 1.25rem;
  box-shadow: 0 8px 16px -4px rgba(99, 102, 241, 0.4);
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.brand-highlight {
  color: var(--color-primary);
}

.brand-text p {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
  margin-top: 2px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-grow: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: var(--transition-normal);
  text-align: left;
  width: 100%;
}

.nav-item i {
  font-size: 1.1rem;
  transition: var(--transition-fast);
}

.nav-item:hover {
  background-color: rgba(99, 102, 241, 0.05);
  color: var(--color-primary);
}

.nav-item.active {
  background-color: var(--color-primary);
  color: white;
  box-shadow: 0 10px 20px -6px rgba(99, 102, 241, 0.35);
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--color-border);
  padding-top: 1.5rem;
}

.quick-info {
  background-color: rgba(100, 116, 139, 0.04);
  padding: 1rem;
  border-radius: var(--border-radius-md);
}

.quick-info p {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.quick-info p:last-child {
  margin-bottom: 0;
}

kbd {
  background-color: #fff;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  box-shadow: 0 1px 1px rgba(0,0,0,0.1);
  color: var(--text-main);
  display: inline-block;
  font-family: var(--font-main);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  padding: 3px 6px;
  white-space: nowrap;
}

/* Main Content Area */
.main-content {
  margin-left: 280px;
  flex-grow: 1;
  min-height: 100vh;
  padding: 2.5rem 3rem;
  display: flex;
  flex-direction: column;
}

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

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.header-title h2 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 0.25rem;
}

/* Application Sections */
.app-section {
  display: none;
  flex-grow: 1;
  animation: fadeIn var(--transition-normal);
}

.app-section.active {
  display: flex;
  flex-direction: column;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Buttons Styling */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: var(--border-radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition-normal);
  outline: none;
}

.btn-primary {
  background-color: var(--color-primary);
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
  background-color: white;
  border-color: var(--color-border);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background-color: var(--bg-input);
  transform: translateY(-2px);
  border-color: var(--text-light);
  box-shadow: var(--shadow-md);
}

.btn-danger {
  background-color: var(--color-accent);
  color: white;
}

.btn-danger:hover {
  background-color: #e11d48;
  transform: translateY(-2px);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: var(--border-radius-md);
}

.btn-xs {
  font-size: 0.75rem;
  padding: 0.4rem 0.8rem;
  border-radius: var(--border-radius-sm);
}

.btn-text {
  background: none;
  border: none;
  color: var(--color-primary);
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-text:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

/* Forms & Inputs */
.form-select, .form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
  background-color: var(--bg-input);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 500;
  outline: none;
  transition: var(--transition-fast);
}

.form-select:focus, .form-input:focus {
  border-color: var(--color-primary);
  background-color: white;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* Section 1: Color Palette Page Layout */
.palette-interface {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 2rem;
  flex-grow: 1;
  min-height: 0;
}

.palette-container {
  display: flex;
  background-color: var(--bg-card);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border);
  min-height: 480px;
  height: 100%;
}

/* Color Column */
.color-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 2rem 1rem;
  position: relative;
  transition: flex var(--transition-slow), background-color var(--transition-fast);
  cursor: pointer;
}

.color-column::before {
  content: '';
  position: absolute;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.15);
  opacity: 0;
  transition: var(--transition-fast);
  pointer-events: none;
}

.color-column:hover::before {
  opacity: 1;
}

.color-column-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: auto;
  opacity: 0;
  transform: translateY(-10px);
  transition: var(--transition-normal);
  z-index: 10;
}

.color-column:hover .color-column-actions,
.color-column.locked .color-column-actions {
  opacity: 1;
  transform: translateY(0);
}

/* Round Action Buttons inside Color Columns */
.col-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius-round);
  border: none;
  background-color: rgba(255, 255, 255, 0.9);
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-normal);
}

.col-btn:hover {
  background-color: white;
  transform: scale(1.1);
  box-shadow: var(--shadow-md);
}

.color-column.locked .col-btn-lock {
  background-color: var(--text-main);
  color: white;
}

/* Color Info Display */
.color-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  background-color: rgba(255, 255, 255, 0.95);
  padding: 1.25rem 1rem;
  border-radius: var(--border-radius-md);
  width: 100%;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(8px);
  z-index: 10;
  transition: var(--transition-normal);
}

.color-column:hover .color-info {
  transform: translateY(-5px);
}

.color-hex-text {
  font-family: var(--font-main);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  cursor: pointer;
  border: none;
  background: transparent;
  text-align: center;
  width: 100%;
  outline: none;
}

.color-details-span {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Controls Panel */
.palette-controls-panel, .gradient-controls-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.control-card {
  background-color: var(--bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
}

.control-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-card h3 i {
  color: var(--color-primary);
}

.control-group {
  margin-bottom: 1.25rem;
}

.control-group:last-of-type {
  margin-bottom: 1.5rem;
}

/* Custom base picker layout */
.color-analyser {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.picker-input-wrapper {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

input[type="color"] {
  -webkit-appearance: none;
  border: none;
  width: 50px;
  height: 50px;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  background: none;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
}

.harmony-preview-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border-top: 1px solid var(--color-border);
  padding-top: 1rem;
}

.harmony-preview-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}

.harmony-label {
  font-weight: 600;
  color: var(--text-muted);
}

.mini-colors {
  display: flex;
  gap: 4px;
}

.mini-color-bubble {
  width: 22px;
  height: 22px;
  border-radius: var(--border-radius-sm);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.05);
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.mini-color-bubble:hover {
  transform: scale(1.15) translateY(-1px);
  z-index: 2;
}

/* Section 2: Gradient Layout */
.gradient-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 2rem;
  flex-grow: 1;
}

.gradient-preview-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background-color: var(--bg-card);
  border-radius: var(--border-radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border);
  height: 100%;
}

.gradient-preview-box {
  flex-grow: 1;
  min-height: 380px;
  border-radius: var(--border-radius-md);
  box-shadow: inset 0 0 40px rgba(0,0,0,0.06);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gradient-hint {
  background-color: rgba(255, 255, 255, 0.85);
  padding: 0.6rem 1.2rem;
  border-radius: var(--border-radius-round);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  box-shadow: var(--shadow-md);
  pointer-events: none;
  backdrop-filter: blur(4px);
}

/* Gradient Rail & Stops */
.gradient-rail-container {
  background-color: var(--bg-input);
  padding: 1rem;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--color-border);
}

.gradient-slider-rail {
  height: 32px;
  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: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0px;
  border-radius: var(--border-radius-sm);
  position: relative;
  cursor: crosshair;
  margin: 1.5rem 0.5rem 0.5rem 0.5rem;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

/* Pseudo rail cover that displays the actual gradient */
.gradient-rail-fill {
  position: absolute;
  inset: 0;
  border-radius: var(--border-radius-sm);
  pointer-events: none;
}

/* Color Stop Marker */
.gradient-stop-marker {
  width: 20px;
  height: 20px;
  border-radius: var(--border-radius-round);
  border: 3px solid #ffffff;
  box-shadow: 0 3px 6px rgba(0,0,0,0.3);
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  cursor: ew-resize;
  transition: transform var(--transition-fast);
  z-index: 10;
}

.gradient-stop-marker:hover, .gradient-stop-marker.active {
  transform: translate(-50%, -50%) scale(1.25);
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}

.gradient-stop-marker.active {
  border-color: var(--color-primary);
}

/* Active Stop Editing Panel */
.active-stop-card {
  background-color: rgba(99, 102, 241, 0.03);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: var(--border-radius-md);
  padding: 1rem;
  margin-bottom: 1.25rem;
}

.active-stop-card h4 {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-primary);
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.stop-editor-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.color-picker-bubble {
  flex-shrink: 0;
}

.stop-position-wrapper {
  flex-grow: 1;
}

.stop-position-wrapper label {
  font-size: 0.7rem;
  margin-bottom: 2px;
}

.stop-position-wrapper input {
  padding: 0.5rem 0.75rem;
}

/* Radio Group */
.radio-group {
  display: flex;
  gap: 0.5rem;
  background-color: var(--bg-input);
  padding: 4px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--color-border);
}

.radio-label {
  flex: 1;
  cursor: pointer;
  margin-bottom: 0;
}

.radio-label input {
  display: none;
}

.radio-label span {
  display: block;
  text-align: center;
  padding: 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--border-radius-sm);
  transition: var(--transition-fast);
}

.radio-label input:checked + span {
  background-color: white;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

/* Range Inputs */
.form-range {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--color-border);
  border-radius: var(--border-radius-sm);
  outline: none;
}

.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: var(--border-radius-round);
  background: var(--color-primary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-fast);
}

.form-range::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  background: var(--color-primary-hover);
}

.label-with-value {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.label-with-value span {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Presets Grid */
.presets-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 4px;
}

.preset-item {
  height: 70px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.preset-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--text-light);
}

.preset-name {
  position: absolute;
  bottom: 0;
  inset-x: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 6px 8px;
  letter-spacing: 0.2px;
}

/* Section 3: Image Picker Layout */
.image-picker-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 2rem;
  flex-grow: 1;
}

.image-workspace-card {
  background-color: var(--bg-card);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  min-height: 480px;
}

/* Upload Dropzone */
.upload-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  height: 100%;
  border: 2px dashed var(--color-border);
  border-radius: var(--border-radius-md);
  background-color: var(--bg-input);
  cursor: pointer;
  transition: var(--transition-normal);
  padding: 4rem 2rem;
}

.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: var(--color-primary);
  background-color: rgba(99, 102, 241, 0.02);
}

.upload-dropzone i {
  font-size: 3.5rem;
  color: var(--text-light);
  margin-bottom: 1.5rem;
  transition: var(--transition-normal);
}

.upload-dropzone:hover i {
  color: var(--color-primary);
  transform: translateY(-4px);
}

.upload-dropzone h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.upload-dropzone p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.upload-dropzone p span {
  color: var(--color-primary);
  font-weight: 700;
}

.file-hidden {
  display: none;
}

/* Canvas Preview Container */
.canvas-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  position: relative;
}

.canvas-scroll-area {
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  border-radius: var(--border-radius-md);
  background-color: var(--bg-input);
  border: 1px solid var(--color-border);
  margin-bottom: 1rem;
  position: relative;
}

#image-canvas {
  max-width: 100%;
  max-height: 480px;
  cursor: crosshair;
  display: block;
}

/* Magnifier glass / loupe styling */
.magnifier-glass {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: var(--border-radius-round);
  border: 4px solid white;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3), inset 0 0 10px rgba(0,0,0,0.2);
  pointer-events: none;
  display: none;
  background-repeat: no-repeat;
  z-index: 50;
  overflow: hidden;
}

/* Pixel alignment indicator in magnifier center */
.magnifier-glass::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  border: 1px solid rgba(255,255,255,0.9);
  outline: 1px solid rgba(0,0,0,0.8);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.canvas-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
}

/* Dominant & Picked Colors list */
.image-results-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.dominant-colors-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.dominant-color-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  cursor: pointer;
  transition: var(--transition-normal);
}

.dominant-color-item:hover {
  transform: translateY(-3px);
}

.dom-color-swatch {
  width: 100%;
  height: 54px;
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,0,0,0.05);
  transition: var(--transition-fast);
}

.dominant-color-item:hover .dom-color-swatch {
  box-shadow: var(--shadow-md);
}

.dom-color-hex {
  font-family: var(--font-main);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-main);
}

.empty-state-placeholder {
  grid-column: span 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1rem;
  color: var(--text-light);
  text-align: center;
}

.empty-state-placeholder i {
  font-size: 2.25rem;
  margin-bottom: 0.75rem;
  opacity: 0.7;
}

.empty-state-placeholder p {
  font-size: 0.8rem;
  font-weight: 600;
}

/* Picked Colors List */
.card-header-with-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.card-header-with-action h3 {
  margin-bottom: 0;
}

.picked-colors-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 4px;
}

.picked-color-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border-radius: var(--border-radius-md);
  background-color: var(--bg-input);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: var(--transition-fast);
}

.picked-color-row:hover {
  background-color: white;
  border-color: var(--text-light);
  transform: translateX(2px);
}

.picked-swatch {
  width: 28px;
  height: 28px;
  border-radius: var(--border-radius-sm);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.05);
}

.picked-values {
  display: flex;
  flex-direction: column;
}

.picked-hex {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
}

.picked-rgb {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.picked-delete-btn {
  margin-left: auto;
  border: none;
  background: transparent;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--border-radius-sm);
  transition: var(--transition-fast);
}

.picked-delete-btn:hover {
  color: var(--color-accent);
  background-color: rgba(244, 63, 94, 0.05);
}

/* Toast System */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background-color: var(--text-main);
  color: white;
  padding: 0.85rem 1.5rem;
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transform: translateY(20px);
  opacity: 0;
  animation: slideUp var(--transition-normal) forwards;
}

.toast i {
  color: var(--color-success);
}

@keyframes slideUp {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.toast.fade-out {
  animation: fadeOut var(--transition-normal) forwards;
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: scale(0.9);
  }
}

/* Modal Overlay & Card */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

.modal-card {
  background-color: var(--bg-card);
  border-radius: var(--border-radius-lg);
  width: 100%;
  max-width: 580px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border);
  transform: scale(0.95);
  transition: transform var(--transition-normal);
  overflow: hidden;
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

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

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 800;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--border-radius-sm);
  transition: var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-main);
  background-color: var(--bg-input);
}

.modal-body {
  padding: 1.75rem;
}

.export-formats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.export-format-card {
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  background-color: var(--bg-input);
  transition: var(--transition-normal);
}

.export-format-card:hover {
  border-color: var(--text-light);
  background-color: white;
  transform: translateY(-2px);
}

.export-format-card.active {
  border-color: var(--color-primary);
  background-color: rgba(99, 102, 241, 0.03);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.export-format-card i {
  font-size: 1.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.export-format-card.active i {
  color: var(--color-primary);
}

.export-format-card h4 {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.export-format-card p {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.export-preview-box {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.export-preview-box label {
  font-size: 0.75rem;
  font-weight: 700;
}

.export-preview-box pre {
  background-color: #0f172a;
  color: #f8fafc;
  padding: 1.25rem;
  border-radius: var(--border-radius-md);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
  max-height: 180px;
  overflow-y: auto;
  line-height: 1.5;
}

.modal-footer {
  padding: 1.25rem 1.75rem;
  background-color: var(--bg-input);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .app-container {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    padding: 1.5rem;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }
  .sidebar-brand {
    margin-bottom: 1.5rem;
  }
  .sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
    white-space: nowrap;
    width: 100%;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar-nav::-webkit-scrollbar {
    display: none;
  }
  .nav-item {
    flex-shrink: 0;
  }
  .sidebar-footer {
    display: none;
  }
  .main-content {
    margin-left: 0;
    padding: 1.5rem;
  }
  .palette-interface, .gradient-layout, .image-picker-layout {
    grid-template-columns: 1fr;
  }
  .palette-container {
    min-height: 400px;
  }
}

@media (max-width: 640px) {
  .nav-item {
    font-size: 0.85rem;
  }
  .palette-container {
    flex-direction: column;
    min-height: 600px;
  }
  .color-column {
    padding: 1rem;
    justify-content: space-between;
    flex-direction: row;
  }
  .color-column-actions {
    flex-direction: row;
    margin-bottom: 0;
    opacity: 1;
    transform: none;
  }
  .color-info {
    width: auto;
    padding: 0.5rem 0.75rem;
  }
  .color-hex-text {
    font-size: 0.95rem;
  }
}

@media (max-width: 768px) {
  .content-header {
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 1.25rem;
    margin-bottom: 1.75rem;
  }
  
  .header-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}

@media (max-width: 480px) {
  .main-content {
    padding: 1rem;
  }
  .color-picker-inline-wrapper {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .picker-controls-row {
    width: 100%;
    justify-content: space-between;
  }
}

/* ========================================== */
/* SECTION 0: COLOR CREATOR LAYOUT STYLING    */
/* ========================================== */

.creator-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 2rem;
  flex-grow: 1;
}

.creator-preview-card {
  background-color: var(--bg-card);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  align-self: start;
}

.color-display-large {
  width: 100%;
  height: 250px;
  border-radius: var(--border-radius-md);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.05), var(--shadow-md);
  border: 1px solid rgba(0, 0, 0, 0.08);
  transition: background-color var(--transition-fast);
  background-color: #6366f1;
}

.color-picker-inline-wrapper {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-input);
  padding: 1rem;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--color-border);
}

.picker-controls-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.color-picker-inline-wrapper label {
  margin-bottom: 0;
  font-weight: 700;
  color: var(--text-main);
}

.creator-codes-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.code-output-group {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.code-output-item {
  display: flex;
  align-items: center;
  background-color: var(--bg-input);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
  overflow: hidden;
  transition: var(--transition-fast);
  cursor: pointer;
}

.code-output-item:hover {
  background-color: white;
  border-color: var(--text-light);
}

.code-output-item:focus-within {
  border-color: var(--color-primary);
  background-color: white;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.code-label {
  padding: 0.75rem 1rem;
  background-color: rgba(100, 116, 139, 0.05);
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-muted);
  width: 70px;
  text-align: center;
  border-right: 1px solid var(--color-border);
}

.code-val-input {
  flex-grow: 1;
  width: 0;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 0.75rem 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
}

.btn-copy-code {
  background: transparent;
  border: none;
  color: var(--text-light);
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-copy-code:hover {
  color: var(--color-primary);
  background-color: rgba(99, 102, 241, 0.05);
}

.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 1.25rem 0;
}

.sliders-grid {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Custom RGB and Hue styling for sliders */
.slider-red::-webkit-slider-thumb {
  background: #ef4444 !important;
}
.slider-green::-webkit-slider-thumb {
  background: #10b981 !important;
}
.slider-blue::-webkit-slider-thumb {
  background: #3b82f6 !important;
}
.slider-hue::-webkit-slider-thumb {
  background: var(--color-primary) !important;
}

@media (max-width: 1024px) {
  .creator-layout {
    grid-template-columns: 1fr;
  }
  .creator-preview-card {
    align-self: stretch;
    width: 100%;
  }
  .color-display-large {
    min-height: 240px;
  }
}

/* ========================================== */
/* SECTION 4: CONTRAST CHECKER LAYOUT STYLING */
/* ========================================== */

.contrast-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 2rem;
  flex-grow: 1;
}

.contrast-pickers-row {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.contrast-picker-box {
  width: 100%;
}

#btn-contrast-swap {
  margin: 0.25rem 0;
  width: 44px;
  height: 44px;
  border-radius: var(--border-radius-round);
}

.contrast-results-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.ratio-display-box {
  background-color: var(--bg-input);
  border: 1px solid var(--color-border);
  padding: 1.5rem;
  border-radius: var(--border-radius-md);
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.ratio-value {
  font-size: 3rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
  margin-bottom: 0.25rem;
}

.ratio-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ratings-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.rating-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--color-border);
}

.rating-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.rating-info {
  display: flex;
  flex-direction: column;
}

.rating-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
}

.rating-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.rating-badges {
  display: flex;
  gap: 0.5rem;
}

.rating-badges .badge {
  padding: 0.35rem 0.75rem;
  border-radius: var(--border-radius-sm);
  font-size: 0.75rem;
  font-weight: 800;
  text-align: center;
  min-width: 54px;
}

.rating-badges .badge.pass {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.rating-badges .badge.fail {
  background-color: rgba(244, 63, 94, 0.1);
  color: var(--color-accent);
  border: 1px solid rgba(244, 63, 94, 0.2);
}

/* Preview Box Panel */
.contrast-preview-panel {
  height: 100%;
}

.preview-card-wrapper {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.contrast-preview-area {
  flex-grow: 1;
  border-radius: var(--border-radius-md);
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 400px;
  border: 1px solid var(--color-border);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.preview-sample {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sample-heading {
  font-size: 4.5rem;
  font-weight: 800;
  line-height: 1;
}

.sample-text-large {
  font-size: 1.5rem;
  font-weight: 700;
}

.sample-text-normal {
  font-size: 0.95rem;
  line-height: 1.6;
}

.preview-ui-component {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-top: 2rem;
}

.preview-btn {
  padding: 0.75rem 1.5rem;
  border-radius: var(--border-radius-md);
  font-weight: 700;
  font-size: 0.9rem;
  border: 1px solid transparent;
  cursor: default;
  transition: all var(--transition-fast);
}

.preview-icon {
  font-size: 0.95rem;
  font-weight: 700;
}

[contenteditable="true"] {
  outline: none;
  border-radius: 4px;
  transition: box-shadow var(--transition-fast) ease;
}

[contenteditable="true"]:hover {
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.4);
  cursor: text;
}

[contenteditable="true"]:focus {
  box-shadow: 0 0 0 2px var(--color-primary);
  background-color: rgba(99, 102, 241, 0.05);
}

@media (max-width: 1024px) {
  .contrast-layout {
    grid-template-columns: 1fr;
  }
}

/* Language Dropdown Menu */
.lang-dropdown-wrapper {
  position: relative;
  display: inline-block;
}

.lang-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background-color: var(--bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 1000;
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.lang-dropdown-menu.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: none;
  border: none;
  border-radius: var(--border-radius-sm);
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.dropdown-item:hover {
  background-color: var(--bg-input);
}

.dropdown-item .flag-icon {
  font-size: 1.1rem;
}

.app-footer {
  margin-top: auto;
  padding: 2.5rem 0 1.5rem 0;
  text-align: center;
  border-top: 1px solid var(--color-border);
  width: 100%;
}

.app-footer p {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}
