:root {
  --bg: #e0e5ec;
  --fg: #2b2f3a;
  --accent: #4f6df5;
  --shadow-light: rgba(255, 255, 255, 0.9);
  --shadow-dark: rgba(163, 177, 198, 0.7);
  --radius-lg: 20px;
  --radius-md: 14px;
  --transition-fast: 0.18s ease-out;
}

:root.dark {
  --bg: #15151b;
  --fg: #f0f0f5;
  --shadow-light: rgba(255, 255, 255, 0.06);
  --shadow-dark: rgba(0, 0, 0, 0.8);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  background: radial-gradient(circle at top left, #f5f7fb, var(--bg));
  color: var(--fg);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 16px;
  transition: background 0.3s, color 0.3s;
}

:root.dark body {
  background: radial-gradient(circle at top left, #1f1f27, #101015);
}

.app {
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Neumorphism + glass */
.neu-card {
  background: rgba(224, 229, 236, 0.9);
  border-radius: var(--radius-lg);
  box-shadow:
    -12px -12px 24px var(--shadow-light),
    12px 12px 24px var(--shadow-dark);
  padding: 20px;
  transition: background 0.3s, box-shadow 0.3s, transform 0.2s;
}

:root.dark .neu-card {
  background: rgba(21, 21, 27, 0.9);
}

.glass {
  backdrop-filter: blur(18px);
}

.neu-card:hover {
  transform: translateY(-1px);
}

/* Header */
.app-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.app-title {
  font-size: 1.8rem;
  font-weight: 600;
}

.app-subtitle {
  font-size: 0.9rem;
  opacity: 0.8;
  line-height: 1.5;
}

/* Theme toggle */
.theme-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-label {
  font-size: 0.85rem;
  opacity: 0.8;
}

.theme-toggle input {
  display: none;
}

.theme-pill {
  width: 42px;
  height: 22px;
  border-radius: 999px;
  background: var(--bg);
  box-shadow:
    -4px -4px 8px var(--shadow-light),
    4px 4px 8px var(--shadow-dark);
  padding: 3px;
  display: flex;
  align-items: center;
  transition: 0.3s;
}

.theme-knob {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 0.2s;
}

.theme-toggle input:checked + .theme-pill .theme-knob {
  transform: translateX(20px);
}

/* Layout */
.layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (min-width: 860px) {
  .layout {
    flex-direction: row;
  }
  .controls {
    flex: 0 0 420px;
  }
  .preview {
    flex: 1;
  }
}

/* Sections */
.section-title {
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0.7;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.neu-input-group {
  margin-bottom: 16px;
}

.label-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 0.85rem;
}

/* Upload */
.upload-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.upload-area {
  border-radius: var(--radius-md);
  padding: 18px;
  background: var(--bg);
  box-shadow:
    -8px -8px 16px var(--shadow-light),
    8px 8px 16px var(--shadow-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-align: center;
}

.upload-icon {
  font-size: 2rem;
}

.upload-text {
  font-size: 0.85rem;
  opacity: 0.8;
}

.image-canvas {
  width: 100%;
  border-radius: var(--radius-md);
  background: #dfe3ea;
  box-shadow:
    inset -6px -6px 12px var(--shadow-light),
    inset 6px 6px 12px var(--shadow-dark);
}

.image-hint {
  font-size: 0.8rem;
  opacity: 0.7;
}

/* Slider */
.neu-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--bg);
  box-shadow:
    inset -4px -4px 8px var(--shadow-light),
    inset 4px 4px 8px var(--shadow-dark);
}

.neu-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow:
    -3px -3px 6px var(--shadow-light),
    3px 3px 6px var(--shadow-dark);
}

/* Pills */
.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg);
  box-shadow:
    -4px -4px 8px var(--shadow-light),
    4px 4px 8px var(--shadow-dark);
  cursor: pointer;
  font-size: 0.8rem;
}

.pill input {
  display: none;
}

.pill input:checked + span {
  color: var(--accent);
  font-weight: 600;
}

/* Check pills */
.checkbox-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.check-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--bg);
  box-shadow:
    -4px -4px 8px var(--shadow-light),
    4px 4px 8px var(--shadow-dark);
  font-size: 0.8rem;
}

.check-pill input {
  width: 14px;
  height: 14px;
}

/* Buttons */
.neu-button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.neu-button {
  border: none;
  outline: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 0.9rem;
  cursor: pointer;
  background: var(--bg);
  box-shadow:
    -6px -6px 12px var(--shadow-light),
    6px 6px 12px var(--shadow-dark);
  color: var(--fg);
  transition: 0.2s;
}

.neu-button.small {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.neu-button.primary {
  background: linear-gradient(135deg, #4f6df5, #7a8cff);
  color: #fff;
}

.neu-button:active {
  transform: translateY(1px);
}

/* Palette */
.palette-card {
  min-height: 220px;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
}

.palette-swatch {
  border-radius: var(--radius-md);
  padding: 10px;
  box-shadow:
    -4px -4px 8px rgba(255, 255, 255, 0.4),
    4px 4px 8px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transform: translateY(0);
  transition: transform 0.15s ease-out, box-shadow 0.15s ease-out;
}

.palette-swatch:hover {
  transform: translateY(-2px);
  box-shadow:
    -6px -6px 12px rgba(255, 255, 255, 0.5),
    6px 6px 12px rgba(0, 0, 0, 0.3);
}

.palette-swatch-inner {
  height: 60px;
  border-radius: 12px;
  margin-bottom: 6px;
}

.palette-swatch-label {
  font-size: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.palette-swatch-hex {
  font-weight: 600;
}

.palette-swatch-copy {
  font-size: 0.75rem;
  opacity: 0.8;
}

/* Selected color */
.detail-card {
  margin-top: 16px;
}

.selected-color-preview {
  width: 100%;
  height: 80px;
  border-radius: var(--radius-md);
  box-shadow:
    -4px -4px 8px var(--shadow-light),
    4px 4px 8px var(--shadow-dark);
  margin-bottom: 10px;
}

.selected-color-info {
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.color-row {
  display: flex;
  justify-content: space-between;
}

/* History */
.history-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.history-tab {
  flex: 1;
  border-radius: 999px;
  border: none;
  padding: 6px 0;
  font-size: 0.8rem;
  cursor: pointer;
  background: var(--bg);
  box-shadow:
    -4px -4px 8px var(--shadow-light),
    4px 4px 8px var(--shadow-dark);
}

.history-tab.active {
  background: var(--accent);
  color: #fff;
}

.history-list {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.history-item {
  border-radius: var(--radius-md);
  padding: 8px;
  background: var(--bg);
  box-shadow:
    -3px -3px 6px var(--shadow-light),
    3px 3px 6px var(--shadow-dark);
  font-size: 0.8rem;
  cursor: pointer;
}

.history-item-colors {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.history-color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.history-actions {
  display: flex;
  justify-content: flex-end;
}

/* Footer */
.footer {
  margin-top: 20px;
}

.footer-inner {
  text-align: center;
  padding: 14px;
}

.footer-link {
  text-decoration: none;
  color: var(--fg);
  font-size: 0.85rem;
  opacity: 0.8;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--bg);
  box-shadow:
    -6px -6px 12px var(--shadow-light),
    6px 6px 12px var(--shadow-dark);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  font-size: 0.85rem;
}

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

/* Mobile tweaks */
@media (max-width: 600px) {
  .app-header-top {
    flex-direction: column;
  }
  .palette-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
