:root {
  --bg-primary: #f8fafc;
  --bg-panel: rgba(255, 255, 255, 0.7);
  --border-color: rgba(226, 232, 240, 0.8);
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-panel: rgba(30, 41, 59, 0.7);
  --border-color: rgba(51, 65, 85, 0.8);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  flex: 1;
}

.glass-panel {
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--primary-color);
}

.logo h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.select-input {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.5rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
}

.icon-btn {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  border-radius: 8px;
}

.icon-btn:hover {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-primary);
}

.main-content {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  flex: 1;
}

@media (min-width: 768px) {
  .main-content { grid-template-columns: 1fr 1fr; }
}

.upload-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  position: relative;
  overflow: hidden;
  border: 2px dashed var(--border-color);
}

.upload-section.dragover {
  border-color: var(--primary-color);
  background: rgba(59, 130, 246, 0.05);
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  color: var(--text-secondary);
}

#image-preview {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  object-fit: contain;
  padding: 1rem;
}

.hidden { display: none !important; }

.primary-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

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

.secondary-btn {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.secondary-btn:hover { background: rgba(148, 163, 184, 0.1); }

.palette-section {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

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

.palette-header h2 { font-size: 1.25rem; font-weight: 600; }

.export-actions { display: flex; gap: 0.5rem; }

.swatches-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
}

.swatch-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem;
  border-radius: 12px;
  transition: transform 0.2s;
}

.swatch-item:hover {
  transform: translateX(4px);
  background: rgba(148, 163, 184, 0.05);
}

.swatch-color {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 0.8rem;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  cursor: pointer;
}

.swatch-details {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
}

.swatch-value {
  font-family: monospace;
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.swatch-name {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: capitalize;
}

.toggle-group {
  display: flex;
  background: rgba(148, 163, 184, 0.1);
  border-radius: 8px;
  padding: 0.25rem;
  width: fit-content;
}

.toggle-btn {
  background: transparent;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}

.toggle-btn.active {
  background: var(--bg-panel);
  color: var(--text-primary);
  box-shadow: var(--shadow);
}

.mt-4 { margin-top: 1.5rem; display: flex; align-items: center; gap: 1rem; }
.toggle-label { font-size: 0.9rem; font-weight: 500; }

.loader {
  margin: auto;
  color: var(--primary-color);
  font-weight: 500;
}

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: var(--bg-primary);
  padding: 0.75rem 1.5rem;
  border-radius: 30px;
  font-weight: 500;
  z-index: 1000;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3);
  opacity: 1;
  transition: opacity 0.3s, transform 0.3s;
}

.toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(20px);
  pointer-events: none;
}
