:root {
  color-scheme: dark;
  --bg: #0a0a0b;
  --panel: #18181b;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --border: #27272a;
  --accent: #6366F1;
  --accent-soft: rgba(99, 102, 241, 0.15);
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  --radius: 16px;
  --transition: 0.2s ease;
}

body[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #6366F1;
  --accent-soft: rgba(99, 102, 241, 0.12);
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", sans-serif;
  background: radial-gradient(circle at top, rgba(37, 99, 235, 0.12), transparent 50%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}

.brand h1 {
  margin: 0;
  font-size: 24px;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.content {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 24px;
}

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.upload-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), transparent);
}

.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.drop-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  font-size: 28px;
  color: var(--accent);
}

.hint {
  color: var(--muted);
  font-size: 12px;
}

.preview-card {
  border-radius: 14px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: rgba(148, 163, 184, 0.06);
}

.preview-card img {
  width: 100%;
  display: block;
  max-height: 320px;
  object-fit: cover;
  background: #111827;
}

.preview-meta {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--muted);
}

.section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.section:last-child {
  margin-bottom: 0;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-header h3 {
  margin: 0;
  font-size: 18px;
}

.badge {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.swatch-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 12px;
}

.swatch {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  min-height: 72px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition);
}

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

.swatch .swatch-info {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  background: rgba(15, 23, 42, 0.4);
  color: #f8fafc;
  padding: 4px 6px;
  border-radius: 8px;
}

.lock-btn {
  border: none;
  background: rgba(15, 23, 42, 0.5);
  color: #ffffff;
  border-radius: 8px;
  padding: 2px 6px;
  font-size: 10px;
  cursor: pointer;
}

.palette-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.select {
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 8px 10px;
  background: transparent;
  color: var(--text);
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.detail {
  background: rgba(148, 163, 184, 0.08);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid var(--border);
}

.detail label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.detail-value {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
}

.export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.export-output {
  min-height: 140px;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 12px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  background: rgba(148, 163, 184, 0.08);
  color: var(--text);
}

.save-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.input {
  flex: 1;
  min-width: 200px;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 10px 12px;
  background: transparent;
  color: var(--text);
}

.btn {
  border-radius: 10px;
  border: none;
  padding: 10px 16px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.2);
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: none;
}

.btn.tiny {
  padding: 4px 8px;
  font-size: 11px;
}

.saved-drawer {
  position: fixed;
  top: 0;
  right: -420px;
  width: 380px;
  height: 100vh;
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: right var(--transition);
  z-index: 10;
}

.saved-drawer.open {
  right: 0;
}

.saved-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.saved-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.saved-card .saved-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(32px, 1fr));
  gap: 6px;
}

.saved-swatch {
  height: 32px;
  border-radius: 6px;
}

.saved-actions {
  display: flex;
  gap: 8px;
}

.footer {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

@media (max-width: 960px) {
  .content {
    grid-template-columns: 1fr;
  }

  .saved-drawer {
    width: 100%;
    right: -100%;
  }
}

@media (max-width: 600px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .footer {
    flex-direction: column;
    gap: 6px;
  }
}
